本文整理汇总了Python中elementtree.ElementTree.SubElement.getiterator方法的典型用法代码示例。如果您正苦于以下问题:Python SubElement.getiterator方法的具体用法?Python SubElement.getiterator怎么用?Python SubElement.getiterator使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类elementtree.ElementTree.SubElement
的用法示例。
在下文中一共展示了SubElement.getiterator方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: gencix
# 需要导入模块: from elementtree.ElementTree import SubElement [as 别名]
# 或者: from elementtree.ElementTree.SubElement import getiterator [as 别名]
def gencix(major, minor):
# First generate first pass at the CILE over all of the lib tree
cixfile = "activeperl-%d.%d.cix" % (major, minor)
command = "python ../../../ci2.py scan -n -r -p -l Perl -T /tmp/ActivePerl-%d.%d/perl/lib -i \"*.pm\"> %s" % (major, minor, cixfile)
retval = os.system(command)
if retval != 0:
print "Error scanning ActivePerl library"
sys.exit(retval)
#
# Grab the output of that scan
root = parse(cixfile).getroot()
newroot = Element("codeintel", version="2.0")
cixfile = SubElement(newroot, "file", lang="Perl",
mtime=str(int(time.time())),
path=os.path.basename('perl.cix'))
for file in root.getiterator('file'):
print >> sys.stderr, "Processing", file.get('path')
for blob in file:
if blob.get("src"):
# Don't want the src string.
del blob.attrib["src"]
cixfile.append(blob)
cix = genPerlStdCIX(cixfile, "/tmp/ActivePerl-%d.%d/perl/lib/pod/perlfunc.pod" % (major, minor))
parent_map = dict((c, p) for p in cixfile.getiterator() for c in p)
for variable in newroot.getiterator('variable'):
attributes = variable.get('attributes')
if attributes and '__local__' in variable.get('attributes'):
parent_map[variable].remove(variable)
# Generate the CIX.
print >>sys.stderr, "Prettying"
prettify(newroot)
tree = ElementTree(newroot)
#fname = '../../../lib/codeintel2/stdlibs/perl-%d.%d.cix' % (major, minor)
fname = 'perl-%d.%d.cix' % (major, minor)
#os.system('p4 edit %s' % fname)
stream = open(fname, "w")
print >>sys.stderr, "Writing"
stream.write('<?xml version="1.0" encoding="UTF-8"?>\n')
tree.write(stream)
stream.close()