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


Python XML.getChildElements方法代码示例

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


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

示例1: format

# 需要导入模块: from cia.LibCIA import XML [as 别名]
# 或者: from cia.LibCIA.XML import getChildElements [as 别名]
 def format(self, args):
     # Format each package inside each result set
     packages = []
     for results in XML.getChildElements(XML.dig(args.message.xml, "message", "body", "builder")):
         if results.nodeName == 'results':
             for package in XML.getChildElements(results):
                 if package.nodeName == 'package':
                     packages.append(self.format_package(package))
     return self.joinMessage(args.message, packages)
开发者ID:Justasic,项目名称:cia-vc,代码行数:11,代码来源:Builder.py

示例2: component_files

# 需要导入模块: from cia.LibCIA import XML [as 别名]
# 或者: from cia.LibCIA.XML import getChildElements [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

示例3: consolidateFiles

# 需要导入模块: from cia.LibCIA import XML [as 别名]
# 或者: from cia.LibCIA.XML import getChildElements [as 别名]
    def consolidateFiles(self, xmlFiles):
        """Given a <files> element, find the directory common to all files
           and return a 2-tuple with that directory followed by
           a list of files within that directory.
           """
        files = []
        if xmlFiles:
            for fileTag in XML.getChildElements(xmlFiles):
                if fileTag.nodeName == 'file':
                    files.append(XML.shallowText(fileTag))

        # If we only have one file, return it as the prefix.
        # This prevents the below regex from deleting the filename
        # itself, assuming it was a partial filename.
        if len(files) == 1:
            return files[0], []

        # Start with the prefix found by commonprefix,
        # then actually make it end with a directory rather than
        # possibly ending with part of a filename.
        prefix = re.sub("[^/]*$", "", posixpath.commonprefix(files))

        endings = []
        for file in files:
            ending = file[len(prefix):].strip()
            if ending == '':
                    ending = '.'
            endings.append(ending)
        return prefix, endings
开发者ID:Justasic,项目名称:cia-vc,代码行数:31,代码来源:Commit.py

示例4: format_results

# 需要导入模块: from cia.LibCIA import XML [as 别名]
# 或者: from cia.LibCIA.XML import getChildElements [as 别名]
 def format_results(self, package):
     """Given a package, returns a formatted representation of all results for that package"""
     results = []
     for element in XML.getChildElements(package):
         f = getattr(self, 'result_' + element.nodeName, None)
         if f:
             results.append(f(element))
开发者ID:Justasic,项目名称:cia-vc,代码行数:9,代码来源:Builder.py

示例5: dbIter

# 需要导入模块: from cia.LibCIA import XML [as 别名]
# 或者: from cia.LibCIA.XML import getChildElements [as 别名]
 def dbIter(self):
     if os.path.isfile(self.path):
         dom = XML.parseStream(open(self.path))
         for element in XML.getChildElements(dom.documentElement):
             if element.nodeName == "ruleset":
                 yield element
     else:
         log.msg("The file %r does not exist, loading no rulesets" % self.path)
开发者ID:Justasic,项目名称:cia-vc,代码行数:10,代码来源:Ruleset.py

示例6: getSvnRevision

# 需要导入模块: from cia.LibCIA import XML [as 别名]
# 或者: from cia.LibCIA.XML import getChildElements [as 别名]
 def getSvnRevision(self):
     """Return the current Subversion repository revision, or None
        if we're not in an svn working copy or it can't be parsed.
        """
     try:
         entries = XML.parseString(open(".svn/entries").read()).documentElement
         highestRev = 0
         for tag in XML.getChildElements(entries):
             if tag.nodeName == 'entry':
                 rev = tag.getAttributeNS(None, 'committed-rev')
                 if rev and rev > highestRev:
                     highestRev = rev
         return highestRev
     except:
         return None
开发者ID:Justasic,项目名称:cia-vc,代码行数:17,代码来源:Info.py

示例7: loadParametersFrom

# 需要导入模块: from cia.LibCIA import XML [as 别名]
# 或者: from cia.LibCIA.XML import getChildElements [as 别名]
    def loadParametersFrom(self, xml, unused=None):
        """This is given a <formatter> element possibly containing
           extra parameters for the formatter to process and store.
           Any problems should be signalled with an XML.XMLValidityError.

           By default, this tries to find a param_* handler for each
           element it comes across.

           Returns a set object, containing the names of all unused
           parameters. This allows callers, during validation, to look
           for misspelled or otherwise unused elements.
           """
        unused = set()
        for tag in XML.getChildElements(xml):
            f = getattr(self, 'param_'+tag.nodeName, None)
            if f:
                f(tag)
            else:
                unused.add(tag.nodeName)
        return unused
开发者ID:Justasic,项目名称:cia-vc,代码行数:22,代码来源:Message.py

示例8: postprocessMessage

# 需要导入模块: from cia.LibCIA import XML [as 别名]
# 或者: from cia.LibCIA.XML import getChildElements [as 别名]
    def postprocessMessage(self, xml):
        """Gets a chance to modify all XML messages before they're loaded
           and dispatched to the Hub. This does the following:
             - If there is no <generator> at all, adds a generic one
             - Removes any <mailHeaders> tag that may already exist in <generator>
             - Adds a correct <mailHeaders> tag to the <generator>
           """
        # Create the <generator> tag if it doesn't exist
        if not XML.dig(xml, "message", "generator"):
            xml.documentElement.appendChild(self.getLocalGenerator(xml))
        generator = XML.dig(xml, "message", "generator")

        # Delete an existing <mailHeaders>
        for child in list(XML.getChildElements(generator)):
            if child.nodeName == "mailHeaders":
                generator.removeChild(child)

        # Add a new <mailHeaders>
        generator.appendChild(self.getXMLMailHeaders(xml))
        return xml
开发者ID:Justasic,项目名称:cia-vc,代码行数:22,代码来源:IncomingMail.py

示例9: element_or

# 需要导入模块: from cia.LibCIA import XML [as 别名]
# 或者: from cia.LibCIA.XML import getChildElements [as 别名]
 def element_or(self, element):
     """Evaluates to True if and only if any child function evaluates to True"""
     return "(%s)" % (" OR ".join([self.parse(node) for node in XML.getChildElements(element)]))
开发者ID:Justasic,项目名称:cia-vc,代码行数:5,代码来源:Database.py

示例10: element_and

# 需要导入模块: from cia.LibCIA import XML [as 别名]
# 或者: from cia.LibCIA.XML import getChildElements [as 别名]
 def element_and(self, element):
     """Evaluates to True if and only if all child expressions evaluate to True"""
     return "(%s)" % (" AND ".join([self.parse(node) for node in XML.getChildElements(element)]))
开发者ID:Justasic,项目名称:cia-vc,代码行数:5,代码来源:Database.py


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