当前位置: 首页>>代码示例>>Python>>正文


Python XMLBuilder.file方法代码示例

本文整理汇总了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)
开发者ID:mapedd,项目名称:fauxpas-converter,代码行数:28,代码来源:fauxpas_convert.py


注:本文中的xmlbuilder.XMLBuilder.file方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。