suppress.py 文件源码

python
阅读 42 收藏 0 点赞 0 评论 0

项目:nojs 作者: chrisdickinson 项目源码 文件源码
def _WriteConfigFile(config_path, issues_dict):
  new_dom = minidom.getDOMImplementation().createDocument(None, 'lint', None)
  top_element = new_dom.documentElement
  top_element.appendChild(new_dom.createComment(_DOC))
  for issue_id, issue in sorted(issues_dict.iteritems(), key=lambda i: i[0]):
    issue_element = new_dom.createElement('issue')
    issue_element.attributes['id'] = issue_id
    if issue.severity:
      issue_element.attributes['severity'] = issue.severity
    if issue.severity == 'ignore':
      print 'Warning: [%s] is suppressed globally.' % issue_id
    else:
      for path in sorted(issue.paths):
        ignore_element = new_dom.createElement('ignore')
        ignore_element.attributes['path'] = path
        issue_element.appendChild(ignore_element)
      for regexp in sorted(issue.regexps):
        ignore_element = new_dom.createElement('ignore')
        ignore_element.attributes['regexp'] = regexp
        issue_element.appendChild(ignore_element)
    top_element.appendChild(issue_element)

  with open(config_path, 'w') as f:
    f.write(new_dom.toprettyxml(indent='  ', encoding='utf-8'))
  print 'Updated %s' % config_path
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号