FreeCAD
3229 строк · 108.3 Кб
1#!/usr/bin/env python3
2
3#
4# Generated Wed Sep 27 11:00:46 2023 by generateDS.py.
5# Update it with: python generateDS.py -o generateModel_Module.py generateMetaModel_Module.xsd
6#
7# WARNING! All changes made in this file will be lost!
8#
9
10
11import sys12import getopt13from xml.dom import minidom14from xml.dom import Node15
16#
17# If you have installed IPython you can uncomment and use the following.
18# IPython is available from http://ipython.scipy.org/.
19#
20
21## from IPython.Shell import IPShellEmbed
22## args = ''
23## ipshell = IPShellEmbed(args,
24## banner = 'Dropping into IPython',
25## exit_msg = 'Leaving Interpreter, back to program.')
26
27# Then use the following line where and when you want to drop into the
28# IPython shell:
29# ipshell('<some message> -- Entering ipshell.\nHit Ctrl-D to exit')
30
31#
32# Support/utility functions.
33#
34
35
36def showIndent(outfile, level):37for idx in range(level):38outfile.write(" ")39
40
41def quote_xml(inStr):42s1 = inStr43s1 = s1.replace("&", "&")44s1 = s1.replace("<", "<")45s1 = s1.replace('"', """)46return s147
48
49def quote_python(inStr):50s1 = inStr51if s1.find("'") == -1:52if s1.find("\n") == -1:53return "'%s'" % s154else:55return "'''%s'''" % s156else:57if s1.find('"') != -1:58s1 = s1.replace('"', '\\"')59if s1.find("\n") == -1:60return '"%s"' % s161else:62return '"""%s"""' % s163
64
65class MixedContainer:66# Constants for category:67CategoryNone = 068CategoryText = 169CategorySimple = 270CategoryComplex = 371# Constants for content_type:72TypeNone = 073TypeText = 174TypeString = 275TypeInteger = 376TypeFloat = 477TypeDecimal = 578TypeDouble = 679TypeBoolean = 780
81def __init__(self, category, content_type, name, value):82self.category = category83self.content_type = content_type84self.name = name85self.value = value86
87def getCategory(self):88return self.category89
90def getContenttype(self, content_type):91return self.content_type92
93def getValue(self):94return self.value95
96def getName(self):97return self.name98
99def export(self, outfile, level, name):100if self.category == MixedContainer.CategoryText:101outfile.write(self.value)102elif self.category == MixedContainer.CategorySimple:103self.exportSimple(outfile, level, name)104else: # category == MixedContainer.CategoryComplex105self.value.export(outfile, level, name)106
107def exportSimple(self, outfile, level, name):108if self.content_type == MixedContainer.TypeString:109outfile.write("<%s>%s</%s>" % (self.name, self.value, self.name))110elif (111self.content_type == MixedContainer.TypeInteger112or self.content_type == MixedContainer.TypeBoolean113):114outfile.write("<%s>%d</%s>" % (self.name, self.value, self.name))115elif (116self.content_type == MixedContainer.TypeFloat117or self.content_type == MixedContainer.TypeDecimal118):119outfile.write("<%s>%f</%s>" % (self.name, self.value, self.name))120elif self.content_type == MixedContainer.TypeDouble:121outfile.write("<%s>%g</%s>" % (self.name, self.value, self.name))122
123def exportLiteral(self, outfile, level, name):124if self.category == MixedContainer.CategoryText:125showIndent(outfile, level)126outfile.write(127'MixedContainer(%d, %d, "%s", "%s"),\n'128% (self.category, self.content_type, self.name, self.value)129)130elif self.category == MixedContainer.CategorySimple:131showIndent(outfile, level)132outfile.write(133'MixedContainer(%d, %d, "%s", "%s"),\n'134% (self.category, self.content_type, self.name, self.value)135)136else: # category == MixedContainer.CategoryComplex137showIndent(outfile, level)138outfile.write(139'MixedContainer(%d, %d, "%s",\n'140% (141self.category,142self.content_type,143self.name,144)145)146self.value.exportLiteral(outfile, level + 1)147showIndent(outfile, level)148outfile.write(")\n")149
150
151#
152# Data representation classes.
153#
154
155
156class GenerateModel:157subclass = None158
159def __init__(self, Module=None, PythonExport=None):160if Module is None:161self.Module = []162else:163self.Module = Module164if PythonExport is None:165self.PythonExport = []166else:167self.PythonExport = PythonExport168
169def factory(*args_, **kwargs_):170if GenerateModel.subclass:171return GenerateModel.subclass(*args_, **kwargs_)172else:173return GenerateModel(*args_, **kwargs_)174
175factory = staticmethod(factory)176
177def getModule(self):178return self.Module179
180def setModule(self, Module):181self.Module = Module182
183def addModule(self, value):184self.Module.append(value)185
186def insertModule(self, index, value):187self.Module[index] = value188
189def getPythonexport(self):190return self.PythonExport191
192def setPythonexport(self, PythonExport):193self.PythonExport = PythonExport194
195def addPythonexport(self, value):196self.PythonExport.append(value)197
198def insertPythonexport(self, index, value):199self.PythonExport[index] = value200
201def export(self, outfile, level, name_="GenerateModel"):202showIndent(outfile, level)203outfile.write("<%s>\n" % name_)204self.exportChildren(outfile, level + 1, name_)205showIndent(outfile, level)206outfile.write("</%s>\n" % name_)207
208def exportAttributes(self, outfile, level, name_="GenerateModel"):209pass210
211def exportChildren(self, outfile, level, name_="GenerateModel"):212for Module_ in self.getModule():213Module_.export(outfile, level)214for PythonExport_ in self.getPythonexport():215PythonExport_.export(outfile, level)216
217def exportLiteral(self, outfile, level, name_="GenerateModel"):218level += 1219self.exportLiteralAttributes(outfile, level, name_)220self.exportLiteralChildren(outfile, level, name_)221
222def exportLiteralAttributes(self, outfile, level, name_):223pass224
225def exportLiteralChildren(self, outfile, level, name_):226showIndent(outfile, level)227outfile.write("Module=[\n")228level += 1229for Module in self.Module:230showIndent(outfile, level)231outfile.write("Module(\n")232Module.exportLiteral(outfile, level)233showIndent(outfile, level)234outfile.write("),\n")235level -= 1236showIndent(outfile, level)237outfile.write("],\n")238showIndent(outfile, level)239outfile.write("PythonExport=[\n")240level += 1241for PythonExport in self.PythonExport:242showIndent(outfile, level)243outfile.write("PythonExport(\n")244PythonExport.exportLiteral(outfile, level)245showIndent(outfile, level)246outfile.write("),\n")247level -= 1248showIndent(outfile, level)249outfile.write("],\n")250
251def build(self, node_):252attrs = node_.attributes253self.buildAttributes(attrs)254for child_ in node_.childNodes:255nodeName_ = child_.nodeName.split(":")[-1]256self.buildChildren(child_, nodeName_)257
258def buildAttributes(self, attrs):259pass260
261def buildChildren(self, child_, nodeName_):262if child_.nodeType == Node.ELEMENT_NODE and nodeName_ == "Module":263obj_ = Module.factory()264obj_.build(child_)265self.Module.append(obj_)266elif child_.nodeType == Node.ELEMENT_NODE and nodeName_ == "PythonExport":267obj_ = PythonExport.factory()268obj_.build(child_)269self.PythonExport.append(obj_)270
271
272# end class GenerateModel
273
274
275class PythonExport:276subclass = None277
278def __init__(279self,280Name="",281PythonName="",282Include="",283Father="",284Twin="",285Namespace="",286FatherInclude="",287FatherNamespace="",288Constructor=0,289NumberProtocol=0,290RichCompare=0,291TwinPointer="",292Delete=0,293Reference=0,294Initialization=0,295DisableNotify=0,296DescriptorGetter=0,297DescriptorSetter=0,298Documentation=None,299Methode=None,300Attribute=None,301Sequence=None,302CustomAttributes="",303ClassDeclarations="",304ForwardDeclarations="",305):306self.Name = Name307self.PythonName = PythonName308self.Include = Include309self.Father = Father310self.Twin = Twin311self.Namespace = Namespace312self.FatherInclude = FatherInclude313self.FatherNamespace = FatherNamespace314self.Constructor = Constructor315self.NumberProtocol = NumberProtocol316self.RichCompare = RichCompare317self.TwinPointer = TwinPointer318self.Delete = Delete319self.Reference = Reference320self.Initialization = Initialization321self.DisableNotify = DisableNotify322self.DescriptorGetter = DescriptorGetter323self.DescriptorSetter = DescriptorSetter324self.Documentation = Documentation325if Methode is None:326self.Methode = []327else:328self.Methode = Methode329if Attribute is None:330self.Attribute = []331else:332self.Attribute = Attribute333self.Sequence = Sequence334self.CustomAttributes = CustomAttributes335self.ClassDeclarations = ClassDeclarations336self.ForwardDeclarations = ForwardDeclarations337
338def factory(*args_, **kwargs_):339if PythonExport.subclass:340return PythonExport.subclass(*args_, **kwargs_)341else:342return PythonExport(*args_, **kwargs_)343
344factory = staticmethod(factory)345
346def getDocumentation(self):347return self.Documentation348
349def setDocumentation(self, Documentation):350self.Documentation = Documentation351
352def getMethode(self):353return self.Methode354
355def setMethode(self, Methode):356self.Methode = Methode357
358def addMethode(self, value):359self.Methode.append(value)360
361def insertMethode(self, index, value):362self.Methode[index] = value363
364def getAttribute(self):365return self.Attribute366
367def setAttribute(self, Attribute):368self.Attribute = Attribute369
370def addAttribute(self, value):371self.Attribute.append(value)372
373def insertAttribute(self, index, value):374self.Attribute[index] = value375
376def getSequence(self):377return self.Sequence378
379def setSequence(self, Sequence):380self.Sequence = Sequence381
382def getCustomattributes(self):383return self.CustomAttributes384
385def setCustomattributes(self, CustomAttributes):386self.CustomAttributes = CustomAttributes387
388def getClassdeclarations(self):389return self.ClassDeclarations390
391def setClassdeclarations(self, ClassDeclarations):392self.ClassDeclarations = ClassDeclarations393
394def getForwarddeclarations(self):395return self.ForwardDeclarations396
397def setForwarddeclarations(self, ForwardDeclarations):398self.ForwardDeclarations = ForwardDeclarations399
400def getName(self):401return self.Name402
403def setName(self, Name):404self.Name = Name405
406def getPythonname(self):407return self.PythonName408
409def setPythonname(self, PythonName):410self.PythonName = PythonName411
412def getInclude(self):413return self.Include414
415def setInclude(self, Include):416self.Include = Include417
418def getFather(self):419return self.Father420
421def setFather(self, Father):422self.Father = Father423
424def getTwin(self):425return self.Twin426
427def setTwin(self, Twin):428self.Twin = Twin429
430def getNamespace(self):431return self.Namespace432
433def setNamespace(self, Namespace):434self.Namespace = Namespace435
436def getFatherinclude(self):437return self.FatherInclude438
439def setFatherinclude(self, FatherInclude):440self.FatherInclude = FatherInclude441
442def getFathernamespace(self):443return self.FatherNamespace444
445def setFathernamespace(self, FatherNamespace):446self.FatherNamespace = FatherNamespace447
448def getConstructor(self):449return self.Constructor450
451def setConstructor(self, Constructor):452self.Constructor = Constructor453
454def getNumberprotocol(self):455return self.NumberProtocol456
457def setNumberprotocol(self, NumberProtocol):458self.NumberProtocol = NumberProtocol459
460def getRichcompare(self):461return self.RichCompare462
463def setRichcompare(self, RichCompare):464self.RichCompare = RichCompare465
466def getTwinpointer(self):467return self.TwinPointer468
469def setTwinpointer(self, TwinPointer):470self.TwinPointer = TwinPointer471
472def getDelete(self):473return self.Delete474
475def setDelete(self, Delete):476self.Delete = Delete477
478def getReference(self):479return self.Reference480
481def setReference(self, Reference):482self.Reference = Reference483
484def getInitialization(self):485return self.Initialization486
487def setInitialization(self, Initialization):488self.Initialization = Initialization489
490def getDisablenotify(self):491return self.DisableNotify492
493def setDisablenotify(self, DisableNotify):494self.DisableNotify = DisableNotify495
496def getDescriptorgetter(self):497return self.DescriptorGetter498
499def setDescriptorgetter(self, DescriptorGetter):500self.DescriptorGetter = DescriptorGetter501
502def getDescriptorsetter(self):503return self.DescriptorSetter504
505def setDescriptorsetter(self, DescriptorSetter):506self.DescriptorSetter = DescriptorSetter507
508def export(self, outfile, level, name_="PythonExport"):509showIndent(outfile, level)510outfile.write("<%s" % (name_,))511self.exportAttributes(outfile, level, name_="PythonExport")512outfile.write(">\n")513self.exportChildren(outfile, level + 1, name_)514showIndent(outfile, level)515outfile.write("</%s>\n" % name_)516
517def exportAttributes(self, outfile, level, name_="PythonExport"):518outfile.write(' Name="%s"' % (self.getName(),))519if self.getPythonname() is not None:520outfile.write(' PythonName="%s"' % (self.getPythonname(),))521outfile.write(' Include="%s"' % (self.getInclude(),))522outfile.write(' Father="%s"' % (self.getFather(),))523outfile.write(' Twin="%s"' % (self.getTwin(),))524outfile.write(' Namespace="%s"' % (self.getNamespace(),))525outfile.write(' FatherInclude="%s"' % (self.getFatherinclude(),))526outfile.write(' FatherNamespace="%s"' % (self.getFathernamespace(),))527if self.getConstructor() is not None:528outfile.write(' Constructor="%s"' % (self.getConstructor(),))529if self.getNumberprotocol() is not None:530outfile.write(' NumberProtocol="%s"' % (self.getNumberprotocol(),))531if self.getRichcompare() is not None:532outfile.write(' RichCompare="%s"' % (self.getRichcompare(),))533outfile.write(' TwinPointer="%s"' % (self.getTwinpointer(),))534if self.getDelete() is not None:535outfile.write(' Delete="%s"' % (self.getDelete(),))536if self.getReference() is not None:537outfile.write(' Reference="%s"' % (self.getReference(),))538if self.getInitialization() is not None:539outfile.write(' Initialization="%s"' % (self.getInitialization(),))540if self.getDisablenotify() is not None:541outfile.write(' DisableNotify="%s"' % (self.getDisablenotify(),))542if self.getDescriptorgetter() is not None:543outfile.write(' DescriptorGetter="%s"' % (self.getDescriptorgetter(),))544if self.getDescriptorsetter() is not None:545outfile.write(' DescriptorSetter="%s"' % (self.getDescriptorsetter(),))546
547def exportChildren(self, outfile, level, name_="PythonExport"):548if self.Documentation:549self.Documentation.export(outfile, level)550for Methode_ in self.getMethode():551Methode_.export(outfile, level)552for Attribute_ in self.getAttribute():553Attribute_.export(outfile, level)554if self.Sequence:555self.Sequence.export(outfile, level)556showIndent(outfile, level)557outfile.write(558"<CustomAttributes>%s</CustomAttributes>\n" % quote_xml(self.getCustomattributes())559)560showIndent(outfile, level)561outfile.write(562"<ClassDeclarations>%s</ClassDeclarations>\n" % quote_xml(self.getClassdeclarations())563)564showIndent(outfile, level)565outfile.write(566"<ForwardDeclarations>%s</ForwardDeclarations>\n"567% quote_xml(self.getForwarddeclarations())568)569
570def exportLiteral(self, outfile, level, name_="PythonExport"):571level += 1572self.exportLiteralAttributes(outfile, level, name_)573self.exportLiteralChildren(outfile, level, name_)574
575def exportLiteralAttributes(self, outfile, level, name_):576showIndent(outfile, level)577outfile.write('Name = "%s",\n' % (self.getName(),))578showIndent(outfile, level)579outfile.write('PythonName = "%s",\n' % (self.getPythonname(),))580showIndent(outfile, level)581outfile.write('Include = "%s",\n' % (self.getInclude(),))582showIndent(outfile, level)583outfile.write('Father = "%s",\n' % (self.getFather(),))584showIndent(outfile, level)585outfile.write('Twin = "%s",\n' % (self.getTwin(),))586showIndent(outfile, level)587outfile.write('Namespace = "%s",\n' % (self.getNamespace(),))588showIndent(outfile, level)589outfile.write('FatherInclude = "%s",\n' % (self.getFatherinclude(),))590showIndent(outfile, level)591outfile.write('FatherNamespace = "%s",\n' % (self.getFathernamespace(),))592showIndent(outfile, level)593outfile.write('Constructor = "%s",\n' % (self.getConstructor(),))594showIndent(outfile, level)595outfile.write('NumberProtocol = "%s",\n' % (self.getNumberprotocol(),))596showIndent(outfile, level)597outfile.write('RichCompare = "%s",\n' % (self.getRichcompare(),))598showIndent(outfile, level)599outfile.write('TwinPointer = "%s",\n' % (self.getTwinpointer(),))600showIndent(outfile, level)601outfile.write('Delete = "%s",\n' % (self.getDelete(),))602showIndent(outfile, level)603outfile.write('Reference = "%s",\n' % (self.getReference(),))604showIndent(outfile, level)605outfile.write('Initialization = "%s",\n' % (self.getInitialization(),))606showIndent(outfile, level)607outfile.write('DisableNotify = "%s",\n' % (self.getDisablenotify(),))608showIndent(outfile, level)609outfile.write('DescriptorGetter = "%s",\n' % (self.getDescriptorgetter(),))610showIndent(outfile, level)611outfile.write('DescriptorSetter = "%s",\n' % (self.getDescriptorsetter(),))612
613def exportLiteralChildren(self, outfile, level, name_):614if self.Documentation:615showIndent(outfile, level)616outfile.write("Documentation=Documentation(\n")617self.Documentation.exportLiteral(outfile, level)618showIndent(outfile, level)619outfile.write("),\n")620showIndent(outfile, level)621outfile.write("Methode=[\n")622level += 1623for Methode in self.Methode:624showIndent(outfile, level)625outfile.write("Methode(\n")626Methode.exportLiteral(outfile, level)627showIndent(outfile, level)628outfile.write("),\n")629level -= 1630showIndent(outfile, level)631outfile.write("],\n")632showIndent(outfile, level)633outfile.write("Attribute=[\n")634level += 1635for Attribute in self.Attribute:636showIndent(outfile, level)637outfile.write("Attribute(\n")638Attribute.exportLiteral(outfile, level)639showIndent(outfile, level)640outfile.write("),\n")641level -= 1642showIndent(outfile, level)643outfile.write("],\n")644if self.Sequence:645showIndent(outfile, level)646outfile.write("Sequence=Sequence(\n")647self.Sequence.exportLiteral(outfile, level)648showIndent(outfile, level)649outfile.write("),\n")650showIndent(outfile, level)651outfile.write("CustomAttributes=%s,\n" % quote_python(self.getCustomattributes()))652showIndent(outfile, level)653outfile.write("ClassDeclarations=%s,\n" % quote_python(self.getClassdeclarations()))654showIndent(outfile, level)655outfile.write("ForwardDeclarations=%s,\n" % quote_python(self.getForwarddeclarations()))656
657def build(self, node_):658attrs = node_.attributes659self.buildAttributes(attrs)660for child_ in node_.childNodes:661nodeName_ = child_.nodeName.split(":")[-1]662self.buildChildren(child_, nodeName_)663
664def buildAttributes(self, attrs):665if attrs.get("Name"):666self.Name = attrs.get("Name").value667if attrs.get("PythonName"):668self.PythonName = attrs.get("PythonName").value669if attrs.get("Include"):670self.Include = attrs.get("Include").value671if attrs.get("Father"):672self.Father = attrs.get("Father").value673if attrs.get("Twin"):674self.Twin = attrs.get("Twin").value675if attrs.get("Namespace"):676self.Namespace = attrs.get("Namespace").value677if attrs.get("FatherInclude"):678self.FatherInclude = attrs.get("FatherInclude").value679if attrs.get("FatherNamespace"):680self.FatherNamespace = attrs.get("FatherNamespace").value681if attrs.get("Constructor"):682if attrs.get("Constructor").value in ("true", "1"):683self.Constructor = 1684elif attrs.get("Constructor").value in ("false", "0"):685self.Constructor = 0686else:687raise ValueError("Bad boolean attribute (Constructor)")688if attrs.get("NumberProtocol"):689if attrs.get("NumberProtocol").value in ("true", "1"):690self.NumberProtocol = 1691elif attrs.get("NumberProtocol").value in ("false", "0"):692self.NumberProtocol = 0693else:694raise ValueError("Bad boolean attribute (NumberProtocol)")695if attrs.get("RichCompare"):696if attrs.get("RichCompare").value in ("true", "1"):697self.RichCompare = 1698elif attrs.get("RichCompare").value in ("false", "0"):699self.RichCompare = 0700else:701raise ValueError("Bad boolean attribute (RichCompare)")702if attrs.get("TwinPointer"):703self.TwinPointer = attrs.get("TwinPointer").value704if attrs.get("Delete"):705if attrs.get("Delete").value in ("true", "1"):706self.Delete = 1707elif attrs.get("Delete").value in ("false", "0"):708self.Delete = 0709else:710raise ValueError("Bad boolean attribute (Delete)")711if attrs.get("Reference"):712if attrs.get("Reference").value in ("true", "1"):713self.Reference = 1714elif attrs.get("Reference").value in ("false", "0"):715self.Reference = 0716else:717raise ValueError("Bad boolean attribute (Reference)")718if attrs.get("Initialization"):719if attrs.get("Initialization").value in ("true", "1"):720self.Initialization = 1721elif attrs.get("Initialization").value in ("false", "0"):722self.Initialization = 0723else:724raise ValueError("Bad boolean attribute (Initialization)")725if attrs.get("DisableNotify"):726if attrs.get("DisableNotify").value in ("true", "1"):727self.DisableNotify = 1728elif attrs.get("DisableNotify").value in ("false", "0"):729self.DisableNotify = 0730else:731raise ValueError("Bad boolean attribute (DisableNotify)")732if attrs.get("DescriptorGetter"):733if attrs.get("DescriptorGetter").value in ("true", "1"):734self.DescriptorGetter = 1735elif attrs.get("DescriptorGetter").value in ("false", "0"):736self.DescriptorGetter = 0737else:738raise ValueError("Bad boolean attribute (DescriptorGetter)")739if attrs.get("DescriptorSetter"):740if attrs.get("DescriptorSetter").value in ("true", "1"):741self.DescriptorSetter = 1742elif attrs.get("DescriptorSetter").value in ("false", "0"):743self.DescriptorSetter = 0744else:745raise ValueError("Bad boolean attribute (DescriptorSetter)")746
747def buildChildren(self, child_, nodeName_):748if child_.nodeType == Node.ELEMENT_NODE and nodeName_ == "Documentation":749obj_ = Documentation.factory()750obj_.build(child_)751self.setDocumentation(obj_)752elif child_.nodeType == Node.ELEMENT_NODE and nodeName_ == "Methode":753obj_ = Methode.factory()754obj_.build(child_)755self.Methode.append(obj_)756elif child_.nodeType == Node.ELEMENT_NODE and nodeName_ == "Attribute":757obj_ = Attribute.factory()758obj_.build(child_)759self.Attribute.append(obj_)760elif child_.nodeType == Node.ELEMENT_NODE and nodeName_ == "Sequence":761obj_ = Sequence.factory()762obj_.build(child_)763self.setSequence(obj_)764elif child_.nodeType == Node.ELEMENT_NODE and nodeName_ == "CustomAttributes":765CustomAttributes_ = ""766for text__content_ in child_.childNodes:767CustomAttributes_ += text__content_.nodeValue768self.CustomAttributes = CustomAttributes_769elif child_.nodeType == Node.ELEMENT_NODE and nodeName_ == "ClassDeclarations":770ClassDeclarations_ = ""771for text__content_ in child_.childNodes:772ClassDeclarations_ += text__content_.nodeValue773self.ClassDeclarations = ClassDeclarations_774elif child_.nodeType == Node.ELEMENT_NODE and nodeName_ == "ForwardDeclarations":775ForwardDeclarations_ = ""776for text__content_ in child_.childNodes:777ForwardDeclarations_ += text__content_.nodeValue778self.ForwardDeclarations = ForwardDeclarations_779
780
781# end class PythonExport
782
783
784class Methode:785subclass = None786
787def __init__(788self,789Name="",790Const=0,791Keyword=0,792NoArgs=0,793Class=0,794Static=0,795Documentation=None,796Parameter=None,797):798self.Name = Name799self.Const = Const800self.Keyword = Keyword801self.NoArgs = NoArgs802self.Class = Class803self.Static = Static804self.Documentation = Documentation805if Parameter is None:806self.Parameter = []807else:808self.Parameter = Parameter809
810def factory(*args_, **kwargs_):811if Methode.subclass:812return Methode.subclass(*args_, **kwargs_)813else:814return Methode(*args_, **kwargs_)815
816factory = staticmethod(factory)817
818def getDocumentation(self):819return self.Documentation820
821def setDocumentation(self, Documentation):822self.Documentation = Documentation823
824def getParameter(self):825return self.Parameter826
827def setParameter(self, Parameter):828self.Parameter = Parameter829
830def addParameter(self, value):831self.Parameter.append(value)832
833def insertParameter(self, index, value):834self.Parameter[index] = value835
836def getName(self):837return self.Name838
839def setName(self, Name):840self.Name = Name841
842def getConst(self):843return self.Const844
845def setConst(self, Const):846self.Const = Const847
848def getKeyword(self):849return self.Keyword850
851def setKeyword(self, Keyword):852self.Keyword = Keyword853
854def getNoargs(self):855return self.NoArgs856
857def setNoargs(self, NoArgs):858self.NoArgs = NoArgs859
860def getClass(self):861return self.Class862
863def setClass(self, Class):864self.Class = Class865
866def getStatic(self):867return self.Static868
869def setStatic(self, Static):870self.Static = Static871
872def export(self, outfile, level, name_="Methode"):873showIndent(outfile, level)874outfile.write("<%s" % (name_,))875self.exportAttributes(outfile, level, name_="Methode")876outfile.write(">\n")877self.exportChildren(outfile, level + 1, name_)878showIndent(outfile, level)879outfile.write("</%s>\n" % name_)880
881def exportAttributes(self, outfile, level, name_="Methode"):882outfile.write(' Name="%s"' % (self.getName(),))883if self.getConst() is not None:884outfile.write(' Const="%s"' % (self.getConst(),))885if self.getKeyword() is not None:886outfile.write(' Keyword="%s"' % (self.getKeyword(),))887if self.getNoargs() is not None:888outfile.write(' NoArgs="%s"' % (self.getNoargs(),))889if self.getClass() is not None:890outfile.write(' Class="%s"' % (self.getClass(),))891if self.getStatic() is not None:892outfile.write(' Static="%s"' % (self.getStatic(),))893
894def exportChildren(self, outfile, level, name_="Methode"):895if self.Documentation:896self.Documentation.export(outfile, level)897for Parameter_ in self.getParameter():898Parameter_.export(outfile, level)899
900def exportLiteral(self, outfile, level, name_="Methode"):901level += 1902self.exportLiteralAttributes(outfile, level, name_)903self.exportLiteralChildren(outfile, level, name_)904
905def exportLiteralAttributes(self, outfile, level, name_):906showIndent(outfile, level)907outfile.write('Name = "%s",\n' % (self.getName(),))908showIndent(outfile, level)909outfile.write('Const = "%s",\n' % (self.getConst(),))910showIndent(outfile, level)911outfile.write('Keyword = "%s",\n' % (self.getKeyword(),))912showIndent(outfile, level)913outfile.write('NoArgs = "%s",\n' % (self.getNoargs(),))914showIndent(outfile, level)915outfile.write('Class = "%s",\n' % (self.getClass(),))916showIndent(outfile, level)917outfile.write('Static = "%s",\n' % (self.getStatic(),))918
919def exportLiteralChildren(self, outfile, level, name_):920if self.Documentation:921showIndent(outfile, level)922outfile.write("Documentation=Documentation(\n")923self.Documentation.exportLiteral(outfile, level)924showIndent(outfile, level)925outfile.write("),\n")926showIndent(outfile, level)927outfile.write("Parameter=[\n")928level += 1929for Parameter in self.Parameter:930showIndent(outfile, level)931outfile.write("Parameter(\n")932Parameter.exportLiteral(outfile, level)933showIndent(outfile, level)934outfile.write("),\n")935level -= 1936showIndent(outfile, level)937outfile.write("],\n")938
939def build(self, node_):940attrs = node_.attributes941self.buildAttributes(attrs)942for child_ in node_.childNodes:943nodeName_ = child_.nodeName.split(":")[-1]944self.buildChildren(child_, nodeName_)945
946def buildAttributes(self, attrs):947if attrs.get("Name"):948self.Name = attrs.get("Name").value949if attrs.get("Const"):950if attrs.get("Const").value in ("true", "1"):951self.Const = 1952elif attrs.get("Const").value in ("false", "0"):953self.Const = 0954else:955raise ValueError("Bad boolean attribute (Const)")956if attrs.get("Keyword"):957if attrs.get("Keyword").value in ("true", "1"):958self.Keyword = 1959elif attrs.get("Keyword").value in ("false", "0"):960self.Keyword = 0961else:962raise ValueError("Bad boolean attribute (Keyword)")963if attrs.get("NoArgs"):964if attrs.get("NoArgs").value in ("true", "1"):965self.NoArgs = 1966elif attrs.get("NoArgs").value in ("false", "0"):967self.NoArgs = 0968else:969raise ValueError("Bad boolean attribute (NoArgs)")970if attrs.get("Class"):971if attrs.get("Class").value in ("true", "1"):972self.Class = 1973elif attrs.get("Class").value in ("false", "0"):974self.Class = 0975else:976raise ValueError("Bad boolean attribute (Class)")977if attrs.get("Static"):978if attrs.get("Static").value in ("true", "1"):979self.Static = 1980elif attrs.get("Static").value in ("false", "0"):981self.Static = 0982else:983raise ValueError("Bad boolean attribute (Static)")984
985def buildChildren(self, child_, nodeName_):986if child_.nodeType == Node.ELEMENT_NODE and nodeName_ == "Documentation":987obj_ = Documentation.factory()988obj_.build(child_)989self.setDocumentation(obj_)990elif child_.nodeType == Node.ELEMENT_NODE and nodeName_ == "Parameter":991obj_ = Parameter.factory()992obj_.build(child_)993self.Parameter.append(obj_)994
995
996# end class Methode
997
998
999class Attribute:1000subclass = None1001
1002def __init__(self, Name="", ReadOnly=0, Documentation=None, Parameter=None):1003self.Name = Name1004self.ReadOnly = ReadOnly1005self.Documentation = Documentation1006self.Parameter = Parameter1007
1008def factory(*args_, **kwargs_):1009if Attribute.subclass:1010return Attribute.subclass(*args_, **kwargs_)1011else:1012return Attribute(*args_, **kwargs_)1013
1014factory = staticmethod(factory)1015
1016def getDocumentation(self):1017return self.Documentation1018
1019def setDocumentation(self, Documentation):1020self.Documentation = Documentation1021
1022def getParameter(self):1023return self.Parameter1024
1025def setParameter(self, Parameter):1026self.Parameter = Parameter1027
1028def getName(self):1029return self.Name1030
1031def setName(self, Name):1032self.Name = Name1033
1034def getReadonly(self):1035return self.ReadOnly1036
1037def setReadonly(self, ReadOnly):1038self.ReadOnly = ReadOnly1039
1040def export(self, outfile, level, name_="Attribute"):1041showIndent(outfile, level)1042outfile.write("<%s" % (name_,))1043self.exportAttributes(outfile, level, name_="Attribute")1044outfile.write(">\n")1045self.exportChildren(outfile, level + 1, name_)1046showIndent(outfile, level)1047outfile.write("</%s>\n" % name_)1048
1049def exportAttributes(self, outfile, level, name_="Attribute"):1050outfile.write(' Name="%s"' % (self.getName(),))1051outfile.write(' ReadOnly="%s"' % (self.getReadonly(),))1052
1053def exportChildren(self, outfile, level, name_="Attribute"):1054if self.Documentation:1055self.Documentation.export(outfile, level)1056if self.Parameter:1057self.Parameter.export(outfile, level)1058
1059def exportLiteral(self, outfile, level, name_="Attribute"):1060level += 11061self.exportLiteralAttributes(outfile, level, name_)1062self.exportLiteralChildren(outfile, level, name_)1063
1064def exportLiteralAttributes(self, outfile, level, name_):1065showIndent(outfile, level)1066outfile.write('Name = "%s",\n' % (self.getName(),))1067showIndent(outfile, level)1068outfile.write('ReadOnly = "%s",\n' % (self.getReadonly(),))1069
1070def exportLiteralChildren(self, outfile, level, name_):1071if self.Documentation:1072showIndent(outfile, level)1073outfile.write("Documentation=Documentation(\n")1074self.Documentation.exportLiteral(outfile, level)1075showIndent(outfile, level)1076outfile.write("),\n")1077if self.Parameter:1078showIndent(outfile, level)1079outfile.write("Parameter=Parameter(\n")1080self.Parameter.exportLiteral(outfile, level)1081showIndent(outfile, level)1082outfile.write("),\n")1083
1084def build(self, node_):1085attrs = node_.attributes1086self.buildAttributes(attrs)1087for child_ in node_.childNodes:1088nodeName_ = child_.nodeName.split(":")[-1]1089self.buildChildren(child_, nodeName_)1090
1091def buildAttributes(self, attrs):1092if attrs.get("Name"):1093self.Name = attrs.get("Name").value1094if attrs.get("ReadOnly"):1095if attrs.get("ReadOnly").value in ("true", "1"):1096self.ReadOnly = 11097elif attrs.get("ReadOnly").value in ("false", "0"):1098self.ReadOnly = 01099else:1100raise ValueError("Bad boolean attribute (ReadOnly)")1101
1102def buildChildren(self, child_, nodeName_):1103if child_.nodeType == Node.ELEMENT_NODE and nodeName_ == "Documentation":1104obj_ = Documentation.factory()1105obj_.build(child_)1106self.setDocumentation(obj_)1107elif child_.nodeType == Node.ELEMENT_NODE and nodeName_ == "Parameter":1108obj_ = Parameter.factory()1109obj_.build(child_)1110self.setParameter(obj_)1111
1112
1113# end class Attribute
1114
1115
1116class Sequence:1117subclass = None1118
1119def __init__(1120self,1121sq_length=0,1122sq_concat=0,1123sq_repeat=0,1124sq_item=0,1125mp_subscript=0,1126sq_ass_item=0,1127mp_ass_subscript=0,1128sq_contains=0,1129sq_inplace_concat=0,1130sq_inplace_repeat=0,1131valueOf_="",1132):1133self.sq_length = sq_length1134self.sq_concat = sq_concat1135self.sq_repeat = sq_repeat1136self.sq_item = sq_item1137self.mp_subscript = mp_subscript1138self.sq_ass_item = sq_ass_item1139self.mp_ass_subscript = mp_ass_subscript1140self.sq_contains = sq_contains1141self.sq_inplace_concat = sq_inplace_concat1142self.sq_inplace_repeat = sq_inplace_repeat1143self.valueOf_ = valueOf_1144
1145def factory(*args_, **kwargs_):1146if Sequence.subclass:1147return Sequence.subclass(*args_, **kwargs_)1148else:1149return Sequence(*args_, **kwargs_)1150
1151factory = staticmethod(factory)1152
1153def getSq_length(self):1154return self.sq_length1155
1156def setSq_length(self, sq_length):1157self.sq_length = sq_length1158
1159def getSq_concat(self):1160return self.sq_concat1161
1162def setSq_concat(self, sq_concat):1163self.sq_concat = sq_concat1164
1165def getSq_repeat(self):1166return self.sq_repeat1167
1168def setSq_repeat(self, sq_repeat):1169self.sq_repeat = sq_repeat1170
1171def getSq_item(self):1172return self.sq_item1173
1174def setSq_item(self, sq_item):1175self.sq_item = sq_item1176
1177def getMp_subscript(self):1178return self.mp_subscript1179
1180def setMp_subscript(self, mp_subscript):1181self.mp_subscript = mp_subscript1182
1183def getSq_ass_item(self):1184return self.sq_ass_item1185
1186def setSq_ass_item(self, sq_ass_item):1187self.sq_ass_item = sq_ass_item1188
1189def getMp_ass_subscript(self):1190return self.mp_ass_subscript1191
1192def setMp_ass_subscript(self, mp_ass_subscript):1193self.mp_ass_subscript = mp_ass_subscript1194
1195def getSq_contains(self):1196return self.sq_contains1197
1198def setSq_contains(self, sq_contains):1199self.sq_contains = sq_contains1200
1201def getSq_inplace_concat(self):1202return self.sq_inplace_concat1203
1204def setSq_inplace_concat(self, sq_inplace_concat):1205self.sq_inplace_concat = sq_inplace_concat1206
1207def getSq_inplace_repeat(self):1208return self.sq_inplace_repeat1209
1210def setSq_inplace_repeat(self, sq_inplace_repeat):1211self.sq_inplace_repeat = sq_inplace_repeat1212
1213def getValueOf_(self):1214return self.valueOf_1215
1216def setValueOf_(self, valueOf_):1217self.valueOf_ = valueOf_1218
1219def export(self, outfile, level, name_="Sequence"):1220showIndent(outfile, level)1221outfile.write("<%s" % (name_,))1222self.exportAttributes(outfile, level, name_="Sequence")1223outfile.write(">\n")1224self.exportChildren(outfile, level + 1, name_)1225showIndent(outfile, level)1226outfile.write("</%s>\n" % name_)1227
1228def exportAttributes(self, outfile, level, name_="Sequence"):1229outfile.write(' sq_length="%s"' % (self.getSq_length(),))1230outfile.write(' sq_concat="%s"' % (self.getSq_concat(),))1231outfile.write(' sq_repeat="%s"' % (self.getSq_repeat(),))1232outfile.write(' sq_item="%s"' % (self.getSq_item(),))1233outfile.write(' mp_subscript="%s"' % (self.getMp_subscript(),))1234outfile.write(' sq_ass_item="%s"' % (self.getSq_ass_item(),))1235outfile.write(' mp_ass_subscript="%s"' % (self.getMp_ass_subscript(),))1236outfile.write(' sq_contains="%s"' % (self.getSq_contains(),))1237outfile.write(' sq_inplace_concat="%s"' % (self.getSq_inplace_concat(),))1238outfile.write(' sq_inplace_repeat="%s"' % (self.getSq_inplace_repeat(),))1239
1240def exportChildren(self, outfile, level, name_="Sequence"):1241outfile.write(self.valueOf_)1242
1243def exportLiteral(self, outfile, level, name_="Sequence"):1244level += 11245self.exportLiteralAttributes(outfile, level, name_)1246self.exportLiteralChildren(outfile, level, name_)1247
1248def exportLiteralAttributes(self, outfile, level, name_):1249showIndent(outfile, level)1250outfile.write('sq_length = "%s",\n' % (self.getSq_length(),))1251showIndent(outfile, level)1252outfile.write('sq_concat = "%s",\n' % (self.getSq_concat(),))1253showIndent(outfile, level)1254outfile.write('sq_repeat = "%s",\n' % (self.getSq_repeat(),))1255showIndent(outfile, level)1256outfile.write('sq_item = "%s",\n' % (self.getSq_item(),))1257showIndent(outfile, level)1258outfile.write('mp_subscript = "%s",\n' % (self.getMp_subscript(),))1259showIndent(outfile, level)1260outfile.write('sq_ass_item = "%s",\n' % (self.getSq_ass_item(),))1261showIndent(outfile, level)1262outfile.write('mp_ass_subscript = "%s",\n' % (self.getMp_ass_subscript(),))1263showIndent(outfile, level)1264outfile.write('sq_contains = "%s",\n' % (self.getSq_contains(),))1265showIndent(outfile, level)1266outfile.write('sq_inplace_concat = "%s",\n' % (self.getSq_inplace_concat(),))1267showIndent(outfile, level)1268outfile.write('sq_inplace_repeat = "%s",\n' % (self.getSq_inplace_repeat(),))1269
1270def exportLiteralChildren(self, outfile, level, name_):1271showIndent(outfile, level)1272outfile.write('valueOf_ = "%s",\n' % (self.valueOf_,))1273
1274def build(self, node_):1275attrs = node_.attributes1276self.buildAttributes(attrs)1277for child_ in node_.childNodes:1278nodeName_ = child_.nodeName.split(":")[-1]1279self.buildChildren(child_, nodeName_)1280
1281def buildAttributes(self, attrs):1282if attrs.get("sq_length"):1283if attrs.get("sq_length").value in ("true", "1"):1284self.sq_length = 11285elif attrs.get("sq_length").value in ("false", "0"):1286self.sq_length = 01287else:1288raise ValueError("Bad boolean attribute (sq_length)")1289if attrs.get("sq_concat"):1290if attrs.get("sq_concat").value in ("true", "1"):1291self.sq_concat = 11292elif attrs.get("sq_concat").value in ("false", "0"):1293self.sq_concat = 01294else:1295raise ValueError("Bad boolean attribute (sq_concat)")1296if attrs.get("sq_repeat"):1297if attrs.get("sq_repeat").value in ("true", "1"):1298self.sq_repeat = 11299elif attrs.get("sq_repeat").value in ("false", "0"):1300self.sq_repeat = 01301else:1302raise ValueError("Bad boolean attribute (sq_repeat)")1303if attrs.get("sq_item"):1304if attrs.get("sq_item").value in ("true", "1"):1305self.sq_item = 11306elif attrs.get("sq_item").value in ("false", "0"):1307self.sq_item = 01308else:1309raise ValueError("Bad boolean attribute (sq_item)")1310if attrs.get("mp_subscript"):1311if attrs.get("mp_subscript").value in ("true", "1"):1312self.mp_subscript = 11313elif attrs.get("mp_subscript").value in ("false", "0"):1314self.mp_subscript = 01315else:1316raise ValueError("Bad boolean attribute (mp_subscript)")1317if attrs.get("sq_ass_item"):1318if attrs.get("sq_ass_item").value in ("true", "1"):1319self.sq_ass_item = 11320elif attrs.get("sq_ass_item").value in ("false", "0"):1321self.sq_ass_item = 01322else:1323raise ValueError("Bad boolean attribute (sq_ass_item)")1324if attrs.get("mp_ass_subscript"):1325if attrs.get("mp_ass_subscript").value in ("true", "1"):1326self.mp_ass_subscript = 11327elif attrs.get("mp_ass_subscript").value in ("false", "0"):1328self.mp_ass_subscript = 01329else:1330raise ValueError("Bad boolean attribute (mp_ass_subscript)")1331if attrs.get("sq_contains"):1332if attrs.get("sq_contains").value in ("true", "1"):1333self.sq_contains = 11334elif attrs.get("sq_contains").value in ("false", "0"):1335self.sq_contains = 01336else:1337raise ValueError("Bad boolean attribute (sq_contains)")1338if attrs.get("sq_inplace_concat"):1339if attrs.get("sq_inplace_concat").value in ("true", "1"):1340self.sq_inplace_concat = 11341elif attrs.get("sq_inplace_concat").value in ("false", "0"):1342self.sq_inplace_concat = 01343else:1344raise ValueError("Bad boolean attribute (sq_inplace_concat)")1345if attrs.get("sq_inplace_repeat"):1346if attrs.get("sq_inplace_repeat").value in ("true", "1"):1347self.sq_inplace_repeat = 11348elif attrs.get("sq_inplace_repeat").value in ("false", "0"):1349self.sq_inplace_repeat = 01350else:1351raise ValueError("Bad boolean attribute (sq_inplace_repeat)")1352
1353def buildChildren(self, child_, nodeName_):1354self.valueOf_ = ""1355for child in child_.childNodes:1356if child.nodeType == Node.TEXT_NODE:1357self.valueOf_ += child.nodeValue1358
1359
1360# end class Sequence
1361
1362
1363class Module:1364subclass = None1365
1366def __init__(self, Name="", Documentation=None, Dependencies=None, Content=None):1367self.Name = Name1368self.Documentation = Documentation1369self.Dependencies = Dependencies1370self.Content = Content1371
1372def factory(*args_, **kwargs_):1373if Module.subclass:1374return Module.subclass(*args_, **kwargs_)1375else:1376return Module(*args_, **kwargs_)1377
1378factory = staticmethod(factory)1379
1380def getDocumentation(self):1381return self.Documentation1382
1383def setDocumentation(self, Documentation):1384self.Documentation = Documentation1385
1386def getDependencies(self):1387return self.Dependencies1388
1389def setDependencies(self, Dependencies):1390self.Dependencies = Dependencies1391
1392def getContent(self):1393return self.Content1394
1395def setContent(self, Content):1396self.Content = Content1397
1398def getName(self):1399return self.Name1400
1401def setName(self, Name):1402self.Name = Name1403
1404def export(self, outfile, level, name_="Module"):1405showIndent(outfile, level)1406outfile.write("<%s" % (name_,))1407self.exportAttributes(outfile, level, name_="Module")1408outfile.write(">\n")1409self.exportChildren(outfile, level + 1, name_)1410showIndent(outfile, level)1411outfile.write("</%s>\n" % name_)1412
1413def exportAttributes(self, outfile, level, name_="Module"):1414outfile.write(' Name="%s"' % (self.getName(),))1415
1416def exportChildren(self, outfile, level, name_="Module"):1417if self.Documentation:1418self.Documentation.export(outfile, level)1419if self.Dependencies:1420self.Dependencies.export(outfile, level)1421if self.Content:1422self.Content.export(outfile, level)1423
1424def exportLiteral(self, outfile, level, name_="Module"):1425level += 11426self.exportLiteralAttributes(outfile, level, name_)1427self.exportLiteralChildren(outfile, level, name_)1428
1429def exportLiteralAttributes(self, outfile, level, name_):1430showIndent(outfile, level)1431outfile.write('Name = "%s",\n' % (self.getName(),))1432
1433def exportLiteralChildren(self, outfile, level, name_):1434if self.Documentation:1435showIndent(outfile, level)1436outfile.write("Documentation=Documentation(\n")1437self.Documentation.exportLiteral(outfile, level)1438showIndent(outfile, level)1439outfile.write("),\n")1440if self.Dependencies:1441showIndent(outfile, level)1442outfile.write("Dependencies=Dependencies(\n")1443self.Dependencies.exportLiteral(outfile, level)1444showIndent(outfile, level)1445outfile.write("),\n")1446if self.Content:1447showIndent(outfile, level)1448outfile.write("Content=Content(\n")1449self.Content.exportLiteral(outfile, level)1450showIndent(outfile, level)1451outfile.write("),\n")1452
1453def build(self, node_):1454attrs = node_.attributes1455self.buildAttributes(attrs)1456for child_ in node_.childNodes:1457nodeName_ = child_.nodeName.split(":")[-1]1458self.buildChildren(child_, nodeName_)1459
1460def buildAttributes(self, attrs):1461if attrs.get("Name"):1462self.Name = attrs.get("Name").value1463
1464def buildChildren(self, child_, nodeName_):1465if child_.nodeType == Node.ELEMENT_NODE and nodeName_ == "Documentation":1466obj_ = Documentation.factory()1467obj_.build(child_)1468self.setDocumentation(obj_)1469elif child_.nodeType == Node.ELEMENT_NODE and nodeName_ == "Dependencies":1470obj_ = Dependencies.factory()1471obj_.build(child_)1472self.setDependencies(obj_)1473elif child_.nodeType == Node.ELEMENT_NODE and nodeName_ == "Content":1474obj_ = Content.factory()1475obj_.build(child_)1476self.setContent(obj_)1477
1478
1479# end class Module
1480
1481
1482class Dependencies:1483subclass = None1484
1485def __init__(self, Module=None):1486if Module is None:1487self.Module = []1488else:1489self.Module = Module1490
1491def factory(*args_, **kwargs_):1492if Dependencies.subclass:1493return Dependencies.subclass(*args_, **kwargs_)1494else:1495return Dependencies(*args_, **kwargs_)1496
1497factory = staticmethod(factory)1498
1499def getModule(self):1500return self.Module1501
1502def setModule(self, Module):1503self.Module = Module1504
1505def addModule(self, value):1506self.Module.append(value)1507
1508def insertModule(self, index, value):1509self.Module[index] = value1510
1511def export(self, outfile, level, name_="Dependencies"):1512showIndent(outfile, level)1513outfile.write("<%s>\n" % name_)1514self.exportChildren(outfile, level + 1, name_)1515showIndent(outfile, level)1516outfile.write("</%s>\n" % name_)1517
1518def exportAttributes(self, outfile, level, name_="Dependencies"):1519pass1520
1521def exportChildren(self, outfile, level, name_="Dependencies"):1522for Module_ in self.getModule():1523Module_.export(outfile, level)1524
1525def exportLiteral(self, outfile, level, name_="Dependencies"):1526level += 11527self.exportLiteralAttributes(outfile, level, name_)1528self.exportLiteralChildren(outfile, level, name_)1529
1530def exportLiteralAttributes(self, outfile, level, name_):1531pass1532
1533def exportLiteralChildren(self, outfile, level, name_):1534showIndent(outfile, level)1535outfile.write("Module=[\n")1536level += 11537for Module in self.Module:1538showIndent(outfile, level)1539outfile.write("Module(\n")1540Module.exportLiteral(outfile, level)1541showIndent(outfile, level)1542outfile.write("),\n")1543level -= 11544showIndent(outfile, level)1545outfile.write("],\n")1546
1547def build(self, node_):1548attrs = node_.attributes1549self.buildAttributes(attrs)1550for child_ in node_.childNodes:1551nodeName_ = child_.nodeName.split(":")[-1]1552self.buildChildren(child_, nodeName_)1553
1554def buildAttributes(self, attrs):1555pass1556
1557def buildChildren(self, child_, nodeName_):1558if child_.nodeType == Node.ELEMENT_NODE and nodeName_ == "Module":1559obj_ = Module.factory()1560obj_.build(child_)1561self.Module.append(obj_)1562
1563
1564# end class Dependencies
1565
1566
1567class Content:1568subclass = None1569
1570def __init__(1571self, Property=None, Feature=None, DocObject=None, GuiCommand=None, PreferencesPage=None1572):1573if Property is None:1574self.Property = []1575else:1576self.Property = Property1577if Feature is None:1578self.Feature = []1579else:1580self.Feature = Feature1581if DocObject is None:1582self.DocObject = []1583else:1584self.DocObject = DocObject1585if GuiCommand is None:1586self.GuiCommand = []1587else:1588self.GuiCommand = GuiCommand1589if PreferencesPage is None:1590self.PreferencesPage = []1591else:1592self.PreferencesPage = PreferencesPage1593
1594def factory(*args_, **kwargs_):1595if Content.subclass:1596return Content.subclass(*args_, **kwargs_)1597else:1598return Content(*args_, **kwargs_)1599
1600factory = staticmethod(factory)1601
1602def getProperty(self):1603return self.Property1604
1605def setProperty(self, Property):1606self.Property = Property1607
1608def addProperty(self, value):1609self.Property.append(value)1610
1611def insertProperty(self, index, value):1612self.Property[index] = value1613
1614def getFeature(self):1615return self.Feature1616
1617def setFeature(self, Feature):1618self.Feature = Feature1619
1620def addFeature(self, value):1621self.Feature.append(value)1622
1623def insertFeature(self, index, value):1624self.Feature[index] = value1625
1626def getDocobject(self):1627return self.DocObject1628
1629def setDocobject(self, DocObject):1630self.DocObject = DocObject1631
1632def addDocobject(self, value):1633self.DocObject.append(value)1634
1635def insertDocobject(self, index, value):1636self.DocObject[index] = value1637
1638def getGuicommand(self):1639return self.GuiCommand1640
1641def setGuicommand(self, GuiCommand):1642self.GuiCommand = GuiCommand1643
1644def addGuicommand(self, value):1645self.GuiCommand.append(value)1646
1647def insertGuicommand(self, index, value):1648self.GuiCommand[index] = value1649
1650def getPreferencespage(self):1651return self.PreferencesPage1652
1653def setPreferencespage(self, PreferencesPage):1654self.PreferencesPage = PreferencesPage1655
1656def addPreferencespage(self, value):1657self.PreferencesPage.append(value)1658
1659def insertPreferencespage(self, index, value):1660self.PreferencesPage[index] = value1661
1662def export(self, outfile, level, name_="Content"):1663showIndent(outfile, level)1664outfile.write("<%s>\n" % name_)1665self.exportChildren(outfile, level + 1, name_)1666showIndent(outfile, level)1667outfile.write("</%s>\n" % name_)1668
1669def exportAttributes(self, outfile, level, name_="Content"):1670pass1671
1672def exportChildren(self, outfile, level, name_="Content"):1673for Property_ in self.getProperty():1674Property_.export(outfile, level)1675for Feature_ in self.getFeature():1676Feature_.export(outfile, level)1677for DocObject_ in self.getDocobject():1678DocObject_.export(outfile, level)1679for GuiCommand_ in self.getGuicommand():1680showIndent(outfile, level)1681outfile.write("<GuiCommand>%s</GuiCommand>\n" % quote_xml(GuiCommand_))1682for PreferencesPage_ in self.getPreferencespage():1683showIndent(outfile, level)1684outfile.write("<PreferencesPage>%s</PreferencesPage>\n" % quote_xml(PreferencesPage_))1685
1686def exportLiteral(self, outfile, level, name_="Content"):1687level += 11688self.exportLiteralAttributes(outfile, level, name_)1689self.exportLiteralChildren(outfile, level, name_)1690
1691def exportLiteralAttributes(self, outfile, level, name_):1692pass1693
1694def exportLiteralChildren(self, outfile, level, name_):1695showIndent(outfile, level)1696outfile.write("Property=[\n")1697level += 11698for Property in self.Property:1699showIndent(outfile, level)1700outfile.write("Property(\n")1701Property.exportLiteral(outfile, level)1702showIndent(outfile, level)1703outfile.write("),\n")1704level -= 11705showIndent(outfile, level)1706outfile.write("],\n")1707showIndent(outfile, level)1708outfile.write("Feature=[\n")1709level += 11710for Feature in self.Feature:1711showIndent(outfile, level)1712outfile.write("Feature(\n")1713Feature.exportLiteral(outfile, level)1714showIndent(outfile, level)1715outfile.write("),\n")1716level -= 11717showIndent(outfile, level)1718outfile.write("],\n")1719showIndent(outfile, level)1720outfile.write("DocObject=[\n")1721level += 11722for DocObject in self.DocObject:1723showIndent(outfile, level)1724outfile.write("DocObject(\n")1725DocObject.exportLiteral(outfile, level)1726showIndent(outfile, level)1727outfile.write("),\n")1728level -= 11729showIndent(outfile, level)1730outfile.write("],\n")1731showIndent(outfile, level)1732outfile.write("GuiCommand=[\n")1733level += 11734for GuiCommand in self.GuiCommand:1735showIndent(outfile, level)1736outfile.write("%s,\n" % quote_python(GuiCommand))1737level -= 11738showIndent(outfile, level)1739outfile.write("],\n")1740showIndent(outfile, level)1741outfile.write("PreferencesPage=[\n")1742level += 11743for PreferencesPage in self.PreferencesPage:1744showIndent(outfile, level)1745outfile.write("%s,\n" % quote_python(PreferencesPage))1746level -= 11747showIndent(outfile, level)1748outfile.write("],\n")1749
1750def build(self, node_):1751attrs = node_.attributes1752self.buildAttributes(attrs)1753for child_ in node_.childNodes:1754nodeName_ = child_.nodeName.split(":")[-1]1755self.buildChildren(child_, nodeName_)1756
1757def buildAttributes(self, attrs):1758pass1759
1760def buildChildren(self, child_, nodeName_):1761if child_.nodeType == Node.ELEMENT_NODE and nodeName_ == "Property":1762obj_ = Property.factory()1763obj_.build(child_)1764self.Property.append(obj_)1765elif child_.nodeType == Node.ELEMENT_NODE and nodeName_ == "Feature":1766obj_ = Feature.factory()1767obj_.build(child_)1768self.Feature.append(obj_)1769elif child_.nodeType == Node.ELEMENT_NODE and nodeName_ == "DocObject":1770obj_ = DocObject.factory()1771obj_.build(child_)1772self.DocObject.append(obj_)1773elif child_.nodeType == Node.ELEMENT_NODE and nodeName_ == "GuiCommand":1774GuiCommand_ = ""1775for text__content_ in child_.childNodes:1776GuiCommand_ += text__content_.nodeValue1777self.GuiCommand.append(GuiCommand_)1778elif child_.nodeType == Node.ELEMENT_NODE and nodeName_ == "PreferencesPage":1779PreferencesPage_ = ""1780for text__content_ in child_.childNodes:1781PreferencesPage_ += text__content_.nodeValue1782self.PreferencesPage.append(PreferencesPage_)1783
1784
1785# end class Content
1786
1787
1788class Feature:1789subclass = None1790
1791def __init__(self, Name="", Documentation=None, Property=None, ViewProvider=None):1792self.Name = Name1793self.Documentation = Documentation1794if Property is None:1795self.Property = []1796else:1797self.Property = Property1798self.ViewProvider = ViewProvider1799
1800def factory(*args_, **kwargs_):1801if Feature.subclass:1802return Feature.subclass(*args_, **kwargs_)1803else:1804return Feature(*args_, **kwargs_)1805
1806factory = staticmethod(factory)1807
1808def getDocumentation(self):1809return self.Documentation1810
1811def setDocumentation(self, Documentation):1812self.Documentation = Documentation1813
1814def getProperty(self):1815return self.Property1816
1817def setProperty(self, Property):1818self.Property = Property1819
1820def addProperty(self, value):1821self.Property.append(value)1822
1823def insertProperty(self, index, value):1824self.Property[index] = value1825
1826def getViewprovider(self):1827return self.ViewProvider1828
1829def setViewprovider(self, ViewProvider):1830self.ViewProvider = ViewProvider1831
1832def getName(self):1833return self.Name1834
1835def setName(self, Name):1836self.Name = Name1837
1838def export(self, outfile, level, name_="Feature"):1839showIndent(outfile, level)1840outfile.write("<%s" % (name_,))1841self.exportAttributes(outfile, level, name_="Feature")1842outfile.write(">\n")1843self.exportChildren(outfile, level + 1, name_)1844showIndent(outfile, level)1845outfile.write("</%s>\n" % name_)1846
1847def exportAttributes(self, outfile, level, name_="Feature"):1848outfile.write(' Name="%s"' % (self.getName(),))1849
1850def exportChildren(self, outfile, level, name_="Feature"):1851if self.Documentation:1852self.Documentation.export(outfile, level)1853for Property_ in self.getProperty():1854Property_.export(outfile, level)1855if self.ViewProvider:1856self.ViewProvider.export(outfile, level)1857
1858def exportLiteral(self, outfile, level, name_="Feature"):1859level += 11860self.exportLiteralAttributes(outfile, level, name_)1861self.exportLiteralChildren(outfile, level, name_)1862
1863def exportLiteralAttributes(self, outfile, level, name_):1864showIndent(outfile, level)1865outfile.write('Name = "%s",\n' % (self.getName(),))1866
1867def exportLiteralChildren(self, outfile, level, name_):1868if self.Documentation:1869showIndent(outfile, level)1870outfile.write("Documentation=Documentation(\n")1871self.Documentation.exportLiteral(outfile, level)1872showIndent(outfile, level)1873outfile.write("),\n")1874showIndent(outfile, level)1875outfile.write("Property=[\n")1876level += 11877for Property in self.Property:1878showIndent(outfile, level)1879outfile.write("Property(\n")1880Property.exportLiteral(outfile, level)1881showIndent(outfile, level)1882outfile.write("),\n")1883level -= 11884showIndent(outfile, level)1885outfile.write("],\n")1886if self.ViewProvider:1887showIndent(outfile, level)1888outfile.write("ViewProvider=ViewProvider(\n")1889self.ViewProvider.exportLiteral(outfile, level)1890showIndent(outfile, level)1891outfile.write("),\n")1892
1893def build(self, node_):1894attrs = node_.attributes1895self.buildAttributes(attrs)1896for child_ in node_.childNodes:1897nodeName_ = child_.nodeName.split(":")[-1]1898self.buildChildren(child_, nodeName_)1899
1900def buildAttributes(self, attrs):1901if attrs.get("Name"):1902self.Name = attrs.get("Name").value1903
1904def buildChildren(self, child_, nodeName_):1905if child_.nodeType == Node.ELEMENT_NODE and nodeName_ == "Documentation":1906obj_ = Documentation.factory()1907obj_.build(child_)1908self.setDocumentation(obj_)1909elif child_.nodeType == Node.ELEMENT_NODE and nodeName_ == "Property":1910obj_ = Property.factory()1911obj_.build(child_)1912self.Property.append(obj_)1913elif child_.nodeType == Node.ELEMENT_NODE and nodeName_ == "ViewProvider":1914obj_ = ViewProvider.factory()1915obj_.build(child_)1916self.setViewprovider(obj_)1917
1918
1919# end class Feature
1920
1921
1922class DocObject:1923subclass = None1924
1925def __init__(self, Name="", Documentation=None, Property=None):1926self.Name = Name1927self.Documentation = Documentation1928if Property is None:1929self.Property = []1930else:1931self.Property = Property1932
1933def factory(*args_, **kwargs_):1934if DocObject.subclass:1935return DocObject.subclass(*args_, **kwargs_)1936else:1937return DocObject(*args_, **kwargs_)1938
1939factory = staticmethod(factory)1940
1941def getDocumentation(self):1942return self.Documentation1943
1944def setDocumentation(self, Documentation):1945self.Documentation = Documentation1946
1947def getProperty(self):1948return self.Property1949
1950def setProperty(self, Property):1951self.Property = Property1952
1953def addProperty(self, value):1954self.Property.append(value)1955
1956def insertProperty(self, index, value):1957self.Property[index] = value1958
1959def getName(self):1960return self.Name1961
1962def setName(self, Name):1963self.Name = Name1964
1965def export(self, outfile, level, name_="DocObject"):1966showIndent(outfile, level)1967outfile.write("<%s" % (name_,))1968self.exportAttributes(outfile, level, name_="DocObject")1969outfile.write(">\n")1970self.exportChildren(outfile, level + 1, name_)1971showIndent(outfile, level)1972outfile.write("</%s>\n" % name_)1973
1974def exportAttributes(self, outfile, level, name_="DocObject"):1975outfile.write(' Name="%s"' % (self.getName(),))1976
1977def exportChildren(self, outfile, level, name_="DocObject"):1978if self.Documentation:1979self.Documentation.export(outfile, level)1980for Property_ in self.getProperty():1981Property_.export(outfile, level)1982
1983def exportLiteral(self, outfile, level, name_="DocObject"):1984level += 11985self.exportLiteralAttributes(outfile, level, name_)1986self.exportLiteralChildren(outfile, level, name_)1987
1988def exportLiteralAttributes(self, outfile, level, name_):1989showIndent(outfile, level)1990outfile.write('Name = "%s",\n' % (self.getName(),))1991
1992def exportLiteralChildren(self, outfile, level, name_):1993if self.Documentation:1994showIndent(outfile, level)1995outfile.write("Documentation=Documentation(\n")1996self.Documentation.exportLiteral(outfile, level)1997showIndent(outfile, level)1998outfile.write("),\n")1999showIndent(outfile, level)2000outfile.write("Property=[\n")2001level += 12002for Property in self.Property:2003showIndent(outfile, level)2004outfile.write("Property(\n")2005Property.exportLiteral(outfile, level)2006showIndent(outfile, level)2007outfile.write("),\n")2008level -= 12009showIndent(outfile, level)2010outfile.write("],\n")2011
2012def build(self, node_):2013attrs = node_.attributes2014self.buildAttributes(attrs)2015for child_ in node_.childNodes:2016nodeName_ = child_.nodeName.split(":")[-1]2017self.buildChildren(child_, nodeName_)2018
2019def buildAttributes(self, attrs):2020if attrs.get("Name"):2021self.Name = attrs.get("Name").value2022
2023def buildChildren(self, child_, nodeName_):2024if child_.nodeType == Node.ELEMENT_NODE and nodeName_ == "Documentation":2025obj_ = Documentation.factory()2026obj_.build(child_)2027self.setDocumentation(obj_)2028elif child_.nodeType == Node.ELEMENT_NODE and nodeName_ == "Property":2029obj_ = Property.factory()2030obj_.build(child_)2031self.Property.append(obj_)2032
2033
2034# end class DocObject
2035
2036
2037class Property:2038subclass = None2039
2040def __init__(self, Name="", Type="", StartValue="", Documentation=None):2041self.Name = Name2042self.Type = Type2043self.StartValue = StartValue2044self.Documentation = Documentation2045
2046def factory(*args_, **kwargs_):2047if Property.subclass:2048return Property.subclass(*args_, **kwargs_)2049else:2050return Property(*args_, **kwargs_)2051
2052factory = staticmethod(factory)2053
2054def getDocumentation(self):2055return self.Documentation2056
2057def setDocumentation(self, Documentation):2058self.Documentation = Documentation2059
2060def getName(self):2061return self.Name2062
2063def setName(self, Name):2064self.Name = Name2065
2066def getType(self):2067return self.Type2068
2069def setType(self, Type):2070self.Type = Type2071
2072def getStartvalue(self):2073return self.StartValue2074
2075def setStartvalue(self, StartValue):2076self.StartValue = StartValue2077
2078def export(self, outfile, level, name_="Property"):2079showIndent(outfile, level)2080outfile.write("<%s" % (name_,))2081self.exportAttributes(outfile, level, name_="Property")2082outfile.write(">\n")2083self.exportChildren(outfile, level + 1, name_)2084showIndent(outfile, level)2085outfile.write("</%s>\n" % name_)2086
2087def exportAttributes(self, outfile, level, name_="Property"):2088outfile.write(' Name="%s"' % (self.getName(),))2089outfile.write(' Type="%s"' % (self.getType(),))2090if self.getStartvalue() is not None:2091outfile.write(' StartValue="%s"' % (self.getStartvalue(),))2092
2093def exportChildren(self, outfile, level, name_="Property"):2094if self.Documentation:2095self.Documentation.export(outfile, level)2096
2097def exportLiteral(self, outfile, level, name_="Property"):2098level += 12099self.exportLiteralAttributes(outfile, level, name_)2100self.exportLiteralChildren(outfile, level, name_)2101
2102def exportLiteralAttributes(self, outfile, level, name_):2103showIndent(outfile, level)2104outfile.write('Name = "%s",\n' % (self.getName(),))2105showIndent(outfile, level)2106outfile.write('Type = "%s",\n' % (self.getType(),))2107showIndent(outfile, level)2108outfile.write('StartValue = "%s",\n' % (self.getStartvalue(),))2109
2110def exportLiteralChildren(self, outfile, level, name_):2111if self.Documentation:2112showIndent(outfile, level)2113outfile.write("Documentation=Documentation(\n")2114self.Documentation.exportLiteral(outfile, level)2115showIndent(outfile, level)2116outfile.write("),\n")2117
2118def build(self, node_):2119attrs = node_.attributes2120self.buildAttributes(attrs)2121for child_ in node_.childNodes:2122nodeName_ = child_.nodeName.split(":")[-1]2123self.buildChildren(child_, nodeName_)2124
2125def buildAttributes(self, attrs):2126if attrs.get("Name"):2127self.Name = attrs.get("Name").value2128if attrs.get("Type"):2129self.Type = attrs.get("Type").value2130if attrs.get("StartValue"):2131self.StartValue = attrs.get("StartValue").value2132
2133def buildChildren(self, child_, nodeName_):2134if child_.nodeType == Node.ELEMENT_NODE and nodeName_ == "Documentation":2135obj_ = Documentation.factory()2136obj_.build(child_)2137self.setDocumentation(obj_)2138
2139
2140# end class Property
2141
2142
2143class Documentation:2144subclass = None2145
2146def __init__(self, Author=None, DeveloperDocu="", UserDocu=""):2147self.Author = Author2148self.DeveloperDocu = DeveloperDocu2149self.UserDocu = UserDocu2150
2151def factory(*args_, **kwargs_):2152if Documentation.subclass:2153return Documentation.subclass(*args_, **kwargs_)2154else:2155return Documentation(*args_, **kwargs_)2156
2157factory = staticmethod(factory)2158
2159def getAuthor(self):2160return self.Author2161
2162def setAuthor(self, Author):2163self.Author = Author2164
2165def getDeveloperdocu(self):2166return self.DeveloperDocu2167
2168def setDeveloperdocu(self, DeveloperDocu):2169self.DeveloperDocu = DeveloperDocu2170
2171def getUserdocu(self):2172return self.UserDocu2173
2174def setUserdocu(self, UserDocu):2175self.UserDocu = UserDocu2176
2177def export(self, outfile, level, name_="Documentation"):2178showIndent(outfile, level)2179outfile.write("<%s>\n" % name_)2180self.exportChildren(outfile, level + 1, name_)2181showIndent(outfile, level)2182outfile.write("</%s>\n" % name_)2183
2184def exportAttributes(self, outfile, level, name_="Documentation"):2185pass2186
2187def exportChildren(self, outfile, level, name_="Documentation"):2188if self.Author:2189self.Author.export(outfile, level)2190showIndent(outfile, level)2191outfile.write("<DeveloperDocu>%s</DeveloperDocu>\n" % quote_xml(self.getDeveloperdocu()))2192showIndent(outfile, level)2193outfile.write("<UserDocu>%s</UserDocu>\n" % quote_xml(self.getUserdocu()))2194
2195def exportLiteral(self, outfile, level, name_="Documentation"):2196level += 12197self.exportLiteralAttributes(outfile, level, name_)2198self.exportLiteralChildren(outfile, level, name_)2199
2200def exportLiteralAttributes(self, outfile, level, name_):2201pass2202
2203def exportLiteralChildren(self, outfile, level, name_):2204if self.Author:2205showIndent(outfile, level)2206outfile.write("Author=Author(\n")2207self.Author.exportLiteral(outfile, level)2208showIndent(outfile, level)2209outfile.write("),\n")2210showIndent(outfile, level)2211outfile.write("DeveloperDocu=%s,\n" % quote_python(self.getDeveloperdocu()))2212showIndent(outfile, level)2213outfile.write("UserDocu=%s,\n" % quote_python(self.getUserdocu()))2214
2215def build(self, node_):2216attrs = node_.attributes2217self.buildAttributes(attrs)2218for child_ in node_.childNodes:2219nodeName_ = child_.nodeName.split(":")[-1]2220self.buildChildren(child_, nodeName_)2221
2222def buildAttributes(self, attrs):2223pass2224
2225def buildChildren(self, child_, nodeName_):2226if child_.nodeType == Node.ELEMENT_NODE and nodeName_ == "Author":2227obj_ = Author.factory()2228obj_.build(child_)2229self.setAuthor(obj_)2230elif child_.nodeType == Node.ELEMENT_NODE and nodeName_ == "DeveloperDocu":2231DeveloperDocu_ = ""2232for text__content_ in child_.childNodes:2233DeveloperDocu_ += text__content_.nodeValue2234self.DeveloperDocu = DeveloperDocu_2235elif child_.nodeType == Node.ELEMENT_NODE and nodeName_ == "UserDocu":2236UserDocu_ = ""2237for text__content_ in child_.childNodes:2238UserDocu_ += text__content_.nodeValue2239self.UserDocu = UserDocu_2240
2241
2242# end class Documentation
2243
2244
2245class Author:2246subclass = None2247
2248def __init__(self, Name="", EMail="", Licence="", valueOf_=""):2249self.Name = Name2250self.EMail = EMail2251self.Licence = Licence2252self.valueOf_ = valueOf_2253
2254def factory(*args_, **kwargs_):2255if Author.subclass:2256return Author.subclass(*args_, **kwargs_)2257else:2258return Author(*args_, **kwargs_)2259
2260factory = staticmethod(factory)2261
2262def getName(self):2263return self.Name2264
2265def setName(self, Name):2266self.Name = Name2267
2268def getEmail(self):2269return self.EMail2270
2271def setEmail(self, EMail):2272self.EMail = EMail2273
2274def getLicence(self):2275return self.Licence2276
2277def setLicence(self, Licence):2278self.Licence = Licence2279
2280def getValueOf_(self):2281return self.valueOf_2282
2283def setValueOf_(self, valueOf_):2284self.valueOf_ = valueOf_2285
2286def export(self, outfile, level, name_="Author"):2287showIndent(outfile, level)2288outfile.write("<%s" % (name_,))2289self.exportAttributes(outfile, level, name_="Author")2290outfile.write(">\n")2291self.exportChildren(outfile, level + 1, name_)2292showIndent(outfile, level)2293outfile.write("</%s>\n" % name_)2294
2295def exportAttributes(self, outfile, level, name_="Author"):2296outfile.write(' Name="%s"' % (self.getName(),))2297outfile.write(' EMail="%s"' % (self.getEmail(),))2298if self.getLicence() is not None:2299outfile.write(' Licence="%s"' % (self.getLicence(),))2300
2301def exportChildren(self, outfile, level, name_="Author"):2302outfile.write(self.valueOf_)2303
2304def exportLiteral(self, outfile, level, name_="Author"):2305level += 12306self.exportLiteralAttributes(outfile, level, name_)2307self.exportLiteralChildren(outfile, level, name_)2308
2309def exportLiteralAttributes(self, outfile, level, name_):2310showIndent(outfile, level)2311outfile.write('Name = "%s",\n' % (self.getName(),))2312showIndent(outfile, level)2313outfile.write('EMail = "%s",\n' % (self.getEmail(),))2314showIndent(outfile, level)2315outfile.write('Licence = "%s",\n' % (self.getLicence(),))2316
2317def exportLiteralChildren(self, outfile, level, name_):2318showIndent(outfile, level)2319outfile.write('valueOf_ = "%s",\n' % (self.valueOf_,))2320
2321def build(self, node_):2322attrs = node_.attributes2323self.buildAttributes(attrs)2324for child_ in node_.childNodes:2325nodeName_ = child_.nodeName.split(":")[-1]2326self.buildChildren(child_, nodeName_)2327
2328def buildAttributes(self, attrs):2329if attrs.get("Name"):2330self.Name = attrs.get("Name").value2331if attrs.get("EMail"):2332self.EMail = attrs.get("EMail").value2333if attrs.get("Licence"):2334self.Licence = attrs.get("Licence").value2335
2336def buildChildren(self, child_, nodeName_):2337self.valueOf_ = ""2338for child in child_.childNodes:2339if child.nodeType == Node.TEXT_NODE:2340self.valueOf_ += child.nodeValue2341
2342
2343# end class Author
2344
2345
2346class ViewProvider:2347subclass = None2348
2349def __init__(self, Property=None):2350if Property is None:2351self.Property = []2352else:2353self.Property = Property2354
2355def factory(*args_, **kwargs_):2356if ViewProvider.subclass:2357return ViewProvider.subclass(*args_, **kwargs_)2358else:2359return ViewProvider(*args_, **kwargs_)2360
2361factory = staticmethod(factory)2362
2363def getProperty(self):2364return self.Property2365
2366def setProperty(self, Property):2367self.Property = Property2368
2369def addProperty(self, value):2370self.Property.append(value)2371
2372def insertProperty(self, index, value):2373self.Property[index] = value2374
2375def export(self, outfile, level, name_="ViewProvider"):2376showIndent(outfile, level)2377outfile.write("<%s>\n" % name_)2378self.exportChildren(outfile, level + 1, name_)2379showIndent(outfile, level)2380outfile.write("</%s>\n" % name_)2381
2382def exportAttributes(self, outfile, level, name_="ViewProvider"):2383pass2384
2385def exportChildren(self, outfile, level, name_="ViewProvider"):2386for Property_ in self.getProperty():2387Property_.export(outfile, level)2388
2389def exportLiteral(self, outfile, level, name_="ViewProvider"):2390level += 12391self.exportLiteralAttributes(outfile, level, name_)2392self.exportLiteralChildren(outfile, level, name_)2393
2394def exportLiteralAttributes(self, outfile, level, name_):2395pass2396
2397def exportLiteralChildren(self, outfile, level, name_):2398showIndent(outfile, level)2399outfile.write("Property=[\n")2400level += 12401for Property in self.Property:2402showIndent(outfile, level)2403outfile.write("Property(\n")2404Property.exportLiteral(outfile, level)2405showIndent(outfile, level)2406outfile.write("),\n")2407level -= 12408showIndent(outfile, level)2409outfile.write("],\n")2410
2411def build(self, node_):2412attrs = node_.attributes2413self.buildAttributes(attrs)2414for child_ in node_.childNodes:2415nodeName_ = child_.nodeName.split(":")[-1]2416self.buildChildren(child_, nodeName_)2417
2418def buildAttributes(self, attrs):2419pass2420
2421def buildChildren(self, child_, nodeName_):2422if child_.nodeType == Node.ELEMENT_NODE and nodeName_ == "Property":2423obj_ = Property.factory()2424obj_.build(child_)2425self.Property.append(obj_)2426
2427
2428# end class ViewProvider
2429
2430
2431class Parameter:2432subclass = None2433
2434def __init__(self, Name="", Type="", valueOf_=""):2435self.Name = Name2436self.Type = Type2437self.valueOf_ = valueOf_2438
2439def factory(*args_, **kwargs_):2440if Parameter.subclass:2441return Parameter.subclass(*args_, **kwargs_)2442else:2443return Parameter(*args_, **kwargs_)2444
2445factory = staticmethod(factory)2446
2447def getName(self):2448return self.Name2449
2450def setName(self, Name):2451self.Name = Name2452
2453def getType(self):2454return self.Type2455
2456def setType(self, Type):2457self.Type = Type2458
2459def getValueOf_(self):2460return self.valueOf_2461
2462def setValueOf_(self, valueOf_):2463self.valueOf_ = valueOf_2464
2465def export(self, outfile, level, name_="Parameter"):2466showIndent(outfile, level)2467outfile.write("<%s" % (name_,))2468self.exportAttributes(outfile, level, name_="Parameter")2469outfile.write(">\n")2470self.exportChildren(outfile, level + 1, name_)2471showIndent(outfile, level)2472outfile.write("</%s>\n" % name_)2473
2474def exportAttributes(self, outfile, level, name_="Parameter"):2475outfile.write(' Name="%s"' % (self.getName(),))2476outfile.write(' Type="%s"' % (self.getType(),))2477
2478def exportChildren(self, outfile, level, name_="Parameter"):2479outfile.write(self.valueOf_)2480
2481def exportLiteral(self, outfile, level, name_="Parameter"):2482level += 12483self.exportLiteralAttributes(outfile, level, name_)2484self.exportLiteralChildren(outfile, level, name_)2485
2486def exportLiteralAttributes(self, outfile, level, name_):2487showIndent(outfile, level)2488outfile.write('Name = "%s",\n' % (self.getName(),))2489showIndent(outfile, level)2490outfile.write('Type = "%s",\n' % (self.getType(),))2491
2492def exportLiteralChildren(self, outfile, level, name_):2493showIndent(outfile, level)2494outfile.write('valueOf_ = "%s",\n' % (self.valueOf_,))2495
2496def build(self, node_):2497attrs = node_.attributes2498self.buildAttributes(attrs)2499for child_ in node_.childNodes:2500nodeName_ = child_.nodeName.split(":")[-1]2501self.buildChildren(child_, nodeName_)2502
2503def buildAttributes(self, attrs):2504if attrs.get("Name"):2505self.Name = attrs.get("Name").value2506if attrs.get("Type"):2507self.Type = attrs.get("Type").value2508
2509def buildChildren(self, child_, nodeName_):2510self.valueOf_ = ""2511for child in child_.childNodes:2512if child.nodeType == Node.TEXT_NODE:2513self.valueOf_ += child.nodeValue2514
2515
2516# end class Parameter
2517
2518
2519from xml.sax import handler, make_parser2520
2521
2522class SaxStackElement:2523def __init__(self, name="", obj=None):2524self.name = name2525self.obj = obj2526self.content = ""2527
2528
2529#
2530# SAX handler
2531#
2532class SaxGeneratemodelHandler(handler.ContentHandler):2533def __init__(self):2534self.stack = []2535self.root = None2536
2537def getRoot(self):2538return self.root2539
2540def setDocumentLocator(self, locator):2541self.locator = locator2542
2543def showError(self, msg):2544print("*** (showError):", msg)2545sys.exit(-1)2546
2547def startElement(self, name, attrs):2548done = 02549if name == "GenerateModel":2550obj = GenerateModel.factory()2551stackObj = SaxStackElement("GenerateModel", obj)2552self.stack.append(stackObj)2553done = 12554elif name == "Module":2555obj = Module.factory()2556stackObj = SaxStackElement("Module", obj)2557self.stack.append(stackObj)2558done = 12559elif name == "PythonExport":2560obj = PythonExport.factory()2561val = attrs.get("Name", None)2562if val is not None:2563obj.setName(val)2564val = attrs.get("PythonName", None)2565if val is not None:2566obj.setPythonname(val)2567val = attrs.get("Include", None)2568if val is not None:2569obj.setInclude(val)2570val = attrs.get("Father", None)2571if val is not None:2572obj.setFather(val)2573val = attrs.get("Twin", None)2574if val is not None:2575obj.setTwin(val)2576val = attrs.get("Namespace", None)2577if val is not None:2578obj.setNamespace(val)2579val = attrs.get("FatherInclude", None)2580if val is not None:2581obj.setFatherinclude(val)2582val = attrs.get("FatherNamespace", None)2583if val is not None:2584obj.setFathernamespace(val)2585val = attrs.get("Constructor", None)2586if val is not None:2587if val in ("true", "1"):2588obj.setConstructor(1)2589elif val in ("false", "0"):2590obj.setConstructor(0)2591else:2592self.reportError(2593'"Constructor" attribute must be boolean ("true", "1", "false", "0")'2594)2595val = attrs.get("NumberProtocol", None)2596if val is not None:2597if val in ("true", "1"):2598obj.setNumberprotocol(1)2599elif val in ("false", "0"):2600obj.setNumberprotocol(0)2601else:2602self.reportError(2603'"NumberProtocol" attribute must be boolean ("true", "1", "false", "0")'2604)2605val = attrs.get("RichCompare", None)2606if val is not None:2607if val in ("true", "1"):2608obj.setRichcompare(1)2609elif val in ("false", "0"):2610obj.setRichcompare(0)2611else:2612self.reportError(2613'"RichCompare" attribute must be boolean ("true", "1", "false", "0")'2614)2615val = attrs.get("TwinPointer", None)2616if val is not None:2617obj.setTwinpointer(val)2618val = attrs.get("Delete", None)2619if val is not None:2620if val in ("true", "1"):2621obj.setDelete(1)2622elif val in ("false", "0"):2623obj.setDelete(0)2624else:2625self.reportError(2626'"Delete" attribute must be boolean ("true", "1", "false", "0")'2627)2628val = attrs.get("Reference", None)2629if val is not None:2630if val in ("true", "1"):2631obj.setReference(1)2632elif val in ("false", "0"):2633obj.setReference(0)2634else:2635self.reportError(2636'"Reference" attribute must be boolean ("true", "1", "false", "0")'2637)2638val = attrs.get("Initialization", None)2639if val is not None:2640if val in ("true", "1"):2641obj.setInitialization(1)2642elif val in ("false", "0"):2643obj.setInitialization(0)2644else:2645self.reportError(2646'"Initialization" attribute must be boolean ("true", "1", "false", "0")'2647)2648val = attrs.get("DisableNotify", None)2649if val is not None:2650if val in ("true", "1"):2651obj.setDisablenotify(1)2652elif val in ("false", "0"):2653obj.setDisablenotify(0)2654else:2655self.reportError(2656'"DisableNotify" attribute must be boolean ("true", "1", "false", "0")'2657)2658val = attrs.get("DescriptorGetter", None)2659if val is not None:2660if val in ("true", "1"):2661obj.setDescriptorgetter(1)2662elif val in ("false", "0"):2663obj.setDescriptorgetter(0)2664else:2665self.reportError(2666'"DescriptorGetter" attribute must be boolean ("true", "1", "false", "0")'2667)2668val = attrs.get("DescriptorSetter", None)2669if val is not None:2670if val in ("true", "1"):2671obj.setDescriptorsetter(1)2672elif val in ("false", "0"):2673obj.setDescriptorsetter(0)2674else:2675self.reportError(2676'"DescriptorSetter" attribute must be boolean ("true", "1", "false", "0")'2677)2678stackObj = SaxStackElement("PythonExport", obj)2679self.stack.append(stackObj)2680done = 12681elif name == "Documentation":2682obj = Documentation.factory()2683stackObj = SaxStackElement("Documentation", obj)2684self.stack.append(stackObj)2685done = 12686elif name == "Methode":2687obj = Methode.factory()2688val = attrs.get("Name", None)2689if val is not None:2690obj.setName(val)2691val = attrs.get("Const", None)2692if val is not None:2693if val in ("true", "1"):2694obj.setConst(1)2695elif val in ("false", "0"):2696obj.setConst(0)2697else:2698self.reportError(2699'"Const" attribute must be boolean ("true", "1", "false", "0")'2700)2701val = attrs.get("Keyword", None)2702if val is not None:2703if val in ("true", "1"):2704obj.setKeyword(1)2705elif val in ("false", "0"):2706obj.setKeyword(0)2707else:2708self.reportError(2709'"Keyword" attribute must be boolean ("true", "1", "false", "0")'2710)2711val = attrs.get("NoArgs", None)2712if val is not None:2713if val in ("true", "1"):2714obj.setNoargs(1)2715elif val in ("false", "0"):2716obj.setNoargs(0)2717else:2718self.reportError(2719'"NoArgs" attribute must be boolean ("true", "1", "false", "0")'2720)2721val = attrs.get("Class", None)2722if val is not None:2723if val in ("true", "1"):2724obj.setClass(1)2725elif val in ("false", "0"):2726obj.setClass(0)2727else:2728self.reportError(2729'"Class" attribute must be boolean ("true", "1", "false", "0")'2730)2731val = attrs.get("Static", None)2732if val is not None:2733if val in ("true", "1"):2734obj.setStatic(1)2735elif val in ("false", "0"):2736obj.setStatic(0)2737else:2738self.reportError(2739'"Static" attribute must be boolean ("true", "1", "false", "0")'2740)2741stackObj = SaxStackElement("Methode", obj)2742self.stack.append(stackObj)2743done = 12744elif name == "Parameter":2745obj = Parameter.factory()2746val = attrs.get("Name", None)2747if val is not None:2748obj.setName(val)2749val = attrs.get("Type", None)2750if val is not None:2751obj.setType(val)2752stackObj = SaxStackElement("Parameter", obj)2753self.stack.append(stackObj)2754done = 12755elif name == "Attribute":2756obj = Attribute.factory()2757val = attrs.get("Name", None)2758if val is not None:2759obj.setName(val)2760val = attrs.get("ReadOnly", None)2761if val is not None:2762if val in ("true", "1"):2763obj.setReadonly(1)2764elif val in ("false", "0"):2765obj.setReadonly(0)2766else:2767self.reportError(2768'"ReadOnly" attribute must be boolean ("true", "1", "false", "0")'2769)2770stackObj = SaxStackElement("Attribute", obj)2771self.stack.append(stackObj)2772done = 12773elif name == "Sequence":2774obj = Sequence.factory()2775val = attrs.get("sq_length", None)2776if val is not None:2777if val in ("true", "1"):2778obj.setSq_length(1)2779elif val in ("false", "0"):2780obj.setSq_length(0)2781else:2782self.reportError(2783'"sq_length" attribute must be boolean ("true", "1", "false", "0")'2784)2785val = attrs.get("sq_concat", None)2786if val is not None:2787if val in ("true", "1"):2788obj.setSq_concat(1)2789elif val in ("false", "0"):2790obj.setSq_concat(0)2791else:2792self.reportError(2793'"sq_concat" attribute must be boolean ("true", "1", "false", "0")'2794)2795val = attrs.get("sq_repeat", None)2796if val is not None:2797if val in ("true", "1"):2798obj.setSq_repeat(1)2799elif val in ("false", "0"):2800obj.setSq_repeat(0)2801else:2802self.reportError(2803'"sq_repeat" attribute must be boolean ("true", "1", "false", "0")'2804)2805val = attrs.get("sq_item", None)2806if val is not None:2807if val in ("true", "1"):2808obj.setSq_item(1)2809elif val in ("false", "0"):2810obj.setSq_item(0)2811else:2812self.reportError(2813'"sq_item" attribute must be boolean ("true", "1", "false", "0")'2814)2815val = attrs.get("mp_subscript", None)2816if val is not None:2817if val in ("true", "1"):2818obj.setMp_subscript(1)2819elif val in ("false", "0"):2820obj.setMp_subscript(0)2821else:2822self.reportError(2823'"mp_subscript" attribute must be boolean ("true", "1", "false", "0")'2824)2825val = attrs.get("sq_ass_item", None)2826if val is not None:2827if val in ("true", "1"):2828obj.setSq_ass_item(1)2829elif val in ("false", "0"):2830obj.setSq_ass_item(0)2831else:2832self.reportError(2833'"sq_ass_item" attribute must be boolean ("true", "1", "false", "0")'2834)2835val = attrs.get("mp_ass_subscript", None)2836if val is not None:2837if val in ("true", "1"):2838obj.setMp_ass_subscript(1)2839elif val in ("false", "0"):2840obj.setMp_ass_subscript(0)2841else:2842self.reportError(2843'"mp_ass_subscript" attribute must be boolean ("true", "1", "false", "0")'2844)2845val = attrs.get("sq_contains", None)2846if val is not None:2847if val in ("true", "1"):2848obj.setSq_contains(1)2849elif val in ("false", "0"):2850obj.setSq_contains(0)2851else:2852self.reportError(2853'"sq_contains" attribute must be boolean ("true", "1", "false", "0")'2854)2855val = attrs.get("sq_inplace_concat", None)2856if val is not None:2857if val in ("true", "1"):2858obj.setSq_inplace_concat(1)2859elif val in ("false", "0"):2860obj.setSq_inplace_concat(0)2861else:2862self.reportError(2863'"sq_inplace_concat" attribute must be boolean ("true", "1", "false", "0")'2864)2865val = attrs.get("sq_inplace_repeat", None)2866if val is not None:2867if val in ("true", "1"):2868obj.setSq_inplace_repeat(1)2869elif val in ("false", "0"):2870obj.setSq_inplace_repeat(0)2871else:2872self.reportError(2873'"sq_inplace_repeat" attribute must be boolean ("true", "1", "false", "0")'2874)2875stackObj = SaxStackElement("Sequence", obj)2876self.stack.append(stackObj)2877done = 12878elif name == "CustomAttributes":2879stackObj = SaxStackElement("CustomAttributes", None)2880self.stack.append(stackObj)2881done = 12882elif name == "ClassDeclarations":2883stackObj = SaxStackElement("ClassDeclarations", None)2884self.stack.append(stackObj)2885done = 12886elif name == "ForwardDeclarations":2887stackObj = SaxStackElement("ForwardDeclarations", None)2888self.stack.append(stackObj)2889done = 12890elif name == "Dependencies":2891obj = Dependencies.factory()2892stackObj = SaxStackElement("Dependencies", obj)2893self.stack.append(stackObj)2894done = 12895elif name == "Content":2896obj = Content.factory()2897stackObj = SaxStackElement("Content", obj)2898self.stack.append(stackObj)2899done = 12900elif name == "Property":2901obj = Property.factory()2902stackObj = SaxStackElement("Property", obj)2903self.stack.append(stackObj)2904done = 12905elif name == "Feature":2906obj = Feature.factory()2907val = attrs.get("Name", None)2908if val is not None:2909obj.setName(val)2910stackObj = SaxStackElement("Feature", obj)2911self.stack.append(stackObj)2912done = 12913elif name == "ViewProvider":2914obj = ViewProvider.factory()2915stackObj = SaxStackElement("ViewProvider", obj)2916self.stack.append(stackObj)2917done = 12918elif name == "DocObject":2919obj = DocObject.factory()2920val = attrs.get("Name", None)2921if val is not None:2922obj.setName(val)2923stackObj = SaxStackElement("DocObject", obj)2924self.stack.append(stackObj)2925done = 12926elif name == "GuiCommand":2927stackObj = SaxStackElement("GuiCommand", None)2928self.stack.append(stackObj)2929done = 12930elif name == "PreferencesPage":2931stackObj = SaxStackElement("PreferencesPage", None)2932self.stack.append(stackObj)2933done = 12934elif name == "Author":2935obj = Author.factory()2936val = attrs.get("Name", None)2937if val is not None:2938obj.setName(val)2939val = attrs.get("EMail", None)2940if val is not None:2941obj.setEmail(val)2942val = attrs.get("Licence", None)2943if val is not None:2944obj.setLicence(val)2945stackObj = SaxStackElement("Author", obj)2946self.stack.append(stackObj)2947done = 12948elif name == "DeveloperDocu":2949stackObj = SaxStackElement("DeveloperDocu", None)2950self.stack.append(stackObj)2951done = 12952elif name == "UserDocu":2953stackObj = SaxStackElement("UserDocu", None)2954self.stack.append(stackObj)2955done = 12956if not done:2957self.reportError('"%s" element not allowed here.' % name)2958
2959def endElement(self, name):2960done = 02961if name == "GenerateModel":2962if len(self.stack) == 1:2963self.root = self.stack[-1].obj2964self.stack.pop()2965done = 12966elif name == "Module":2967if len(self.stack) >= 2:2968self.stack[-2].obj.addModule(self.stack[-1].obj)2969self.stack.pop()2970done = 12971elif name == "PythonExport":2972if len(self.stack) >= 2:2973self.stack[-2].obj.addPythonexport(self.stack[-1].obj)2974self.stack.pop()2975done = 12976elif name == "Documentation":2977if len(self.stack) >= 2:2978self.stack[-2].obj.setDocumentation(self.stack[-1].obj)2979self.stack.pop()2980done = 12981elif name == "Methode":2982if len(self.stack) >= 2:2983self.stack[-2].obj.addMethode(self.stack[-1].obj)2984self.stack.pop()2985done = 12986elif name == "Parameter":2987if len(self.stack) >= 2:2988self.stack[-2].obj.addParameter(self.stack[-1].obj)2989self.stack.pop()2990done = 12991elif name == "Attribute":2992if len(self.stack) >= 2:2993self.stack[-2].obj.addAttribute(self.stack[-1].obj)2994self.stack.pop()2995done = 12996elif name == "Sequence":2997if len(self.stack) >= 2:2998self.stack[-2].obj.setSequence(self.stack[-1].obj)2999self.stack.pop()3000done = 13001elif name == "CustomAttributes":3002if len(self.stack) >= 2:3003content = self.stack[-1].content3004self.stack[-2].obj.setCustomattributes(content)3005self.stack.pop()3006done = 13007elif name == "ClassDeclarations":3008if len(self.stack) >= 2:3009content = self.stack[-1].content3010self.stack[-2].obj.setClassdeclarations(content)3011self.stack.pop()3012done = 13013elif name == "ForwardDeclarations":3014if len(self.stack) >= 2:3015content = self.stack[-1].content3016self.stack[-2].obj.setForwarddeclarations(content)3017self.stack.pop()3018done = 13019elif name == "Dependencies":3020if len(self.stack) >= 2:3021self.stack[-2].obj.setDependencies(self.stack[-1].obj)3022self.stack.pop()3023done = 13024elif name == "Content":3025if len(self.stack) >= 2:3026self.stack[-2].obj.setContent(self.stack[-1].obj)3027self.stack.pop()3028done = 13029elif name == "Property":3030if len(self.stack) >= 2:3031self.stack[-2].obj.addProperty(self.stack[-1].obj)3032self.stack.pop()3033done = 13034elif name == "Feature":3035if len(self.stack) >= 2:3036self.stack[-2].obj.addFeature(self.stack[-1].obj)3037self.stack.pop()3038done = 13039elif name == "ViewProvider":3040if len(self.stack) >= 2:3041self.stack[-2].obj.setViewprovider(self.stack[-1].obj)3042self.stack.pop()3043done = 13044elif name == "DocObject":3045if len(self.stack) >= 2:3046self.stack[-2].obj.addDocobject(self.stack[-1].obj)3047self.stack.pop()3048done = 13049elif name == "GuiCommand":3050if len(self.stack) >= 2:3051content = self.stack[-1].content3052self.stack[-2].obj.addGuicommand(content)3053self.stack.pop()3054done = 13055elif name == "PreferencesPage":3056if len(self.stack) >= 2:3057content = self.stack[-1].content3058self.stack[-2].obj.addPreferencespage(content)3059self.stack.pop()3060done = 13061elif name == "Author":3062if len(self.stack) >= 2:3063self.stack[-2].obj.setAuthor(self.stack[-1].obj)3064self.stack.pop()3065done = 13066elif name == "DeveloperDocu":3067if len(self.stack) >= 2:3068content = self.stack[-1].content3069self.stack[-2].obj.setDeveloperdocu(content)3070self.stack.pop()3071done = 13072elif name == "UserDocu":3073if len(self.stack) >= 2:3074content = self.stack[-1].content3075self.stack[-2].obj.setUserdocu(content)3076self.stack.pop()3077done = 13078if not done:3079self.reportError('"%s" element not allowed here.' % name)3080
3081def characters(self, chrs, start, end):3082if len(self.stack) > 0:3083self.stack[-1].content += chrs[start:end]3084
3085def reportError(self, mesg):3086locator = self.locator3087sys.stderr.write(3088"Doc: %s Line: %d Column: %d\n"3089% (locator.getSystemId(), locator.getLineNumber(), locator.getColumnNumber() + 1)3090)3091sys.stderr.write(mesg)3092sys.stderr.write("\n")3093sys.exit(-1)3094# raise RuntimeError3095
3096
3097USAGE_TEXT = """3098Usage: python <Parser>.py [ -s ] <in_xml_file>
3099Options:
3100-s Use the SAX parser, not the minidom parser.
3101"""
3102
3103
3104def usage():3105print(USAGE_TEXT)3106sys.exit(-1)3107
3108
3109#
3110# SAX handler used to determine the top level element.
3111#
3112class SaxSelectorHandler(handler.ContentHandler):3113def __init__(self):3114self.topElementName = None3115
3116def getTopElementName(self):3117return self.topElementName3118
3119def startElement(self, name, attrs):3120self.topElementName = name3121raise StopIteration3122
3123
3124def parseSelect(inFileName):3125infile = open(inFileName, "r")3126topElementName = None3127parser = make_parser()3128documentHandler = SaxSelectorHandler()3129parser.setContentHandler(documentHandler)3130try:3131try:3132parser.parse(infile)3133except StopIteration:3134topElementName = documentHandler.getTopElementName()3135if topElementName is None:3136raise RuntimeError("no top level element")3137topElementName = topElementName.replace("-", "_").replace(":", "_")3138if topElementName not in globals():3139raise RuntimeError("no class for top element: %s" % topElementName)3140topElement = globals()[topElementName]3141infile.seek(0)3142doc = minidom.parse(infile)3143finally:3144infile.close()3145rootNode = doc.childNodes[0]3146rootObj = topElement.factory()3147rootObj.build(rootNode)3148# Enable Python to collect the space used by the DOM.3149doc = None3150sys.stdout.write('<?xml version="1.0" ?>\n')3151rootObj.export(sys.stdout, 0)3152return rootObj3153
3154
3155def saxParse(inFileName):3156parser = make_parser()3157documentHandler = SaxGeneratemodelHandler()3158parser.setDocumentHandler(documentHandler)3159parser.parse("file:%s" % inFileName)3160root = documentHandler.getRoot()3161sys.stdout.write('<?xml version="1.0" ?>\n')3162root.export(sys.stdout, 0)3163return root3164
3165
3166def saxParseString(inString):3167parser = make_parser()3168documentHandler = SaxGeneratemodelHandler()3169parser.setDocumentHandler(documentHandler)3170parser.feed(inString)3171parser.close()3172rootObj = documentHandler.getRoot()3173# sys.stdout.write('<?xml version="1.0" ?>\n')3174# rootObj.export(sys.stdout, 0)3175return rootObj3176
3177
3178def parse(inFileName):3179doc = minidom.parse(inFileName)3180rootNode = doc.documentElement3181rootObj = GenerateModel.factory()3182rootObj.build(rootNode)3183# Enable Python to collect the space used by the DOM.3184doc = None3185sys.stdout.write('<?xml version="1.0" ?>\n')3186rootObj.export(sys.stdout, 0, name_="GenerateModel")3187return rootObj3188
3189
3190def parseString(inString):3191doc = minidom.parseString(inString)3192rootNode = doc.documentElement3193rootObj = GenerateModel.factory()3194rootObj.build(rootNode)3195# Enable Python to collect the space used by the DOM.3196doc = None3197sys.stdout.write('<?xml version="1.0" ?>\n')3198rootObj.export(sys.stdout, 0, name_="GenerateModel")3199return rootObj3200
3201
3202def parseLiteral(inFileName):3203doc = minidom.parse(inFileName)3204rootNode = doc.documentElement3205rootObj = GenerateModel.factory()3206rootObj.build(rootNode)3207# Enable Python to collect the space used by the DOM.3208doc = None3209sys.stdout.write("from generateModel_Module import *\n\n")3210sys.stdout.write("rootObj = GenerateModel(\n")3211rootObj.exportLiteral(sys.stdout, 0, name_="GenerateModel")3212sys.stdout.write(")\n")3213return rootObj3214
3215
3216def main():3217args = sys.argv[1:]3218if len(args) == 2 and args[0] == "-s":3219saxParse(args[1])3220elif len(args) == 1:3221parse(args[0])3222else:3223usage()3224
3225
3226if __name__ == "__main__":3227main()3228# import pdb3229# pdb.run('main()')3230