本文整理汇总了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))]
示例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)