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


Python XML.hasChildElements方法代码示例

本文整理汇总了Python中cia.LibCIA.XML.hasChildElements方法的典型用法代码示例。如果您正苦于以下问题:Python XML.hasChildElements方法的具体用法?Python XML.hasChildElements怎么用?Python XML.hasChildElements使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在cia.LibCIA.XML的用法示例。


在下文中一共展示了XML.hasChildElements方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: component_files

# 需要导入模块: from cia.LibCIA import XML [as 别名]
# 或者: from cia.LibCIA.XML import hasChildElements [as 别名]
    def component_files(self, element, args):
        """Format the contents of our <files> tag as a tree with nested lists"""
        from cia.LibCIA.Web import Template

        files = XML.dig(args.message.xml, "message", "body", "commit", "files")
        if not (files and XML.hasChildElements(files)):
            return []

        # First we organize the files into a tree of nested dictionaries.
        # The dictionary we ultimately have FileTree render maps each node
        # (file or directory) to a dictionary of its contents. The keys
        # in these dictionaries can be any Nouvelle-renderable object
        # produced by format_file.
        #
        # As a first step, we build a dictionary mapping path segment to
        # [fileTag, children] lists. We then create a visual representation
        # of each fileTag and generate the final dictionary.
        fileTree = {}
        for fileTag in XML.getChildElements(files):
            if fileTag.nodeName == 'file':
                # Separate the file into path segments and walk into our tree
                node = [None, fileTree]
                for segment in XML.shallowText(fileTag).split('/'):
                    if segment:
                        node = node[1].setdefault(segment, [None, {}])
                # The leaf node owns this fileTag
                node[0] = fileTag

        return [Template.FileTree(self.format_file_tree(fileTree))]
开发者ID:Justasic,项目名称:cia-vc,代码行数:31,代码来源:Commit.py

示例2: isEmpty

# 需要导入模块: from cia.LibCIA import XML [as 别名]
# 或者: from cia.LibCIA.XML import hasChildElements [as 别名]
 def isEmpty(self):
     """Returns True if the ruleset has no contents"""
     return not XML.hasChildElements(self.xml.documentElement)
开发者ID:Justasic,项目名称:cia-vc,代码行数:5,代码来源:Ruleset.py


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