本文整理汇总了Python中elementtree.ElementTree.Element.tail方法的典型用法代码示例。如果您正苦于以下问题:Python Element.tail方法的具体用法?Python Element.tail怎么用?Python Element.tail使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类elementtree.ElementTree.Element
的用法示例。
在下文中一共展示了Element.tail方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: dump
# 需要导入模块: from elementtree.ElementTree import Element [as 别名]
# 或者: from elementtree.ElementTree.Element import tail [as 别名]
def dump(self, output):
tempo = {}
root = Element('resources')
root.tail = '\n'
tempo[()] = root
for key in self._resources_order:
for i in range(1, len(key)+1):
if key[0:i] not in tempo:
parent = tempo[key[0:i-1]]
value = self._resources.get(key[0:i], None)
if value is None:
elem = SubElement(parent, 'node', name=key[i-1])
else:
fullKey = key[0];
for j in range(1, i):
fullKey += '/' + key[j]
newValue = self._dictionary[fullKey]
elem = SubElement(parent, 'node', name=key[i-1], value=newValue)
parent.text = elem.tail = '\n' + i*SPACES
tempo[key[0:i]] = elem
fix_it(root)
print >> output, '<?xml version="1.0" encoding="UTF-8"?>'
ElementTree(root).write(output, 'ascii')
示例2: dump
# 需要导入模块: from elementtree.ElementTree import Element [as 别名]
# 或者: from elementtree.ElementTree.Element import tail [as 别名]
def dump(self, output, lang):
tempo = {}
root = Element("resources")
root.tail = "\n"
tempo[()] = root
for key in self._resources_order:
for i in range(1, len(key) + 1):
if key[0:i] not in tempo:
parent = tempo[key[0 : i - 1]]
value = self._resources.get(key[0:i], None)
if value is None:
elem = SubElement(parent, "node", name=key[i - 1])
else:
localized = value.get(lang, None)
english = value.get("en", None)
if english is None:
print >>sys.stderr, "English file does not have the string for", key[0:i]
print >>sys.stderr, " entry is marked as obosolete."
elem = SubElement(parent, "node", name=key[i - 1], value=localized, obsolete="true")
elif localized is not None:
elem = SubElement(parent, "node", name=key[i - 1], value=localized)
else:
elem = SubElement(parent, "node", name=key[i - 1], value=english, toBeTranslated="true")
parent.text = elem.tail = "\n" + i * SPACES
tempo[key[0:i]] = elem
fix_it(root)
print >> output, '<?xml version="1.0" encoding="UTF-8"?>'
ElementTree(root).write(output, "utf-8")
示例3: __call__
# 需要导入模块: from elementtree.ElementTree import Element [as 别名]
# 或者: from elementtree.ElementTree.Element import tail [as 别名]
def __call__(self):
el = Element("{http://www.w3.org/2005/Atom}entry")
el.tail = '\n'
alsoProvides(el, IAtomFeedEntrySkeleton)
return el