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


Python Element.tail方法代码示例

本文整理汇总了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')
开发者ID:ALEXGUOQ,项目名称:FBReader,代码行数:34,代码来源:restore-i18n.py

示例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")
开发者ID:hbao,项目名称:FBReader,代码行数:40,代码来源:update-i18n.py

示例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
开发者ID:bluedynamics,项目名称:cornerstone.feed.core,代码行数:7,代码来源:atom.py


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