Пример #1
0
def read_root_name(path: Path) -> str:
    try:
        recovering_parser = etree.XMLParser(recover=True)
        tree = etree.parse(str(path), parser=recovering_parser)
        root = tree.getroot()
        return PythonAbstractGenerator.class_name(
            etree.QName(root.tag).localname)
    except etree.XMLSyntaxError:
        return ""
    except OSError:
        return ""
Пример #2
0
 def test_class_name(self):
     self.assertEqual("XsString", generator.class_name("xs:string"))
     self.assertEqual("FooBarBam", generator.class_name("foo:bar_bam"))
     self.assertEqual("ListType", generator.class_name("List"))
     self.assertEqual("Type", generator.class_name(".*"))