xmlclass/xsdschema.py
changeset 1736 7e61baa047f0
parent 1734 750eeb7230a1
child 1739 ec153828ded2
--- a/xmlclass/xsdschema.py	Mon Aug 14 22:30:41 2017 +0300
+++ b/xmlclass/xsdschema.py	Mon Aug 14 23:27:15 2017 +0300
@@ -30,9 +30,11 @@
 
 from xmlclass import *
 
+
 def GenerateDictFacets(facets):
     return dict([(name, (None, False)) for name in facets])
 
+
 def GenerateSimpleTypeXMLText(function):
     def generateXMLTextMethod(value, name=None, indent=0):
         text = ""
@@ -45,6 +47,7 @@
         return text
     return generateXMLTextMethod
 
+
 def GenerateFloatXMLText(extra_values=[], decimal=None):
     float_format = (lambda x: "{:.{width}f}".format(x, width=decimal).rstrip('0')
                     if decimal is not None else str)
@@ -110,6 +113,7 @@
 
 # Simple type elements
 
+
 def GenerateFacetReducing(facetname, canbefixed):
     def ReduceFacet(factory, attributes, elements):
         annotations, children = factory.ReduceElements(elements)
@@ -486,6 +490,7 @@
     simpleType["generate"] = GenerateSimpleType
     return simpleType
 
+
 def ReduceSimpleType(factory, attributes, elements):
     # Reduce all the simple type children
     annotations, children = factory.ReduceElements(elements)
@@ -497,6 +502,7 @@
 
 # Complex type
 
+
 def ExtractAttributes(factory, elements, base=None):
     attrs = []
     attrnames = {}
@@ -717,6 +723,7 @@
     any.update(attributes)
     return any
 
+
 def ReduceElement(factory, attributes, elements):
     annotations, children = factory.ReduceElements(elements)
 
@@ -771,6 +778,7 @@
     else:
         raise ValueError("\"Element\" must have at least a \"ref\" or a \"name\" defined!")
 
+
 def ReduceAll(factory, attributes, elements):
     annotations, children = factory.ReduceElements(elements)
 
@@ -867,6 +875,7 @@
 
 # Constraint elements
 
+
 def ReduceUnique(factory, attributes, elements):
     annotations, children = factory.ReduceElements(elements)
 
@@ -874,6 +883,7 @@
     unique.update(attributes)
     return unique
 
+
 def ReduceKey(factory, attributes, elements):
     annotations, children = factory.ReduceElements(elements)
 
@@ -881,6 +891,7 @@
     key.update(attributes)
     return key
 
+
 def ReduceKeyRef(factory, attributes, elements):
     annotations, children = factory.ReduceElements(elements)
 
@@ -888,6 +899,7 @@
     keyref.update(attributes)
     return keyref
 
+
 def ReduceSelector(factory, attributes, elements):
     annotations, children = factory.ReduceElements(elements)
 
@@ -895,6 +907,7 @@
     selector.update(attributes)
     return selector
 
+
 def ReduceField(factory, attributes, elements):
     annotations, children = factory.ReduceElements(elements)
 
@@ -909,6 +922,7 @@
     annotations, children = factory.ReduceElements(elements)
     raise ValueError("\"import\" element isn't supported yet!")
 
+
 def ReduceInclude(factory, attributes, elements):
     annotations, children = factory.ReduceElements(elements)
 
@@ -933,6 +947,7 @@
     factory.EquivalentClassesParent.update(include_factory.EquivalentClassesParent)
     return None
 
+
 def ReduceRedefine(factory, attributes, elements):
     annotations, children = factory.ReduceElements(elements)
     raise ValueError("\"redefine\" element isn't supported yet!")
@@ -962,6 +977,7 @@
             elif not CompareSchema(infos, child):
                 raise ValueError("\"%s\" is defined twice in targetNamespace!" % child["name"])
 
+
 def CompareSchema(schema, reference):
     if isinstance(schema, ListType):
         if not isinstance(reference, ListType) or len(schema) != len(reference):
@@ -1091,11 +1107,12 @@
                     return element_infos
         return None
 
-"""
-This function opens the xsd file and generate a xml parser with class lookup from
-the xml tree
-"""
+
 def GenerateParserFromXSD(filepath):
+    """
+    This function opens the xsd file and generate a xml parser with class lookup from
+    the xml tree
+    """
     xsdfile = open(filepath, 'r')
     xsdstring = xsdfile.read()
     xsdfile.close()
@@ -1105,10 +1122,11 @@
     os.chdir(cwd)
     return parser
 
-"""
-This function generate a xml from the xsd given as a string
-"""
+
 def GenerateParserFromXSDstring(xsdstring):
+    """
+    This function generate a xml from the xsd given as a string
+    """
     return GenerateParser(XSDClassFactory(minidom.parseString(xsdstring)), xsdstring)