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 in sorted(issues_dict.keys()):
severity = issues_dict[issue_id].severity
paths = issues_dict[issue_id].paths
issue = new_dom.createElement('issue')
issue.attributes['id'] = issue_id
if severity:
issue.attributes['severity'] = severity
if severity == 'ignore':
print 'Warning: [%s] is suppressed globally.' % issue_id
else:
for path in sorted(paths):
ignore = new_dom.createElement('ignore')
ignore.attributes['path'] = path
issue.appendChild(ignore)
top_element.appendChild(issue)
with open(config_path, 'w') as f:
f.write(new_dom.toprettyxml(indent=' ', encoding='utf-8'))
print 'Updated %s' % config_path
评论列表
文章目录