4
# Generated Sun Jan 11 02:25:41 2009 by generateDS.py.
9
from xml.dom import minidom
10
from xml.dom import Node
13
# If you have installed IPython you can uncomment and use the following.
14
# IPython is available from http://ipython.scipy.org/.
17
## from IPython.Shell import IPShellEmbed
19
## ipshell = IPShellEmbed(args,
20
## banner = 'Dropping into IPython',
21
## exit_msg = 'Leaving Interpreter, back to program.')
23
# Then use the following line where and when you want to drop into the
25
# ipshell('<some message> -- Entering ipshell.\nHit Ctrl-D to exit')
28
# Support/utility functions.
31
def showIndent(outfile, level):
32
for idx in range(level):
37
s1 = s1.replace('&', '&')
38
s1 = s1.replace('<', '<')
39
s1 = s1.replace('"', '"')
42
def quote_python(inStr):
44
if s1.find("'") == -1:
45
if s1.find('\n') == -1:
48
return "'''%s'''" % s1
50
if s1.find('"') != -1:
51
s1 = s1.replace('"', '\\"')
52
if s1.find('\n') == -1:
55
return '"""%s"""' % s1
59
# Constants for category:
64
# Constants for content_type:
73
def __init__(self, category, content_type, name, value):
74
self.category = category
75
self.content_type = content_type
78
def getCategory(self):
80
def getContenttype(self, content_type):
81
return self.content_type
86
def export(self, outfile, level, name):
87
if self.category == MixedContainer.CategoryText:
88
outfile.write(self.value)
89
elif self.category == MixedContainer.CategorySimple:
90
self.exportSimple(outfile, level, name)
91
else: # category == MixedContainer.CategoryComplex
92
self.value.export(outfile, level, name)
93
def exportSimple(self, outfile, level, name):
94
if self.content_type == MixedContainer.TypeString:
95
outfile.write('<%s>%s</%s>' % (self.name, self.value, self.name))
96
elif self.content_type == MixedContainer.TypeInteger or \
97
self.content_type == MixedContainer.TypeBoolean:
98
outfile.write('<%s>%d</%s>' % (self.name, self.value, self.name))
99
elif self.content_type == MixedContainer.TypeFloat or \
100
self.content_type == MixedContainer.TypeDecimal:
101
outfile.write('<%s>%f</%s>' % (self.name, self.value, self.name))
102
elif self.content_type == MixedContainer.TypeDouble:
103
outfile.write('<%s>%g</%s>' % (self.name, self.value, self.name))
104
def exportLiteral(self, outfile, level, name):
105
if self.category == MixedContainer.CategoryText:
106
showIndent(outfile, level)
107
outfile.write('MixedContainer(%d, %d, "%s", "%s"),\n' % \
108
(self.category, self.content_type, self.name, self.value))
109
elif self.category == MixedContainer.CategorySimple:
110
showIndent(outfile, level)
111
outfile.write('MixedContainer(%d, %d, "%s", "%s"),\n' % \
112
(self.category, self.content_type, self.name, self.value))
113
else: # category == MixedContainer.CategoryComplex
114
showIndent(outfile, level)
115
outfile.write('MixedContainer(%d, %d, "%s",\n' % \
116
(self.category, self.content_type, self.name,))
117
self.value.exportLiteral(outfile, level + 1)
118
showIndent(outfile, level)
123
# Data representation classes.
128
def __init__(self, Module=None, PythonExport=None):
133
if PythonExport is None:
134
self.PythonExport = []
136
self.PythonExport = PythonExport
137
def factory(*args_, **kwargs_):
138
if GenerateModel.subclass:
139
return GenerateModel.subclass(*args_, **kwargs_)
141
return GenerateModel(*args_, **kwargs_)
142
factory = staticmethod(factory)
143
def getModule(self): return self.Module
144
def setModule(self, Module): self.Module = Module
145
def addModule(self, value): self.Module.append(value)
146
def insertModule(self, index, value): self.Module[index] = value
147
def getPythonexport(self): return self.PythonExport
148
def setPythonexport(self, PythonExport): self.PythonExport = PythonExport
149
def addPythonexport(self, value): self.PythonExport.append(value)
150
def insertPythonexport(self, index, value): self.PythonExport[index] = value
151
def export(self, outfile, level, name_='GenerateModel'):
152
showIndent(outfile, level)
153
outfile.write('<%s>\n' % name_)
154
self.exportChildren(outfile, level + 1, name_)
155
showIndent(outfile, level)
156
outfile.write('</%s>\n' % name_)
157
def exportAttributes(self, outfile, level, name_='GenerateModel'):
159
def exportChildren(self, outfile, level, name_='GenerateModel'):
160
for Module_ in self.getModule():
161
Module_.export(outfile, level)
162
for PythonExport_ in self.getPythonexport():
163
PythonExport_.export(outfile, level)
164
def exportLiteral(self, outfile, level, name_='GenerateModel'):
166
self.exportLiteralAttributes(outfile, level, name_)
167
self.exportLiteralChildren(outfile, level, name_)
168
def exportLiteralAttributes(self, outfile, level, name_):
170
def exportLiteralChildren(self, outfile, level, name_):
171
showIndent(outfile, level)
172
outfile.write('Module=[\n')
174
for Module in self.Module:
175
showIndent(outfile, level)
176
outfile.write('Module(\n')
177
Module.exportLiteral(outfile, level)
178
showIndent(outfile, level)
179
outfile.write('),\n')
181
showIndent(outfile, level)
182
outfile.write('],\n')
183
showIndent(outfile, level)
184
outfile.write('PythonExport=[\n')
186
for PythonExport in self.PythonExport:
187
showIndent(outfile, level)
188
outfile.write('PythonExport(\n')
189
PythonExport.exportLiteral(outfile, level)
190
showIndent(outfile, level)
191
outfile.write('),\n')
193
showIndent(outfile, level)
194
outfile.write('],\n')
195
def build(self, node_):
196
attrs = node_.attributes
197
self.buildAttributes(attrs)
198
for child_ in node_.childNodes:
199
nodeName_ = child_.nodeName.split(':')[-1]
200
self.buildChildren(child_, nodeName_)
201
def buildAttributes(self, attrs):
203
def buildChildren(self, child_, nodeName_):
204
if child_.nodeType == Node.ELEMENT_NODE and \
205
nodeName_ == 'Module':
206
obj_ = Module.factory()
208
self.Module.append(obj_)
209
elif child_.nodeType == Node.ELEMENT_NODE and \
210
nodeName_ == 'PythonExport':
211
obj_ = PythonExport.factory()
213
self.PythonExport.append(obj_)
214
# end class GenerateModel
219
def __init__(self, FatherNamespace='', Name='', Reference=0, FatherInclude='', Father='', Namespace='', Twin='', Constructor=0, TwinPointer='', Include='', NumberProtocol=0, Delete=0, Documentation=None, Methode=None, Attribute=None, CustomAttributes='', ClassDeclarations=''):
220
self.FatherNamespace = FatherNamespace
222
self.Reference = Reference
223
self.FatherInclude = FatherInclude
225
self.Namespace = Namespace
227
self.Constructor = Constructor
228
self.TwinPointer = TwinPointer
229
self.Include = Include
230
self.NumberProtocol = NumberProtocol
232
self.Documentation = Documentation
236
self.Methode = Methode
237
if Attribute is None:
240
self.Attribute = Attribute
241
self.CustomAttributes = CustomAttributes
242
self.ClassDeclarations = ClassDeclarations
243
def factory(*args_, **kwargs_):
244
if PythonExport.subclass:
245
return PythonExport.subclass(*args_, **kwargs_)
247
return PythonExport(*args_, **kwargs_)
248
factory = staticmethod(factory)
249
def getDocumentation(self): return self.Documentation
250
def setDocumentation(self, Documentation): self.Documentation = Documentation
251
def getMethode(self): return self.Methode
252
def setMethode(self, Methode): self.Methode = Methode
253
def addMethode(self, value): self.Methode.append(value)
254
def insertMethode(self, index, value): self.Methode[index] = value
255
def getAttribute(self): return self.Attribute
256
def setAttribute(self, Attribute): self.Attribute = Attribute
257
def addAttribute(self, value): self.Attribute.append(value)
258
def insertAttribute(self, index, value): self.Attribute[index] = value
259
def getCustomattributes(self): return self.CustomAttributes
260
def setCustomattributes(self, CustomAttributes): self.CustomAttributes = CustomAttributes
261
def getClassdeclarations(self): return self.ClassDeclarations
262
def setClassdeclarations(self, ClassDeclarations): self.ClassDeclarations = ClassDeclarations
263
def getFathernamespace(self): return self.FatherNamespace
264
def setFathernamespace(self, FatherNamespace): self.FatherNamespace = FatherNamespace
265
def getName(self): return self.Name
266
def setName(self, Name): self.Name = Name
267
def getReference(self): return self.Reference
268
def setReference(self, Reference): self.Reference = Reference
269
def getFatherinclude(self): return self.FatherInclude
270
def setFatherinclude(self, FatherInclude): self.FatherInclude = FatherInclude
271
def getFather(self): return self.Father
272
def setFather(self, Father): self.Father = Father
273
def getNamespace(self): return self.Namespace
274
def setNamespace(self, Namespace): self.Namespace = Namespace
275
def getTwin(self): return self.Twin
276
def setTwin(self, Twin): self.Twin = Twin
277
def getConstructor(self): return self.Constructor
278
def setConstructor(self, Constructor): self.Constructor = Constructor
279
def getTwinpointer(self): return self.TwinPointer
280
def setTwinpointer(self, TwinPointer): self.TwinPointer = TwinPointer
281
def getInclude(self): return self.Include
282
def setInclude(self, Include): self.Include = Include
283
def getNumberprotocol(self): return self.NumberProtocol
284
def setNumberprotocol(self, NumberProtocol): self.NumberProtocol = NumberProtocol
285
def getDelete(self): return self.Delete
286
def setDelete(self, Delete): self.Delete = Delete
287
def export(self, outfile, level, name_='PythonExport'):
288
showIndent(outfile, level)
289
outfile.write('<%s' % (name_, ))
290
self.exportAttributes(outfile, level, name_='PythonExport')
292
self.exportChildren(outfile, level + 1, name_)
293
showIndent(outfile, level)
294
outfile.write('</%s>\n' % name_)
295
def exportAttributes(self, outfile, level, name_='PythonExport'):
296
outfile.write(' FatherNamespace="%s"' % (self.getFathernamespace(), ))
297
outfile.write(' Name="%s"' % (self.getName(), ))
298
if self.getReference() is not None:
299
outfile.write(' Reference="%s"' % (self.getReference(), ))
300
outfile.write(' FatherInclude="%s"' % (self.getFatherinclude(), ))
301
outfile.write(' Father="%s"' % (self.getFather(), ))
302
outfile.write(' Namespace="%s"' % (self.getNamespace(), ))
303
outfile.write(' Twin="%s"' % (self.getTwin(), ))
304
if self.getConstructor() is not None:
305
outfile.write(' Constructor="%s"' % (self.getConstructor(), ))
306
outfile.write(' TwinPointer="%s"' % (self.getTwinpointer(), ))
307
outfile.write(' Include="%s"' % (self.getInclude(), ))
308
if self.getNumberprotocol() is not None:
309
outfile.write(' NumberProtocol="%s"' % (self.getNumberprotocol(), ))
310
if self.getDelete() is not None:
311
outfile.write(' Delete="%s"' % (self.getDelete(), ))
312
def exportChildren(self, outfile, level, name_='PythonExport'):
313
if self.Documentation:
314
self.Documentation.export(outfile, level)
315
for Methode_ in self.getMethode():
316
Methode_.export(outfile, level)
317
for Attribute_ in self.getAttribute():
318
Attribute_.export(outfile, level)
319
showIndent(outfile, level)
320
outfile.write('<CustomAttributes>%s</CustomAttributes>\n' % quote_xml(self.getCustomattributes()))
321
showIndent(outfile, level)
322
outfile.write('<ClassDeclarations>%s</ClassDeclarations>\n' % quote_xml(self.getClassdeclarations()))
323
def exportLiteral(self, outfile, level, name_='PythonExport'):
325
self.exportLiteralAttributes(outfile, level, name_)
326
self.exportLiteralChildren(outfile, level, name_)
327
def exportLiteralAttributes(self, outfile, level, name_):
328
showIndent(outfile, level)
329
outfile.write('FatherNamespace = "%s",\n' % (self.getFathernamespace(),))
330
showIndent(outfile, level)
331
outfile.write('Name = "%s",\n' % (self.getName(),))
332
showIndent(outfile, level)
333
outfile.write('Reference = "%s",\n' % (self.getReference(),))
334
showIndent(outfile, level)
335
outfile.write('FatherInclude = "%s",\n' % (self.getFatherinclude(),))
336
showIndent(outfile, level)
337
outfile.write('Father = "%s",\n' % (self.getFather(),))
338
showIndent(outfile, level)
339
outfile.write('Namespace = "%s",\n' % (self.getNamespace(),))
340
showIndent(outfile, level)
341
outfile.write('Twin = "%s",\n' % (self.getTwin(),))
342
showIndent(outfile, level)
343
outfile.write('Constructor = "%s",\n' % (self.getConstructor(),))
344
showIndent(outfile, level)
345
outfile.write('TwinPointer = "%s",\n' % (self.getTwinpointer(),))
346
showIndent(outfile, level)
347
outfile.write('Include = "%s",\n' % (self.getInclude(),))
348
showIndent(outfile, level)
349
outfile.write('NumberProtocol = "%s",\n' % (self.getNumberprotocol(),))
350
showIndent(outfile, level)
351
outfile.write('Delete = "%s",\n' % (self.getDelete(),))
352
def exportLiteralChildren(self, outfile, level, name_):
353
if self.Documentation:
354
showIndent(outfile, level)
355
outfile.write('Documentation=Documentation(\n')
356
self.Documentation.exportLiteral(outfile, level)
357
showIndent(outfile, level)
358
outfile.write('),\n')
359
showIndent(outfile, level)
360
outfile.write('Methode=[\n')
362
for Methode in self.Methode:
363
showIndent(outfile, level)
364
outfile.write('Methode(\n')
365
Methode.exportLiteral(outfile, level)
366
showIndent(outfile, level)
367
outfile.write('),\n')
369
showIndent(outfile, level)
370
outfile.write('],\n')
371
showIndent(outfile, level)
372
outfile.write('Attribute=[\n')
374
for Attribute in self.Attribute:
375
showIndent(outfile, level)
376
outfile.write('Attribute(\n')
377
Attribute.exportLiteral(outfile, level)
378
showIndent(outfile, level)
379
outfile.write('),\n')
381
showIndent(outfile, level)
382
outfile.write('],\n')
383
showIndent(outfile, level)
384
outfile.write('CustomAttributes=%s,\n' % quote_python(self.getCustomattributes()))
385
showIndent(outfile, level)
386
outfile.write('ClassDeclarations=%s,\n' % quote_python(self.getClassdeclarations()))
387
def build(self, node_):
388
attrs = node_.attributes
389
self.buildAttributes(attrs)
390
for child_ in node_.childNodes:
391
nodeName_ = child_.nodeName.split(':')[-1]
392
self.buildChildren(child_, nodeName_)
393
def buildAttributes(self, attrs):
394
if attrs.get('FatherNamespace'):
395
self.FatherNamespace = attrs.get('FatherNamespace').value
396
if attrs.get('Name'):
397
self.Name = attrs.get('Name').value
398
if attrs.get('Reference'):
399
if attrs.get('Reference').value in ('true', '1'):
401
elif attrs.get('Reference').value in ('false', '0'):
404
raise ValueError('Bad boolean attribute (Reference)')
405
if attrs.get('FatherInclude'):
406
self.FatherInclude = attrs.get('FatherInclude').value
407
if attrs.get('Father'):
408
self.Father = attrs.get('Father').value
409
if attrs.get('Namespace'):
410
self.Namespace = attrs.get('Namespace').value
411
if attrs.get('Twin'):
412
self.Twin = attrs.get('Twin').value
413
if attrs.get('Constructor'):
414
if attrs.get('Constructor').value in ('true', '1'):
416
elif attrs.get('Constructor').value in ('false', '0'):
419
raise ValueError('Bad boolean attribute (Constructor)')
420
if attrs.get('TwinPointer'):
421
self.TwinPointer = attrs.get('TwinPointer').value
422
if attrs.get('Include'):
423
self.Include = attrs.get('Include').value
424
if attrs.get('NumberProtocol'):
425
if attrs.get('NumberProtocol').value in ('true', '1'):
426
self.NumberProtocol = 1
427
elif attrs.get('NumberProtocol').value in ('false', '0'):
428
self.NumberProtocol = 0
430
raise ValueError('Bad boolean attribute (NumberProtocol)')
431
if attrs.get('Delete'):
432
if attrs.get('Delete').value in ('true', '1'):
434
elif attrs.get('Delete').value in ('false', '0'):
437
raise ValueError('Bad boolean attribute (Delete)')
438
def buildChildren(self, child_, nodeName_):
439
if child_.nodeType == Node.ELEMENT_NODE and \
440
nodeName_ == 'Documentation':
441
obj_ = Documentation.factory()
443
self.setDocumentation(obj_)
444
elif child_.nodeType == Node.ELEMENT_NODE and \
445
nodeName_ == 'Methode':
446
obj_ = Methode.factory()
448
self.Methode.append(obj_)
449
elif child_.nodeType == Node.ELEMENT_NODE and \
450
nodeName_ == 'Attribute':
451
obj_ = Attribute.factory()
453
self.Attribute.append(obj_)
454
elif child_.nodeType == Node.ELEMENT_NODE and \
455
nodeName_ == 'CustomAttributes':
456
CustomAttributes_ = ''
457
for text__content_ in child_.childNodes:
458
CustomAttributes_ += text__content_.nodeValue
459
self.CustomAttributes = CustomAttributes_
460
elif child_.nodeType == Node.ELEMENT_NODE and \
461
nodeName_ == 'ClassDeclarations':
462
ClassDeclarations_ = ''
463
for text__content_ in child_.childNodes:
464
ClassDeclarations_ += text__content_.nodeValue
465
self.ClassDeclarations = ClassDeclarations_
466
# end class PythonExport
471
def __init__(self, Const=0, Name='', Documentation=None, Parameter=None):
474
self.Documentation = Documentation
475
if Parameter is None:
478
self.Parameter = Parameter
479
def factory(*args_, **kwargs_):
481
return Methode.subclass(*args_, **kwargs_)
483
return Methode(*args_, **kwargs_)
484
factory = staticmethod(factory)
485
def getDocumentation(self): return self.Documentation
486
def setDocumentation(self, Documentation): self.Documentation = Documentation
487
def getParameter(self): return self.Parameter
488
def setParameter(self, Parameter): self.Parameter = Parameter
489
def addParameter(self, value): self.Parameter.append(value)
490
def insertParameter(self, index, value): self.Parameter[index] = value
491
def getConst(self): return self.Const
492
def setConst(self, Const): self.Const = Const
493
def getName(self): return self.Name
494
def setName(self, Name): self.Name = Name
495
def export(self, outfile, level, name_='Methode'):
496
showIndent(outfile, level)
497
outfile.write('<%s' % (name_, ))
498
self.exportAttributes(outfile, level, name_='Methode')
500
self.exportChildren(outfile, level + 1, name_)
501
showIndent(outfile, level)
502
outfile.write('</%s>\n' % name_)
503
def exportAttributes(self, outfile, level, name_='Methode'):
504
if self.getConst() is not None:
505
outfile.write(' Const="%s"' % (self.getConst(), ))
506
outfile.write(' Name="%s"' % (self.getName(), ))
507
def exportChildren(self, outfile, level, name_='Methode'):
508
if self.Documentation:
509
self.Documentation.export(outfile, level)
510
for Parameter_ in self.getParameter():
511
Parameter_.export(outfile, level)
512
def exportLiteral(self, outfile, level, name_='Methode'):
514
self.exportLiteralAttributes(outfile, level, name_)
515
self.exportLiteralChildren(outfile, level, name_)
516
def exportLiteralAttributes(self, outfile, level, name_):
517
showIndent(outfile, level)
518
outfile.write('Const = "%s",\n' % (self.getConst(),))
519
showIndent(outfile, level)
520
outfile.write('Name = "%s",\n' % (self.getName(),))
521
def exportLiteralChildren(self, outfile, level, name_):
522
if self.Documentation:
523
showIndent(outfile, level)
524
outfile.write('Documentation=Documentation(\n')
525
self.Documentation.exportLiteral(outfile, level)
526
showIndent(outfile, level)
527
outfile.write('),\n')
528
showIndent(outfile, level)
529
outfile.write('Parameter=[\n')
531
for Parameter in self.Parameter:
532
showIndent(outfile, level)
533
outfile.write('Parameter(\n')
534
Parameter.exportLiteral(outfile, level)
535
showIndent(outfile, level)
536
outfile.write('),\n')
538
showIndent(outfile, level)
539
outfile.write('],\n')
540
def build(self, node_):
541
attrs = node_.attributes
542
self.buildAttributes(attrs)
543
for child_ in node_.childNodes:
544
nodeName_ = child_.nodeName.split(':')[-1]
545
self.buildChildren(child_, nodeName_)
546
def buildAttributes(self, attrs):
547
if attrs.get('Const'):
548
if attrs.get('Const').value in ('true', '1'):
550
elif attrs.get('Const').value in ('false', '0'):
553
raise ValueError('Bad boolean attribute (Const)')
554
if attrs.get('Name'):
555
self.Name = attrs.get('Name').value
556
def buildChildren(self, child_, nodeName_):
557
if child_.nodeType == Node.ELEMENT_NODE and \
558
nodeName_ == 'Documentation':
559
obj_ = Documentation.factory()
561
self.setDocumentation(obj_)
562
elif child_.nodeType == Node.ELEMENT_NODE and \
563
nodeName_ == 'Parameter':
564
obj_ = Parameter.factory()
566
self.Parameter.append(obj_)
572
def __init__(self, ReadOnly=0, Name='', Documentation=None, Parameter=None):
573
self.ReadOnly = ReadOnly
575
self.Documentation = Documentation
576
self.Parameter = Parameter
577
def factory(*args_, **kwargs_):
578
if Attribute.subclass:
579
return Attribute.subclass(*args_, **kwargs_)
581
return Attribute(*args_, **kwargs_)
582
factory = staticmethod(factory)
583
def getDocumentation(self): return self.Documentation
584
def setDocumentation(self, Documentation): self.Documentation = Documentation
585
def getParameter(self): return self.Parameter
586
def setParameter(self, Parameter): self.Parameter = Parameter
587
def getReadonly(self): return self.ReadOnly
588
def setReadonly(self, ReadOnly): self.ReadOnly = ReadOnly
589
def getName(self): return self.Name
590
def setName(self, Name): self.Name = Name
591
def export(self, outfile, level, name_='Attribute'):
592
showIndent(outfile, level)
593
outfile.write('<%s' % (name_, ))
594
self.exportAttributes(outfile, level, name_='Attribute')
596
self.exportChildren(outfile, level + 1, name_)
597
showIndent(outfile, level)
598
outfile.write('</%s>\n' % name_)
599
def exportAttributes(self, outfile, level, name_='Attribute'):
600
outfile.write(' ReadOnly="%s"' % (self.getReadonly(), ))
601
outfile.write(' Name="%s"' % (self.getName(), ))
602
def exportChildren(self, outfile, level, name_='Attribute'):
603
if self.Documentation:
604
self.Documentation.export(outfile, level)
606
self.Parameter.export(outfile, level)
607
def exportLiteral(self, outfile, level, name_='Attribute'):
609
self.exportLiteralAttributes(outfile, level, name_)
610
self.exportLiteralChildren(outfile, level, name_)
611
def exportLiteralAttributes(self, outfile, level, name_):
612
showIndent(outfile, level)
613
outfile.write('ReadOnly = "%s",\n' % (self.getReadonly(),))
614
showIndent(outfile, level)
615
outfile.write('Name = "%s",\n' % (self.getName(),))
616
def exportLiteralChildren(self, outfile, level, name_):
617
if self.Documentation:
618
showIndent(outfile, level)
619
outfile.write('Documentation=Documentation(\n')
620
self.Documentation.exportLiteral(outfile, level)
621
showIndent(outfile, level)
622
outfile.write('),\n')
624
showIndent(outfile, level)
625
outfile.write('Parameter=Parameter(\n')
626
self.Parameter.exportLiteral(outfile, level)
627
showIndent(outfile, level)
628
outfile.write('),\n')
629
def build(self, node_):
630
attrs = node_.attributes
631
self.buildAttributes(attrs)
632
for child_ in node_.childNodes:
633
nodeName_ = child_.nodeName.split(':')[-1]
634
self.buildChildren(child_, nodeName_)
635
def buildAttributes(self, attrs):
636
if attrs.get('ReadOnly'):
637
if attrs.get('ReadOnly').value in ('true', '1'):
639
elif attrs.get('ReadOnly').value in ('false', '0'):
642
raise ValueError('Bad boolean attribute (ReadOnly)')
643
if attrs.get('Name'):
644
self.Name = attrs.get('Name').value
645
def buildChildren(self, child_, nodeName_):
646
if child_.nodeType == Node.ELEMENT_NODE and \
647
nodeName_ == 'Documentation':
648
obj_ = Documentation.factory()
650
self.setDocumentation(obj_)
651
elif child_.nodeType == Node.ELEMENT_NODE and \
652
nodeName_ == 'Parameter':
653
obj_ = Parameter.factory()
655
self.setParameter(obj_)
656
# end class Attribute
661
def __init__(self, Name='', Documentation=None, Dependencies=None, Content=None):
663
self.Documentation = Documentation
664
self.Dependencies = Dependencies
665
self.Content = Content
666
def factory(*args_, **kwargs_):
668
return Module.subclass(*args_, **kwargs_)
670
return Module(*args_, **kwargs_)
671
factory = staticmethod(factory)
672
def getDocumentation(self): return self.Documentation
673
def setDocumentation(self, Documentation): self.Documentation = Documentation
674
def getDependencies(self): return self.Dependencies
675
def setDependencies(self, Dependencies): self.Dependencies = Dependencies
676
def getContent(self): return self.Content
677
def setContent(self, Content): self.Content = Content
678
def getName(self): return self.Name
679
def setName(self, Name): self.Name = Name
680
def export(self, outfile, level, name_='Module'):
681
showIndent(outfile, level)
682
outfile.write('<%s' % (name_, ))
683
self.exportAttributes(outfile, level, name_='Module')
685
self.exportChildren(outfile, level + 1, name_)
686
showIndent(outfile, level)
687
outfile.write('</%s>\n' % name_)
688
def exportAttributes(self, outfile, level, name_='Module'):
689
outfile.write(' Name="%s"' % (self.getName(), ))
690
def exportChildren(self, outfile, level, name_='Module'):
691
if self.Documentation:
692
self.Documentation.export(outfile, level)
693
if self.Dependencies:
694
self.Dependencies.export(outfile, level)
696
self.Content.export(outfile, level)
697
def exportLiteral(self, outfile, level, name_='Module'):
699
self.exportLiteralAttributes(outfile, level, name_)
700
self.exportLiteralChildren(outfile, level, name_)
701
def exportLiteralAttributes(self, outfile, level, name_):
702
showIndent(outfile, level)
703
outfile.write('Name = "%s",\n' % (self.getName(),))
704
def exportLiteralChildren(self, outfile, level, name_):
705
if self.Documentation:
706
showIndent(outfile, level)
707
outfile.write('Documentation=Documentation(\n')
708
self.Documentation.exportLiteral(outfile, level)
709
showIndent(outfile, level)
710
outfile.write('),\n')
711
if self.Dependencies:
712
showIndent(outfile, level)
713
outfile.write('Dependencies=Dependencies(\n')
714
self.Dependencies.exportLiteral(outfile, level)
715
showIndent(outfile, level)
716
outfile.write('),\n')
718
showIndent(outfile, level)
719
outfile.write('Content=Content(\n')
720
self.Content.exportLiteral(outfile, level)
721
showIndent(outfile, level)
722
outfile.write('),\n')
723
def build(self, node_):
724
attrs = node_.attributes
725
self.buildAttributes(attrs)
726
for child_ in node_.childNodes:
727
nodeName_ = child_.nodeName.split(':')[-1]
728
self.buildChildren(child_, nodeName_)
729
def buildAttributes(self, attrs):
730
if attrs.get('Name'):
731
self.Name = attrs.get('Name').value
732
def buildChildren(self, child_, nodeName_):
733
if child_.nodeType == Node.ELEMENT_NODE and \
734
nodeName_ == 'Documentation':
735
obj_ = Documentation.factory()
737
self.setDocumentation(obj_)
738
elif child_.nodeType == Node.ELEMENT_NODE and \
739
nodeName_ == 'Dependencies':
740
obj_ = Dependencies.factory()
742
self.setDependencies(obj_)
743
elif child_.nodeType == Node.ELEMENT_NODE and \
744
nodeName_ == 'Content':
745
obj_ = Content.factory()
747
self.setContent(obj_)
753
def __init__(self, Module=None):
758
def factory(*args_, **kwargs_):
759
if Dependencies.subclass:
760
return Dependencies.subclass(*args_, **kwargs_)
762
return Dependencies(*args_, **kwargs_)
763
factory = staticmethod(factory)
764
def getModule(self): return self.Module
765
def setModule(self, Module): self.Module = Module
766
def addModule(self, value): self.Module.append(value)
767
def insertModule(self, index, value): self.Module[index] = value
768
def export(self, outfile, level, name_='Dependencies'):
769
showIndent(outfile, level)
770
outfile.write('<%s>\n' % name_)
771
self.exportChildren(outfile, level + 1, name_)
772
showIndent(outfile, level)
773
outfile.write('</%s>\n' % name_)
774
def exportAttributes(self, outfile, level, name_='Dependencies'):
776
def exportChildren(self, outfile, level, name_='Dependencies'):
777
for Module_ in self.getModule():
778
Module_.export(outfile, level)
779
def exportLiteral(self, outfile, level, name_='Dependencies'):
781
self.exportLiteralAttributes(outfile, level, name_)
782
self.exportLiteralChildren(outfile, level, name_)
783
def exportLiteralAttributes(self, outfile, level, name_):
785
def exportLiteralChildren(self, outfile, level, name_):
786
showIndent(outfile, level)
787
outfile.write('Module=[\n')
789
for Module in self.Module:
790
showIndent(outfile, level)
791
outfile.write('Module(\n')
792
Module.exportLiteral(outfile, level)
793
showIndent(outfile, level)
794
outfile.write('),\n')
796
showIndent(outfile, level)
797
outfile.write('],\n')
798
def build(self, node_):
799
attrs = node_.attributes
800
self.buildAttributes(attrs)
801
for child_ in node_.childNodes:
802
nodeName_ = child_.nodeName.split(':')[-1]
803
self.buildChildren(child_, nodeName_)
804
def buildAttributes(self, attrs):
806
def buildChildren(self, child_, nodeName_):
807
if child_.nodeType == Node.ELEMENT_NODE and \
808
nodeName_ == 'Module':
809
obj_ = Module.factory()
811
self.Module.append(obj_)
812
# end class Dependencies
817
def __init__(self, Property=None, Feature=None, DocObject=None, GuiCommand=None, PreferencesPage=None):
821
self.Property = Property
825
self.Feature = Feature
826
if DocObject is None:
829
self.DocObject = DocObject
830
if GuiCommand is None:
833
self.GuiCommand = GuiCommand
834
if PreferencesPage is None:
835
self.PreferencesPage = []
837
self.PreferencesPage = PreferencesPage
838
def factory(*args_, **kwargs_):
840
return Content.subclass(*args_, **kwargs_)
842
return Content(*args_, **kwargs_)
843
factory = staticmethod(factory)
844
def getProperty(self): return self.Property
845
def setProperty(self, Property): self.Property = Property
846
def addProperty(self, value): self.Property.append(value)
847
def insertProperty(self, index, value): self.Property[index] = value
848
def getFeature(self): return self.Feature
849
def setFeature(self, Feature): self.Feature = Feature
850
def addFeature(self, value): self.Feature.append(value)
851
def insertFeature(self, index, value): self.Feature[index] = value
852
def getDocobject(self): return self.DocObject
853
def setDocobject(self, DocObject): self.DocObject = DocObject
854
def addDocobject(self, value): self.DocObject.append(value)
855
def insertDocobject(self, index, value): self.DocObject[index] = value
856
def getGuicommand(self): return self.GuiCommand
857
def setGuicommand(self, GuiCommand): self.GuiCommand = GuiCommand
858
def addGuicommand(self, value): self.GuiCommand.append(value)
859
def insertGuicommand(self, index, value): self.GuiCommand[index] = value
860
def getPreferencespage(self): return self.PreferencesPage
861
def setPreferencespage(self, PreferencesPage): self.PreferencesPage = PreferencesPage
862
def addPreferencespage(self, value): self.PreferencesPage.append(value)
863
def insertPreferencespage(self, index, value): self.PreferencesPage[index] = value
864
def export(self, outfile, level, name_='Content'):
865
showIndent(outfile, level)
866
outfile.write('<%s>\n' % name_)
867
self.exportChildren(outfile, level + 1, name_)
868
showIndent(outfile, level)
869
outfile.write('</%s>\n' % name_)
870
def exportAttributes(self, outfile, level, name_='Content'):
872
def exportChildren(self, outfile, level, name_='Content'):
873
for Property_ in self.getProperty():
874
Property_.export(outfile, level)
875
for Feature_ in self.getFeature():
876
Feature_.export(outfile, level)
877
for DocObject_ in self.getDocobject():
878
DocObject_.export(outfile, level)
879
for GuiCommand_ in self.getGuicommand():
880
showIndent(outfile, level)
881
outfile.write('<GuiCommand>%s</GuiCommand>\n' % quote_xml(GuiCommand_))
882
for PreferencesPage_ in self.getPreferencespage():
883
showIndent(outfile, level)
884
outfile.write('<PreferencesPage>%s</PreferencesPage>\n' % quote_xml(PreferencesPage_))
885
def exportLiteral(self, outfile, level, name_='Content'):
887
self.exportLiteralAttributes(outfile, level, name_)
888
self.exportLiteralChildren(outfile, level, name_)
889
def exportLiteralAttributes(self, outfile, level, name_):
891
def exportLiteralChildren(self, outfile, level, name_):
892
showIndent(outfile, level)
893
outfile.write('Property=[\n')
895
for Property in self.Property:
896
showIndent(outfile, level)
897
outfile.write('Property(\n')
898
Property.exportLiteral(outfile, level)
899
showIndent(outfile, level)
900
outfile.write('),\n')
902
showIndent(outfile, level)
903
outfile.write('],\n')
904
showIndent(outfile, level)
905
outfile.write('Feature=[\n')
907
for Feature in self.Feature:
908
showIndent(outfile, level)
909
outfile.write('Feature(\n')
910
Feature.exportLiteral(outfile, level)
911
showIndent(outfile, level)
912
outfile.write('),\n')
914
showIndent(outfile, level)
915
outfile.write('],\n')
916
showIndent(outfile, level)
917
outfile.write('DocObject=[\n')
919
for DocObject in self.DocObject:
920
showIndent(outfile, level)
921
outfile.write('DocObject(\n')
922
DocObject.exportLiteral(outfile, level)
923
showIndent(outfile, level)
924
outfile.write('),\n')
926
showIndent(outfile, level)
927
outfile.write('],\n')
928
showIndent(outfile, level)
929
outfile.write('GuiCommand=[\n')
931
for GuiCommand in self.GuiCommand:
932
showIndent(outfile, level)
933
outfile.write('%s,\n' % quote_python(GuiCommand))
935
showIndent(outfile, level)
936
outfile.write('],\n')
937
showIndent(outfile, level)
938
outfile.write('PreferencesPage=[\n')
940
for PreferencesPage in self.PreferencesPage:
941
showIndent(outfile, level)
942
outfile.write('%s,\n' % quote_python(PreferencesPage))
944
showIndent(outfile, level)
945
outfile.write('],\n')
946
def build(self, node_):
947
attrs = node_.attributes
948
self.buildAttributes(attrs)
949
for child_ in node_.childNodes:
950
nodeName_ = child_.nodeName.split(':')[-1]
951
self.buildChildren(child_, nodeName_)
952
def buildAttributes(self, attrs):
954
def buildChildren(self, child_, nodeName_):
955
if child_.nodeType == Node.ELEMENT_NODE and \
956
nodeName_ == 'Property':
957
obj_ = Property.factory()
959
self.Property.append(obj_)
960
elif child_.nodeType == Node.ELEMENT_NODE and \
961
nodeName_ == 'Feature':
962
obj_ = Feature.factory()
964
self.Feature.append(obj_)
965
elif child_.nodeType == Node.ELEMENT_NODE and \
966
nodeName_ == 'DocObject':
967
obj_ = DocObject.factory()
969
self.DocObject.append(obj_)
970
elif child_.nodeType == Node.ELEMENT_NODE and \
971
nodeName_ == 'GuiCommand':
973
for text__content_ in child_.childNodes:
974
GuiCommand_ += text__content_.nodeValue
975
self.GuiCommand.append(GuiCommand_)
976
elif child_.nodeType == Node.ELEMENT_NODE and \
977
nodeName_ == 'PreferencesPage':
978
PreferencesPage_ = ''
979
for text__content_ in child_.childNodes:
980
PreferencesPage_ += text__content_.nodeValue
981
self.PreferencesPage.append(PreferencesPage_)
987
def __init__(self, Name='', Documentation=None, Property=None, ViewProvider=None):
989
self.Documentation = Documentation
993
self.Property = Property
994
self.ViewProvider = ViewProvider
995
def factory(*args_, **kwargs_):
997
return Feature.subclass(*args_, **kwargs_)
999
return Feature(*args_, **kwargs_)
1000
factory = staticmethod(factory)
1001
def getDocumentation(self): return self.Documentation
1002
def setDocumentation(self, Documentation): self.Documentation = Documentation
1003
def getProperty(self): return self.Property
1004
def setProperty(self, Property): self.Property = Property
1005
def addProperty(self, value): self.Property.append(value)
1006
def insertProperty(self, index, value): self.Property[index] = value
1007
def getViewprovider(self): return self.ViewProvider
1008
def setViewprovider(self, ViewProvider): self.ViewProvider = ViewProvider
1009
def getName(self): return self.Name
1010
def setName(self, Name): self.Name = Name
1011
def export(self, outfile, level, name_='Feature'):
1012
showIndent(outfile, level)
1013
outfile.write('<%s' % (name_, ))
1014
self.exportAttributes(outfile, level, name_='Feature')
1015
outfile.write('>\n')
1016
self.exportChildren(outfile, level + 1, name_)
1017
showIndent(outfile, level)
1018
outfile.write('</%s>\n' % name_)
1019
def exportAttributes(self, outfile, level, name_='Feature'):
1020
outfile.write(' Name="%s"' % (self.getName(), ))
1021
def exportChildren(self, outfile, level, name_='Feature'):
1022
if self.Documentation:
1023
self.Documentation.export(outfile, level)
1024
for Property_ in self.getProperty():
1025
Property_.export(outfile, level)
1026
if self.ViewProvider:
1027
self.ViewProvider.export(outfile, level)
1028
def exportLiteral(self, outfile, level, name_='Feature'):
1030
self.exportLiteralAttributes(outfile, level, name_)
1031
self.exportLiteralChildren(outfile, level, name_)
1032
def exportLiteralAttributes(self, outfile, level, name_):
1033
showIndent(outfile, level)
1034
outfile.write('Name = "%s",\n' % (self.getName(),))
1035
def exportLiteralChildren(self, outfile, level, name_):
1036
if self.Documentation:
1037
showIndent(outfile, level)
1038
outfile.write('Documentation=Documentation(\n')
1039
self.Documentation.exportLiteral(outfile, level)
1040
showIndent(outfile, level)
1041
outfile.write('),\n')
1042
showIndent(outfile, level)
1043
outfile.write('Property=[\n')
1045
for Property in self.Property:
1046
showIndent(outfile, level)
1047
outfile.write('Property(\n')
1048
Property.exportLiteral(outfile, level)
1049
showIndent(outfile, level)
1050
outfile.write('),\n')
1052
showIndent(outfile, level)
1053
outfile.write('],\n')
1054
if self.ViewProvider:
1055
showIndent(outfile, level)
1056
outfile.write('ViewProvider=ViewProvider(\n')
1057
self.ViewProvider.exportLiteral(outfile, level)
1058
showIndent(outfile, level)
1059
outfile.write('),\n')
1060
def build(self, node_):
1061
attrs = node_.attributes
1062
self.buildAttributes(attrs)
1063
for child_ in node_.childNodes:
1064
nodeName_ = child_.nodeName.split(':')[-1]
1065
self.buildChildren(child_, nodeName_)
1066
def buildAttributes(self, attrs):
1067
if attrs.get('Name'):
1068
self.Name = attrs.get('Name').value
1069
def buildChildren(self, child_, nodeName_):
1070
if child_.nodeType == Node.ELEMENT_NODE and \
1071
nodeName_ == 'Documentation':
1072
obj_ = Documentation.factory()
1074
self.setDocumentation(obj_)
1075
elif child_.nodeType == Node.ELEMENT_NODE and \
1076
nodeName_ == 'Property':
1077
obj_ = Property.factory()
1079
self.Property.append(obj_)
1080
elif child_.nodeType == Node.ELEMENT_NODE and \
1081
nodeName_ == 'ViewProvider':
1082
obj_ = ViewProvider.factory()
1084
self.setViewprovider(obj_)
1090
def __init__(self, Name='', Documentation=None, Property=None):
1092
self.Documentation = Documentation
1093
if Property is None:
1096
self.Property = Property
1097
def factory(*args_, **kwargs_):
1098
if DocObject.subclass:
1099
return DocObject.subclass(*args_, **kwargs_)
1101
return DocObject(*args_, **kwargs_)
1102
factory = staticmethod(factory)
1103
def getDocumentation(self): return self.Documentation
1104
def setDocumentation(self, Documentation): self.Documentation = Documentation
1105
def getProperty(self): return self.Property
1106
def setProperty(self, Property): self.Property = Property
1107
def addProperty(self, value): self.Property.append(value)
1108
def insertProperty(self, index, value): self.Property[index] = value
1109
def getName(self): return self.Name
1110
def setName(self, Name): self.Name = Name
1111
def export(self, outfile, level, name_='DocObject'):
1112
showIndent(outfile, level)
1113
outfile.write('<%s' % (name_, ))
1114
self.exportAttributes(outfile, level, name_='DocObject')
1115
outfile.write('>\n')
1116
self.exportChildren(outfile, level + 1, name_)
1117
showIndent(outfile, level)
1118
outfile.write('</%s>\n' % name_)
1119
def exportAttributes(self, outfile, level, name_='DocObject'):
1120
outfile.write(' Name="%s"' % (self.getName(), ))
1121
def exportChildren(self, outfile, level, name_='DocObject'):
1122
if self.Documentation:
1123
self.Documentation.export(outfile, level)
1124
for Property_ in self.getProperty():
1125
Property_.export(outfile, level)
1126
def exportLiteral(self, outfile, level, name_='DocObject'):
1128
self.exportLiteralAttributes(outfile, level, name_)
1129
self.exportLiteralChildren(outfile, level, name_)
1130
def exportLiteralAttributes(self, outfile, level, name_):
1131
showIndent(outfile, level)
1132
outfile.write('Name = "%s",\n' % (self.getName(),))
1133
def exportLiteralChildren(self, outfile, level, name_):
1134
if self.Documentation:
1135
showIndent(outfile, level)
1136
outfile.write('Documentation=Documentation(\n')
1137
self.Documentation.exportLiteral(outfile, level)
1138
showIndent(outfile, level)
1139
outfile.write('),\n')
1140
showIndent(outfile, level)
1141
outfile.write('Property=[\n')
1143
for Property in self.Property:
1144
showIndent(outfile, level)
1145
outfile.write('Property(\n')
1146
Property.exportLiteral(outfile, level)
1147
showIndent(outfile, level)
1148
outfile.write('),\n')
1150
showIndent(outfile, level)
1151
outfile.write('],\n')
1152
def build(self, node_):
1153
attrs = node_.attributes
1154
self.buildAttributes(attrs)
1155
for child_ in node_.childNodes:
1156
nodeName_ = child_.nodeName.split(':')[-1]
1157
self.buildChildren(child_, nodeName_)
1158
def buildAttributes(self, attrs):
1159
if attrs.get('Name'):
1160
self.Name = attrs.get('Name').value
1161
def buildChildren(self, child_, nodeName_):
1162
if child_.nodeType == Node.ELEMENT_NODE and \
1163
nodeName_ == 'Documentation':
1164
obj_ = Documentation.factory()
1166
self.setDocumentation(obj_)
1167
elif child_.nodeType == Node.ELEMENT_NODE and \
1168
nodeName_ == 'Property':
1169
obj_ = Property.factory()
1171
self.Property.append(obj_)
1172
# end class DocObject
1177
def __init__(self, Type='', Name='', StartValue='', Documentation=None):
1180
self.StartValue = StartValue
1181
self.Documentation = Documentation
1182
def factory(*args_, **kwargs_):
1183
if Property.subclass:
1184
return Property.subclass(*args_, **kwargs_)
1186
return Property(*args_, **kwargs_)
1187
factory = staticmethod(factory)
1188
def getDocumentation(self): return self.Documentation
1189
def setDocumentation(self, Documentation): self.Documentation = Documentation
1190
def getType(self): return self.Type
1191
def setType(self, Type): self.Type = Type
1192
def getName(self): return self.Name
1193
def setName(self, Name): self.Name = Name
1194
def getStartvalue(self): return self.StartValue
1195
def setStartvalue(self, StartValue): self.StartValue = StartValue
1196
def export(self, outfile, level, name_='Property'):
1197
showIndent(outfile, level)
1198
outfile.write('<%s' % (name_, ))
1199
self.exportAttributes(outfile, level, name_='Property')
1200
outfile.write('>\n')
1201
self.exportChildren(outfile, level + 1, name_)
1202
showIndent(outfile, level)
1203
outfile.write('</%s>\n' % name_)
1204
def exportAttributes(self, outfile, level, name_='Property'):
1205
outfile.write(' Type="%s"' % (self.getType(), ))
1206
outfile.write(' Name="%s"' % (self.getName(), ))
1207
if self.getStartvalue() is not None:
1208
outfile.write(' StartValue="%s"' % (self.getStartvalue(), ))
1209
def exportChildren(self, outfile, level, name_='Property'):
1210
if self.Documentation:
1211
self.Documentation.export(outfile, level)
1212
def exportLiteral(self, outfile, level, name_='Property'):
1214
self.exportLiteralAttributes(outfile, level, name_)
1215
self.exportLiteralChildren(outfile, level, name_)
1216
def exportLiteralAttributes(self, outfile, level, name_):
1217
showIndent(outfile, level)
1218
outfile.write('Type = "%s",\n' % (self.getType(),))
1219
showIndent(outfile, level)
1220
outfile.write('Name = "%s",\n' % (self.getName(),))
1221
showIndent(outfile, level)
1222
outfile.write('StartValue = "%s",\n' % (self.getStartvalue(),))
1223
def exportLiteralChildren(self, outfile, level, name_):
1224
if self.Documentation:
1225
showIndent(outfile, level)
1226
outfile.write('Documentation=Documentation(\n')
1227
self.Documentation.exportLiteral(outfile, level)
1228
showIndent(outfile, level)
1229
outfile.write('),\n')
1230
def build(self, node_):
1231
attrs = node_.attributes
1232
self.buildAttributes(attrs)
1233
for child_ in node_.childNodes:
1234
nodeName_ = child_.nodeName.split(':')[-1]
1235
self.buildChildren(child_, nodeName_)
1236
def buildAttributes(self, attrs):
1237
if attrs.get('Type'):
1238
self.Type = attrs.get('Type').value
1239
if attrs.get('Name'):
1240
self.Name = attrs.get('Name').value
1241
if attrs.get('StartValue'):
1242
self.StartValue = attrs.get('StartValue').value
1243
def buildChildren(self, child_, nodeName_):
1244
if child_.nodeType == Node.ELEMENT_NODE and \
1245
nodeName_ == 'Documentation':
1246
obj_ = Documentation.factory()
1248
self.setDocumentation(obj_)
1249
# end class Property
1252
class Documentation:
1254
def __init__(self, Author=None, DeveloperDocu='', UserDocu=''):
1255
self.Author = Author
1256
self.DeveloperDocu = DeveloperDocu
1257
self.UserDocu = UserDocu
1258
def factory(*args_, **kwargs_):
1259
if Documentation.subclass:
1260
return Documentation.subclass(*args_, **kwargs_)
1262
return Documentation(*args_, **kwargs_)
1263
factory = staticmethod(factory)
1264
def getAuthor(self): return self.Author
1265
def setAuthor(self, Author): self.Author = Author
1266
def getDeveloperdocu(self): return self.DeveloperDocu
1267
def setDeveloperdocu(self, DeveloperDocu): self.DeveloperDocu = DeveloperDocu
1268
def getUserdocu(self): return self.UserDocu
1269
def setUserdocu(self, UserDocu): self.UserDocu = UserDocu
1270
def export(self, outfile, level, name_='Documentation'):
1271
showIndent(outfile, level)
1272
outfile.write('<%s>\n' % name_)
1273
self.exportChildren(outfile, level + 1, name_)
1274
showIndent(outfile, level)
1275
outfile.write('</%s>\n' % name_)
1276
def exportAttributes(self, outfile, level, name_='Documentation'):
1278
def exportChildren(self, outfile, level, name_='Documentation'):
1280
self.Author.export(outfile, level)
1281
showIndent(outfile, level)
1282
outfile.write('<DeveloperDocu>%s</DeveloperDocu>\n' % quote_xml(self.getDeveloperdocu()))
1283
showIndent(outfile, level)
1284
outfile.write('<UserDocu>%s</UserDocu>\n' % quote_xml(self.getUserdocu()))
1285
def exportLiteral(self, outfile, level, name_='Documentation'):
1287
self.exportLiteralAttributes(outfile, level, name_)
1288
self.exportLiteralChildren(outfile, level, name_)
1289
def exportLiteralAttributes(self, outfile, level, name_):
1291
def exportLiteralChildren(self, outfile, level, name_):
1293
showIndent(outfile, level)
1294
outfile.write('Author=Author(\n')
1295
self.Author.exportLiteral(outfile, level)
1296
showIndent(outfile, level)
1297
outfile.write('),\n')
1298
showIndent(outfile, level)
1299
outfile.write('DeveloperDocu=%s,\n' % quote_python(self.getDeveloperdocu()))
1300
showIndent(outfile, level)
1301
outfile.write('UserDocu=%s,\n' % quote_python(self.getUserdocu()))
1302
def build(self, node_):
1303
attrs = node_.attributes
1304
self.buildAttributes(attrs)
1305
for child_ in node_.childNodes:
1306
nodeName_ = child_.nodeName.split(':')[-1]
1307
self.buildChildren(child_, nodeName_)
1308
def buildAttributes(self, attrs):
1310
def buildChildren(self, child_, nodeName_):
1311
if child_.nodeType == Node.ELEMENT_NODE and \
1312
nodeName_ == 'Author':
1313
obj_ = Author.factory()
1315
self.setAuthor(obj_)
1316
elif child_.nodeType == Node.ELEMENT_NODE and \
1317
nodeName_ == 'DeveloperDocu':
1319
for text__content_ in child_.childNodes:
1320
DeveloperDocu_ += text__content_.nodeValue
1321
self.DeveloperDocu = DeveloperDocu_
1322
elif child_.nodeType == Node.ELEMENT_NODE and \
1323
nodeName_ == 'UserDocu':
1325
for text__content_ in child_.childNodes:
1326
UserDocu_ += text__content_.nodeValue
1327
self.UserDocu = UserDocu_
1328
# end class Documentation
1333
def __init__(self, Name='', Licence='', EMail='', valueOf_=''):
1335
self.Licence = Licence
1337
self.valueOf_ = valueOf_
1338
def factory(*args_, **kwargs_):
1340
return Author.subclass(*args_, **kwargs_)
1342
return Author(*args_, **kwargs_)
1343
factory = staticmethod(factory)
1344
def getName(self): return self.Name
1345
def setName(self, Name): self.Name = Name
1346
def getLicence(self): return self.Licence
1347
def setLicence(self, Licence): self.Licence = Licence
1348
def getEmail(self): return self.EMail
1349
def setEmail(self, EMail): self.EMail = EMail
1350
def getValueOf_(self): return self.valueOf_
1351
def setValueOf_(self, valueOf_): self.valueOf_ = valueOf_
1352
def export(self, outfile, level, name_='Author'):
1353
showIndent(outfile, level)
1354
outfile.write('<%s' % (name_, ))
1355
self.exportAttributes(outfile, level, name_='Author')
1356
outfile.write('>\n')
1357
self.exportChildren(outfile, level + 1, name_)
1358
showIndent(outfile, level)
1359
outfile.write('</%s>\n' % name_)
1360
def exportAttributes(self, outfile, level, name_='Author'):
1361
outfile.write(' Name="%s"' % (self.getName(), ))
1362
if self.getLicence() is not None:
1363
outfile.write(' Licence="%s"' % (self.getLicence(), ))
1364
outfile.write(' EMail="%s"' % (self.getEmail(), ))
1365
def exportChildren(self, outfile, level, name_='Author'):
1366
outfile.write(self.valueOf_)
1367
def exportLiteral(self, outfile, level, name_='Author'):
1369
self.exportLiteralAttributes(outfile, level, name_)
1370
self.exportLiteralChildren(outfile, level, name_)
1371
def exportLiteralAttributes(self, outfile, level, name_):
1372
showIndent(outfile, level)
1373
outfile.write('Name = "%s",\n' % (self.getName(),))
1374
showIndent(outfile, level)
1375
outfile.write('Licence = "%s",\n' % (self.getLicence(),))
1376
showIndent(outfile, level)
1377
outfile.write('EMail = "%s",\n' % (self.getEmail(),))
1378
def exportLiteralChildren(self, outfile, level, name_):
1379
showIndent(outfile, level)
1380
outfile.write('valueOf_ = "%s",\n' % (self.valueOf_,))
1381
def build(self, node_):
1382
attrs = node_.attributes
1383
self.buildAttributes(attrs)
1384
for child_ in node_.childNodes:
1385
nodeName_ = child_.nodeName.split(':')[-1]
1386
self.buildChildren(child_, nodeName_)
1387
def buildAttributes(self, attrs):
1388
if attrs.get('Name'):
1389
self.Name = attrs.get('Name').value
1390
if attrs.get('Licence'):
1391
self.Licence = attrs.get('Licence').value
1392
if attrs.get('EMail'):
1393
self.EMail = attrs.get('EMail').value
1394
def buildChildren(self, child_, nodeName_):
1396
for child in child_.childNodes:
1397
if child.nodeType == Node.TEXT_NODE:
1398
self.valueOf_ += child.nodeValue
1404
def __init__(self, Property=None):
1405
if Property is None:
1408
self.Property = Property
1409
def factory(*args_, **kwargs_):
1410
if ViewProvider.subclass:
1411
return ViewProvider.subclass(*args_, **kwargs_)
1413
return ViewProvider(*args_, **kwargs_)
1414
factory = staticmethod(factory)
1415
def getProperty(self): return self.Property
1416
def setProperty(self, Property): self.Property = Property
1417
def addProperty(self, value): self.Property.append(value)
1418
def insertProperty(self, index, value): self.Property[index] = value
1419
def export(self, outfile, level, name_='ViewProvider'):
1420
showIndent(outfile, level)
1421
outfile.write('<%s>\n' % name_)
1422
self.exportChildren(outfile, level + 1, name_)
1423
showIndent(outfile, level)
1424
outfile.write('</%s>\n' % name_)
1425
def exportAttributes(self, outfile, level, name_='ViewProvider'):
1427
def exportChildren(self, outfile, level, name_='ViewProvider'):
1428
for Property_ in self.getProperty():
1429
Property_.export(outfile, level)
1430
def exportLiteral(self, outfile, level, name_='ViewProvider'):
1432
self.exportLiteralAttributes(outfile, level, name_)
1433
self.exportLiteralChildren(outfile, level, name_)
1434
def exportLiteralAttributes(self, outfile, level, name_):
1436
def exportLiteralChildren(self, outfile, level, name_):
1437
showIndent(outfile, level)
1438
outfile.write('Property=[\n')
1440
for Property in self.Property:
1441
showIndent(outfile, level)
1442
outfile.write('Property(\n')
1443
Property.exportLiteral(outfile, level)
1444
showIndent(outfile, level)
1445
outfile.write('),\n')
1447
showIndent(outfile, level)
1448
outfile.write('],\n')
1449
def build(self, node_):
1450
attrs = node_.attributes
1451
self.buildAttributes(attrs)
1452
for child_ in node_.childNodes:
1453
nodeName_ = child_.nodeName.split(':')[-1]
1454
self.buildChildren(child_, nodeName_)
1455
def buildAttributes(self, attrs):
1457
def buildChildren(self, child_, nodeName_):
1458
if child_.nodeType == Node.ELEMENT_NODE and \
1459
nodeName_ == 'Property':
1460
obj_ = Property.factory()
1462
self.Property.append(obj_)
1463
# end class ViewProvider
1468
def __init__(self, Type='', Name='', valueOf_=''):
1471
self.valueOf_ = valueOf_
1472
def factory(*args_, **kwargs_):
1473
if Parameter.subclass:
1474
return Parameter.subclass(*args_, **kwargs_)
1476
return Parameter(*args_, **kwargs_)
1477
factory = staticmethod(factory)
1478
def getType(self): return self.Type
1479
def setType(self, Type): self.Type = Type
1480
def getName(self): return self.Name
1481
def setName(self, Name): self.Name = Name
1482
def getValueOf_(self): return self.valueOf_
1483
def setValueOf_(self, valueOf_): self.valueOf_ = valueOf_
1484
def export(self, outfile, level, name_='Parameter'):
1485
showIndent(outfile, level)
1486
outfile.write('<%s' % (name_, ))
1487
self.exportAttributes(outfile, level, name_='Parameter')
1488
outfile.write('>\n')
1489
self.exportChildren(outfile, level + 1, name_)
1490
showIndent(outfile, level)
1491
outfile.write('</%s>\n' % name_)
1492
def exportAttributes(self, outfile, level, name_='Parameter'):
1493
outfile.write(' Type="%s"' % (self.getType(), ))
1494
outfile.write(' Name="%s"' % (self.getName(), ))
1495
def exportChildren(self, outfile, level, name_='Parameter'):
1496
outfile.write(self.valueOf_)
1497
def exportLiteral(self, outfile, level, name_='Parameter'):
1499
self.exportLiteralAttributes(outfile, level, name_)
1500
self.exportLiteralChildren(outfile, level, name_)
1501
def exportLiteralAttributes(self, outfile, level, name_):
1502
showIndent(outfile, level)
1503
outfile.write('Type = "%s",\n' % (self.getType(),))
1504
showIndent(outfile, level)
1505
outfile.write('Name = "%s",\n' % (self.getName(),))
1506
def exportLiteralChildren(self, outfile, level, name_):
1507
showIndent(outfile, level)
1508
outfile.write('valueOf_ = "%s",\n' % (self.valueOf_,))
1509
def build(self, node_):
1510
attrs = node_.attributes
1511
self.buildAttributes(attrs)
1512
for child_ in node_.childNodes:
1513
nodeName_ = child_.nodeName.split(':')[-1]
1514
self.buildChildren(child_, nodeName_)
1515
def buildAttributes(self, attrs):
1516
if attrs.get('Type'):
1517
self.Type = attrs.get('Type').value
1518
if attrs.get('Name'):
1519
self.Name = attrs.get('Name').value
1520
def buildChildren(self, child_, nodeName_):
1522
for child in child_.childNodes:
1523
if child.nodeType == Node.TEXT_NODE:
1524
self.valueOf_ += child.nodeValue
1525
# end class Parameter
1528
from xml.sax import handler, make_parser
1530
class SaxStackElement:
1531
def __init__(self, name='', obj=None):
1539
class SaxGeneratemodelHandler(handler.ContentHandler):
1547
def setDocumentLocator(self, locator):
1548
self.locator = locator
1550
def showError(self, msg):
1551
print '*** (showError):', msg
1554
def startElement(self, name, attrs):
1556
if name == 'GenerateModel':
1557
obj = GenerateModel.factory()
1558
stackObj = SaxStackElement('GenerateModel', obj)
1559
self.stack.append(stackObj)
1561
elif name == 'Module':
1562
obj = Module.factory()
1563
stackObj = SaxStackElement('Module', obj)
1564
self.stack.append(stackObj)
1566
elif name == 'PythonExport':
1567
obj = PythonExport.factory()
1568
val = attrs.get('FatherNamespace', None)
1570
obj.setFathernamespace(val)
1571
val = attrs.get('Name', None)
1574
val = attrs.get('Reference', None)
1576
if val in ('true', '1'):
1578
elif val in ('false', '0'):
1581
self.reportError('"Reference" attribute must be boolean ("true", "1", "false", "0")')
1582
val = attrs.get('FatherInclude', None)
1584
obj.setFatherinclude(val)
1585
val = attrs.get('Father', None)
1588
val = attrs.get('Namespace', None)
1590
obj.setNamespace(val)
1591
val = attrs.get('Twin', None)
1594
val = attrs.get('Constructor', None)
1596
if val in ('true', '1'):
1597
obj.setConstructor(1)
1598
elif val in ('false', '0'):
1599
obj.setConstructor(0)
1601
self.reportError('"Constructor" attribute must be boolean ("true", "1", "false", "0")')
1602
val = attrs.get('TwinPointer', None)
1604
obj.setTwinpointer(val)
1605
val = attrs.get('Include', None)
1608
val = attrs.get('NumberProtocol', None)
1610
if val in ('true', '1'):
1611
obj.setNumberprotocol(1)
1612
elif val in ('false', '0'):
1613
obj.setNumberprotocol(0)
1615
self.reportError('"NumberProtocol" attribute must be boolean ("true", "1", "false", "0")')
1616
val = attrs.get('Delete', None)
1618
if val in ('true', '1'):
1620
elif val in ('false', '0'):
1623
self.reportError('"Delete" attribute must be boolean ("true", "1", "false", "0")')
1624
stackObj = SaxStackElement('PythonExport', obj)
1625
self.stack.append(stackObj)
1627
elif name == 'Documentation':
1628
obj = Documentation.factory()
1629
stackObj = SaxStackElement('Documentation', obj)
1630
self.stack.append(stackObj)
1632
elif name == 'Methode':
1633
obj = Methode.factory()
1634
val = attrs.get('Const', None)
1636
if val in ('true', '1'):
1638
elif val in ('false', '0'):
1641
self.reportError('"Const" attribute must be boolean ("true", "1", "false", "0")')
1642
val = attrs.get('Name', None)
1645
stackObj = SaxStackElement('Methode', obj)
1646
self.stack.append(stackObj)
1648
elif name == 'Parameter':
1649
obj = Parameter.factory()
1650
val = attrs.get('Type', None)
1653
val = attrs.get('Name', None)
1656
stackObj = SaxStackElement('Parameter', obj)
1657
self.stack.append(stackObj)
1659
elif name == 'Attribute':
1660
obj = Attribute.factory()
1661
val = attrs.get('ReadOnly', None)
1663
if val in ('true', '1'):
1665
elif val in ('false', '0'):
1668
self.reportError('"ReadOnly" attribute must be boolean ("true", "1", "false", "0")')
1669
val = attrs.get('Name', None)
1672
stackObj = SaxStackElement('Attribute', obj)
1673
self.stack.append(stackObj)
1675
elif name == 'CustomAttributes':
1676
stackObj = SaxStackElement('CustomAttributes', None)
1677
self.stack.append(stackObj)
1679
elif name == 'ClassDeclarations':
1680
stackObj = SaxStackElement('ClassDeclarations', None)
1681
self.stack.append(stackObj)
1683
elif name == 'Dependencies':
1684
obj = Dependencies.factory()
1685
stackObj = SaxStackElement('Dependencies', obj)
1686
self.stack.append(stackObj)
1688
elif name == 'Content':
1689
obj = Content.factory()
1690
stackObj = SaxStackElement('Content', obj)
1691
self.stack.append(stackObj)
1693
elif name == 'Property':
1694
obj = Property.factory()
1695
stackObj = SaxStackElement('Property', obj)
1696
self.stack.append(stackObj)
1698
elif name == 'Feature':
1699
obj = Feature.factory()
1700
val = attrs.get('Name', None)
1703
stackObj = SaxStackElement('Feature', obj)
1704
self.stack.append(stackObj)
1706
elif name == 'ViewProvider':
1707
obj = ViewProvider.factory()
1708
stackObj = SaxStackElement('ViewProvider', obj)
1709
self.stack.append(stackObj)
1711
elif name == 'DocObject':
1712
obj = DocObject.factory()
1713
val = attrs.get('Name', None)
1716
stackObj = SaxStackElement('DocObject', obj)
1717
self.stack.append(stackObj)
1719
elif name == 'GuiCommand':
1720
stackObj = SaxStackElement('GuiCommand', None)
1721
self.stack.append(stackObj)
1723
elif name == 'PreferencesPage':
1724
stackObj = SaxStackElement('PreferencesPage', None)
1725
self.stack.append(stackObj)
1727
elif name == 'Author':
1728
obj = Author.factory()
1729
val = attrs.get('Name', None)
1732
val = attrs.get('Licence', None)
1735
val = attrs.get('EMail', None)
1738
stackObj = SaxStackElement('Author', obj)
1739
self.stack.append(stackObj)
1741
elif name == 'DeveloperDocu':
1742
stackObj = SaxStackElement('DeveloperDocu', None)
1743
self.stack.append(stackObj)
1745
elif name == 'UserDocu':
1746
stackObj = SaxStackElement('UserDocu', None)
1747
self.stack.append(stackObj)
1750
self.reportError('"%s" element not allowed here.' % name)
1752
def endElement(self, name):
1754
if name == 'GenerateModel':
1755
if len(self.stack) == 1:
1756
self.root = self.stack[-1].obj
1759
elif name == 'Module':
1760
if len(self.stack) >= 2:
1761
self.stack[-2].obj.addModule(self.stack[-1].obj)
1764
elif name == 'PythonExport':
1765
if len(self.stack) >= 2:
1766
self.stack[-2].obj.addPythonexport(self.stack[-1].obj)
1769
elif name == 'Documentation':
1770
if len(self.stack) >= 2:
1771
self.stack[-2].obj.setDocumentation(self.stack[-1].obj)
1774
elif name == 'Methode':
1775
if len(self.stack) >= 2:
1776
self.stack[-2].obj.addMethode(self.stack[-1].obj)
1779
elif name == 'Parameter':
1780
if len(self.stack) >= 2:
1781
self.stack[-2].obj.addParameter(self.stack[-1].obj)
1784
elif name == 'Attribute':
1785
if len(self.stack) >= 2:
1786
self.stack[-2].obj.addAttribute(self.stack[-1].obj)
1789
elif name == 'CustomAttributes':
1790
if len(self.stack) >= 2:
1791
content = self.stack[-1].content
1792
self.stack[-2].obj.setCustomattributes(content)
1795
elif name == 'ClassDeclarations':
1796
if len(self.stack) >= 2:
1797
content = self.stack[-1].content
1798
self.stack[-2].obj.setClassdeclarations(content)
1801
elif name == 'Dependencies':
1802
if len(self.stack) >= 2:
1803
self.stack[-2].obj.setDependencies(self.stack[-1].obj)
1806
elif name == 'Content':
1807
if len(self.stack) >= 2:
1808
self.stack[-2].obj.setContent(self.stack[-1].obj)
1811
elif name == 'Property':
1812
if len(self.stack) >= 2:
1813
self.stack[-2].obj.addProperty(self.stack[-1].obj)
1816
elif name == 'Feature':
1817
if len(self.stack) >= 2:
1818
self.stack[-2].obj.addFeature(self.stack[-1].obj)
1821
elif name == 'ViewProvider':
1822
if len(self.stack) >= 2:
1823
self.stack[-2].obj.setViewprovider(self.stack[-1].obj)
1826
elif name == 'DocObject':
1827
if len(self.stack) >= 2:
1828
self.stack[-2].obj.addDocobject(self.stack[-1].obj)
1831
elif name == 'GuiCommand':
1832
if len(self.stack) >= 2:
1833
content = self.stack[-1].content
1834
self.stack[-2].obj.addGuicommand(content)
1837
elif name == 'PreferencesPage':
1838
if len(self.stack) >= 2:
1839
content = self.stack[-1].content
1840
self.stack[-2].obj.addPreferencespage(content)
1843
elif name == 'Author':
1844
if len(self.stack) >= 2:
1845
self.stack[-2].obj.setAuthor(self.stack[-1].obj)
1848
elif name == 'DeveloperDocu':
1849
if len(self.stack) >= 2:
1850
content = self.stack[-1].content
1851
self.stack[-2].obj.setDeveloperdocu(content)
1854
elif name == 'UserDocu':
1855
if len(self.stack) >= 2:
1856
content = self.stack[-1].content
1857
self.stack[-2].obj.setUserdocu(content)
1861
self.reportError('"%s" element not allowed here.' % name)
1863
def characters(self, chrs, start, end):
1864
if len(self.stack) > 0:
1865
self.stack[-1].content += chrs[start:end]
1867
def reportError(self, mesg):
1868
locator = self.locator
1869
sys.stderr.write('Doc: %s Line: %d Column: %d\n' % \
1870
(locator.getSystemId(), locator.getLineNumber(),
1871
locator.getColumnNumber() + 1))
1872
sys.stderr.write(mesg)
1873
sys.stderr.write('\n')
1878
Usage: python <Parser>.py [ -s ] <in_xml_file>
1880
-s Use the SAX parser, not the minidom parser.
1889
# SAX handler used to determine the top level element.
1891
class SaxSelectorHandler(handler.ContentHandler):
1893
self.topElementName = None
1894
def getTopElementName(self):
1895
return self.topElementName
1896
def startElement(self, name, attrs):
1897
self.topElementName = name
1901
def parseSelect(inFileName):
1902
infile = file(inFileName, 'r')
1903
topElementName = None
1904
parser = make_parser()
1905
documentHandler = SaxSelectorHandler()
1906
parser.setContentHandler(documentHandler)
1909
parser.parse(infile)
1910
except StopIteration:
1911
topElementName = documentHandler.getTopElementName()
1912
if topElementName is None:
1913
raise RuntimeError, 'no top level element'
1914
topElementName = topElementName.replace('-', '_').replace(':', '_')
1915
if topElementName not in globals():
1916
raise RuntimeError, 'no class for top element: %s' % topElementName
1917
topElement = globals()[topElementName]
1919
doc = minidom.parse(infile)
1922
rootNode = doc.childNodes[0]
1923
rootObj = topElement.factory()
1924
rootObj.build(rootNode)
1925
# Enable Python to collect the space used by the DOM.
1927
sys.stdout.write('<?xml version="1.0" ?>\n')
1928
rootObj.export(sys.stdout, 0)
1932
def saxParse(inFileName):
1933
parser = make_parser()
1934
documentHandler = SaxGeneratemodelHandler()
1935
parser.setDocumentHandler(documentHandler)
1936
parser.parse('file:%s' % inFileName)
1937
root = documentHandler.getRoot()
1938
sys.stdout.write('<?xml version="1.0" ?>\n')
1939
root.export(sys.stdout, 0)
1943
def saxParseString(inString):
1944
parser = make_parser()
1945
documentHandler = SaxGeneratemodelHandler()
1946
parser.setDocumentHandler(documentHandler)
1947
parser.feed(inString)
1949
rootObj = documentHandler.getRoot()
1950
#sys.stdout.write('<?xml version="1.0" ?>\n')
1951
#rootObj.export(sys.stdout, 0)
1955
def parse(inFileName):
1956
doc = minidom.parse(inFileName)
1957
rootNode = doc.documentElement
1958
rootObj = GenerateModel.factory()
1959
rootObj.build(rootNode)
1960
# Enable Python to collect the space used by the DOM.
1962
sys.stdout.write('<?xml version="1.0" ?>\n')
1963
rootObj.export(sys.stdout, 0, name_="GenerateModel")
1967
def parseString(inString):
1968
doc = minidom.parseString(inString)
1969
rootNode = doc.documentElement
1970
rootObj = GenerateModel.factory()
1971
rootObj.build(rootNode)
1972
# Enable Python to collect the space used by the DOM.
1974
sys.stdout.write('<?xml version="1.0" ?>\n')
1975
rootObj.export(sys.stdout, 0, name_="GenerateModel")
1979
def parseLiteral(inFileName):
1980
doc = minidom.parse(inFileName)
1981
rootNode = doc.documentElement
1982
rootObj = GenerateModel.factory()
1983
rootObj.build(rootNode)
1984
# Enable Python to collect the space used by the DOM.
1986
sys.stdout.write('from generateModel_Module import *\n\n')
1987
sys.stdout.write('rootObj = GenerateModel(\n')
1988
rootObj.exportLiteral(sys.stdout, 0, name_="GenerateModel")
1989
sys.stdout.write(')\n')
1995
if len(args) == 2 and args[0] == '-s':
1997
elif len(args) == 1:
2003
if __name__ == '__main__':