~ubuntu-branches/ubuntu/maverick/freecad/maverick

« back to all changes in this revision

Viewing changes to src/Tools/generateBase/generateModel_Module.py

  • Committer: Bazaar Package Importer
  • Author(s): Teemu Ikonen
  • Date: 2009-07-16 18:37:41 UTC
  • Revision ID: james.westby@ubuntu.com-20090716183741-oww9kcxqrk991i1n
Tags: upstream-0.8.2237
ImportĀ upstreamĀ versionĀ 0.8.2237

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/usr/bin/env python
 
2
 
 
3
#
 
4
# Generated Sun Jan 11 02:25:41 2009 by generateDS.py.
 
5
#
 
6
 
 
7
import sys
 
8
import getopt
 
9
from xml.dom import minidom
 
10
from xml.dom import Node
 
11
 
 
12
#
 
13
# If you have installed IPython you can uncomment and use the following.
 
14
# IPython is available from http://ipython.scipy.org/.
 
15
#
 
16
 
 
17
## from IPython.Shell import IPShellEmbed
 
18
## args = ''
 
19
## ipshell = IPShellEmbed(args,
 
20
##     banner = 'Dropping into IPython',
 
21
##     exit_msg = 'Leaving Interpreter, back to program.')
 
22
 
 
23
# Then use the following line where and when you want to drop into the
 
24
# IPython shell:
 
25
#    ipshell('<some message> -- Entering ipshell.\nHit Ctrl-D to exit')
 
26
 
 
27
#
 
28
# Support/utility functions.
 
29
#
 
30
 
 
31
def showIndent(outfile, level):
 
32
    for idx in range(level):
 
33
        outfile.write('    ')
 
34
 
 
35
def quote_xml(inStr):
 
36
    s1 = inStr
 
37
    s1 = s1.replace('&', '&amp;')
 
38
    s1 = s1.replace('<', '&lt;')
 
39
    s1 = s1.replace('"', '&quot;')
 
40
    return s1
 
41
 
 
42
def quote_python(inStr):
 
43
    s1 = inStr
 
44
    if s1.find("'") == -1:
 
45
        if s1.find('\n') == -1:
 
46
            return "'%s'" % s1
 
47
        else:
 
48
            return "'''%s'''" % s1
 
49
    else:
 
50
        if s1.find('"') != -1:
 
51
            s1 = s1.replace('"', '\\"')
 
52
        if s1.find('\n') == -1:
 
53
            return '"%s"' % s1
 
54
        else:
 
55
            return '"""%s"""' % s1
 
56
 
 
57
 
 
58
class MixedContainer:
 
59
    # Constants for category:
 
60
    CategoryNone = 0
 
61
    CategoryText = 1
 
62
    CategorySimple = 2
 
63
    CategoryComplex = 3
 
64
    # Constants for content_type:
 
65
    TypeNone = 0
 
66
    TypeText = 1
 
67
    TypeString = 2
 
68
    TypeInteger = 3
 
69
    TypeFloat = 4
 
70
    TypeDecimal = 5
 
71
    TypeDouble = 6
 
72
    TypeBoolean = 7
 
73
    def __init__(self, category, content_type, name, value):
 
74
        self.category = category
 
75
        self.content_type = content_type
 
76
        self.name = name
 
77
        self.value = value
 
78
    def getCategory(self):
 
79
        return self.category
 
80
    def getContenttype(self, content_type):
 
81
        return self.content_type
 
82
    def getValue(self):
 
83
        return self.value
 
84
    def getName(self):
 
85
        return self.name
 
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)
 
119
            outfile.write(')\n')
 
120
 
 
121
 
 
122
#
 
123
# Data representation classes.
 
124
#
 
125
 
 
126
class GenerateModel:
 
127
    subclass = None
 
128
    def __init__(self, Module=None, PythonExport=None):
 
129
        if Module is None:
 
130
            self.Module = []
 
131
        else:
 
132
            self.Module = Module
 
133
        if PythonExport is None:
 
134
            self.PythonExport = []
 
135
        else:
 
136
            self.PythonExport = PythonExport
 
137
    def factory(*args_, **kwargs_):
 
138
        if GenerateModel.subclass:
 
139
            return GenerateModel.subclass(*args_, **kwargs_)
 
140
        else:
 
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'):
 
158
        pass
 
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'):
 
165
        level += 1
 
166
        self.exportLiteralAttributes(outfile, level, name_)
 
167
        self.exportLiteralChildren(outfile, level, name_)
 
168
    def exportLiteralAttributes(self, outfile, level, name_):
 
169
        pass
 
170
    def exportLiteralChildren(self, outfile, level, name_):
 
171
        showIndent(outfile, level)
 
172
        outfile.write('Module=[\n')
 
173
        level += 1
 
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')
 
180
        level -= 1
 
181
        showIndent(outfile, level)
 
182
        outfile.write('],\n')
 
183
        showIndent(outfile, level)
 
184
        outfile.write('PythonExport=[\n')
 
185
        level += 1
 
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')
 
192
        level -= 1
 
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):
 
202
        pass
 
203
    def buildChildren(self, child_, nodeName_):
 
204
        if child_.nodeType == Node.ELEMENT_NODE and \
 
205
            nodeName_ == 'Module':
 
206
            obj_ = Module.factory()
 
207
            obj_.build(child_)
 
208
            self.Module.append(obj_)
 
209
        elif child_.nodeType == Node.ELEMENT_NODE and \
 
210
            nodeName_ == 'PythonExport':
 
211
            obj_ = PythonExport.factory()
 
212
            obj_.build(child_)
 
213
            self.PythonExport.append(obj_)
 
214
# end class GenerateModel
 
215
 
 
216
 
 
217
class PythonExport:
 
218
    subclass = None
 
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
 
221
        self.Name = Name
 
222
        self.Reference = Reference
 
223
        self.FatherInclude = FatherInclude
 
224
        self.Father = Father
 
225
        self.Namespace = Namespace
 
226
        self.Twin = Twin
 
227
        self.Constructor = Constructor
 
228
        self.TwinPointer = TwinPointer
 
229
        self.Include = Include
 
230
        self.NumberProtocol = NumberProtocol
 
231
        self.Delete = Delete
 
232
        self.Documentation = Documentation
 
233
        if Methode is None:
 
234
            self.Methode = []
 
235
        else:
 
236
            self.Methode = Methode
 
237
        if Attribute is None:
 
238
            self.Attribute = []
 
239
        else:
 
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_)
 
246
        else:
 
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')
 
291
        outfile.write('>\n')
 
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'):
 
324
        level += 1
 
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')
 
361
        level += 1
 
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')
 
368
        level -= 1
 
369
        showIndent(outfile, level)
 
370
        outfile.write('],\n')
 
371
        showIndent(outfile, level)
 
372
        outfile.write('Attribute=[\n')
 
373
        level += 1
 
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')
 
380
        level -= 1
 
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'):
 
400
                self.Reference = 1
 
401
            elif attrs.get('Reference').value in ('false', '0'):
 
402
                self.Reference = 0
 
403
            else:
 
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'):
 
415
                self.Constructor = 1
 
416
            elif attrs.get('Constructor').value in ('false', '0'):
 
417
                self.Constructor = 0
 
418
            else:
 
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
 
429
            else:
 
430
                raise ValueError('Bad boolean attribute (NumberProtocol)')
 
431
        if attrs.get('Delete'):
 
432
            if attrs.get('Delete').value in ('true', '1'):
 
433
                self.Delete = 1
 
434
            elif attrs.get('Delete').value in ('false', '0'):
 
435
                self.Delete = 0
 
436
            else:
 
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()
 
442
            obj_.build(child_)
 
443
            self.setDocumentation(obj_)
 
444
        elif child_.nodeType == Node.ELEMENT_NODE and \
 
445
            nodeName_ == 'Methode':
 
446
            obj_ = Methode.factory()
 
447
            obj_.build(child_)
 
448
            self.Methode.append(obj_)
 
449
        elif child_.nodeType == Node.ELEMENT_NODE and \
 
450
            nodeName_ == 'Attribute':
 
451
            obj_ = Attribute.factory()
 
452
            obj_.build(child_)
 
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
 
467
 
 
468
 
 
469
class Methode:
 
470
    subclass = None
 
471
    def __init__(self, Const=0, Name='', Documentation=None, Parameter=None):
 
472
        self.Const = Const
 
473
        self.Name = Name
 
474
        self.Documentation = Documentation
 
475
        if Parameter is None:
 
476
            self.Parameter = []
 
477
        else:
 
478
            self.Parameter = Parameter
 
479
    def factory(*args_, **kwargs_):
 
480
        if Methode.subclass:
 
481
            return Methode.subclass(*args_, **kwargs_)
 
482
        else:
 
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')
 
499
        outfile.write('>\n')
 
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'):
 
513
        level += 1
 
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')
 
530
        level += 1
 
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')
 
537
        level -= 1
 
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'):
 
549
                self.Const = 1
 
550
            elif attrs.get('Const').value in ('false', '0'):
 
551
                self.Const = 0
 
552
            else:
 
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()
 
560
            obj_.build(child_)
 
561
            self.setDocumentation(obj_)
 
562
        elif child_.nodeType == Node.ELEMENT_NODE and \
 
563
            nodeName_ == 'Parameter':
 
564
            obj_ = Parameter.factory()
 
565
            obj_.build(child_)
 
566
            self.Parameter.append(obj_)
 
567
# end class Methode
 
568
 
 
569
 
 
570
class Attribute:
 
571
    subclass = None
 
572
    def __init__(self, ReadOnly=0, Name='', Documentation=None, Parameter=None):
 
573
        self.ReadOnly = ReadOnly
 
574
        self.Name = Name
 
575
        self.Documentation = Documentation
 
576
        self.Parameter = Parameter
 
577
    def factory(*args_, **kwargs_):
 
578
        if Attribute.subclass:
 
579
            return Attribute.subclass(*args_, **kwargs_)
 
580
        else:
 
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')
 
595
        outfile.write('>\n')
 
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)
 
605
        if self.Parameter:
 
606
            self.Parameter.export(outfile, level)
 
607
    def exportLiteral(self, outfile, level, name_='Attribute'):
 
608
        level += 1
 
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')
 
623
        if self.Parameter:
 
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'):
 
638
                self.ReadOnly = 1
 
639
            elif attrs.get('ReadOnly').value in ('false', '0'):
 
640
                self.ReadOnly = 0
 
641
            else:
 
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()
 
649
            obj_.build(child_)
 
650
            self.setDocumentation(obj_)
 
651
        elif child_.nodeType == Node.ELEMENT_NODE and \
 
652
            nodeName_ == 'Parameter':
 
653
            obj_ = Parameter.factory()
 
654
            obj_.build(child_)
 
655
            self.setParameter(obj_)
 
656
# end class Attribute
 
657
 
 
658
 
 
659
class Module:
 
660
    subclass = None
 
661
    def __init__(self, Name='', Documentation=None, Dependencies=None, Content=None):
 
662
        self.Name = Name
 
663
        self.Documentation = Documentation
 
664
        self.Dependencies = Dependencies
 
665
        self.Content = Content
 
666
    def factory(*args_, **kwargs_):
 
667
        if Module.subclass:
 
668
            return Module.subclass(*args_, **kwargs_)
 
669
        else:
 
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')
 
684
        outfile.write('>\n')
 
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)
 
695
        if self.Content:
 
696
            self.Content.export(outfile, level)
 
697
    def exportLiteral(self, outfile, level, name_='Module'):
 
698
        level += 1
 
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')
 
717
        if self.Content:
 
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()
 
736
            obj_.build(child_)
 
737
            self.setDocumentation(obj_)
 
738
        elif child_.nodeType == Node.ELEMENT_NODE and \
 
739
            nodeName_ == 'Dependencies':
 
740
            obj_ = Dependencies.factory()
 
741
            obj_.build(child_)
 
742
            self.setDependencies(obj_)
 
743
        elif child_.nodeType == Node.ELEMENT_NODE and \
 
744
            nodeName_ == 'Content':
 
745
            obj_ = Content.factory()
 
746
            obj_.build(child_)
 
747
            self.setContent(obj_)
 
748
# end class Module
 
749
 
 
750
 
 
751
class Dependencies:
 
752
    subclass = None
 
753
    def __init__(self, Module=None):
 
754
        if Module is None:
 
755
            self.Module = []
 
756
        else:
 
757
            self.Module = Module
 
758
    def factory(*args_, **kwargs_):
 
759
        if Dependencies.subclass:
 
760
            return Dependencies.subclass(*args_, **kwargs_)
 
761
        else:
 
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'):
 
775
        pass
 
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'):
 
780
        level += 1
 
781
        self.exportLiteralAttributes(outfile, level, name_)
 
782
        self.exportLiteralChildren(outfile, level, name_)
 
783
    def exportLiteralAttributes(self, outfile, level, name_):
 
784
        pass
 
785
    def exportLiteralChildren(self, outfile, level, name_):
 
786
        showIndent(outfile, level)
 
787
        outfile.write('Module=[\n')
 
788
        level += 1
 
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')
 
795
        level -= 1
 
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):
 
805
        pass
 
806
    def buildChildren(self, child_, nodeName_):
 
807
        if child_.nodeType == Node.ELEMENT_NODE and \
 
808
            nodeName_ == 'Module':
 
809
            obj_ = Module.factory()
 
810
            obj_.build(child_)
 
811
            self.Module.append(obj_)
 
812
# end class Dependencies
 
813
 
 
814
 
 
815
class Content:
 
816
    subclass = None
 
817
    def __init__(self, Property=None, Feature=None, DocObject=None, GuiCommand=None, PreferencesPage=None):
 
818
        if Property is None:
 
819
            self.Property = []
 
820
        else:
 
821
            self.Property = Property
 
822
        if Feature is None:
 
823
            self.Feature = []
 
824
        else:
 
825
            self.Feature = Feature
 
826
        if DocObject is None:
 
827
            self.DocObject = []
 
828
        else:
 
829
            self.DocObject = DocObject
 
830
        if GuiCommand is None:
 
831
            self.GuiCommand = []
 
832
        else:
 
833
            self.GuiCommand = GuiCommand
 
834
        if PreferencesPage is None:
 
835
            self.PreferencesPage = []
 
836
        else:
 
837
            self.PreferencesPage = PreferencesPage
 
838
    def factory(*args_, **kwargs_):
 
839
        if Content.subclass:
 
840
            return Content.subclass(*args_, **kwargs_)
 
841
        else:
 
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'):
 
871
        pass
 
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'):
 
886
        level += 1
 
887
        self.exportLiteralAttributes(outfile, level, name_)
 
888
        self.exportLiteralChildren(outfile, level, name_)
 
889
    def exportLiteralAttributes(self, outfile, level, name_):
 
890
        pass
 
891
    def exportLiteralChildren(self, outfile, level, name_):
 
892
        showIndent(outfile, level)
 
893
        outfile.write('Property=[\n')
 
894
        level += 1
 
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')
 
901
        level -= 1
 
902
        showIndent(outfile, level)
 
903
        outfile.write('],\n')
 
904
        showIndent(outfile, level)
 
905
        outfile.write('Feature=[\n')
 
906
        level += 1
 
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')
 
913
        level -= 1
 
914
        showIndent(outfile, level)
 
915
        outfile.write('],\n')
 
916
        showIndent(outfile, level)
 
917
        outfile.write('DocObject=[\n')
 
918
        level += 1
 
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')
 
925
        level -= 1
 
926
        showIndent(outfile, level)
 
927
        outfile.write('],\n')
 
928
        showIndent(outfile, level)
 
929
        outfile.write('GuiCommand=[\n')
 
930
        level += 1
 
931
        for GuiCommand in self.GuiCommand:
 
932
            showIndent(outfile, level)
 
933
            outfile.write('%s,\n' % quote_python(GuiCommand))
 
934
        level -= 1
 
935
        showIndent(outfile, level)
 
936
        outfile.write('],\n')
 
937
        showIndent(outfile, level)
 
938
        outfile.write('PreferencesPage=[\n')
 
939
        level += 1
 
940
        for PreferencesPage in self.PreferencesPage:
 
941
            showIndent(outfile, level)
 
942
            outfile.write('%s,\n' % quote_python(PreferencesPage))
 
943
        level -= 1
 
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):
 
953
        pass
 
954
    def buildChildren(self, child_, nodeName_):
 
955
        if child_.nodeType == Node.ELEMENT_NODE and \
 
956
            nodeName_ == 'Property':
 
957
            obj_ = Property.factory()
 
958
            obj_.build(child_)
 
959
            self.Property.append(obj_)
 
960
        elif child_.nodeType == Node.ELEMENT_NODE and \
 
961
            nodeName_ == 'Feature':
 
962
            obj_ = Feature.factory()
 
963
            obj_.build(child_)
 
964
            self.Feature.append(obj_)
 
965
        elif child_.nodeType == Node.ELEMENT_NODE and \
 
966
            nodeName_ == 'DocObject':
 
967
            obj_ = DocObject.factory()
 
968
            obj_.build(child_)
 
969
            self.DocObject.append(obj_)
 
970
        elif child_.nodeType == Node.ELEMENT_NODE and \
 
971
            nodeName_ == 'GuiCommand':
 
972
            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_)
 
982
# end class Content
 
983
 
 
984
 
 
985
class Feature:
 
986
    subclass = None
 
987
    def __init__(self, Name='', Documentation=None, Property=None, ViewProvider=None):
 
988
        self.Name = Name
 
989
        self.Documentation = Documentation
 
990
        if Property is None:
 
991
            self.Property = []
 
992
        else:
 
993
            self.Property = Property
 
994
        self.ViewProvider = ViewProvider
 
995
    def factory(*args_, **kwargs_):
 
996
        if Feature.subclass:
 
997
            return Feature.subclass(*args_, **kwargs_)
 
998
        else:
 
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'):
 
1029
        level += 1
 
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')
 
1044
        level += 1
 
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')
 
1051
        level -= 1
 
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()
 
1073
            obj_.build(child_)
 
1074
            self.setDocumentation(obj_)
 
1075
        elif child_.nodeType == Node.ELEMENT_NODE and \
 
1076
            nodeName_ == 'Property':
 
1077
            obj_ = Property.factory()
 
1078
            obj_.build(child_)
 
1079
            self.Property.append(obj_)
 
1080
        elif child_.nodeType == Node.ELEMENT_NODE and \
 
1081
            nodeName_ == 'ViewProvider':
 
1082
            obj_ = ViewProvider.factory()
 
1083
            obj_.build(child_)
 
1084
            self.setViewprovider(obj_)
 
1085
# end class Feature
 
1086
 
 
1087
 
 
1088
class DocObject:
 
1089
    subclass = None
 
1090
    def __init__(self, Name='', Documentation=None, Property=None):
 
1091
        self.Name = Name
 
1092
        self.Documentation = Documentation
 
1093
        if Property is None:
 
1094
            self.Property = []
 
1095
        else:
 
1096
            self.Property = Property
 
1097
    def factory(*args_, **kwargs_):
 
1098
        if DocObject.subclass:
 
1099
            return DocObject.subclass(*args_, **kwargs_)
 
1100
        else:
 
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'):
 
1127
        level += 1
 
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')
 
1142
        level += 1
 
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')
 
1149
        level -= 1
 
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()
 
1165
            obj_.build(child_)
 
1166
            self.setDocumentation(obj_)
 
1167
        elif child_.nodeType == Node.ELEMENT_NODE and \
 
1168
            nodeName_ == 'Property':
 
1169
            obj_ = Property.factory()
 
1170
            obj_.build(child_)
 
1171
            self.Property.append(obj_)
 
1172
# end class DocObject
 
1173
 
 
1174
 
 
1175
class Property:
 
1176
    subclass = None
 
1177
    def __init__(self, Type='', Name='', StartValue='', Documentation=None):
 
1178
        self.Type = Type
 
1179
        self.Name = Name
 
1180
        self.StartValue = StartValue
 
1181
        self.Documentation = Documentation
 
1182
    def factory(*args_, **kwargs_):
 
1183
        if Property.subclass:
 
1184
            return Property.subclass(*args_, **kwargs_)
 
1185
        else:
 
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'):
 
1213
        level += 1
 
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()
 
1247
            obj_.build(child_)
 
1248
            self.setDocumentation(obj_)
 
1249
# end class Property
 
1250
 
 
1251
 
 
1252
class Documentation:
 
1253
    subclass = None
 
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_)
 
1261
        else:
 
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'):
 
1277
        pass
 
1278
    def exportChildren(self, outfile, level, name_='Documentation'):
 
1279
        if self.Author:
 
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'):
 
1286
        level += 1
 
1287
        self.exportLiteralAttributes(outfile, level, name_)
 
1288
        self.exportLiteralChildren(outfile, level, name_)
 
1289
    def exportLiteralAttributes(self, outfile, level, name_):
 
1290
        pass
 
1291
    def exportLiteralChildren(self, outfile, level, name_):
 
1292
        if self.Author:
 
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):
 
1309
        pass
 
1310
    def buildChildren(self, child_, nodeName_):
 
1311
        if child_.nodeType == Node.ELEMENT_NODE and \
 
1312
            nodeName_ == 'Author':
 
1313
            obj_ = Author.factory()
 
1314
            obj_.build(child_)
 
1315
            self.setAuthor(obj_)
 
1316
        elif child_.nodeType == Node.ELEMENT_NODE and \
 
1317
            nodeName_ == 'DeveloperDocu':
 
1318
            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':
 
1324
            UserDocu_ = ''
 
1325
            for text__content_ in child_.childNodes:
 
1326
                UserDocu_ += text__content_.nodeValue
 
1327
            self.UserDocu = UserDocu_
 
1328
# end class Documentation
 
1329
 
 
1330
 
 
1331
class Author:
 
1332
    subclass = None
 
1333
    def __init__(self, Name='', Licence='', EMail='', valueOf_=''):
 
1334
        self.Name = Name
 
1335
        self.Licence = Licence
 
1336
        self.EMail = EMail
 
1337
        self.valueOf_ = valueOf_
 
1338
    def factory(*args_, **kwargs_):
 
1339
        if Author.subclass:
 
1340
            return Author.subclass(*args_, **kwargs_)
 
1341
        else:
 
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'):
 
1368
        level += 1
 
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_):
 
1395
        self.valueOf_ = ''
 
1396
        for child in child_.childNodes:
 
1397
            if child.nodeType == Node.TEXT_NODE:
 
1398
                self.valueOf_ += child.nodeValue
 
1399
# end class Author
 
1400
 
 
1401
 
 
1402
class ViewProvider:
 
1403
    subclass = None
 
1404
    def __init__(self, Property=None):
 
1405
        if Property is None:
 
1406
            self.Property = []
 
1407
        else:
 
1408
            self.Property = Property
 
1409
    def factory(*args_, **kwargs_):
 
1410
        if ViewProvider.subclass:
 
1411
            return ViewProvider.subclass(*args_, **kwargs_)
 
1412
        else:
 
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'):
 
1426
        pass
 
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'):
 
1431
        level += 1
 
1432
        self.exportLiteralAttributes(outfile, level, name_)
 
1433
        self.exportLiteralChildren(outfile, level, name_)
 
1434
    def exportLiteralAttributes(self, outfile, level, name_):
 
1435
        pass
 
1436
    def exportLiteralChildren(self, outfile, level, name_):
 
1437
        showIndent(outfile, level)
 
1438
        outfile.write('Property=[\n')
 
1439
        level += 1
 
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')
 
1446
        level -= 1
 
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):
 
1456
        pass
 
1457
    def buildChildren(self, child_, nodeName_):
 
1458
        if child_.nodeType == Node.ELEMENT_NODE and \
 
1459
            nodeName_ == 'Property':
 
1460
            obj_ = Property.factory()
 
1461
            obj_.build(child_)
 
1462
            self.Property.append(obj_)
 
1463
# end class ViewProvider
 
1464
 
 
1465
 
 
1466
class Parameter:
 
1467
    subclass = None
 
1468
    def __init__(self, Type='', Name='', valueOf_=''):
 
1469
        self.Type = Type
 
1470
        self.Name = Name
 
1471
        self.valueOf_ = valueOf_
 
1472
    def factory(*args_, **kwargs_):
 
1473
        if Parameter.subclass:
 
1474
            return Parameter.subclass(*args_, **kwargs_)
 
1475
        else:
 
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'):
 
1498
        level += 1
 
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_):
 
1521
        self.valueOf_ = ''
 
1522
        for child in child_.childNodes:
 
1523
            if child.nodeType == Node.TEXT_NODE:
 
1524
                self.valueOf_ += child.nodeValue
 
1525
# end class Parameter
 
1526
 
 
1527
 
 
1528
from xml.sax import handler, make_parser
 
1529
 
 
1530
class SaxStackElement:
 
1531
    def __init__(self, name='', obj=None):
 
1532
        self.name = name
 
1533
        self.obj = obj
 
1534
        self.content = ''
 
1535
 
 
1536
#
 
1537
# SAX handler
 
1538
#
 
1539
class SaxGeneratemodelHandler(handler.ContentHandler):
 
1540
    def __init__(self):
 
1541
        self.stack = []
 
1542
        self.root = None
 
1543
 
 
1544
    def getRoot(self):
 
1545
        return self.root
 
1546
 
 
1547
    def setDocumentLocator(self, locator):
 
1548
        self.locator = locator
 
1549
    
 
1550
    def showError(self, msg):
 
1551
        print '*** (showError):', msg
 
1552
        sys.exit(-1)
 
1553
 
 
1554
    def startElement(self, name, attrs):
 
1555
        done = 0
 
1556
        if name == 'GenerateModel':
 
1557
            obj = GenerateModel.factory()
 
1558
            stackObj = SaxStackElement('GenerateModel', obj)
 
1559
            self.stack.append(stackObj)
 
1560
            done = 1
 
1561
        elif name == 'Module':
 
1562
            obj = Module.factory()
 
1563
            stackObj = SaxStackElement('Module', obj)
 
1564
            self.stack.append(stackObj)
 
1565
            done = 1
 
1566
        elif name == 'PythonExport':
 
1567
            obj = PythonExport.factory()
 
1568
            val = attrs.get('FatherNamespace', None)
 
1569
            if val is not None:
 
1570
                obj.setFathernamespace(val)
 
1571
            val = attrs.get('Name', None)
 
1572
            if val is not None:
 
1573
                obj.setName(val)
 
1574
            val = attrs.get('Reference', None)
 
1575
            if val is not None:
 
1576
                if val in ('true', '1'):
 
1577
                    obj.setReference(1)
 
1578
                elif val in ('false', '0'):
 
1579
                    obj.setReference(0)
 
1580
                else:
 
1581
                    self.reportError('"Reference" attribute must be boolean ("true", "1", "false", "0")')
 
1582
            val = attrs.get('FatherInclude', None)
 
1583
            if val is not None:
 
1584
                obj.setFatherinclude(val)
 
1585
            val = attrs.get('Father', None)
 
1586
            if val is not None:
 
1587
                obj.setFather(val)
 
1588
            val = attrs.get('Namespace', None)
 
1589
            if val is not None:
 
1590
                obj.setNamespace(val)
 
1591
            val = attrs.get('Twin', None)
 
1592
            if val is not None:
 
1593
                obj.setTwin(val)
 
1594
            val = attrs.get('Constructor', None)
 
1595
            if val is not None:
 
1596
                if val in ('true', '1'):
 
1597
                    obj.setConstructor(1)
 
1598
                elif val in ('false', '0'):
 
1599
                    obj.setConstructor(0)
 
1600
                else:
 
1601
                    self.reportError('"Constructor" attribute must be boolean ("true", "1", "false", "0")')
 
1602
            val = attrs.get('TwinPointer', None)
 
1603
            if val is not None:
 
1604
                obj.setTwinpointer(val)
 
1605
            val = attrs.get('Include', None)
 
1606
            if val is not None:
 
1607
                obj.setInclude(val)
 
1608
            val = attrs.get('NumberProtocol', None)
 
1609
            if val is not None:
 
1610
                if val in ('true', '1'):
 
1611
                    obj.setNumberprotocol(1)
 
1612
                elif val in ('false', '0'):
 
1613
                    obj.setNumberprotocol(0)
 
1614
                else:
 
1615
                    self.reportError('"NumberProtocol" attribute must be boolean ("true", "1", "false", "0")')
 
1616
            val = attrs.get('Delete', None)
 
1617
            if val is not None:
 
1618
                if val in ('true', '1'):
 
1619
                    obj.setDelete(1)
 
1620
                elif val in ('false', '0'):
 
1621
                    obj.setDelete(0)
 
1622
                else:
 
1623
                    self.reportError('"Delete" attribute must be boolean ("true", "1", "false", "0")')
 
1624
            stackObj = SaxStackElement('PythonExport', obj)
 
1625
            self.stack.append(stackObj)
 
1626
            done = 1
 
1627
        elif name == 'Documentation':
 
1628
            obj = Documentation.factory()
 
1629
            stackObj = SaxStackElement('Documentation', obj)
 
1630
            self.stack.append(stackObj)
 
1631
            done = 1
 
1632
        elif name == 'Methode':
 
1633
            obj = Methode.factory()
 
1634
            val = attrs.get('Const', None)
 
1635
            if val is not None:
 
1636
                if val in ('true', '1'):
 
1637
                    obj.setConst(1)
 
1638
                elif val in ('false', '0'):
 
1639
                    obj.setConst(0)
 
1640
                else:
 
1641
                    self.reportError('"Const" attribute must be boolean ("true", "1", "false", "0")')
 
1642
            val = attrs.get('Name', None)
 
1643
            if val is not None:
 
1644
                obj.setName(val)
 
1645
            stackObj = SaxStackElement('Methode', obj)
 
1646
            self.stack.append(stackObj)
 
1647
            done = 1
 
1648
        elif name == 'Parameter':
 
1649
            obj = Parameter.factory()
 
1650
            val = attrs.get('Type', None)
 
1651
            if val is not None:
 
1652
                obj.setType(val)
 
1653
            val = attrs.get('Name', None)
 
1654
            if val is not None:
 
1655
                obj.setName(val)
 
1656
            stackObj = SaxStackElement('Parameter', obj)
 
1657
            self.stack.append(stackObj)
 
1658
            done = 1
 
1659
        elif name == 'Attribute':
 
1660
            obj = Attribute.factory()
 
1661
            val = attrs.get('ReadOnly', None)
 
1662
            if val is not None:
 
1663
                if val in ('true', '1'):
 
1664
                    obj.setReadonly(1)
 
1665
                elif val in ('false', '0'):
 
1666
                    obj.setReadonly(0)
 
1667
                else:
 
1668
                    self.reportError('"ReadOnly" attribute must be boolean ("true", "1", "false", "0")')
 
1669
            val = attrs.get('Name', None)
 
1670
            if val is not None:
 
1671
                obj.setName(val)
 
1672
            stackObj = SaxStackElement('Attribute', obj)
 
1673
            self.stack.append(stackObj)
 
1674
            done = 1
 
1675
        elif name == 'CustomAttributes':
 
1676
            stackObj = SaxStackElement('CustomAttributes', None)
 
1677
            self.stack.append(stackObj)
 
1678
            done = 1
 
1679
        elif name == 'ClassDeclarations':
 
1680
            stackObj = SaxStackElement('ClassDeclarations', None)
 
1681
            self.stack.append(stackObj)
 
1682
            done = 1
 
1683
        elif name == 'Dependencies':
 
1684
            obj = Dependencies.factory()
 
1685
            stackObj = SaxStackElement('Dependencies', obj)
 
1686
            self.stack.append(stackObj)
 
1687
            done = 1
 
1688
        elif name == 'Content':
 
1689
            obj = Content.factory()
 
1690
            stackObj = SaxStackElement('Content', obj)
 
1691
            self.stack.append(stackObj)
 
1692
            done = 1
 
1693
        elif name == 'Property':
 
1694
            obj = Property.factory()
 
1695
            stackObj = SaxStackElement('Property', obj)
 
1696
            self.stack.append(stackObj)
 
1697
            done = 1
 
1698
        elif name == 'Feature':
 
1699
            obj = Feature.factory()
 
1700
            val = attrs.get('Name', None)
 
1701
            if val is not None:
 
1702
                obj.setName(val)
 
1703
            stackObj = SaxStackElement('Feature', obj)
 
1704
            self.stack.append(stackObj)
 
1705
            done = 1
 
1706
        elif name == 'ViewProvider':
 
1707
            obj = ViewProvider.factory()
 
1708
            stackObj = SaxStackElement('ViewProvider', obj)
 
1709
            self.stack.append(stackObj)
 
1710
            done = 1
 
1711
        elif name == 'DocObject':
 
1712
            obj = DocObject.factory()
 
1713
            val = attrs.get('Name', None)
 
1714
            if val is not None:
 
1715
                obj.setName(val)
 
1716
            stackObj = SaxStackElement('DocObject', obj)
 
1717
            self.stack.append(stackObj)
 
1718
            done = 1
 
1719
        elif name == 'GuiCommand':
 
1720
            stackObj = SaxStackElement('GuiCommand', None)
 
1721
            self.stack.append(stackObj)
 
1722
            done = 1
 
1723
        elif name == 'PreferencesPage':
 
1724
            stackObj = SaxStackElement('PreferencesPage', None)
 
1725
            self.stack.append(stackObj)
 
1726
            done = 1
 
1727
        elif name == 'Author':
 
1728
            obj = Author.factory()
 
1729
            val = attrs.get('Name', None)
 
1730
            if val is not None:
 
1731
                obj.setName(val)
 
1732
            val = attrs.get('Licence', None)
 
1733
            if val is not None:
 
1734
                obj.setLicence(val)
 
1735
            val = attrs.get('EMail', None)
 
1736
            if val is not None:
 
1737
                obj.setEmail(val)
 
1738
            stackObj = SaxStackElement('Author', obj)
 
1739
            self.stack.append(stackObj)
 
1740
            done = 1
 
1741
        elif name == 'DeveloperDocu':
 
1742
            stackObj = SaxStackElement('DeveloperDocu', None)
 
1743
            self.stack.append(stackObj)
 
1744
            done = 1
 
1745
        elif name == 'UserDocu':
 
1746
            stackObj = SaxStackElement('UserDocu', None)
 
1747
            self.stack.append(stackObj)
 
1748
            done = 1
 
1749
        if not done:
 
1750
            self.reportError('"%s" element not allowed here.' % name)
 
1751
 
 
1752
    def endElement(self, name):
 
1753
        done = 0
 
1754
        if name == 'GenerateModel':
 
1755
            if len(self.stack) == 1:
 
1756
                self.root = self.stack[-1].obj
 
1757
                self.stack.pop()
 
1758
                done = 1
 
1759
        elif name == 'Module':
 
1760
            if len(self.stack) >= 2:
 
1761
                self.stack[-2].obj.addModule(self.stack[-1].obj)
 
1762
                self.stack.pop()
 
1763
                done = 1
 
1764
        elif name == 'PythonExport':
 
1765
            if len(self.stack) >= 2:
 
1766
                self.stack[-2].obj.addPythonexport(self.stack[-1].obj)
 
1767
                self.stack.pop()
 
1768
                done = 1
 
1769
        elif name == 'Documentation':
 
1770
            if len(self.stack) >= 2:
 
1771
                self.stack[-2].obj.setDocumentation(self.stack[-1].obj)
 
1772
                self.stack.pop()
 
1773
                done = 1
 
1774
        elif name == 'Methode':
 
1775
            if len(self.stack) >= 2:
 
1776
                self.stack[-2].obj.addMethode(self.stack[-1].obj)
 
1777
                self.stack.pop()
 
1778
                done = 1
 
1779
        elif name == 'Parameter':
 
1780
            if len(self.stack) >= 2:
 
1781
                self.stack[-2].obj.addParameter(self.stack[-1].obj)
 
1782
                self.stack.pop()
 
1783
                done = 1
 
1784
        elif name == 'Attribute':
 
1785
            if len(self.stack) >= 2:
 
1786
                self.stack[-2].obj.addAttribute(self.stack[-1].obj)
 
1787
                self.stack.pop()
 
1788
                done = 1
 
1789
        elif name == 'CustomAttributes':
 
1790
            if len(self.stack) >= 2:
 
1791
                content = self.stack[-1].content
 
1792
                self.stack[-2].obj.setCustomattributes(content)
 
1793
                self.stack.pop()
 
1794
                done = 1
 
1795
        elif name == 'ClassDeclarations':
 
1796
            if len(self.stack) >= 2:
 
1797
                content = self.stack[-1].content
 
1798
                self.stack[-2].obj.setClassdeclarations(content)
 
1799
                self.stack.pop()
 
1800
                done = 1
 
1801
        elif name == 'Dependencies':
 
1802
            if len(self.stack) >= 2:
 
1803
                self.stack[-2].obj.setDependencies(self.stack[-1].obj)
 
1804
                self.stack.pop()
 
1805
                done = 1
 
1806
        elif name == 'Content':
 
1807
            if len(self.stack) >= 2:
 
1808
                self.stack[-2].obj.setContent(self.stack[-1].obj)
 
1809
                self.stack.pop()
 
1810
                done = 1
 
1811
        elif name == 'Property':
 
1812
            if len(self.stack) >= 2:
 
1813
                self.stack[-2].obj.addProperty(self.stack[-1].obj)
 
1814
                self.stack.pop()
 
1815
                done = 1
 
1816
        elif name == 'Feature':
 
1817
            if len(self.stack) >= 2:
 
1818
                self.stack[-2].obj.addFeature(self.stack[-1].obj)
 
1819
                self.stack.pop()
 
1820
                done = 1
 
1821
        elif name == 'ViewProvider':
 
1822
            if len(self.stack) >= 2:
 
1823
                self.stack[-2].obj.setViewprovider(self.stack[-1].obj)
 
1824
                self.stack.pop()
 
1825
                done = 1
 
1826
        elif name == 'DocObject':
 
1827
            if len(self.stack) >= 2:
 
1828
                self.stack[-2].obj.addDocobject(self.stack[-1].obj)
 
1829
                self.stack.pop()
 
1830
                done = 1
 
1831
        elif name == 'GuiCommand':
 
1832
            if len(self.stack) >= 2:
 
1833
                content = self.stack[-1].content
 
1834
                self.stack[-2].obj.addGuicommand(content)
 
1835
                self.stack.pop()
 
1836
                done = 1
 
1837
        elif name == 'PreferencesPage':
 
1838
            if len(self.stack) >= 2:
 
1839
                content = self.stack[-1].content
 
1840
                self.stack[-2].obj.addPreferencespage(content)
 
1841
                self.stack.pop()
 
1842
                done = 1
 
1843
        elif name == 'Author':
 
1844
            if len(self.stack) >= 2:
 
1845
                self.stack[-2].obj.setAuthor(self.stack[-1].obj)
 
1846
                self.stack.pop()
 
1847
                done = 1
 
1848
        elif name == 'DeveloperDocu':
 
1849
            if len(self.stack) >= 2:
 
1850
                content = self.stack[-1].content
 
1851
                self.stack[-2].obj.setDeveloperdocu(content)
 
1852
                self.stack.pop()
 
1853
                done = 1
 
1854
        elif name == 'UserDocu':
 
1855
            if len(self.stack) >= 2:
 
1856
                content = self.stack[-1].content
 
1857
                self.stack[-2].obj.setUserdocu(content)
 
1858
                self.stack.pop()
 
1859
                done = 1
 
1860
        if not done:
 
1861
            self.reportError('"%s" element not allowed here.' % name)
 
1862
 
 
1863
    def characters(self, chrs, start, end):
 
1864
        if len(self.stack) > 0:
 
1865
            self.stack[-1].content += chrs[start:end]
 
1866
 
 
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')
 
1874
        sys.exit(-1)
 
1875
        #raise RuntimeError
 
1876
 
 
1877
USAGE_TEXT = """
 
1878
Usage: python <Parser>.py [ -s ] <in_xml_file>
 
1879
Options:
 
1880
    -s        Use the SAX parser, not the minidom parser.
 
1881
"""
 
1882
 
 
1883
def usage():
 
1884
    print USAGE_TEXT
 
1885
    sys.exit(-1)
 
1886
 
 
1887
 
 
1888
#
 
1889
# SAX handler used to determine the top level element.
 
1890
#
 
1891
class SaxSelectorHandler(handler.ContentHandler):
 
1892
    def __init__(self):
 
1893
        self.topElementName = None
 
1894
    def getTopElementName(self):
 
1895
        return self.topElementName
 
1896
    def startElement(self, name, attrs):
 
1897
        self.topElementName = name
 
1898
        raise StopIteration
 
1899
 
 
1900
 
 
1901
def parseSelect(inFileName):
 
1902
    infile = file(inFileName, 'r')
 
1903
    topElementName = None
 
1904
    parser = make_parser()
 
1905
    documentHandler = SaxSelectorHandler()
 
1906
    parser.setContentHandler(documentHandler)
 
1907
    try:
 
1908
        try:
 
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]
 
1918
        infile.seek(0)
 
1919
        doc = minidom.parse(infile)
 
1920
    finally:
 
1921
        infile.close()
 
1922
    rootNode = doc.childNodes[0]
 
1923
    rootObj = topElement.factory()
 
1924
    rootObj.build(rootNode)
 
1925
    # Enable Python to collect the space used by the DOM.
 
1926
    doc = None
 
1927
    sys.stdout.write('<?xml version="1.0" ?>\n')
 
1928
    rootObj.export(sys.stdout, 0)
 
1929
    return rootObj
 
1930
 
 
1931
 
 
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)
 
1940
    return root
 
1941
 
 
1942
 
 
1943
def saxParseString(inString):
 
1944
    parser = make_parser()
 
1945
    documentHandler = SaxGeneratemodelHandler()
 
1946
    parser.setDocumentHandler(documentHandler)
 
1947
    parser.feed(inString)
 
1948
    parser.close()
 
1949
    rootObj = documentHandler.getRoot()
 
1950
    #sys.stdout.write('<?xml version="1.0" ?>\n')
 
1951
    #rootObj.export(sys.stdout, 0)
 
1952
    return rootObj
 
1953
 
 
1954
 
 
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.
 
1961
    doc = None
 
1962
    sys.stdout.write('<?xml version="1.0" ?>\n')
 
1963
    rootObj.export(sys.stdout, 0, name_="GenerateModel")
 
1964
    return rootObj
 
1965
 
 
1966
 
 
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.
 
1973
    doc = None
 
1974
    sys.stdout.write('<?xml version="1.0" ?>\n')
 
1975
    rootObj.export(sys.stdout, 0, name_="GenerateModel")
 
1976
    return rootObj
 
1977
 
 
1978
 
 
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.
 
1985
    doc = None
 
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')
 
1990
    return rootObj
 
1991
 
 
1992
 
 
1993
def main():
 
1994
    args = sys.argv[1:]
 
1995
    if len(args) == 2 and args[0] == '-s':
 
1996
        saxParse(args[1])
 
1997
    elif len(args) == 1:
 
1998
        parse(args[0])
 
1999
    else:
 
2000
        usage()
 
2001
 
 
2002
 
 
2003
if __name__ == '__main__':
 
2004
    main()
 
2005
    #import pdb
 
2006
    #pdb.run('main()')
 
2007