xmlclass/xmlclass.py
changeset 1847 6198190bc121
parent 1846 14b40afccd69
child 1850 614396cbffbf
equal deleted inserted replaced
1846:14b40afccd69 1847:6198190bc121
   587         else:
   587         else:
   588             return None
   588             return None
   589 
   589 
   590     def GenerateTag(value, name=None, indent=0):
   590     def GenerateTag(value, name=None, indent=0):
   591         if name is not None and not (infos["minOccurs"] == 0 and value is None):
   591         if name is not None and not (infos["minOccurs"] == 0 and value is None):
   592             ind1, ind2 = getIndent(indent, name)
   592             ind1, _ind2 = getIndent(indent, name)
   593             return ind1 + "<%s/>\n" % name
   593             return ind1 + "<%s/>\n" % name
   594         else:
   594         else:
   595             return ""
   595             return ""
   596 
   596 
   597     return {
   597     return {
   624                 value = infos["elmt_type"]["initial"]()
   624                 value = infos["elmt_type"]["initial"]()
   625                 if infos["type"] != ANY:
   625                 if infos["type"] != ANY:
   626                     DefaultElementClass.__setattr__(value, "tag", element_name)
   626                     DefaultElementClass.__setattr__(value, "tag", element_name)
   627                     value._init_()
   627                     value._init_()
   628                 return value
   628                 return value
   629         return [initial_value() for i in xrange(infos["minOccurs"])]
   629         return [initial_value() for dummy in xrange(infos["minOccurs"])]
   630     else:
   630     else:
   631         return []
   631         return []
   632 
   632 
   633 
   633 
   634 def GetContentInfos(name, choices):
   634 def GetContentInfos(name, choices):
   687 
   687 
   688     def GetContentInitial():
   688     def GetContentInitial():
   689         content_name, infos = choices[0]
   689         content_name, infos = choices[0]
   690         if content_name == "sequence":
   690         if content_name == "sequence":
   691             content_value = []
   691             content_value = []
   692             for i in xrange(infos["minOccurs"]):
   692             for dummy in xrange(infos["minOccurs"]):
   693                 for element_infos in infos["elements"]:
   693                 for element_infos in infos["elements"]:
   694                     content_value.extend(GetElementInitialValue(factory, element_infos))
   694                     content_value.extend(GetElementInitialValue(factory, element_infos))
   695         else:
   695         else:
   696             content_value = GetElementInitialValue(factory, infos)
   696             content_value = GetElementInitialValue(factory, infos)
   697         return content_value
   697         return content_value