FreeCAD

Форк
0
/
generateModel_Module.py 
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

11
import sys
12
import getopt
13
from xml.dom import minidom
14
from xml.dom import Node
15

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

36
def showIndent(outfile, level):
37
    for idx in range(level):
38
        outfile.write("    ")
39

40

41
def quote_xml(inStr):
42
    s1 = inStr
43
    s1 = s1.replace("&", "&amp;")
44
    s1 = s1.replace("<", "&lt;")
45
    s1 = s1.replace('"', "&quot;")
46
    return s1
47

48

49
def quote_python(inStr):
50
    s1 = inStr
51
    if s1.find("'") == -1:
52
        if s1.find("\n") == -1:
53
            return "'%s'" % s1
54
        else:
55
            return "'''%s'''" % s1
56
    else:
57
        if s1.find('"') != -1:
58
            s1 = s1.replace('"', '\\"')
59
        if s1.find("\n") == -1:
60
            return '"%s"' % s1
61
        else:
62
            return '"""%s"""' % s1
63

64

65
class MixedContainer:
66
    # Constants for category:
67
    CategoryNone = 0
68
    CategoryText = 1
69
    CategorySimple = 2
70
    CategoryComplex = 3
71
    # Constants for content_type:
72
    TypeNone = 0
73
    TypeText = 1
74
    TypeString = 2
75
    TypeInteger = 3
76
    TypeFloat = 4
77
    TypeDecimal = 5
78
    TypeDouble = 6
79
    TypeBoolean = 7
80

81
    def __init__(self, category, content_type, name, value):
82
        self.category = category
83
        self.content_type = content_type
84
        self.name = name
85
        self.value = value
86

87
    def getCategory(self):
88
        return self.category
89

90
    def getContenttype(self, content_type):
91
        return self.content_type
92

93
    def getValue(self):
94
        return self.value
95

96
    def getName(self):
97
        return self.name
98

99
    def export(self, outfile, level, name):
100
        if self.category == MixedContainer.CategoryText:
101
            outfile.write(self.value)
102
        elif self.category == MixedContainer.CategorySimple:
103
            self.exportSimple(outfile, level, name)
104
        else:  # category == MixedContainer.CategoryComplex
105
            self.value.export(outfile, level, name)
106

107
    def exportSimple(self, outfile, level, name):
108
        if self.content_type == MixedContainer.TypeString:
109
            outfile.write("<%s>%s</%s>" % (self.name, self.value, self.name))
110
        elif (
111
            self.content_type == MixedContainer.TypeInteger
112
            or self.content_type == MixedContainer.TypeBoolean
113
        ):
114
            outfile.write("<%s>%d</%s>" % (self.name, self.value, self.name))
115
        elif (
116
            self.content_type == MixedContainer.TypeFloat
117
            or self.content_type == MixedContainer.TypeDecimal
118
        ):
119
            outfile.write("<%s>%f</%s>" % (self.name, self.value, self.name))
120
        elif self.content_type == MixedContainer.TypeDouble:
121
            outfile.write("<%s>%g</%s>" % (self.name, self.value, self.name))
122

123
    def exportLiteral(self, outfile, level, name):
124
        if self.category == MixedContainer.CategoryText:
125
            showIndent(outfile, level)
126
            outfile.write(
127
                'MixedContainer(%d, %d, "%s", "%s"),\n'
128
                % (self.category, self.content_type, self.name, self.value)
129
            )
130
        elif self.category == MixedContainer.CategorySimple:
131
            showIndent(outfile, level)
132
            outfile.write(
133
                'MixedContainer(%d, %d, "%s", "%s"),\n'
134
                % (self.category, self.content_type, self.name, self.value)
135
            )
136
        else:  # category == MixedContainer.CategoryComplex
137
            showIndent(outfile, level)
138
            outfile.write(
139
                'MixedContainer(%d, %d, "%s",\n'
140
                % (
141
                    self.category,
142
                    self.content_type,
143
                    self.name,
144
                )
145
            )
146
            self.value.exportLiteral(outfile, level + 1)
147
            showIndent(outfile, level)
148
            outfile.write(")\n")
149

150

151
#
152
# Data representation classes.
153
#
154

155

156
class GenerateModel:
157
    subclass = None
158

159
    def __init__(self, Module=None, PythonExport=None):
160
        if Module is None:
161
            self.Module = []
162
        else:
163
            self.Module = Module
164
        if PythonExport is None:
165
            self.PythonExport = []
166
        else:
167
            self.PythonExport = PythonExport
168

169
    def factory(*args_, **kwargs_):
170
        if GenerateModel.subclass:
171
            return GenerateModel.subclass(*args_, **kwargs_)
172
        else:
173
            return GenerateModel(*args_, **kwargs_)
174

175
    factory = staticmethod(factory)
176

177
    def getModule(self):
178
        return self.Module
179

180
    def setModule(self, Module):
181
        self.Module = Module
182

183
    def addModule(self, value):
184
        self.Module.append(value)
185

186
    def insertModule(self, index, value):
187
        self.Module[index] = value
188

189
    def getPythonexport(self):
190
        return self.PythonExport
191

192
    def setPythonexport(self, PythonExport):
193
        self.PythonExport = PythonExport
194

195
    def addPythonexport(self, value):
196
        self.PythonExport.append(value)
197

198
    def insertPythonexport(self, index, value):
199
        self.PythonExport[index] = value
200

201
    def export(self, outfile, level, name_="GenerateModel"):
202
        showIndent(outfile, level)
203
        outfile.write("<%s>\n" % name_)
204
        self.exportChildren(outfile, level + 1, name_)
205
        showIndent(outfile, level)
206
        outfile.write("</%s>\n" % name_)
207

208
    def exportAttributes(self, outfile, level, name_="GenerateModel"):
209
        pass
210

211
    def exportChildren(self, outfile, level, name_="GenerateModel"):
212
        for Module_ in self.getModule():
213
            Module_.export(outfile, level)
214
        for PythonExport_ in self.getPythonexport():
215
            PythonExport_.export(outfile, level)
216

217
    def exportLiteral(self, outfile, level, name_="GenerateModel"):
218
        level += 1
219
        self.exportLiteralAttributes(outfile, level, name_)
220
        self.exportLiteralChildren(outfile, level, name_)
221

222
    def exportLiteralAttributes(self, outfile, level, name_):
223
        pass
224

225
    def exportLiteralChildren(self, outfile, level, name_):
226
        showIndent(outfile, level)
227
        outfile.write("Module=[\n")
228
        level += 1
229
        for Module in self.Module:
230
            showIndent(outfile, level)
231
            outfile.write("Module(\n")
232
            Module.exportLiteral(outfile, level)
233
            showIndent(outfile, level)
234
            outfile.write("),\n")
235
        level -= 1
236
        showIndent(outfile, level)
237
        outfile.write("],\n")
238
        showIndent(outfile, level)
239
        outfile.write("PythonExport=[\n")
240
        level += 1
241
        for PythonExport in self.PythonExport:
242
            showIndent(outfile, level)
243
            outfile.write("PythonExport(\n")
244
            PythonExport.exportLiteral(outfile, level)
245
            showIndent(outfile, level)
246
            outfile.write("),\n")
247
        level -= 1
248
        showIndent(outfile, level)
249
        outfile.write("],\n")
250

251
    def build(self, node_):
252
        attrs = node_.attributes
253
        self.buildAttributes(attrs)
254
        for child_ in node_.childNodes:
255
            nodeName_ = child_.nodeName.split(":")[-1]
256
            self.buildChildren(child_, nodeName_)
257

258
    def buildAttributes(self, attrs):
259
        pass
260

261
    def buildChildren(self, child_, nodeName_):
262
        if child_.nodeType == Node.ELEMENT_NODE and nodeName_ == "Module":
263
            obj_ = Module.factory()
264
            obj_.build(child_)
265
            self.Module.append(obj_)
266
        elif child_.nodeType == Node.ELEMENT_NODE and nodeName_ == "PythonExport":
267
            obj_ = PythonExport.factory()
268
            obj_.build(child_)
269
            self.PythonExport.append(obj_)
270

271

272
# end class GenerateModel
273

274

275
class PythonExport:
276
    subclass = None
277

278
    def __init__(
279
        self,
280
        Name="",
281
        PythonName="",
282
        Include="",
283
        Father="",
284
        Twin="",
285
        Namespace="",
286
        FatherInclude="",
287
        FatherNamespace="",
288
        Constructor=0,
289
        NumberProtocol=0,
290
        RichCompare=0,
291
        TwinPointer="",
292
        Delete=0,
293
        Reference=0,
294
        Initialization=0,
295
        DisableNotify=0,
296
        DescriptorGetter=0,
297
        DescriptorSetter=0,
298
        Documentation=None,
299
        Methode=None,
300
        Attribute=None,
301
        Sequence=None,
302
        CustomAttributes="",
303
        ClassDeclarations="",
304
        ForwardDeclarations="",
305
    ):
306
        self.Name = Name
307
        self.PythonName = PythonName
308
        self.Include = Include
309
        self.Father = Father
310
        self.Twin = Twin
311
        self.Namespace = Namespace
312
        self.FatherInclude = FatherInclude
313
        self.FatherNamespace = FatherNamespace
314
        self.Constructor = Constructor
315
        self.NumberProtocol = NumberProtocol
316
        self.RichCompare = RichCompare
317
        self.TwinPointer = TwinPointer
318
        self.Delete = Delete
319
        self.Reference = Reference
320
        self.Initialization = Initialization
321
        self.DisableNotify = DisableNotify
322
        self.DescriptorGetter = DescriptorGetter
323
        self.DescriptorSetter = DescriptorSetter
324
        self.Documentation = Documentation
325
        if Methode is None:
326
            self.Methode = []
327
        else:
328
            self.Methode = Methode
329
        if Attribute is None:
330
            self.Attribute = []
331
        else:
332
            self.Attribute = Attribute
333
        self.Sequence = Sequence
334
        self.CustomAttributes = CustomAttributes
335
        self.ClassDeclarations = ClassDeclarations
336
        self.ForwardDeclarations = ForwardDeclarations
337

338
    def factory(*args_, **kwargs_):
339
        if PythonExport.subclass:
340
            return PythonExport.subclass(*args_, **kwargs_)
341
        else:
342
            return PythonExport(*args_, **kwargs_)
343

344
    factory = staticmethod(factory)
345

346
    def getDocumentation(self):
347
        return self.Documentation
348

349
    def setDocumentation(self, Documentation):
350
        self.Documentation = Documentation
351

352
    def getMethode(self):
353
        return self.Methode
354

355
    def setMethode(self, Methode):
356
        self.Methode = Methode
357

358
    def addMethode(self, value):
359
        self.Methode.append(value)
360

361
    def insertMethode(self, index, value):
362
        self.Methode[index] = value
363

364
    def getAttribute(self):
365
        return self.Attribute
366

367
    def setAttribute(self, Attribute):
368
        self.Attribute = Attribute
369

370
    def addAttribute(self, value):
371
        self.Attribute.append(value)
372

373
    def insertAttribute(self, index, value):
374
        self.Attribute[index] = value
375

376
    def getSequence(self):
377
        return self.Sequence
378

379
    def setSequence(self, Sequence):
380
        self.Sequence = Sequence
381

382
    def getCustomattributes(self):
383
        return self.CustomAttributes
384

385
    def setCustomattributes(self, CustomAttributes):
386
        self.CustomAttributes = CustomAttributes
387

388
    def getClassdeclarations(self):
389
        return self.ClassDeclarations
390

391
    def setClassdeclarations(self, ClassDeclarations):
392
        self.ClassDeclarations = ClassDeclarations
393

394
    def getForwarddeclarations(self):
395
        return self.ForwardDeclarations
396

397
    def setForwarddeclarations(self, ForwardDeclarations):
398
        self.ForwardDeclarations = ForwardDeclarations
399

400
    def getName(self):
401
        return self.Name
402

403
    def setName(self, Name):
404
        self.Name = Name
405

406
    def getPythonname(self):
407
        return self.PythonName
408

409
    def setPythonname(self, PythonName):
410
        self.PythonName = PythonName
411

412
    def getInclude(self):
413
        return self.Include
414

415
    def setInclude(self, Include):
416
        self.Include = Include
417

418
    def getFather(self):
419
        return self.Father
420

421
    def setFather(self, Father):
422
        self.Father = Father
423

424
    def getTwin(self):
425
        return self.Twin
426

427
    def setTwin(self, Twin):
428
        self.Twin = Twin
429

430
    def getNamespace(self):
431
        return self.Namespace
432

433
    def setNamespace(self, Namespace):
434
        self.Namespace = Namespace
435

436
    def getFatherinclude(self):
437
        return self.FatherInclude
438

439
    def setFatherinclude(self, FatherInclude):
440
        self.FatherInclude = FatherInclude
441

442
    def getFathernamespace(self):
443
        return self.FatherNamespace
444

445
    def setFathernamespace(self, FatherNamespace):
446
        self.FatherNamespace = FatherNamespace
447

448
    def getConstructor(self):
449
        return self.Constructor
450

451
    def setConstructor(self, Constructor):
452
        self.Constructor = Constructor
453

454
    def getNumberprotocol(self):
455
        return self.NumberProtocol
456

457
    def setNumberprotocol(self, NumberProtocol):
458
        self.NumberProtocol = NumberProtocol
459

460
    def getRichcompare(self):
461
        return self.RichCompare
462

463
    def setRichcompare(self, RichCompare):
464
        self.RichCompare = RichCompare
465

466
    def getTwinpointer(self):
467
        return self.TwinPointer
468

469
    def setTwinpointer(self, TwinPointer):
470
        self.TwinPointer = TwinPointer
471

472
    def getDelete(self):
473
        return self.Delete
474

475
    def setDelete(self, Delete):
476
        self.Delete = Delete
477

478
    def getReference(self):
479
        return self.Reference
480

481
    def setReference(self, Reference):
482
        self.Reference = Reference
483

484
    def getInitialization(self):
485
        return self.Initialization
486

487
    def setInitialization(self, Initialization):
488
        self.Initialization = Initialization
489

490
    def getDisablenotify(self):
491
        return self.DisableNotify
492

493
    def setDisablenotify(self, DisableNotify):
494
        self.DisableNotify = DisableNotify
495

496
    def getDescriptorgetter(self):
497
        return self.DescriptorGetter
498

499
    def setDescriptorgetter(self, DescriptorGetter):
500
        self.DescriptorGetter = DescriptorGetter
501

502
    def getDescriptorsetter(self):
503
        return self.DescriptorSetter
504

505
    def setDescriptorsetter(self, DescriptorSetter):
506
        self.DescriptorSetter = DescriptorSetter
507

508
    def export(self, outfile, level, name_="PythonExport"):
509
        showIndent(outfile, level)
510
        outfile.write("<%s" % (name_,))
511
        self.exportAttributes(outfile, level, name_="PythonExport")
512
        outfile.write(">\n")
513
        self.exportChildren(outfile, level + 1, name_)
514
        showIndent(outfile, level)
515
        outfile.write("</%s>\n" % name_)
516

517
    def exportAttributes(self, outfile, level, name_="PythonExport"):
518
        outfile.write(' Name="%s"' % (self.getName(),))
519
        if self.getPythonname() is not None:
520
            outfile.write(' PythonName="%s"' % (self.getPythonname(),))
521
        outfile.write(' Include="%s"' % (self.getInclude(),))
522
        outfile.write(' Father="%s"' % (self.getFather(),))
523
        outfile.write(' Twin="%s"' % (self.getTwin(),))
524
        outfile.write(' Namespace="%s"' % (self.getNamespace(),))
525
        outfile.write(' FatherInclude="%s"' % (self.getFatherinclude(),))
526
        outfile.write(' FatherNamespace="%s"' % (self.getFathernamespace(),))
527
        if self.getConstructor() is not None:
528
            outfile.write(' Constructor="%s"' % (self.getConstructor(),))
529
        if self.getNumberprotocol() is not None:
530
            outfile.write(' NumberProtocol="%s"' % (self.getNumberprotocol(),))
531
        if self.getRichcompare() is not None:
532
            outfile.write(' RichCompare="%s"' % (self.getRichcompare(),))
533
        outfile.write(' TwinPointer="%s"' % (self.getTwinpointer(),))
534
        if self.getDelete() is not None:
535
            outfile.write(' Delete="%s"' % (self.getDelete(),))
536
        if self.getReference() is not None:
537
            outfile.write(' Reference="%s"' % (self.getReference(),))
538
        if self.getInitialization() is not None:
539
            outfile.write(' Initialization="%s"' % (self.getInitialization(),))
540
        if self.getDisablenotify() is not None:
541
            outfile.write(' DisableNotify="%s"' % (self.getDisablenotify(),))
542
        if self.getDescriptorgetter() is not None:
543
            outfile.write(' DescriptorGetter="%s"' % (self.getDescriptorgetter(),))
544
        if self.getDescriptorsetter() is not None:
545
            outfile.write(' DescriptorSetter="%s"' % (self.getDescriptorsetter(),))
546

547
    def exportChildren(self, outfile, level, name_="PythonExport"):
548
        if self.Documentation:
549
            self.Documentation.export(outfile, level)
550
        for Methode_ in self.getMethode():
551
            Methode_.export(outfile, level)
552
        for Attribute_ in self.getAttribute():
553
            Attribute_.export(outfile, level)
554
        if self.Sequence:
555
            self.Sequence.export(outfile, level)
556
        showIndent(outfile, level)
557
        outfile.write(
558
            "<CustomAttributes>%s</CustomAttributes>\n" % quote_xml(self.getCustomattributes())
559
        )
560
        showIndent(outfile, level)
561
        outfile.write(
562
            "<ClassDeclarations>%s</ClassDeclarations>\n" % quote_xml(self.getClassdeclarations())
563
        )
564
        showIndent(outfile, level)
565
        outfile.write(
566
            "<ForwardDeclarations>%s</ForwardDeclarations>\n"
567
            % quote_xml(self.getForwarddeclarations())
568
        )
569

570
    def exportLiteral(self, outfile, level, name_="PythonExport"):
571
        level += 1
572
        self.exportLiteralAttributes(outfile, level, name_)
573
        self.exportLiteralChildren(outfile, level, name_)
574

575
    def exportLiteralAttributes(self, outfile, level, name_):
576
        showIndent(outfile, level)
577
        outfile.write('Name = "%s",\n' % (self.getName(),))
578
        showIndent(outfile, level)
579
        outfile.write('PythonName = "%s",\n' % (self.getPythonname(),))
580
        showIndent(outfile, level)
581
        outfile.write('Include = "%s",\n' % (self.getInclude(),))
582
        showIndent(outfile, level)
583
        outfile.write('Father = "%s",\n' % (self.getFather(),))
584
        showIndent(outfile, level)
585
        outfile.write('Twin = "%s",\n' % (self.getTwin(),))
586
        showIndent(outfile, level)
587
        outfile.write('Namespace = "%s",\n' % (self.getNamespace(),))
588
        showIndent(outfile, level)
589
        outfile.write('FatherInclude = "%s",\n' % (self.getFatherinclude(),))
590
        showIndent(outfile, level)
591
        outfile.write('FatherNamespace = "%s",\n' % (self.getFathernamespace(),))
592
        showIndent(outfile, level)
593
        outfile.write('Constructor = "%s",\n' % (self.getConstructor(),))
594
        showIndent(outfile, level)
595
        outfile.write('NumberProtocol = "%s",\n' % (self.getNumberprotocol(),))
596
        showIndent(outfile, level)
597
        outfile.write('RichCompare = "%s",\n' % (self.getRichcompare(),))
598
        showIndent(outfile, level)
599
        outfile.write('TwinPointer = "%s",\n' % (self.getTwinpointer(),))
600
        showIndent(outfile, level)
601
        outfile.write('Delete = "%s",\n' % (self.getDelete(),))
602
        showIndent(outfile, level)
603
        outfile.write('Reference = "%s",\n' % (self.getReference(),))
604
        showIndent(outfile, level)
605
        outfile.write('Initialization = "%s",\n' % (self.getInitialization(),))
606
        showIndent(outfile, level)
607
        outfile.write('DisableNotify = "%s",\n' % (self.getDisablenotify(),))
608
        showIndent(outfile, level)
609
        outfile.write('DescriptorGetter = "%s",\n' % (self.getDescriptorgetter(),))
610
        showIndent(outfile, level)
611
        outfile.write('DescriptorSetter = "%s",\n' % (self.getDescriptorsetter(),))
612

613
    def exportLiteralChildren(self, outfile, level, name_):
614
        if self.Documentation:
615
            showIndent(outfile, level)
616
            outfile.write("Documentation=Documentation(\n")
617
            self.Documentation.exportLiteral(outfile, level)
618
            showIndent(outfile, level)
619
            outfile.write("),\n")
620
        showIndent(outfile, level)
621
        outfile.write("Methode=[\n")
622
        level += 1
623
        for Methode in self.Methode:
624
            showIndent(outfile, level)
625
            outfile.write("Methode(\n")
626
            Methode.exportLiteral(outfile, level)
627
            showIndent(outfile, level)
628
            outfile.write("),\n")
629
        level -= 1
630
        showIndent(outfile, level)
631
        outfile.write("],\n")
632
        showIndent(outfile, level)
633
        outfile.write("Attribute=[\n")
634
        level += 1
635
        for Attribute in self.Attribute:
636
            showIndent(outfile, level)
637
            outfile.write("Attribute(\n")
638
            Attribute.exportLiteral(outfile, level)
639
            showIndent(outfile, level)
640
            outfile.write("),\n")
641
        level -= 1
642
        showIndent(outfile, level)
643
        outfile.write("],\n")
644
        if self.Sequence:
645
            showIndent(outfile, level)
646
            outfile.write("Sequence=Sequence(\n")
647
            self.Sequence.exportLiteral(outfile, level)
648
            showIndent(outfile, level)
649
            outfile.write("),\n")
650
        showIndent(outfile, level)
651
        outfile.write("CustomAttributes=%s,\n" % quote_python(self.getCustomattributes()))
652
        showIndent(outfile, level)
653
        outfile.write("ClassDeclarations=%s,\n" % quote_python(self.getClassdeclarations()))
654
        showIndent(outfile, level)
655
        outfile.write("ForwardDeclarations=%s,\n" % quote_python(self.getForwarddeclarations()))
656

657
    def build(self, node_):
658
        attrs = node_.attributes
659
        self.buildAttributes(attrs)
660
        for child_ in node_.childNodes:
661
            nodeName_ = child_.nodeName.split(":")[-1]
662
            self.buildChildren(child_, nodeName_)
663

664
    def buildAttributes(self, attrs):
665
        if attrs.get("Name"):
666
            self.Name = attrs.get("Name").value
667
        if attrs.get("PythonName"):
668
            self.PythonName = attrs.get("PythonName").value
669
        if attrs.get("Include"):
670
            self.Include = attrs.get("Include").value
671
        if attrs.get("Father"):
672
            self.Father = attrs.get("Father").value
673
        if attrs.get("Twin"):
674
            self.Twin = attrs.get("Twin").value
675
        if attrs.get("Namespace"):
676
            self.Namespace = attrs.get("Namespace").value
677
        if attrs.get("FatherInclude"):
678
            self.FatherInclude = attrs.get("FatherInclude").value
679
        if attrs.get("FatherNamespace"):
680
            self.FatherNamespace = attrs.get("FatherNamespace").value
681
        if attrs.get("Constructor"):
682
            if attrs.get("Constructor").value in ("true", "1"):
683
                self.Constructor = 1
684
            elif attrs.get("Constructor").value in ("false", "0"):
685
                self.Constructor = 0
686
            else:
687
                raise ValueError("Bad boolean attribute (Constructor)")
688
        if attrs.get("NumberProtocol"):
689
            if attrs.get("NumberProtocol").value in ("true", "1"):
690
                self.NumberProtocol = 1
691
            elif attrs.get("NumberProtocol").value in ("false", "0"):
692
                self.NumberProtocol = 0
693
            else:
694
                raise ValueError("Bad boolean attribute (NumberProtocol)")
695
        if attrs.get("RichCompare"):
696
            if attrs.get("RichCompare").value in ("true", "1"):
697
                self.RichCompare = 1
698
            elif attrs.get("RichCompare").value in ("false", "0"):
699
                self.RichCompare = 0
700
            else:
701
                raise ValueError("Bad boolean attribute (RichCompare)")
702
        if attrs.get("TwinPointer"):
703
            self.TwinPointer = attrs.get("TwinPointer").value
704
        if attrs.get("Delete"):
705
            if attrs.get("Delete").value in ("true", "1"):
706
                self.Delete = 1
707
            elif attrs.get("Delete").value in ("false", "0"):
708
                self.Delete = 0
709
            else:
710
                raise ValueError("Bad boolean attribute (Delete)")
711
        if attrs.get("Reference"):
712
            if attrs.get("Reference").value in ("true", "1"):
713
                self.Reference = 1
714
            elif attrs.get("Reference").value in ("false", "0"):
715
                self.Reference = 0
716
            else:
717
                raise ValueError("Bad boolean attribute (Reference)")
718
        if attrs.get("Initialization"):
719
            if attrs.get("Initialization").value in ("true", "1"):
720
                self.Initialization = 1
721
            elif attrs.get("Initialization").value in ("false", "0"):
722
                self.Initialization = 0
723
            else:
724
                raise ValueError("Bad boolean attribute (Initialization)")
725
        if attrs.get("DisableNotify"):
726
            if attrs.get("DisableNotify").value in ("true", "1"):
727
                self.DisableNotify = 1
728
            elif attrs.get("DisableNotify").value in ("false", "0"):
729
                self.DisableNotify = 0
730
            else:
731
                raise ValueError("Bad boolean attribute (DisableNotify)")
732
        if attrs.get("DescriptorGetter"):
733
            if attrs.get("DescriptorGetter").value in ("true", "1"):
734
                self.DescriptorGetter = 1
735
            elif attrs.get("DescriptorGetter").value in ("false", "0"):
736
                self.DescriptorGetter = 0
737
            else:
738
                raise ValueError("Bad boolean attribute (DescriptorGetter)")
739
        if attrs.get("DescriptorSetter"):
740
            if attrs.get("DescriptorSetter").value in ("true", "1"):
741
                self.DescriptorSetter = 1
742
            elif attrs.get("DescriptorSetter").value in ("false", "0"):
743
                self.DescriptorSetter = 0
744
            else:
745
                raise ValueError("Bad boolean attribute (DescriptorSetter)")
746

747
    def buildChildren(self, child_, nodeName_):
748
        if child_.nodeType == Node.ELEMENT_NODE and nodeName_ == "Documentation":
749
            obj_ = Documentation.factory()
750
            obj_.build(child_)
751
            self.setDocumentation(obj_)
752
        elif child_.nodeType == Node.ELEMENT_NODE and nodeName_ == "Methode":
753
            obj_ = Methode.factory()
754
            obj_.build(child_)
755
            self.Methode.append(obj_)
756
        elif child_.nodeType == Node.ELEMENT_NODE and nodeName_ == "Attribute":
757
            obj_ = Attribute.factory()
758
            obj_.build(child_)
759
            self.Attribute.append(obj_)
760
        elif child_.nodeType == Node.ELEMENT_NODE and nodeName_ == "Sequence":
761
            obj_ = Sequence.factory()
762
            obj_.build(child_)
763
            self.setSequence(obj_)
764
        elif child_.nodeType == Node.ELEMENT_NODE and nodeName_ == "CustomAttributes":
765
            CustomAttributes_ = ""
766
            for text__content_ in child_.childNodes:
767
                CustomAttributes_ += text__content_.nodeValue
768
            self.CustomAttributes = CustomAttributes_
769
        elif child_.nodeType == Node.ELEMENT_NODE and nodeName_ == "ClassDeclarations":
770
            ClassDeclarations_ = ""
771
            for text__content_ in child_.childNodes:
772
                ClassDeclarations_ += text__content_.nodeValue
773
            self.ClassDeclarations = ClassDeclarations_
774
        elif child_.nodeType == Node.ELEMENT_NODE and nodeName_ == "ForwardDeclarations":
775
            ForwardDeclarations_ = ""
776
            for text__content_ in child_.childNodes:
777
                ForwardDeclarations_ += text__content_.nodeValue
778
            self.ForwardDeclarations = ForwardDeclarations_
779

780

781
# end class PythonExport
782

783

784
class Methode:
785
    subclass = None
786

787
    def __init__(
788
        self,
789
        Name="",
790
        Const=0,
791
        Keyword=0,
792
        NoArgs=0,
793
        Class=0,
794
        Static=0,
795
        Documentation=None,
796
        Parameter=None,
797
    ):
798
        self.Name = Name
799
        self.Const = Const
800
        self.Keyword = Keyword
801
        self.NoArgs = NoArgs
802
        self.Class = Class
803
        self.Static = Static
804
        self.Documentation = Documentation
805
        if Parameter is None:
806
            self.Parameter = []
807
        else:
808
            self.Parameter = Parameter
809

810
    def factory(*args_, **kwargs_):
811
        if Methode.subclass:
812
            return Methode.subclass(*args_, **kwargs_)
813
        else:
814
            return Methode(*args_, **kwargs_)
815

816
    factory = staticmethod(factory)
817

818
    def getDocumentation(self):
819
        return self.Documentation
820

821
    def setDocumentation(self, Documentation):
822
        self.Documentation = Documentation
823

824
    def getParameter(self):
825
        return self.Parameter
826

827
    def setParameter(self, Parameter):
828
        self.Parameter = Parameter
829

830
    def addParameter(self, value):
831
        self.Parameter.append(value)
832

833
    def insertParameter(self, index, value):
834
        self.Parameter[index] = value
835

836
    def getName(self):
837
        return self.Name
838

839
    def setName(self, Name):
840
        self.Name = Name
841

842
    def getConst(self):
843
        return self.Const
844

845
    def setConst(self, Const):
846
        self.Const = Const
847

848
    def getKeyword(self):
849
        return self.Keyword
850

851
    def setKeyword(self, Keyword):
852
        self.Keyword = Keyword
853

854
    def getNoargs(self):
855
        return self.NoArgs
856

857
    def setNoargs(self, NoArgs):
858
        self.NoArgs = NoArgs
859

860
    def getClass(self):
861
        return self.Class
862

863
    def setClass(self, Class):
864
        self.Class = Class
865

866
    def getStatic(self):
867
        return self.Static
868

869
    def setStatic(self, Static):
870
        self.Static = Static
871

872
    def export(self, outfile, level, name_="Methode"):
873
        showIndent(outfile, level)
874
        outfile.write("<%s" % (name_,))
875
        self.exportAttributes(outfile, level, name_="Methode")
876
        outfile.write(">\n")
877
        self.exportChildren(outfile, level + 1, name_)
878
        showIndent(outfile, level)
879
        outfile.write("</%s>\n" % name_)
880

881
    def exportAttributes(self, outfile, level, name_="Methode"):
882
        outfile.write(' Name="%s"' % (self.getName(),))
883
        if self.getConst() is not None:
884
            outfile.write(' Const="%s"' % (self.getConst(),))
885
        if self.getKeyword() is not None:
886
            outfile.write(' Keyword="%s"' % (self.getKeyword(),))
887
        if self.getNoargs() is not None:
888
            outfile.write(' NoArgs="%s"' % (self.getNoargs(),))
889
        if self.getClass() is not None:
890
            outfile.write(' Class="%s"' % (self.getClass(),))
891
        if self.getStatic() is not None:
892
            outfile.write(' Static="%s"' % (self.getStatic(),))
893

894
    def exportChildren(self, outfile, level, name_="Methode"):
895
        if self.Documentation:
896
            self.Documentation.export(outfile, level)
897
        for Parameter_ in self.getParameter():
898
            Parameter_.export(outfile, level)
899

900
    def exportLiteral(self, outfile, level, name_="Methode"):
901
        level += 1
902
        self.exportLiteralAttributes(outfile, level, name_)
903
        self.exportLiteralChildren(outfile, level, name_)
904

905
    def exportLiteralAttributes(self, outfile, level, name_):
906
        showIndent(outfile, level)
907
        outfile.write('Name = "%s",\n' % (self.getName(),))
908
        showIndent(outfile, level)
909
        outfile.write('Const = "%s",\n' % (self.getConst(),))
910
        showIndent(outfile, level)
911
        outfile.write('Keyword = "%s",\n' % (self.getKeyword(),))
912
        showIndent(outfile, level)
913
        outfile.write('NoArgs = "%s",\n' % (self.getNoargs(),))
914
        showIndent(outfile, level)
915
        outfile.write('Class = "%s",\n' % (self.getClass(),))
916
        showIndent(outfile, level)
917
        outfile.write('Static = "%s",\n' % (self.getStatic(),))
918

919
    def exportLiteralChildren(self, outfile, level, name_):
920
        if self.Documentation:
921
            showIndent(outfile, level)
922
            outfile.write("Documentation=Documentation(\n")
923
            self.Documentation.exportLiteral(outfile, level)
924
            showIndent(outfile, level)
925
            outfile.write("),\n")
926
        showIndent(outfile, level)
927
        outfile.write("Parameter=[\n")
928
        level += 1
929
        for Parameter in self.Parameter:
930
            showIndent(outfile, level)
931
            outfile.write("Parameter(\n")
932
            Parameter.exportLiteral(outfile, level)
933
            showIndent(outfile, level)
934
            outfile.write("),\n")
935
        level -= 1
936
        showIndent(outfile, level)
937
        outfile.write("],\n")
938

939
    def build(self, node_):
940
        attrs = node_.attributes
941
        self.buildAttributes(attrs)
942
        for child_ in node_.childNodes:
943
            nodeName_ = child_.nodeName.split(":")[-1]
944
            self.buildChildren(child_, nodeName_)
945

946
    def buildAttributes(self, attrs):
947
        if attrs.get("Name"):
948
            self.Name = attrs.get("Name").value
949
        if attrs.get("Const"):
950
            if attrs.get("Const").value in ("true", "1"):
951
                self.Const = 1
952
            elif attrs.get("Const").value in ("false", "0"):
953
                self.Const = 0
954
            else:
955
                raise ValueError("Bad boolean attribute (Const)")
956
        if attrs.get("Keyword"):
957
            if attrs.get("Keyword").value in ("true", "1"):
958
                self.Keyword = 1
959
            elif attrs.get("Keyword").value in ("false", "0"):
960
                self.Keyword = 0
961
            else:
962
                raise ValueError("Bad boolean attribute (Keyword)")
963
        if attrs.get("NoArgs"):
964
            if attrs.get("NoArgs").value in ("true", "1"):
965
                self.NoArgs = 1
966
            elif attrs.get("NoArgs").value in ("false", "0"):
967
                self.NoArgs = 0
968
            else:
969
                raise ValueError("Bad boolean attribute (NoArgs)")
970
        if attrs.get("Class"):
971
            if attrs.get("Class").value in ("true", "1"):
972
                self.Class = 1
973
            elif attrs.get("Class").value in ("false", "0"):
974
                self.Class = 0
975
            else:
976
                raise ValueError("Bad boolean attribute (Class)")
977
        if attrs.get("Static"):
978
            if attrs.get("Static").value in ("true", "1"):
979
                self.Static = 1
980
            elif attrs.get("Static").value in ("false", "0"):
981
                self.Static = 0
982
            else:
983
                raise ValueError("Bad boolean attribute (Static)")
984

985
    def buildChildren(self, child_, nodeName_):
986
        if child_.nodeType == Node.ELEMENT_NODE and nodeName_ == "Documentation":
987
            obj_ = Documentation.factory()
988
            obj_.build(child_)
989
            self.setDocumentation(obj_)
990
        elif child_.nodeType == Node.ELEMENT_NODE and nodeName_ == "Parameter":
991
            obj_ = Parameter.factory()
992
            obj_.build(child_)
993
            self.Parameter.append(obj_)
994

995

996
# end class Methode
997

998

999
class Attribute:
1000
    subclass = None
1001

1002
    def __init__(self, Name="", ReadOnly=0, Documentation=None, Parameter=None):
1003
        self.Name = Name
1004
        self.ReadOnly = ReadOnly
1005
        self.Documentation = Documentation
1006
        self.Parameter = Parameter
1007

1008
    def factory(*args_, **kwargs_):
1009
        if Attribute.subclass:
1010
            return Attribute.subclass(*args_, **kwargs_)
1011
        else:
1012
            return Attribute(*args_, **kwargs_)
1013

1014
    factory = staticmethod(factory)
1015

1016
    def getDocumentation(self):
1017
        return self.Documentation
1018

1019
    def setDocumentation(self, Documentation):
1020
        self.Documentation = Documentation
1021

1022
    def getParameter(self):
1023
        return self.Parameter
1024

1025
    def setParameter(self, Parameter):
1026
        self.Parameter = Parameter
1027

1028
    def getName(self):
1029
        return self.Name
1030

1031
    def setName(self, Name):
1032
        self.Name = Name
1033

1034
    def getReadonly(self):
1035
        return self.ReadOnly
1036

1037
    def setReadonly(self, ReadOnly):
1038
        self.ReadOnly = ReadOnly
1039

1040
    def export(self, outfile, level, name_="Attribute"):
1041
        showIndent(outfile, level)
1042
        outfile.write("<%s" % (name_,))
1043
        self.exportAttributes(outfile, level, name_="Attribute")
1044
        outfile.write(">\n")
1045
        self.exportChildren(outfile, level + 1, name_)
1046
        showIndent(outfile, level)
1047
        outfile.write("</%s>\n" % name_)
1048

1049
    def exportAttributes(self, outfile, level, name_="Attribute"):
1050
        outfile.write(' Name="%s"' % (self.getName(),))
1051
        outfile.write(' ReadOnly="%s"' % (self.getReadonly(),))
1052

1053
    def exportChildren(self, outfile, level, name_="Attribute"):
1054
        if self.Documentation:
1055
            self.Documentation.export(outfile, level)
1056
        if self.Parameter:
1057
            self.Parameter.export(outfile, level)
1058

1059
    def exportLiteral(self, outfile, level, name_="Attribute"):
1060
        level += 1
1061
        self.exportLiteralAttributes(outfile, level, name_)
1062
        self.exportLiteralChildren(outfile, level, name_)
1063

1064
    def exportLiteralAttributes(self, outfile, level, name_):
1065
        showIndent(outfile, level)
1066
        outfile.write('Name = "%s",\n' % (self.getName(),))
1067
        showIndent(outfile, level)
1068
        outfile.write('ReadOnly = "%s",\n' % (self.getReadonly(),))
1069

1070
    def exportLiteralChildren(self, outfile, level, name_):
1071
        if self.Documentation:
1072
            showIndent(outfile, level)
1073
            outfile.write("Documentation=Documentation(\n")
1074
            self.Documentation.exportLiteral(outfile, level)
1075
            showIndent(outfile, level)
1076
            outfile.write("),\n")
1077
        if self.Parameter:
1078
            showIndent(outfile, level)
1079
            outfile.write("Parameter=Parameter(\n")
1080
            self.Parameter.exportLiteral(outfile, level)
1081
            showIndent(outfile, level)
1082
            outfile.write("),\n")
1083

1084
    def build(self, node_):
1085
        attrs = node_.attributes
1086
        self.buildAttributes(attrs)
1087
        for child_ in node_.childNodes:
1088
            nodeName_ = child_.nodeName.split(":")[-1]
1089
            self.buildChildren(child_, nodeName_)
1090

1091
    def buildAttributes(self, attrs):
1092
        if attrs.get("Name"):
1093
            self.Name = attrs.get("Name").value
1094
        if attrs.get("ReadOnly"):
1095
            if attrs.get("ReadOnly").value in ("true", "1"):
1096
                self.ReadOnly = 1
1097
            elif attrs.get("ReadOnly").value in ("false", "0"):
1098
                self.ReadOnly = 0
1099
            else:
1100
                raise ValueError("Bad boolean attribute (ReadOnly)")
1101

1102
    def buildChildren(self, child_, nodeName_):
1103
        if child_.nodeType == Node.ELEMENT_NODE and nodeName_ == "Documentation":
1104
            obj_ = Documentation.factory()
1105
            obj_.build(child_)
1106
            self.setDocumentation(obj_)
1107
        elif child_.nodeType == Node.ELEMENT_NODE and nodeName_ == "Parameter":
1108
            obj_ = Parameter.factory()
1109
            obj_.build(child_)
1110
            self.setParameter(obj_)
1111

1112

1113
# end class Attribute
1114

1115

1116
class Sequence:
1117
    subclass = None
1118

1119
    def __init__(
1120
        self,
1121
        sq_length=0,
1122
        sq_concat=0,
1123
        sq_repeat=0,
1124
        sq_item=0,
1125
        mp_subscript=0,
1126
        sq_ass_item=0,
1127
        mp_ass_subscript=0,
1128
        sq_contains=0,
1129
        sq_inplace_concat=0,
1130
        sq_inplace_repeat=0,
1131
        valueOf_="",
1132
    ):
1133
        self.sq_length = sq_length
1134
        self.sq_concat = sq_concat
1135
        self.sq_repeat = sq_repeat
1136
        self.sq_item = sq_item
1137
        self.mp_subscript = mp_subscript
1138
        self.sq_ass_item = sq_ass_item
1139
        self.mp_ass_subscript = mp_ass_subscript
1140
        self.sq_contains = sq_contains
1141
        self.sq_inplace_concat = sq_inplace_concat
1142
        self.sq_inplace_repeat = sq_inplace_repeat
1143
        self.valueOf_ = valueOf_
1144

1145
    def factory(*args_, **kwargs_):
1146
        if Sequence.subclass:
1147
            return Sequence.subclass(*args_, **kwargs_)
1148
        else:
1149
            return Sequence(*args_, **kwargs_)
1150

1151
    factory = staticmethod(factory)
1152

1153
    def getSq_length(self):
1154
        return self.sq_length
1155

1156
    def setSq_length(self, sq_length):
1157
        self.sq_length = sq_length
1158

1159
    def getSq_concat(self):
1160
        return self.sq_concat
1161

1162
    def setSq_concat(self, sq_concat):
1163
        self.sq_concat = sq_concat
1164

1165
    def getSq_repeat(self):
1166
        return self.sq_repeat
1167

1168
    def setSq_repeat(self, sq_repeat):
1169
        self.sq_repeat = sq_repeat
1170

1171
    def getSq_item(self):
1172
        return self.sq_item
1173

1174
    def setSq_item(self, sq_item):
1175
        self.sq_item = sq_item
1176

1177
    def getMp_subscript(self):
1178
        return self.mp_subscript
1179

1180
    def setMp_subscript(self, mp_subscript):
1181
        self.mp_subscript = mp_subscript
1182

1183
    def getSq_ass_item(self):
1184
        return self.sq_ass_item
1185

1186
    def setSq_ass_item(self, sq_ass_item):
1187
        self.sq_ass_item = sq_ass_item
1188

1189
    def getMp_ass_subscript(self):
1190
        return self.mp_ass_subscript
1191

1192
    def setMp_ass_subscript(self, mp_ass_subscript):
1193
        self.mp_ass_subscript = mp_ass_subscript
1194

1195
    def getSq_contains(self):
1196
        return self.sq_contains
1197

1198
    def setSq_contains(self, sq_contains):
1199
        self.sq_contains = sq_contains
1200

1201
    def getSq_inplace_concat(self):
1202
        return self.sq_inplace_concat
1203

1204
    def setSq_inplace_concat(self, sq_inplace_concat):
1205
        self.sq_inplace_concat = sq_inplace_concat
1206

1207
    def getSq_inplace_repeat(self):
1208
        return self.sq_inplace_repeat
1209

1210
    def setSq_inplace_repeat(self, sq_inplace_repeat):
1211
        self.sq_inplace_repeat = sq_inplace_repeat
1212

1213
    def getValueOf_(self):
1214
        return self.valueOf_
1215

1216
    def setValueOf_(self, valueOf_):
1217
        self.valueOf_ = valueOf_
1218

1219
    def export(self, outfile, level, name_="Sequence"):
1220
        showIndent(outfile, level)
1221
        outfile.write("<%s" % (name_,))
1222
        self.exportAttributes(outfile, level, name_="Sequence")
1223
        outfile.write(">\n")
1224
        self.exportChildren(outfile, level + 1, name_)
1225
        showIndent(outfile, level)
1226
        outfile.write("</%s>\n" % name_)
1227

1228
    def exportAttributes(self, outfile, level, name_="Sequence"):
1229
        outfile.write(' sq_length="%s"' % (self.getSq_length(),))
1230
        outfile.write(' sq_concat="%s"' % (self.getSq_concat(),))
1231
        outfile.write(' sq_repeat="%s"' % (self.getSq_repeat(),))
1232
        outfile.write(' sq_item="%s"' % (self.getSq_item(),))
1233
        outfile.write(' mp_subscript="%s"' % (self.getMp_subscript(),))
1234
        outfile.write(' sq_ass_item="%s"' % (self.getSq_ass_item(),))
1235
        outfile.write(' mp_ass_subscript="%s"' % (self.getMp_ass_subscript(),))
1236
        outfile.write(' sq_contains="%s"' % (self.getSq_contains(),))
1237
        outfile.write(' sq_inplace_concat="%s"' % (self.getSq_inplace_concat(),))
1238
        outfile.write(' sq_inplace_repeat="%s"' % (self.getSq_inplace_repeat(),))
1239

1240
    def exportChildren(self, outfile, level, name_="Sequence"):
1241
        outfile.write(self.valueOf_)
1242

1243
    def exportLiteral(self, outfile, level, name_="Sequence"):
1244
        level += 1
1245
        self.exportLiteralAttributes(outfile, level, name_)
1246
        self.exportLiteralChildren(outfile, level, name_)
1247

1248
    def exportLiteralAttributes(self, outfile, level, name_):
1249
        showIndent(outfile, level)
1250
        outfile.write('sq_length = "%s",\n' % (self.getSq_length(),))
1251
        showIndent(outfile, level)
1252
        outfile.write('sq_concat = "%s",\n' % (self.getSq_concat(),))
1253
        showIndent(outfile, level)
1254
        outfile.write('sq_repeat = "%s",\n' % (self.getSq_repeat(),))
1255
        showIndent(outfile, level)
1256
        outfile.write('sq_item = "%s",\n' % (self.getSq_item(),))
1257
        showIndent(outfile, level)
1258
        outfile.write('mp_subscript = "%s",\n' % (self.getMp_subscript(),))
1259
        showIndent(outfile, level)
1260
        outfile.write('sq_ass_item = "%s",\n' % (self.getSq_ass_item(),))
1261
        showIndent(outfile, level)
1262
        outfile.write('mp_ass_subscript = "%s",\n' % (self.getMp_ass_subscript(),))
1263
        showIndent(outfile, level)
1264
        outfile.write('sq_contains = "%s",\n' % (self.getSq_contains(),))
1265
        showIndent(outfile, level)
1266
        outfile.write('sq_inplace_concat = "%s",\n' % (self.getSq_inplace_concat(),))
1267
        showIndent(outfile, level)
1268
        outfile.write('sq_inplace_repeat = "%s",\n' % (self.getSq_inplace_repeat(),))
1269

1270
    def exportLiteralChildren(self, outfile, level, name_):
1271
        showIndent(outfile, level)
1272
        outfile.write('valueOf_ = "%s",\n' % (self.valueOf_,))
1273

1274
    def build(self, node_):
1275
        attrs = node_.attributes
1276
        self.buildAttributes(attrs)
1277
        for child_ in node_.childNodes:
1278
            nodeName_ = child_.nodeName.split(":")[-1]
1279
            self.buildChildren(child_, nodeName_)
1280

1281
    def buildAttributes(self, attrs):
1282
        if attrs.get("sq_length"):
1283
            if attrs.get("sq_length").value in ("true", "1"):
1284
                self.sq_length = 1
1285
            elif attrs.get("sq_length").value in ("false", "0"):
1286
                self.sq_length = 0
1287
            else:
1288
                raise ValueError("Bad boolean attribute (sq_length)")
1289
        if attrs.get("sq_concat"):
1290
            if attrs.get("sq_concat").value in ("true", "1"):
1291
                self.sq_concat = 1
1292
            elif attrs.get("sq_concat").value in ("false", "0"):
1293
                self.sq_concat = 0
1294
            else:
1295
                raise ValueError("Bad boolean attribute (sq_concat)")
1296
        if attrs.get("sq_repeat"):
1297
            if attrs.get("sq_repeat").value in ("true", "1"):
1298
                self.sq_repeat = 1
1299
            elif attrs.get("sq_repeat").value in ("false", "0"):
1300
                self.sq_repeat = 0
1301
            else:
1302
                raise ValueError("Bad boolean attribute (sq_repeat)")
1303
        if attrs.get("sq_item"):
1304
            if attrs.get("sq_item").value in ("true", "1"):
1305
                self.sq_item = 1
1306
            elif attrs.get("sq_item").value in ("false", "0"):
1307
                self.sq_item = 0
1308
            else:
1309
                raise ValueError("Bad boolean attribute (sq_item)")
1310
        if attrs.get("mp_subscript"):
1311
            if attrs.get("mp_subscript").value in ("true", "1"):
1312
                self.mp_subscript = 1
1313
            elif attrs.get("mp_subscript").value in ("false", "0"):
1314
                self.mp_subscript = 0
1315
            else:
1316
                raise ValueError("Bad boolean attribute (mp_subscript)")
1317
        if attrs.get("sq_ass_item"):
1318
            if attrs.get("sq_ass_item").value in ("true", "1"):
1319
                self.sq_ass_item = 1
1320
            elif attrs.get("sq_ass_item").value in ("false", "0"):
1321
                self.sq_ass_item = 0
1322
            else:
1323
                raise ValueError("Bad boolean attribute (sq_ass_item)")
1324
        if attrs.get("mp_ass_subscript"):
1325
            if attrs.get("mp_ass_subscript").value in ("true", "1"):
1326
                self.mp_ass_subscript = 1
1327
            elif attrs.get("mp_ass_subscript").value in ("false", "0"):
1328
                self.mp_ass_subscript = 0
1329
            else:
1330
                raise ValueError("Bad boolean attribute (mp_ass_subscript)")
1331
        if attrs.get("sq_contains"):
1332
            if attrs.get("sq_contains").value in ("true", "1"):
1333
                self.sq_contains = 1
1334
            elif attrs.get("sq_contains").value in ("false", "0"):
1335
                self.sq_contains = 0
1336
            else:
1337
                raise ValueError("Bad boolean attribute (sq_contains)")
1338
        if attrs.get("sq_inplace_concat"):
1339
            if attrs.get("sq_inplace_concat").value in ("true", "1"):
1340
                self.sq_inplace_concat = 1
1341
            elif attrs.get("sq_inplace_concat").value in ("false", "0"):
1342
                self.sq_inplace_concat = 0
1343
            else:
1344
                raise ValueError("Bad boolean attribute (sq_inplace_concat)")
1345
        if attrs.get("sq_inplace_repeat"):
1346
            if attrs.get("sq_inplace_repeat").value in ("true", "1"):
1347
                self.sq_inplace_repeat = 1
1348
            elif attrs.get("sq_inplace_repeat").value in ("false", "0"):
1349
                self.sq_inplace_repeat = 0
1350
            else:
1351
                raise ValueError("Bad boolean attribute (sq_inplace_repeat)")
1352

1353
    def buildChildren(self, child_, nodeName_):
1354
        self.valueOf_ = ""
1355
        for child in child_.childNodes:
1356
            if child.nodeType == Node.TEXT_NODE:
1357
                self.valueOf_ += child.nodeValue
1358

1359

1360
# end class Sequence
1361

1362

1363
class Module:
1364
    subclass = None
1365

1366
    def __init__(self, Name="", Documentation=None, Dependencies=None, Content=None):
1367
        self.Name = Name
1368
        self.Documentation = Documentation
1369
        self.Dependencies = Dependencies
1370
        self.Content = Content
1371

1372
    def factory(*args_, **kwargs_):
1373
        if Module.subclass:
1374
            return Module.subclass(*args_, **kwargs_)
1375
        else:
1376
            return Module(*args_, **kwargs_)
1377

1378
    factory = staticmethod(factory)
1379

1380
    def getDocumentation(self):
1381
        return self.Documentation
1382

1383
    def setDocumentation(self, Documentation):
1384
        self.Documentation = Documentation
1385

1386
    def getDependencies(self):
1387
        return self.Dependencies
1388

1389
    def setDependencies(self, Dependencies):
1390
        self.Dependencies = Dependencies
1391

1392
    def getContent(self):
1393
        return self.Content
1394

1395
    def setContent(self, Content):
1396
        self.Content = Content
1397

1398
    def getName(self):
1399
        return self.Name
1400

1401
    def setName(self, Name):
1402
        self.Name = Name
1403

1404
    def export(self, outfile, level, name_="Module"):
1405
        showIndent(outfile, level)
1406
        outfile.write("<%s" % (name_,))
1407
        self.exportAttributes(outfile, level, name_="Module")
1408
        outfile.write(">\n")
1409
        self.exportChildren(outfile, level + 1, name_)
1410
        showIndent(outfile, level)
1411
        outfile.write("</%s>\n" % name_)
1412

1413
    def exportAttributes(self, outfile, level, name_="Module"):
1414
        outfile.write(' Name="%s"' % (self.getName(),))
1415

1416
    def exportChildren(self, outfile, level, name_="Module"):
1417
        if self.Documentation:
1418
            self.Documentation.export(outfile, level)
1419
        if self.Dependencies:
1420
            self.Dependencies.export(outfile, level)
1421
        if self.Content:
1422
            self.Content.export(outfile, level)
1423

1424
    def exportLiteral(self, outfile, level, name_="Module"):
1425
        level += 1
1426
        self.exportLiteralAttributes(outfile, level, name_)
1427
        self.exportLiteralChildren(outfile, level, name_)
1428

1429
    def exportLiteralAttributes(self, outfile, level, name_):
1430
        showIndent(outfile, level)
1431
        outfile.write('Name = "%s",\n' % (self.getName(),))
1432

1433
    def exportLiteralChildren(self, outfile, level, name_):
1434
        if self.Documentation:
1435
            showIndent(outfile, level)
1436
            outfile.write("Documentation=Documentation(\n")
1437
            self.Documentation.exportLiteral(outfile, level)
1438
            showIndent(outfile, level)
1439
            outfile.write("),\n")
1440
        if self.Dependencies:
1441
            showIndent(outfile, level)
1442
            outfile.write("Dependencies=Dependencies(\n")
1443
            self.Dependencies.exportLiteral(outfile, level)
1444
            showIndent(outfile, level)
1445
            outfile.write("),\n")
1446
        if self.Content:
1447
            showIndent(outfile, level)
1448
            outfile.write("Content=Content(\n")
1449
            self.Content.exportLiteral(outfile, level)
1450
            showIndent(outfile, level)
1451
            outfile.write("),\n")
1452

1453
    def build(self, node_):
1454
        attrs = node_.attributes
1455
        self.buildAttributes(attrs)
1456
        for child_ in node_.childNodes:
1457
            nodeName_ = child_.nodeName.split(":")[-1]
1458
            self.buildChildren(child_, nodeName_)
1459

1460
    def buildAttributes(self, attrs):
1461
        if attrs.get("Name"):
1462
            self.Name = attrs.get("Name").value
1463

1464
    def buildChildren(self, child_, nodeName_):
1465
        if child_.nodeType == Node.ELEMENT_NODE and nodeName_ == "Documentation":
1466
            obj_ = Documentation.factory()
1467
            obj_.build(child_)
1468
            self.setDocumentation(obj_)
1469
        elif child_.nodeType == Node.ELEMENT_NODE and nodeName_ == "Dependencies":
1470
            obj_ = Dependencies.factory()
1471
            obj_.build(child_)
1472
            self.setDependencies(obj_)
1473
        elif child_.nodeType == Node.ELEMENT_NODE and nodeName_ == "Content":
1474
            obj_ = Content.factory()
1475
            obj_.build(child_)
1476
            self.setContent(obj_)
1477

1478

1479
# end class Module
1480

1481

1482
class Dependencies:
1483
    subclass = None
1484

1485
    def __init__(self, Module=None):
1486
        if Module is None:
1487
            self.Module = []
1488
        else:
1489
            self.Module = Module
1490

1491
    def factory(*args_, **kwargs_):
1492
        if Dependencies.subclass:
1493
            return Dependencies.subclass(*args_, **kwargs_)
1494
        else:
1495
            return Dependencies(*args_, **kwargs_)
1496

1497
    factory = staticmethod(factory)
1498

1499
    def getModule(self):
1500
        return self.Module
1501

1502
    def setModule(self, Module):
1503
        self.Module = Module
1504

1505
    def addModule(self, value):
1506
        self.Module.append(value)
1507

1508
    def insertModule(self, index, value):
1509
        self.Module[index] = value
1510

1511
    def export(self, outfile, level, name_="Dependencies"):
1512
        showIndent(outfile, level)
1513
        outfile.write("<%s>\n" % name_)
1514
        self.exportChildren(outfile, level + 1, name_)
1515
        showIndent(outfile, level)
1516
        outfile.write("</%s>\n" % name_)
1517

1518
    def exportAttributes(self, outfile, level, name_="Dependencies"):
1519
        pass
1520

1521
    def exportChildren(self, outfile, level, name_="Dependencies"):
1522
        for Module_ in self.getModule():
1523
            Module_.export(outfile, level)
1524

1525
    def exportLiteral(self, outfile, level, name_="Dependencies"):
1526
        level += 1
1527
        self.exportLiteralAttributes(outfile, level, name_)
1528
        self.exportLiteralChildren(outfile, level, name_)
1529

1530
    def exportLiteralAttributes(self, outfile, level, name_):
1531
        pass
1532

1533
    def exportLiteralChildren(self, outfile, level, name_):
1534
        showIndent(outfile, level)
1535
        outfile.write("Module=[\n")
1536
        level += 1
1537
        for Module in self.Module:
1538
            showIndent(outfile, level)
1539
            outfile.write("Module(\n")
1540
            Module.exportLiteral(outfile, level)
1541
            showIndent(outfile, level)
1542
            outfile.write("),\n")
1543
        level -= 1
1544
        showIndent(outfile, level)
1545
        outfile.write("],\n")
1546

1547
    def build(self, node_):
1548
        attrs = node_.attributes
1549
        self.buildAttributes(attrs)
1550
        for child_ in node_.childNodes:
1551
            nodeName_ = child_.nodeName.split(":")[-1]
1552
            self.buildChildren(child_, nodeName_)
1553

1554
    def buildAttributes(self, attrs):
1555
        pass
1556

1557
    def buildChildren(self, child_, nodeName_):
1558
        if child_.nodeType == Node.ELEMENT_NODE and nodeName_ == "Module":
1559
            obj_ = Module.factory()
1560
            obj_.build(child_)
1561
            self.Module.append(obj_)
1562

1563

1564
# end class Dependencies
1565

1566

1567
class Content:
1568
    subclass = None
1569

1570
    def __init__(
1571
        self, Property=None, Feature=None, DocObject=None, GuiCommand=None, PreferencesPage=None
1572
    ):
1573
        if Property is None:
1574
            self.Property = []
1575
        else:
1576
            self.Property = Property
1577
        if Feature is None:
1578
            self.Feature = []
1579
        else:
1580
            self.Feature = Feature
1581
        if DocObject is None:
1582
            self.DocObject = []
1583
        else:
1584
            self.DocObject = DocObject
1585
        if GuiCommand is None:
1586
            self.GuiCommand = []
1587
        else:
1588
            self.GuiCommand = GuiCommand
1589
        if PreferencesPage is None:
1590
            self.PreferencesPage = []
1591
        else:
1592
            self.PreferencesPage = PreferencesPage
1593

1594
    def factory(*args_, **kwargs_):
1595
        if Content.subclass:
1596
            return Content.subclass(*args_, **kwargs_)
1597
        else:
1598
            return Content(*args_, **kwargs_)
1599

1600
    factory = staticmethod(factory)
1601

1602
    def getProperty(self):
1603
        return self.Property
1604

1605
    def setProperty(self, Property):
1606
        self.Property = Property
1607

1608
    def addProperty(self, value):
1609
        self.Property.append(value)
1610

1611
    def insertProperty(self, index, value):
1612
        self.Property[index] = value
1613

1614
    def getFeature(self):
1615
        return self.Feature
1616

1617
    def setFeature(self, Feature):
1618
        self.Feature = Feature
1619

1620
    def addFeature(self, value):
1621
        self.Feature.append(value)
1622

1623
    def insertFeature(self, index, value):
1624
        self.Feature[index] = value
1625

1626
    def getDocobject(self):
1627
        return self.DocObject
1628

1629
    def setDocobject(self, DocObject):
1630
        self.DocObject = DocObject
1631

1632
    def addDocobject(self, value):
1633
        self.DocObject.append(value)
1634

1635
    def insertDocobject(self, index, value):
1636
        self.DocObject[index] = value
1637

1638
    def getGuicommand(self):
1639
        return self.GuiCommand
1640

1641
    def setGuicommand(self, GuiCommand):
1642
        self.GuiCommand = GuiCommand
1643

1644
    def addGuicommand(self, value):
1645
        self.GuiCommand.append(value)
1646

1647
    def insertGuicommand(self, index, value):
1648
        self.GuiCommand[index] = value
1649

1650
    def getPreferencespage(self):
1651
        return self.PreferencesPage
1652

1653
    def setPreferencespage(self, PreferencesPage):
1654
        self.PreferencesPage = PreferencesPage
1655

1656
    def addPreferencespage(self, value):
1657
        self.PreferencesPage.append(value)
1658

1659
    def insertPreferencespage(self, index, value):
1660
        self.PreferencesPage[index] = value
1661

1662
    def export(self, outfile, level, name_="Content"):
1663
        showIndent(outfile, level)
1664
        outfile.write("<%s>\n" % name_)
1665
        self.exportChildren(outfile, level + 1, name_)
1666
        showIndent(outfile, level)
1667
        outfile.write("</%s>\n" % name_)
1668

1669
    def exportAttributes(self, outfile, level, name_="Content"):
1670
        pass
1671

1672
    def exportChildren(self, outfile, level, name_="Content"):
1673
        for Property_ in self.getProperty():
1674
            Property_.export(outfile, level)
1675
        for Feature_ in self.getFeature():
1676
            Feature_.export(outfile, level)
1677
        for DocObject_ in self.getDocobject():
1678
            DocObject_.export(outfile, level)
1679
        for GuiCommand_ in self.getGuicommand():
1680
            showIndent(outfile, level)
1681
            outfile.write("<GuiCommand>%s</GuiCommand>\n" % quote_xml(GuiCommand_))
1682
        for PreferencesPage_ in self.getPreferencespage():
1683
            showIndent(outfile, level)
1684
            outfile.write("<PreferencesPage>%s</PreferencesPage>\n" % quote_xml(PreferencesPage_))
1685

1686
    def exportLiteral(self, outfile, level, name_="Content"):
1687
        level += 1
1688
        self.exportLiteralAttributes(outfile, level, name_)
1689
        self.exportLiteralChildren(outfile, level, name_)
1690

1691
    def exportLiteralAttributes(self, outfile, level, name_):
1692
        pass
1693

1694
    def exportLiteralChildren(self, outfile, level, name_):
1695
        showIndent(outfile, level)
1696
        outfile.write("Property=[\n")
1697
        level += 1
1698
        for Property in self.Property:
1699
            showIndent(outfile, level)
1700
            outfile.write("Property(\n")
1701
            Property.exportLiteral(outfile, level)
1702
            showIndent(outfile, level)
1703
            outfile.write("),\n")
1704
        level -= 1
1705
        showIndent(outfile, level)
1706
        outfile.write("],\n")
1707
        showIndent(outfile, level)
1708
        outfile.write("Feature=[\n")
1709
        level += 1
1710
        for Feature in self.Feature:
1711
            showIndent(outfile, level)
1712
            outfile.write("Feature(\n")
1713
            Feature.exportLiteral(outfile, level)
1714
            showIndent(outfile, level)
1715
            outfile.write("),\n")
1716
        level -= 1
1717
        showIndent(outfile, level)
1718
        outfile.write("],\n")
1719
        showIndent(outfile, level)
1720
        outfile.write("DocObject=[\n")
1721
        level += 1
1722
        for DocObject in self.DocObject:
1723
            showIndent(outfile, level)
1724
            outfile.write("DocObject(\n")
1725
            DocObject.exportLiteral(outfile, level)
1726
            showIndent(outfile, level)
1727
            outfile.write("),\n")
1728
        level -= 1
1729
        showIndent(outfile, level)
1730
        outfile.write("],\n")
1731
        showIndent(outfile, level)
1732
        outfile.write("GuiCommand=[\n")
1733
        level += 1
1734
        for GuiCommand in self.GuiCommand:
1735
            showIndent(outfile, level)
1736
            outfile.write("%s,\n" % quote_python(GuiCommand))
1737
        level -= 1
1738
        showIndent(outfile, level)
1739
        outfile.write("],\n")
1740
        showIndent(outfile, level)
1741
        outfile.write("PreferencesPage=[\n")
1742
        level += 1
1743
        for PreferencesPage in self.PreferencesPage:
1744
            showIndent(outfile, level)
1745
            outfile.write("%s,\n" % quote_python(PreferencesPage))
1746
        level -= 1
1747
        showIndent(outfile, level)
1748
        outfile.write("],\n")
1749

1750
    def build(self, node_):
1751
        attrs = node_.attributes
1752
        self.buildAttributes(attrs)
1753
        for child_ in node_.childNodes:
1754
            nodeName_ = child_.nodeName.split(":")[-1]
1755
            self.buildChildren(child_, nodeName_)
1756

1757
    def buildAttributes(self, attrs):
1758
        pass
1759

1760
    def buildChildren(self, child_, nodeName_):
1761
        if child_.nodeType == Node.ELEMENT_NODE and nodeName_ == "Property":
1762
            obj_ = Property.factory()
1763
            obj_.build(child_)
1764
            self.Property.append(obj_)
1765
        elif child_.nodeType == Node.ELEMENT_NODE and nodeName_ == "Feature":
1766
            obj_ = Feature.factory()
1767
            obj_.build(child_)
1768
            self.Feature.append(obj_)
1769
        elif child_.nodeType == Node.ELEMENT_NODE and nodeName_ == "DocObject":
1770
            obj_ = DocObject.factory()
1771
            obj_.build(child_)
1772
            self.DocObject.append(obj_)
1773
        elif child_.nodeType == Node.ELEMENT_NODE and nodeName_ == "GuiCommand":
1774
            GuiCommand_ = ""
1775
            for text__content_ in child_.childNodes:
1776
                GuiCommand_ += text__content_.nodeValue
1777
            self.GuiCommand.append(GuiCommand_)
1778
        elif child_.nodeType == Node.ELEMENT_NODE and nodeName_ == "PreferencesPage":
1779
            PreferencesPage_ = ""
1780
            for text__content_ in child_.childNodes:
1781
                PreferencesPage_ += text__content_.nodeValue
1782
            self.PreferencesPage.append(PreferencesPage_)
1783

1784

1785
# end class Content
1786

1787

1788
class Feature:
1789
    subclass = None
1790

1791
    def __init__(self, Name="", Documentation=None, Property=None, ViewProvider=None):
1792
        self.Name = Name
1793
        self.Documentation = Documentation
1794
        if Property is None:
1795
            self.Property = []
1796
        else:
1797
            self.Property = Property
1798
        self.ViewProvider = ViewProvider
1799

1800
    def factory(*args_, **kwargs_):
1801
        if Feature.subclass:
1802
            return Feature.subclass(*args_, **kwargs_)
1803
        else:
1804
            return Feature(*args_, **kwargs_)
1805

1806
    factory = staticmethod(factory)
1807

1808
    def getDocumentation(self):
1809
        return self.Documentation
1810

1811
    def setDocumentation(self, Documentation):
1812
        self.Documentation = Documentation
1813

1814
    def getProperty(self):
1815
        return self.Property
1816

1817
    def setProperty(self, Property):
1818
        self.Property = Property
1819

1820
    def addProperty(self, value):
1821
        self.Property.append(value)
1822

1823
    def insertProperty(self, index, value):
1824
        self.Property[index] = value
1825

1826
    def getViewprovider(self):
1827
        return self.ViewProvider
1828

1829
    def setViewprovider(self, ViewProvider):
1830
        self.ViewProvider = ViewProvider
1831

1832
    def getName(self):
1833
        return self.Name
1834

1835
    def setName(self, Name):
1836
        self.Name = Name
1837

1838
    def export(self, outfile, level, name_="Feature"):
1839
        showIndent(outfile, level)
1840
        outfile.write("<%s" % (name_,))
1841
        self.exportAttributes(outfile, level, name_="Feature")
1842
        outfile.write(">\n")
1843
        self.exportChildren(outfile, level + 1, name_)
1844
        showIndent(outfile, level)
1845
        outfile.write("</%s>\n" % name_)
1846

1847
    def exportAttributes(self, outfile, level, name_="Feature"):
1848
        outfile.write(' Name="%s"' % (self.getName(),))
1849

1850
    def exportChildren(self, outfile, level, name_="Feature"):
1851
        if self.Documentation:
1852
            self.Documentation.export(outfile, level)
1853
        for Property_ in self.getProperty():
1854
            Property_.export(outfile, level)
1855
        if self.ViewProvider:
1856
            self.ViewProvider.export(outfile, level)
1857

1858
    def exportLiteral(self, outfile, level, name_="Feature"):
1859
        level += 1
1860
        self.exportLiteralAttributes(outfile, level, name_)
1861
        self.exportLiteralChildren(outfile, level, name_)
1862

1863
    def exportLiteralAttributes(self, outfile, level, name_):
1864
        showIndent(outfile, level)
1865
        outfile.write('Name = "%s",\n' % (self.getName(),))
1866

1867
    def exportLiteralChildren(self, outfile, level, name_):
1868
        if self.Documentation:
1869
            showIndent(outfile, level)
1870
            outfile.write("Documentation=Documentation(\n")
1871
            self.Documentation.exportLiteral(outfile, level)
1872
            showIndent(outfile, level)
1873
            outfile.write("),\n")
1874
        showIndent(outfile, level)
1875
        outfile.write("Property=[\n")
1876
        level += 1
1877
        for Property in self.Property:
1878
            showIndent(outfile, level)
1879
            outfile.write("Property(\n")
1880
            Property.exportLiteral(outfile, level)
1881
            showIndent(outfile, level)
1882
            outfile.write("),\n")
1883
        level -= 1
1884
        showIndent(outfile, level)
1885
        outfile.write("],\n")
1886
        if self.ViewProvider:
1887
            showIndent(outfile, level)
1888
            outfile.write("ViewProvider=ViewProvider(\n")
1889
            self.ViewProvider.exportLiteral(outfile, level)
1890
            showIndent(outfile, level)
1891
            outfile.write("),\n")
1892

1893
    def build(self, node_):
1894
        attrs = node_.attributes
1895
        self.buildAttributes(attrs)
1896
        for child_ in node_.childNodes:
1897
            nodeName_ = child_.nodeName.split(":")[-1]
1898
            self.buildChildren(child_, nodeName_)
1899

1900
    def buildAttributes(self, attrs):
1901
        if attrs.get("Name"):
1902
            self.Name = attrs.get("Name").value
1903

1904
    def buildChildren(self, child_, nodeName_):
1905
        if child_.nodeType == Node.ELEMENT_NODE and nodeName_ == "Documentation":
1906
            obj_ = Documentation.factory()
1907
            obj_.build(child_)
1908
            self.setDocumentation(obj_)
1909
        elif child_.nodeType == Node.ELEMENT_NODE and nodeName_ == "Property":
1910
            obj_ = Property.factory()
1911
            obj_.build(child_)
1912
            self.Property.append(obj_)
1913
        elif child_.nodeType == Node.ELEMENT_NODE and nodeName_ == "ViewProvider":
1914
            obj_ = ViewProvider.factory()
1915
            obj_.build(child_)
1916
            self.setViewprovider(obj_)
1917

1918

1919
# end class Feature
1920

1921

1922
class DocObject:
1923
    subclass = None
1924

1925
    def __init__(self, Name="", Documentation=None, Property=None):
1926
        self.Name = Name
1927
        self.Documentation = Documentation
1928
        if Property is None:
1929
            self.Property = []
1930
        else:
1931
            self.Property = Property
1932

1933
    def factory(*args_, **kwargs_):
1934
        if DocObject.subclass:
1935
            return DocObject.subclass(*args_, **kwargs_)
1936
        else:
1937
            return DocObject(*args_, **kwargs_)
1938

1939
    factory = staticmethod(factory)
1940

1941
    def getDocumentation(self):
1942
        return self.Documentation
1943

1944
    def setDocumentation(self, Documentation):
1945
        self.Documentation = Documentation
1946

1947
    def getProperty(self):
1948
        return self.Property
1949

1950
    def setProperty(self, Property):
1951
        self.Property = Property
1952

1953
    def addProperty(self, value):
1954
        self.Property.append(value)
1955

1956
    def insertProperty(self, index, value):
1957
        self.Property[index] = value
1958

1959
    def getName(self):
1960
        return self.Name
1961

1962
    def setName(self, Name):
1963
        self.Name = Name
1964

1965
    def export(self, outfile, level, name_="DocObject"):
1966
        showIndent(outfile, level)
1967
        outfile.write("<%s" % (name_,))
1968
        self.exportAttributes(outfile, level, name_="DocObject")
1969
        outfile.write(">\n")
1970
        self.exportChildren(outfile, level + 1, name_)
1971
        showIndent(outfile, level)
1972
        outfile.write("</%s>\n" % name_)
1973

1974
    def exportAttributes(self, outfile, level, name_="DocObject"):
1975
        outfile.write(' Name="%s"' % (self.getName(),))
1976

1977
    def exportChildren(self, outfile, level, name_="DocObject"):
1978
        if self.Documentation:
1979
            self.Documentation.export(outfile, level)
1980
        for Property_ in self.getProperty():
1981
            Property_.export(outfile, level)
1982

1983
    def exportLiteral(self, outfile, level, name_="DocObject"):
1984
        level += 1
1985
        self.exportLiteralAttributes(outfile, level, name_)
1986
        self.exportLiteralChildren(outfile, level, name_)
1987

1988
    def exportLiteralAttributes(self, outfile, level, name_):
1989
        showIndent(outfile, level)
1990
        outfile.write('Name = "%s",\n' % (self.getName(),))
1991

1992
    def exportLiteralChildren(self, outfile, level, name_):
1993
        if self.Documentation:
1994
            showIndent(outfile, level)
1995
            outfile.write("Documentation=Documentation(\n")
1996
            self.Documentation.exportLiteral(outfile, level)
1997
            showIndent(outfile, level)
1998
            outfile.write("),\n")
1999
        showIndent(outfile, level)
2000
        outfile.write("Property=[\n")
2001
        level += 1
2002
        for Property in self.Property:
2003
            showIndent(outfile, level)
2004
            outfile.write("Property(\n")
2005
            Property.exportLiteral(outfile, level)
2006
            showIndent(outfile, level)
2007
            outfile.write("),\n")
2008
        level -= 1
2009
        showIndent(outfile, level)
2010
        outfile.write("],\n")
2011

2012
    def build(self, node_):
2013
        attrs = node_.attributes
2014
        self.buildAttributes(attrs)
2015
        for child_ in node_.childNodes:
2016
            nodeName_ = child_.nodeName.split(":")[-1]
2017
            self.buildChildren(child_, nodeName_)
2018

2019
    def buildAttributes(self, attrs):
2020
        if attrs.get("Name"):
2021
            self.Name = attrs.get("Name").value
2022

2023
    def buildChildren(self, child_, nodeName_):
2024
        if child_.nodeType == Node.ELEMENT_NODE and nodeName_ == "Documentation":
2025
            obj_ = Documentation.factory()
2026
            obj_.build(child_)
2027
            self.setDocumentation(obj_)
2028
        elif child_.nodeType == Node.ELEMENT_NODE and nodeName_ == "Property":
2029
            obj_ = Property.factory()
2030
            obj_.build(child_)
2031
            self.Property.append(obj_)
2032

2033

2034
# end class DocObject
2035

2036

2037
class Property:
2038
    subclass = None
2039

2040
    def __init__(self, Name="", Type="", StartValue="", Documentation=None):
2041
        self.Name = Name
2042
        self.Type = Type
2043
        self.StartValue = StartValue
2044
        self.Documentation = Documentation
2045

2046
    def factory(*args_, **kwargs_):
2047
        if Property.subclass:
2048
            return Property.subclass(*args_, **kwargs_)
2049
        else:
2050
            return Property(*args_, **kwargs_)
2051

2052
    factory = staticmethod(factory)
2053

2054
    def getDocumentation(self):
2055
        return self.Documentation
2056

2057
    def setDocumentation(self, Documentation):
2058
        self.Documentation = Documentation
2059

2060
    def getName(self):
2061
        return self.Name
2062

2063
    def setName(self, Name):
2064
        self.Name = Name
2065

2066
    def getType(self):
2067
        return self.Type
2068

2069
    def setType(self, Type):
2070
        self.Type = Type
2071

2072
    def getStartvalue(self):
2073
        return self.StartValue
2074

2075
    def setStartvalue(self, StartValue):
2076
        self.StartValue = StartValue
2077

2078
    def export(self, outfile, level, name_="Property"):
2079
        showIndent(outfile, level)
2080
        outfile.write("<%s" % (name_,))
2081
        self.exportAttributes(outfile, level, name_="Property")
2082
        outfile.write(">\n")
2083
        self.exportChildren(outfile, level + 1, name_)
2084
        showIndent(outfile, level)
2085
        outfile.write("</%s>\n" % name_)
2086

2087
    def exportAttributes(self, outfile, level, name_="Property"):
2088
        outfile.write(' Name="%s"' % (self.getName(),))
2089
        outfile.write(' Type="%s"' % (self.getType(),))
2090
        if self.getStartvalue() is not None:
2091
            outfile.write(' StartValue="%s"' % (self.getStartvalue(),))
2092

2093
    def exportChildren(self, outfile, level, name_="Property"):
2094
        if self.Documentation:
2095
            self.Documentation.export(outfile, level)
2096

2097
    def exportLiteral(self, outfile, level, name_="Property"):
2098
        level += 1
2099
        self.exportLiteralAttributes(outfile, level, name_)
2100
        self.exportLiteralChildren(outfile, level, name_)
2101

2102
    def exportLiteralAttributes(self, outfile, level, name_):
2103
        showIndent(outfile, level)
2104
        outfile.write('Name = "%s",\n' % (self.getName(),))
2105
        showIndent(outfile, level)
2106
        outfile.write('Type = "%s",\n' % (self.getType(),))
2107
        showIndent(outfile, level)
2108
        outfile.write('StartValue = "%s",\n' % (self.getStartvalue(),))
2109

2110
    def exportLiteralChildren(self, outfile, level, name_):
2111
        if self.Documentation:
2112
            showIndent(outfile, level)
2113
            outfile.write("Documentation=Documentation(\n")
2114
            self.Documentation.exportLiteral(outfile, level)
2115
            showIndent(outfile, level)
2116
            outfile.write("),\n")
2117

2118
    def build(self, node_):
2119
        attrs = node_.attributes
2120
        self.buildAttributes(attrs)
2121
        for child_ in node_.childNodes:
2122
            nodeName_ = child_.nodeName.split(":")[-1]
2123
            self.buildChildren(child_, nodeName_)
2124

2125
    def buildAttributes(self, attrs):
2126
        if attrs.get("Name"):
2127
            self.Name = attrs.get("Name").value
2128
        if attrs.get("Type"):
2129
            self.Type = attrs.get("Type").value
2130
        if attrs.get("StartValue"):
2131
            self.StartValue = attrs.get("StartValue").value
2132

2133
    def buildChildren(self, child_, nodeName_):
2134
        if child_.nodeType == Node.ELEMENT_NODE and nodeName_ == "Documentation":
2135
            obj_ = Documentation.factory()
2136
            obj_.build(child_)
2137
            self.setDocumentation(obj_)
2138

2139

2140
# end class Property
2141

2142

2143
class Documentation:
2144
    subclass = None
2145

2146
    def __init__(self, Author=None, DeveloperDocu="", UserDocu=""):
2147
        self.Author = Author
2148
        self.DeveloperDocu = DeveloperDocu
2149
        self.UserDocu = UserDocu
2150

2151
    def factory(*args_, **kwargs_):
2152
        if Documentation.subclass:
2153
            return Documentation.subclass(*args_, **kwargs_)
2154
        else:
2155
            return Documentation(*args_, **kwargs_)
2156

2157
    factory = staticmethod(factory)
2158

2159
    def getAuthor(self):
2160
        return self.Author
2161

2162
    def setAuthor(self, Author):
2163
        self.Author = Author
2164

2165
    def getDeveloperdocu(self):
2166
        return self.DeveloperDocu
2167

2168
    def setDeveloperdocu(self, DeveloperDocu):
2169
        self.DeveloperDocu = DeveloperDocu
2170

2171
    def getUserdocu(self):
2172
        return self.UserDocu
2173

2174
    def setUserdocu(self, UserDocu):
2175
        self.UserDocu = UserDocu
2176

2177
    def export(self, outfile, level, name_="Documentation"):
2178
        showIndent(outfile, level)
2179
        outfile.write("<%s>\n" % name_)
2180
        self.exportChildren(outfile, level + 1, name_)
2181
        showIndent(outfile, level)
2182
        outfile.write("</%s>\n" % name_)
2183

2184
    def exportAttributes(self, outfile, level, name_="Documentation"):
2185
        pass
2186

2187
    def exportChildren(self, outfile, level, name_="Documentation"):
2188
        if self.Author:
2189
            self.Author.export(outfile, level)
2190
        showIndent(outfile, level)
2191
        outfile.write("<DeveloperDocu>%s</DeveloperDocu>\n" % quote_xml(self.getDeveloperdocu()))
2192
        showIndent(outfile, level)
2193
        outfile.write("<UserDocu>%s</UserDocu>\n" % quote_xml(self.getUserdocu()))
2194

2195
    def exportLiteral(self, outfile, level, name_="Documentation"):
2196
        level += 1
2197
        self.exportLiteralAttributes(outfile, level, name_)
2198
        self.exportLiteralChildren(outfile, level, name_)
2199

2200
    def exportLiteralAttributes(self, outfile, level, name_):
2201
        pass
2202

2203
    def exportLiteralChildren(self, outfile, level, name_):
2204
        if self.Author:
2205
            showIndent(outfile, level)
2206
            outfile.write("Author=Author(\n")
2207
            self.Author.exportLiteral(outfile, level)
2208
            showIndent(outfile, level)
2209
            outfile.write("),\n")
2210
        showIndent(outfile, level)
2211
        outfile.write("DeveloperDocu=%s,\n" % quote_python(self.getDeveloperdocu()))
2212
        showIndent(outfile, level)
2213
        outfile.write("UserDocu=%s,\n" % quote_python(self.getUserdocu()))
2214

2215
    def build(self, node_):
2216
        attrs = node_.attributes
2217
        self.buildAttributes(attrs)
2218
        for child_ in node_.childNodes:
2219
            nodeName_ = child_.nodeName.split(":")[-1]
2220
            self.buildChildren(child_, nodeName_)
2221

2222
    def buildAttributes(self, attrs):
2223
        pass
2224

2225
    def buildChildren(self, child_, nodeName_):
2226
        if child_.nodeType == Node.ELEMENT_NODE and nodeName_ == "Author":
2227
            obj_ = Author.factory()
2228
            obj_.build(child_)
2229
            self.setAuthor(obj_)
2230
        elif child_.nodeType == Node.ELEMENT_NODE and nodeName_ == "DeveloperDocu":
2231
            DeveloperDocu_ = ""
2232
            for text__content_ in child_.childNodes:
2233
                DeveloperDocu_ += text__content_.nodeValue
2234
            self.DeveloperDocu = DeveloperDocu_
2235
        elif child_.nodeType == Node.ELEMENT_NODE and nodeName_ == "UserDocu":
2236
            UserDocu_ = ""
2237
            for text__content_ in child_.childNodes:
2238
                UserDocu_ += text__content_.nodeValue
2239
            self.UserDocu = UserDocu_
2240

2241

2242
# end class Documentation
2243

2244

2245
class Author:
2246
    subclass = None
2247

2248
    def __init__(self, Name="", EMail="", Licence="", valueOf_=""):
2249
        self.Name = Name
2250
        self.EMail = EMail
2251
        self.Licence = Licence
2252
        self.valueOf_ = valueOf_
2253

2254
    def factory(*args_, **kwargs_):
2255
        if Author.subclass:
2256
            return Author.subclass(*args_, **kwargs_)
2257
        else:
2258
            return Author(*args_, **kwargs_)
2259

2260
    factory = staticmethod(factory)
2261

2262
    def getName(self):
2263
        return self.Name
2264

2265
    def setName(self, Name):
2266
        self.Name = Name
2267

2268
    def getEmail(self):
2269
        return self.EMail
2270

2271
    def setEmail(self, EMail):
2272
        self.EMail = EMail
2273

2274
    def getLicence(self):
2275
        return self.Licence
2276

2277
    def setLicence(self, Licence):
2278
        self.Licence = Licence
2279

2280
    def getValueOf_(self):
2281
        return self.valueOf_
2282

2283
    def setValueOf_(self, valueOf_):
2284
        self.valueOf_ = valueOf_
2285

2286
    def export(self, outfile, level, name_="Author"):
2287
        showIndent(outfile, level)
2288
        outfile.write("<%s" % (name_,))
2289
        self.exportAttributes(outfile, level, name_="Author")
2290
        outfile.write(">\n")
2291
        self.exportChildren(outfile, level + 1, name_)
2292
        showIndent(outfile, level)
2293
        outfile.write("</%s>\n" % name_)
2294

2295
    def exportAttributes(self, outfile, level, name_="Author"):
2296
        outfile.write(' Name="%s"' % (self.getName(),))
2297
        outfile.write(' EMail="%s"' % (self.getEmail(),))
2298
        if self.getLicence() is not None:
2299
            outfile.write(' Licence="%s"' % (self.getLicence(),))
2300

2301
    def exportChildren(self, outfile, level, name_="Author"):
2302
        outfile.write(self.valueOf_)
2303

2304
    def exportLiteral(self, outfile, level, name_="Author"):
2305
        level += 1
2306
        self.exportLiteralAttributes(outfile, level, name_)
2307
        self.exportLiteralChildren(outfile, level, name_)
2308

2309
    def exportLiteralAttributes(self, outfile, level, name_):
2310
        showIndent(outfile, level)
2311
        outfile.write('Name = "%s",\n' % (self.getName(),))
2312
        showIndent(outfile, level)
2313
        outfile.write('EMail = "%s",\n' % (self.getEmail(),))
2314
        showIndent(outfile, level)
2315
        outfile.write('Licence = "%s",\n' % (self.getLicence(),))
2316

2317
    def exportLiteralChildren(self, outfile, level, name_):
2318
        showIndent(outfile, level)
2319
        outfile.write('valueOf_ = "%s",\n' % (self.valueOf_,))
2320

2321
    def build(self, node_):
2322
        attrs = node_.attributes
2323
        self.buildAttributes(attrs)
2324
        for child_ in node_.childNodes:
2325
            nodeName_ = child_.nodeName.split(":")[-1]
2326
            self.buildChildren(child_, nodeName_)
2327

2328
    def buildAttributes(self, attrs):
2329
        if attrs.get("Name"):
2330
            self.Name = attrs.get("Name").value
2331
        if attrs.get("EMail"):
2332
            self.EMail = attrs.get("EMail").value
2333
        if attrs.get("Licence"):
2334
            self.Licence = attrs.get("Licence").value
2335

2336
    def buildChildren(self, child_, nodeName_):
2337
        self.valueOf_ = ""
2338
        for child in child_.childNodes:
2339
            if child.nodeType == Node.TEXT_NODE:
2340
                self.valueOf_ += child.nodeValue
2341

2342

2343
# end class Author
2344

2345

2346
class ViewProvider:
2347
    subclass = None
2348

2349
    def __init__(self, Property=None):
2350
        if Property is None:
2351
            self.Property = []
2352
        else:
2353
            self.Property = Property
2354

2355
    def factory(*args_, **kwargs_):
2356
        if ViewProvider.subclass:
2357
            return ViewProvider.subclass(*args_, **kwargs_)
2358
        else:
2359
            return ViewProvider(*args_, **kwargs_)
2360

2361
    factory = staticmethod(factory)
2362

2363
    def getProperty(self):
2364
        return self.Property
2365

2366
    def setProperty(self, Property):
2367
        self.Property = Property
2368

2369
    def addProperty(self, value):
2370
        self.Property.append(value)
2371

2372
    def insertProperty(self, index, value):
2373
        self.Property[index] = value
2374

2375
    def export(self, outfile, level, name_="ViewProvider"):
2376
        showIndent(outfile, level)
2377
        outfile.write("<%s>\n" % name_)
2378
        self.exportChildren(outfile, level + 1, name_)
2379
        showIndent(outfile, level)
2380
        outfile.write("</%s>\n" % name_)
2381

2382
    def exportAttributes(self, outfile, level, name_="ViewProvider"):
2383
        pass
2384

2385
    def exportChildren(self, outfile, level, name_="ViewProvider"):
2386
        for Property_ in self.getProperty():
2387
            Property_.export(outfile, level)
2388

2389
    def exportLiteral(self, outfile, level, name_="ViewProvider"):
2390
        level += 1
2391
        self.exportLiteralAttributes(outfile, level, name_)
2392
        self.exportLiteralChildren(outfile, level, name_)
2393

2394
    def exportLiteralAttributes(self, outfile, level, name_):
2395
        pass
2396

2397
    def exportLiteralChildren(self, outfile, level, name_):
2398
        showIndent(outfile, level)
2399
        outfile.write("Property=[\n")
2400
        level += 1
2401
        for Property in self.Property:
2402
            showIndent(outfile, level)
2403
            outfile.write("Property(\n")
2404
            Property.exportLiteral(outfile, level)
2405
            showIndent(outfile, level)
2406
            outfile.write("),\n")
2407
        level -= 1
2408
        showIndent(outfile, level)
2409
        outfile.write("],\n")
2410

2411
    def build(self, node_):
2412
        attrs = node_.attributes
2413
        self.buildAttributes(attrs)
2414
        for child_ in node_.childNodes:
2415
            nodeName_ = child_.nodeName.split(":")[-1]
2416
            self.buildChildren(child_, nodeName_)
2417

2418
    def buildAttributes(self, attrs):
2419
        pass
2420

2421
    def buildChildren(self, child_, nodeName_):
2422
        if child_.nodeType == Node.ELEMENT_NODE and nodeName_ == "Property":
2423
            obj_ = Property.factory()
2424
            obj_.build(child_)
2425
            self.Property.append(obj_)
2426

2427

2428
# end class ViewProvider
2429

2430

2431
class Parameter:
2432
    subclass = None
2433

2434
    def __init__(self, Name="", Type="", valueOf_=""):
2435
        self.Name = Name
2436
        self.Type = Type
2437
        self.valueOf_ = valueOf_
2438

2439
    def factory(*args_, **kwargs_):
2440
        if Parameter.subclass:
2441
            return Parameter.subclass(*args_, **kwargs_)
2442
        else:
2443
            return Parameter(*args_, **kwargs_)
2444

2445
    factory = staticmethod(factory)
2446

2447
    def getName(self):
2448
        return self.Name
2449

2450
    def setName(self, Name):
2451
        self.Name = Name
2452

2453
    def getType(self):
2454
        return self.Type
2455

2456
    def setType(self, Type):
2457
        self.Type = Type
2458

2459
    def getValueOf_(self):
2460
        return self.valueOf_
2461

2462
    def setValueOf_(self, valueOf_):
2463
        self.valueOf_ = valueOf_
2464

2465
    def export(self, outfile, level, name_="Parameter"):
2466
        showIndent(outfile, level)
2467
        outfile.write("<%s" % (name_,))
2468
        self.exportAttributes(outfile, level, name_="Parameter")
2469
        outfile.write(">\n")
2470
        self.exportChildren(outfile, level + 1, name_)
2471
        showIndent(outfile, level)
2472
        outfile.write("</%s>\n" % name_)
2473

2474
    def exportAttributes(self, outfile, level, name_="Parameter"):
2475
        outfile.write(' Name="%s"' % (self.getName(),))
2476
        outfile.write(' Type="%s"' % (self.getType(),))
2477

2478
    def exportChildren(self, outfile, level, name_="Parameter"):
2479
        outfile.write(self.valueOf_)
2480

2481
    def exportLiteral(self, outfile, level, name_="Parameter"):
2482
        level += 1
2483
        self.exportLiteralAttributes(outfile, level, name_)
2484
        self.exportLiteralChildren(outfile, level, name_)
2485

2486
    def exportLiteralAttributes(self, outfile, level, name_):
2487
        showIndent(outfile, level)
2488
        outfile.write('Name = "%s",\n' % (self.getName(),))
2489
        showIndent(outfile, level)
2490
        outfile.write('Type = "%s",\n' % (self.getType(),))
2491

2492
    def exportLiteralChildren(self, outfile, level, name_):
2493
        showIndent(outfile, level)
2494
        outfile.write('valueOf_ = "%s",\n' % (self.valueOf_,))
2495

2496
    def build(self, node_):
2497
        attrs = node_.attributes
2498
        self.buildAttributes(attrs)
2499
        for child_ in node_.childNodes:
2500
            nodeName_ = child_.nodeName.split(":")[-1]
2501
            self.buildChildren(child_, nodeName_)
2502

2503
    def buildAttributes(self, attrs):
2504
        if attrs.get("Name"):
2505
            self.Name = attrs.get("Name").value
2506
        if attrs.get("Type"):
2507
            self.Type = attrs.get("Type").value
2508

2509
    def buildChildren(self, child_, nodeName_):
2510
        self.valueOf_ = ""
2511
        for child in child_.childNodes:
2512
            if child.nodeType == Node.TEXT_NODE:
2513
                self.valueOf_ += child.nodeValue
2514

2515

2516
# end class Parameter
2517

2518

2519
from xml.sax import handler, make_parser
2520

2521

2522
class SaxStackElement:
2523
    def __init__(self, name="", obj=None):
2524
        self.name = name
2525
        self.obj = obj
2526
        self.content = ""
2527

2528

2529
#
2530
# SAX handler
2531
#
2532
class SaxGeneratemodelHandler(handler.ContentHandler):
2533
    def __init__(self):
2534
        self.stack = []
2535
        self.root = None
2536

2537
    def getRoot(self):
2538
        return self.root
2539

2540
    def setDocumentLocator(self, locator):
2541
        self.locator = locator
2542

2543
    def showError(self, msg):
2544
        print("*** (showError):", msg)
2545
        sys.exit(-1)
2546

2547
    def startElement(self, name, attrs):
2548
        done = 0
2549
        if name == "GenerateModel":
2550
            obj = GenerateModel.factory()
2551
            stackObj = SaxStackElement("GenerateModel", obj)
2552
            self.stack.append(stackObj)
2553
            done = 1
2554
        elif name == "Module":
2555
            obj = Module.factory()
2556
            stackObj = SaxStackElement("Module", obj)
2557
            self.stack.append(stackObj)
2558
            done = 1
2559
        elif name == "PythonExport":
2560
            obj = PythonExport.factory()
2561
            val = attrs.get("Name", None)
2562
            if val is not None:
2563
                obj.setName(val)
2564
            val = attrs.get("PythonName", None)
2565
            if val is not None:
2566
                obj.setPythonname(val)
2567
            val = attrs.get("Include", None)
2568
            if val is not None:
2569
                obj.setInclude(val)
2570
            val = attrs.get("Father", None)
2571
            if val is not None:
2572
                obj.setFather(val)
2573
            val = attrs.get("Twin", None)
2574
            if val is not None:
2575
                obj.setTwin(val)
2576
            val = attrs.get("Namespace", None)
2577
            if val is not None:
2578
                obj.setNamespace(val)
2579
            val = attrs.get("FatherInclude", None)
2580
            if val is not None:
2581
                obj.setFatherinclude(val)
2582
            val = attrs.get("FatherNamespace", None)
2583
            if val is not None:
2584
                obj.setFathernamespace(val)
2585
            val = attrs.get("Constructor", None)
2586
            if val is not None:
2587
                if val in ("true", "1"):
2588
                    obj.setConstructor(1)
2589
                elif val in ("false", "0"):
2590
                    obj.setConstructor(0)
2591
                else:
2592
                    self.reportError(
2593
                        '"Constructor" attribute must be boolean ("true", "1", "false", "0")'
2594
                    )
2595
            val = attrs.get("NumberProtocol", None)
2596
            if val is not None:
2597
                if val in ("true", "1"):
2598
                    obj.setNumberprotocol(1)
2599
                elif val in ("false", "0"):
2600
                    obj.setNumberprotocol(0)
2601
                else:
2602
                    self.reportError(
2603
                        '"NumberProtocol" attribute must be boolean ("true", "1", "false", "0")'
2604
                    )
2605
            val = attrs.get("RichCompare", None)
2606
            if val is not None:
2607
                if val in ("true", "1"):
2608
                    obj.setRichcompare(1)
2609
                elif val in ("false", "0"):
2610
                    obj.setRichcompare(0)
2611
                else:
2612
                    self.reportError(
2613
                        '"RichCompare" attribute must be boolean ("true", "1", "false", "0")'
2614
                    )
2615
            val = attrs.get("TwinPointer", None)
2616
            if val is not None:
2617
                obj.setTwinpointer(val)
2618
            val = attrs.get("Delete", None)
2619
            if val is not None:
2620
                if val in ("true", "1"):
2621
                    obj.setDelete(1)
2622
                elif val in ("false", "0"):
2623
                    obj.setDelete(0)
2624
                else:
2625
                    self.reportError(
2626
                        '"Delete" attribute must be boolean ("true", "1", "false", "0")'
2627
                    )
2628
            val = attrs.get("Reference", None)
2629
            if val is not None:
2630
                if val in ("true", "1"):
2631
                    obj.setReference(1)
2632
                elif val in ("false", "0"):
2633
                    obj.setReference(0)
2634
                else:
2635
                    self.reportError(
2636
                        '"Reference" attribute must be boolean ("true", "1", "false", "0")'
2637
                    )
2638
            val = attrs.get("Initialization", None)
2639
            if val is not None:
2640
                if val in ("true", "1"):
2641
                    obj.setInitialization(1)
2642
                elif val in ("false", "0"):
2643
                    obj.setInitialization(0)
2644
                else:
2645
                    self.reportError(
2646
                        '"Initialization" attribute must be boolean ("true", "1", "false", "0")'
2647
                    )
2648
            val = attrs.get("DisableNotify", None)
2649
            if val is not None:
2650
                if val in ("true", "1"):
2651
                    obj.setDisablenotify(1)
2652
                elif val in ("false", "0"):
2653
                    obj.setDisablenotify(0)
2654
                else:
2655
                    self.reportError(
2656
                        '"DisableNotify" attribute must be boolean ("true", "1", "false", "0")'
2657
                    )
2658
            val = attrs.get("DescriptorGetter", None)
2659
            if val is not None:
2660
                if val in ("true", "1"):
2661
                    obj.setDescriptorgetter(1)
2662
                elif val in ("false", "0"):
2663
                    obj.setDescriptorgetter(0)
2664
                else:
2665
                    self.reportError(
2666
                        '"DescriptorGetter" attribute must be boolean ("true", "1", "false", "0")'
2667
                    )
2668
            val = attrs.get("DescriptorSetter", None)
2669
            if val is not None:
2670
                if val in ("true", "1"):
2671
                    obj.setDescriptorsetter(1)
2672
                elif val in ("false", "0"):
2673
                    obj.setDescriptorsetter(0)
2674
                else:
2675
                    self.reportError(
2676
                        '"DescriptorSetter" attribute must be boolean ("true", "1", "false", "0")'
2677
                    )
2678
            stackObj = SaxStackElement("PythonExport", obj)
2679
            self.stack.append(stackObj)
2680
            done = 1
2681
        elif name == "Documentation":
2682
            obj = Documentation.factory()
2683
            stackObj = SaxStackElement("Documentation", obj)
2684
            self.stack.append(stackObj)
2685
            done = 1
2686
        elif name == "Methode":
2687
            obj = Methode.factory()
2688
            val = attrs.get("Name", None)
2689
            if val is not None:
2690
                obj.setName(val)
2691
            val = attrs.get("Const", None)
2692
            if val is not None:
2693
                if val in ("true", "1"):
2694
                    obj.setConst(1)
2695
                elif val in ("false", "0"):
2696
                    obj.setConst(0)
2697
                else:
2698
                    self.reportError(
2699
                        '"Const" attribute must be boolean ("true", "1", "false", "0")'
2700
                    )
2701
            val = attrs.get("Keyword", None)
2702
            if val is not None:
2703
                if val in ("true", "1"):
2704
                    obj.setKeyword(1)
2705
                elif val in ("false", "0"):
2706
                    obj.setKeyword(0)
2707
                else:
2708
                    self.reportError(
2709
                        '"Keyword" attribute must be boolean ("true", "1", "false", "0")'
2710
                    )
2711
            val = attrs.get("NoArgs", None)
2712
            if val is not None:
2713
                if val in ("true", "1"):
2714
                    obj.setNoargs(1)
2715
                elif val in ("false", "0"):
2716
                    obj.setNoargs(0)
2717
                else:
2718
                    self.reportError(
2719
                        '"NoArgs" attribute must be boolean ("true", "1", "false", "0")'
2720
                    )
2721
            val = attrs.get("Class", None)
2722
            if val is not None:
2723
                if val in ("true", "1"):
2724
                    obj.setClass(1)
2725
                elif val in ("false", "0"):
2726
                    obj.setClass(0)
2727
                else:
2728
                    self.reportError(
2729
                        '"Class" attribute must be boolean ("true", "1", "false", "0")'
2730
                    )
2731
            val = attrs.get("Static", None)
2732
            if val is not None:
2733
                if val in ("true", "1"):
2734
                    obj.setStatic(1)
2735
                elif val in ("false", "0"):
2736
                    obj.setStatic(0)
2737
                else:
2738
                    self.reportError(
2739
                        '"Static" attribute must be boolean ("true", "1", "false", "0")'
2740
                    )
2741
            stackObj = SaxStackElement("Methode", obj)
2742
            self.stack.append(stackObj)
2743
            done = 1
2744
        elif name == "Parameter":
2745
            obj = Parameter.factory()
2746
            val = attrs.get("Name", None)
2747
            if val is not None:
2748
                obj.setName(val)
2749
            val = attrs.get("Type", None)
2750
            if val is not None:
2751
                obj.setType(val)
2752
            stackObj = SaxStackElement("Parameter", obj)
2753
            self.stack.append(stackObj)
2754
            done = 1
2755
        elif name == "Attribute":
2756
            obj = Attribute.factory()
2757
            val = attrs.get("Name", None)
2758
            if val is not None:
2759
                obj.setName(val)
2760
            val = attrs.get("ReadOnly", None)
2761
            if val is not None:
2762
                if val in ("true", "1"):
2763
                    obj.setReadonly(1)
2764
                elif val in ("false", "0"):
2765
                    obj.setReadonly(0)
2766
                else:
2767
                    self.reportError(
2768
                        '"ReadOnly" attribute must be boolean ("true", "1", "false", "0")'
2769
                    )
2770
            stackObj = SaxStackElement("Attribute", obj)
2771
            self.stack.append(stackObj)
2772
            done = 1
2773
        elif name == "Sequence":
2774
            obj = Sequence.factory()
2775
            val = attrs.get("sq_length", None)
2776
            if val is not None:
2777
                if val in ("true", "1"):
2778
                    obj.setSq_length(1)
2779
                elif val in ("false", "0"):
2780
                    obj.setSq_length(0)
2781
                else:
2782
                    self.reportError(
2783
                        '"sq_length" attribute must be boolean ("true", "1", "false", "0")'
2784
                    )
2785
            val = attrs.get("sq_concat", None)
2786
            if val is not None:
2787
                if val in ("true", "1"):
2788
                    obj.setSq_concat(1)
2789
                elif val in ("false", "0"):
2790
                    obj.setSq_concat(0)
2791
                else:
2792
                    self.reportError(
2793
                        '"sq_concat" attribute must be boolean ("true", "1", "false", "0")'
2794
                    )
2795
            val = attrs.get("sq_repeat", None)
2796
            if val is not None:
2797
                if val in ("true", "1"):
2798
                    obj.setSq_repeat(1)
2799
                elif val in ("false", "0"):
2800
                    obj.setSq_repeat(0)
2801
                else:
2802
                    self.reportError(
2803
                        '"sq_repeat" attribute must be boolean ("true", "1", "false", "0")'
2804
                    )
2805
            val = attrs.get("sq_item", None)
2806
            if val is not None:
2807
                if val in ("true", "1"):
2808
                    obj.setSq_item(1)
2809
                elif val in ("false", "0"):
2810
                    obj.setSq_item(0)
2811
                else:
2812
                    self.reportError(
2813
                        '"sq_item" attribute must be boolean ("true", "1", "false", "0")'
2814
                    )
2815
            val = attrs.get("mp_subscript", None)
2816
            if val is not None:
2817
                if val in ("true", "1"):
2818
                    obj.setMp_subscript(1)
2819
                elif val in ("false", "0"):
2820
                    obj.setMp_subscript(0)
2821
                else:
2822
                    self.reportError(
2823
                        '"mp_subscript" attribute must be boolean ("true", "1", "false", "0")'
2824
                    )
2825
            val = attrs.get("sq_ass_item", None)
2826
            if val is not None:
2827
                if val in ("true", "1"):
2828
                    obj.setSq_ass_item(1)
2829
                elif val in ("false", "0"):
2830
                    obj.setSq_ass_item(0)
2831
                else:
2832
                    self.reportError(
2833
                        '"sq_ass_item" attribute must be boolean ("true", "1", "false", "0")'
2834
                    )
2835
            val = attrs.get("mp_ass_subscript", None)
2836
            if val is not None:
2837
                if val in ("true", "1"):
2838
                    obj.setMp_ass_subscript(1)
2839
                elif val in ("false", "0"):
2840
                    obj.setMp_ass_subscript(0)
2841
                else:
2842
                    self.reportError(
2843
                        '"mp_ass_subscript" attribute must be boolean ("true", "1", "false", "0")'
2844
                    )
2845
            val = attrs.get("sq_contains", None)
2846
            if val is not None:
2847
                if val in ("true", "1"):
2848
                    obj.setSq_contains(1)
2849
                elif val in ("false", "0"):
2850
                    obj.setSq_contains(0)
2851
                else:
2852
                    self.reportError(
2853
                        '"sq_contains" attribute must be boolean ("true", "1", "false", "0")'
2854
                    )
2855
            val = attrs.get("sq_inplace_concat", None)
2856
            if val is not None:
2857
                if val in ("true", "1"):
2858
                    obj.setSq_inplace_concat(1)
2859
                elif val in ("false", "0"):
2860
                    obj.setSq_inplace_concat(0)
2861
                else:
2862
                    self.reportError(
2863
                        '"sq_inplace_concat" attribute must be boolean ("true", "1", "false", "0")'
2864
                    )
2865
            val = attrs.get("sq_inplace_repeat", None)
2866
            if val is not None:
2867
                if val in ("true", "1"):
2868
                    obj.setSq_inplace_repeat(1)
2869
                elif val in ("false", "0"):
2870
                    obj.setSq_inplace_repeat(0)
2871
                else:
2872
                    self.reportError(
2873
                        '"sq_inplace_repeat" attribute must be boolean ("true", "1", "false", "0")'
2874
                    )
2875
            stackObj = SaxStackElement("Sequence", obj)
2876
            self.stack.append(stackObj)
2877
            done = 1
2878
        elif name == "CustomAttributes":
2879
            stackObj = SaxStackElement("CustomAttributes", None)
2880
            self.stack.append(stackObj)
2881
            done = 1
2882
        elif name == "ClassDeclarations":
2883
            stackObj = SaxStackElement("ClassDeclarations", None)
2884
            self.stack.append(stackObj)
2885
            done = 1
2886
        elif name == "ForwardDeclarations":
2887
            stackObj = SaxStackElement("ForwardDeclarations", None)
2888
            self.stack.append(stackObj)
2889
            done = 1
2890
        elif name == "Dependencies":
2891
            obj = Dependencies.factory()
2892
            stackObj = SaxStackElement("Dependencies", obj)
2893
            self.stack.append(stackObj)
2894
            done = 1
2895
        elif name == "Content":
2896
            obj = Content.factory()
2897
            stackObj = SaxStackElement("Content", obj)
2898
            self.stack.append(stackObj)
2899
            done = 1
2900
        elif name == "Property":
2901
            obj = Property.factory()
2902
            stackObj = SaxStackElement("Property", obj)
2903
            self.stack.append(stackObj)
2904
            done = 1
2905
        elif name == "Feature":
2906
            obj = Feature.factory()
2907
            val = attrs.get("Name", None)
2908
            if val is not None:
2909
                obj.setName(val)
2910
            stackObj = SaxStackElement("Feature", obj)
2911
            self.stack.append(stackObj)
2912
            done = 1
2913
        elif name == "ViewProvider":
2914
            obj = ViewProvider.factory()
2915
            stackObj = SaxStackElement("ViewProvider", obj)
2916
            self.stack.append(stackObj)
2917
            done = 1
2918
        elif name == "DocObject":
2919
            obj = DocObject.factory()
2920
            val = attrs.get("Name", None)
2921
            if val is not None:
2922
                obj.setName(val)
2923
            stackObj = SaxStackElement("DocObject", obj)
2924
            self.stack.append(stackObj)
2925
            done = 1
2926
        elif name == "GuiCommand":
2927
            stackObj = SaxStackElement("GuiCommand", None)
2928
            self.stack.append(stackObj)
2929
            done = 1
2930
        elif name == "PreferencesPage":
2931
            stackObj = SaxStackElement("PreferencesPage", None)
2932
            self.stack.append(stackObj)
2933
            done = 1
2934
        elif name == "Author":
2935
            obj = Author.factory()
2936
            val = attrs.get("Name", None)
2937
            if val is not None:
2938
                obj.setName(val)
2939
            val = attrs.get("EMail", None)
2940
            if val is not None:
2941
                obj.setEmail(val)
2942
            val = attrs.get("Licence", None)
2943
            if val is not None:
2944
                obj.setLicence(val)
2945
            stackObj = SaxStackElement("Author", obj)
2946
            self.stack.append(stackObj)
2947
            done = 1
2948
        elif name == "DeveloperDocu":
2949
            stackObj = SaxStackElement("DeveloperDocu", None)
2950
            self.stack.append(stackObj)
2951
            done = 1
2952
        elif name == "UserDocu":
2953
            stackObj = SaxStackElement("UserDocu", None)
2954
            self.stack.append(stackObj)
2955
            done = 1
2956
        if not done:
2957
            self.reportError('"%s" element not allowed here.' % name)
2958

2959
    def endElement(self, name):
2960
        done = 0
2961
        if name == "GenerateModel":
2962
            if len(self.stack) == 1:
2963
                self.root = self.stack[-1].obj
2964
                self.stack.pop()
2965
                done = 1
2966
        elif name == "Module":
2967
            if len(self.stack) >= 2:
2968
                self.stack[-2].obj.addModule(self.stack[-1].obj)
2969
                self.stack.pop()
2970
                done = 1
2971
        elif name == "PythonExport":
2972
            if len(self.stack) >= 2:
2973
                self.stack[-2].obj.addPythonexport(self.stack[-1].obj)
2974
                self.stack.pop()
2975
                done = 1
2976
        elif name == "Documentation":
2977
            if len(self.stack) >= 2:
2978
                self.stack[-2].obj.setDocumentation(self.stack[-1].obj)
2979
                self.stack.pop()
2980
                done = 1
2981
        elif name == "Methode":
2982
            if len(self.stack) >= 2:
2983
                self.stack[-2].obj.addMethode(self.stack[-1].obj)
2984
                self.stack.pop()
2985
                done = 1
2986
        elif name == "Parameter":
2987
            if len(self.stack) >= 2:
2988
                self.stack[-2].obj.addParameter(self.stack[-1].obj)
2989
                self.stack.pop()
2990
                done = 1
2991
        elif name == "Attribute":
2992
            if len(self.stack) >= 2:
2993
                self.stack[-2].obj.addAttribute(self.stack[-1].obj)
2994
                self.stack.pop()
2995
                done = 1
2996
        elif name == "Sequence":
2997
            if len(self.stack) >= 2:
2998
                self.stack[-2].obj.setSequence(self.stack[-1].obj)
2999
                self.stack.pop()
3000
                done = 1
3001
        elif name == "CustomAttributes":
3002
            if len(self.stack) >= 2:
3003
                content = self.stack[-1].content
3004
                self.stack[-2].obj.setCustomattributes(content)
3005
                self.stack.pop()
3006
                done = 1
3007
        elif name == "ClassDeclarations":
3008
            if len(self.stack) >= 2:
3009
                content = self.stack[-1].content
3010
                self.stack[-2].obj.setClassdeclarations(content)
3011
                self.stack.pop()
3012
                done = 1
3013
        elif name == "ForwardDeclarations":
3014
            if len(self.stack) >= 2:
3015
                content = self.stack[-1].content
3016
                self.stack[-2].obj.setForwarddeclarations(content)
3017
                self.stack.pop()
3018
                done = 1
3019
        elif name == "Dependencies":
3020
            if len(self.stack) >= 2:
3021
                self.stack[-2].obj.setDependencies(self.stack[-1].obj)
3022
                self.stack.pop()
3023
                done = 1
3024
        elif name == "Content":
3025
            if len(self.stack) >= 2:
3026
                self.stack[-2].obj.setContent(self.stack[-1].obj)
3027
                self.stack.pop()
3028
                done = 1
3029
        elif name == "Property":
3030
            if len(self.stack) >= 2:
3031
                self.stack[-2].obj.addProperty(self.stack[-1].obj)
3032
                self.stack.pop()
3033
                done = 1
3034
        elif name == "Feature":
3035
            if len(self.stack) >= 2:
3036
                self.stack[-2].obj.addFeature(self.stack[-1].obj)
3037
                self.stack.pop()
3038
                done = 1
3039
        elif name == "ViewProvider":
3040
            if len(self.stack) >= 2:
3041
                self.stack[-2].obj.setViewprovider(self.stack[-1].obj)
3042
                self.stack.pop()
3043
                done = 1
3044
        elif name == "DocObject":
3045
            if len(self.stack) >= 2:
3046
                self.stack[-2].obj.addDocobject(self.stack[-1].obj)
3047
                self.stack.pop()
3048
                done = 1
3049
        elif name == "GuiCommand":
3050
            if len(self.stack) >= 2:
3051
                content = self.stack[-1].content
3052
                self.stack[-2].obj.addGuicommand(content)
3053
                self.stack.pop()
3054
                done = 1
3055
        elif name == "PreferencesPage":
3056
            if len(self.stack) >= 2:
3057
                content = self.stack[-1].content
3058
                self.stack[-2].obj.addPreferencespage(content)
3059
                self.stack.pop()
3060
                done = 1
3061
        elif name == "Author":
3062
            if len(self.stack) >= 2:
3063
                self.stack[-2].obj.setAuthor(self.stack[-1].obj)
3064
                self.stack.pop()
3065
                done = 1
3066
        elif name == "DeveloperDocu":
3067
            if len(self.stack) >= 2:
3068
                content = self.stack[-1].content
3069
                self.stack[-2].obj.setDeveloperdocu(content)
3070
                self.stack.pop()
3071
                done = 1
3072
        elif name == "UserDocu":
3073
            if len(self.stack) >= 2:
3074
                content = self.stack[-1].content
3075
                self.stack[-2].obj.setUserdocu(content)
3076
                self.stack.pop()
3077
                done = 1
3078
        if not done:
3079
            self.reportError('"%s" element not allowed here.' % name)
3080

3081
    def characters(self, chrs, start, end):
3082
        if len(self.stack) > 0:
3083
            self.stack[-1].content += chrs[start:end]
3084

3085
    def reportError(self, mesg):
3086
        locator = self.locator
3087
        sys.stderr.write(
3088
            "Doc: %s  Line: %d  Column: %d\n"
3089
            % (locator.getSystemId(), locator.getLineNumber(), locator.getColumnNumber() + 1)
3090
        )
3091
        sys.stderr.write(mesg)
3092
        sys.stderr.write("\n")
3093
        sys.exit(-1)
3094
        # raise RuntimeError
3095

3096

3097
USAGE_TEXT = """
3098
Usage: python <Parser>.py [ -s ] <in_xml_file>
3099
Options:
3100
    -s        Use the SAX parser, not the minidom parser.
3101
"""
3102

3103

3104
def usage():
3105
    print(USAGE_TEXT)
3106
    sys.exit(-1)
3107

3108

3109
#
3110
# SAX handler used to determine the top level element.
3111
#
3112
class SaxSelectorHandler(handler.ContentHandler):
3113
    def __init__(self):
3114
        self.topElementName = None
3115

3116
    def getTopElementName(self):
3117
        return self.topElementName
3118

3119
    def startElement(self, name, attrs):
3120
        self.topElementName = name
3121
        raise StopIteration
3122

3123

3124
def parseSelect(inFileName):
3125
    infile = open(inFileName, "r")
3126
    topElementName = None
3127
    parser = make_parser()
3128
    documentHandler = SaxSelectorHandler()
3129
    parser.setContentHandler(documentHandler)
3130
    try:
3131
        try:
3132
            parser.parse(infile)
3133
        except StopIteration:
3134
            topElementName = documentHandler.getTopElementName()
3135
        if topElementName is None:
3136
            raise RuntimeError("no top level element")
3137
        topElementName = topElementName.replace("-", "_").replace(":", "_")
3138
        if topElementName not in globals():
3139
            raise RuntimeError("no class for top element: %s" % topElementName)
3140
        topElement = globals()[topElementName]
3141
        infile.seek(0)
3142
        doc = minidom.parse(infile)
3143
    finally:
3144
        infile.close()
3145
    rootNode = doc.childNodes[0]
3146
    rootObj = topElement.factory()
3147
    rootObj.build(rootNode)
3148
    # Enable Python to collect the space used by the DOM.
3149
    doc = None
3150
    sys.stdout.write('<?xml version="1.0" ?>\n')
3151
    rootObj.export(sys.stdout, 0)
3152
    return rootObj
3153

3154

3155
def saxParse(inFileName):
3156
    parser = make_parser()
3157
    documentHandler = SaxGeneratemodelHandler()
3158
    parser.setDocumentHandler(documentHandler)
3159
    parser.parse("file:%s" % inFileName)
3160
    root = documentHandler.getRoot()
3161
    sys.stdout.write('<?xml version="1.0" ?>\n')
3162
    root.export(sys.stdout, 0)
3163
    return root
3164

3165

3166
def saxParseString(inString):
3167
    parser = make_parser()
3168
    documentHandler = SaxGeneratemodelHandler()
3169
    parser.setDocumentHandler(documentHandler)
3170
    parser.feed(inString)
3171
    parser.close()
3172
    rootObj = documentHandler.getRoot()
3173
    # sys.stdout.write('<?xml version="1.0" ?>\n')
3174
    # rootObj.export(sys.stdout, 0)
3175
    return rootObj
3176

3177

3178
def parse(inFileName):
3179
    doc = minidom.parse(inFileName)
3180
    rootNode = doc.documentElement
3181
    rootObj = GenerateModel.factory()
3182
    rootObj.build(rootNode)
3183
    # Enable Python to collect the space used by the DOM.
3184
    doc = None
3185
    sys.stdout.write('<?xml version="1.0" ?>\n')
3186
    rootObj.export(sys.stdout, 0, name_="GenerateModel")
3187
    return rootObj
3188

3189

3190
def parseString(inString):
3191
    doc = minidom.parseString(inString)
3192
    rootNode = doc.documentElement
3193
    rootObj = GenerateModel.factory()
3194
    rootObj.build(rootNode)
3195
    # Enable Python to collect the space used by the DOM.
3196
    doc = None
3197
    sys.stdout.write('<?xml version="1.0" ?>\n')
3198
    rootObj.export(sys.stdout, 0, name_="GenerateModel")
3199
    return rootObj
3200

3201

3202
def parseLiteral(inFileName):
3203
    doc = minidom.parse(inFileName)
3204
    rootNode = doc.documentElement
3205
    rootObj = GenerateModel.factory()
3206
    rootObj.build(rootNode)
3207
    # Enable Python to collect the space used by the DOM.
3208
    doc = None
3209
    sys.stdout.write("from generateModel_Module import *\n\n")
3210
    sys.stdout.write("rootObj = GenerateModel(\n")
3211
    rootObj.exportLiteral(sys.stdout, 0, name_="GenerateModel")
3212
    sys.stdout.write(")\n")
3213
    return rootObj
3214

3215

3216
def main():
3217
    args = sys.argv[1:]
3218
    if len(args) == 2 and args[0] == "-s":
3219
        saxParse(args[1])
3220
    elif len(args) == 1:
3221
        parse(args[0])
3222
    else:
3223
        usage()
3224

3225

3226
if __name__ == "__main__":
3227
    main()
3228
    # import pdb
3229
    # pdb.run('main()')
3230

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.