本文整理汇总了Python中xmlbuilder.XMLBuilder.file方法的典型用法代码示例。如果您正苦于以下问题:Python XMLBuilder.file方法的具体用法?Python XMLBuilder.file怎么用?Python XMLBuilder.file使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类xmlbuilder.XMLBuilder
的用法示例。
在下文中一共展示了XMLBuilder.file方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: checkstyle_xml
# 需要导入模块: from xmlbuilder import XMLBuilder [as 别名]
# 或者: from xmlbuilder.XMLBuilder import file [as 别名]
def checkstyle_xml(diags_set):
def converted_severity(fauxpas_severity):
# checkstyle severities: ignore, info, warning, error
if (9 <= fauxpas_severity):
return 'error'
elif (5 <= fauxpas_severity):
return 'warning'
return 'info'
x = XMLBuilder('checkstyle')
diags_by_file = diags_set.grouped_diagnostics(by_property='file')
for filepath, diags in diags_by_file.items():
with x.file(name=filepath or diags_set.pbxproj_path):
for diag in diags:
message = diag.info
if 0 < len(message):
message += ' '
message += '(%s - %s)' % (diag.ruleName, diag.ruleDescription)
x.error(severity=converted_severity(diag.severity),
source=diag.ruleShortName,
message=message,
line=str(diag.extent.start.line),
column=str(diag.extent.start.utf16Column)
)
return str(x)