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


Python xml.etree方法代码示例

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


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

示例1: import_etree

# 需要导入模块: import xml [as 别名]
# 或者: from xml import etree [as 别名]
def import_etree():
    import xml
    # first try the usual way
    try:
        import xml.etree
        return xml.etree
    except ImportError:
        pass
    # do it by hook or by crook...
    import os
    import imp
    xml_site_package = os.path.join(os.path.dirname(os.__file__), 'xml')
    m = imp.find_module('etree', [xml_site_package])

    etree = imp.load_module('xml.etree', *m)
    setattr(xml, 'etree', etree)
    return etree 
开发者ID:cloudregistry,项目名称:eppy,代码行数:19,代码来源:xmldict.py

示例2: test_multiplePackages

# 需要导入模块: import xml [as 别名]
# 或者: from xml import etree [as 别名]
def test_multiplePackages(self):
        """
        L{wrapFQPN} returns a L{twisted.python.modules.PythonModule}
        referring to the deepest package described by dotted FQPN.
        """
        import xml.etree
        self.assertModuleWrapperRefersTo(self.wrapFQPN('xml.etree'), xml.etree) 
开发者ID:glyph,项目名称:automat,代码行数:9,代码来源:test_discover.py

示例3: test_multiplePackagesFinalModule

# 需要导入模块: import xml [as 别名]
# 或者: from xml import etree [as 别名]
def test_multiplePackagesFinalModule(self):
        """
        L{wrapFQPN} returns a L{twisted.python.modules.PythonModule}
        referring to the deepest module described by dotted FQPN.
        """
        import xml.etree.ElementTree
        self.assertModuleWrapperRefersTo(
            self.wrapFQPN('xml.etree.ElementTree'), xml.etree.ElementTree) 
开发者ID:glyph,项目名称:automat,代码行数:10,代码来源:test_discover.py

示例4: test_multiplePackagesObject

# 需要导入模块: import xml [as 别名]
# 或者: from xml import etree [as 别名]
def test_multiplePackagesObject(self):
        """
        L{wrapFQPN} returns a L{twisted.python.modules.PythonAttribute}
        referring to the deepest object described by an FQPN,
        descending through several packages.
        """
        import xml.etree.ElementTree
        import automat

        for fqpn, obj in [('xml.etree.ElementTree.fromstring',
                           xml.etree.ElementTree.fromstring),
                          ('automat.MethodicalMachine.__doc__',
                           automat.MethodicalMachine.__doc__)]:
            self.assertAttributeWrapperRefersTo(
                self.wrapFQPN(fqpn), fqpn, obj) 
开发者ID:glyph,项目名称:automat,代码行数:17,代码来源:test_discover.py

示例5: test_failsWithMultiplePackagesMissingModuleOrPackage

# 需要导入模块: import xml [as 别名]
# 或者: from xml import etree [as 别名]
def test_failsWithMultiplePackagesMissingModuleOrPackage(self):
        """
        L{wrapFQPN} raises L{NoObject} when given an FQPN that contains a
        missing attribute, module, or package.
        """
        for bad in ('xml.etree.nope!',
                    'xml.etree.nope!.but.the.rest.is.believable'):
            with self.assertRaises(self.NoObject):
                self.wrapFQPN(bad) 
开发者ID:glyph,项目名称:automat,代码行数:11,代码来源:test_discover.py

示例6: test_ignored_modules_invalid_pattern

# 需要导入模块: import xml [as 别名]
# 或者: from xml import etree [as 别名]
def test_ignored_modules_invalid_pattern(self):
        node = astroid.extract_node(
            """
        import xml
        xml.etree.Lala
        """
        )
        message = Message(
            "no-member", node=node, args=("Module", "xml.etree", "Lala", "")
        )
        with self.assertAddsMessages(message):
            self.checker.visit_attribute(node) 
开发者ID:sofia-netsurv,项目名称:python-netsurv,代码行数:14,代码来源:unittest_checker_typecheck.py

示例7: test_ignored_modules_patterns

# 需要导入模块: import xml [as 别名]
# 或者: from xml import etree [as 别名]
def test_ignored_modules_patterns(self):
        node = astroid.extract_node(
            """
        import xml
        xml.etree.portocola #@
        """
        )
        with self.assertNoMessages():
            self.checker.visit_attribute(node) 
开发者ID:sofia-netsurv,项目名称:python-netsurv,代码行数:11,代码来源:unittest_checker_typecheck.py

示例8: test_ignored_classes_no_recursive_pattern

# 需要导入模块: import xml [as 别名]
# 或者: from xml import etree [as 别名]
def test_ignored_classes_no_recursive_pattern(self):
        node = astroid.extract_node(
            """
        import xml
        xml.etree.ElementTree.Test
        """
        )
        message = Message(
            "no-member", node=node, args=("Module", "xml.etree.ElementTree", "Test", "")
        )
        with self.assertAddsMessages(message):
            self.checker.visit_attribute(node) 
开发者ID:sofia-netsurv,项目名称:python-netsurv,代码行数:14,代码来源:unittest_checker_typecheck.py


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