karrio-canadapost 2025.5rc1__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (41) hide show
  1. karrio/mappers/canadapost/__init__.py +3 -0
  2. karrio/mappers/canadapost/mapper.py +88 -0
  3. karrio/mappers/canadapost/proxy.py +373 -0
  4. karrio/mappers/canadapost/settings.py +23 -0
  5. karrio/plugins/canadapost/__init__.py +23 -0
  6. karrio/providers/canadapost/__init__.py +25 -0
  7. karrio/providers/canadapost/error.py +42 -0
  8. karrio/providers/canadapost/manifest.py +127 -0
  9. karrio/providers/canadapost/pickup/__init__.py +3 -0
  10. karrio/providers/canadapost/pickup/cancel.py +33 -0
  11. karrio/providers/canadapost/pickup/create.py +217 -0
  12. karrio/providers/canadapost/pickup/update.py +55 -0
  13. karrio/providers/canadapost/rate.py +192 -0
  14. karrio/providers/canadapost/shipment/__init__.py +8 -0
  15. karrio/providers/canadapost/shipment/cancel.py +53 -0
  16. karrio/providers/canadapost/shipment/create.py +308 -0
  17. karrio/providers/canadapost/tracking.py +75 -0
  18. karrio/providers/canadapost/units.py +285 -0
  19. karrio/providers/canadapost/utils.py +92 -0
  20. karrio/schemas/canadapost/__init__.py +0 -0
  21. karrio/schemas/canadapost/authreturn.py +3389 -0
  22. karrio/schemas/canadapost/common.py +2037 -0
  23. karrio/schemas/canadapost/customerinfo.py +2307 -0
  24. karrio/schemas/canadapost/discovery.py +3016 -0
  25. karrio/schemas/canadapost/manifest.py +3704 -0
  26. karrio/schemas/canadapost/merchantregistration.py +1498 -0
  27. karrio/schemas/canadapost/messages.py +1431 -0
  28. karrio/schemas/canadapost/ncshipment.py +7231 -0
  29. karrio/schemas/canadapost/openreturn.py +2438 -0
  30. karrio/schemas/canadapost/pickup.py +1407 -0
  31. karrio/schemas/canadapost/pickuprequest.py +6794 -0
  32. karrio/schemas/canadapost/postoffice.py +2240 -0
  33. karrio/schemas/canadapost/rating.py +5308 -0
  34. karrio/schemas/canadapost/serviceinfo.py +1505 -0
  35. karrio/schemas/canadapost/shipment.py +9982 -0
  36. karrio/schemas/canadapost/track.py +3100 -0
  37. karrio_canadapost-2025.5rc1.dist-info/METADATA +44 -0
  38. karrio_canadapost-2025.5rc1.dist-info/RECORD +41 -0
  39. karrio_canadapost-2025.5rc1.dist-info/WHEEL +5 -0
  40. karrio_canadapost-2025.5rc1.dist-info/entry_points.txt +2 -0
  41. karrio_canadapost-2025.5rc1.dist-info/top_level.txt +3 -0
@@ -0,0 +1,2037 @@
1
+ #!/usr/bin/env python
2
+ # -*- coding: utf-8 -*-
3
+
4
+ #
5
+ # Generated Sat Mar 16 02:19:28 2024 by generateDS.py version 2.43.3.
6
+ # Python 3.12.2 (main, Feb 28 2024, 21:12:07) [GCC 11.4.0]
7
+ #
8
+ # Command line options:
9
+ # ('--no-namespace-defs', '')
10
+ # ('-o', './karrio/schemas/canadapost/common.py')
11
+ #
12
+ # Command line arguments:
13
+ # ./schemas/common.xsd
14
+ #
15
+ # Command line:
16
+ # /home/kserver/Workspace/karrio/.venv/karrio/bin/generateDS --no-namespace-defs -o "./karrio/schemas/canadapost/common.py" ./schemas/common.xsd
17
+ #
18
+ # Current working directory (os.getcwd()):
19
+ # canadapost
20
+ #
21
+
22
+ import sys
23
+ try:
24
+ ModulenotfoundExp_ = ModuleNotFoundError
25
+ except NameError:
26
+ ModulenotfoundExp_ = ImportError
27
+ from six.moves import zip_longest
28
+ import os
29
+ import re as re_
30
+ import base64
31
+ import datetime as datetime_
32
+ import decimal as decimal_
33
+ from lxml import etree as etree_
34
+
35
+
36
+ Validate_simpletypes_ = True
37
+ SaveElementTreeNode = True
38
+ TagNamePrefix = ""
39
+ if sys.version_info.major == 2:
40
+ BaseStrType_ = basestring
41
+ else:
42
+ BaseStrType_ = str
43
+
44
+
45
+ def parsexml_(infile, parser=None, **kwargs):
46
+ if parser is None:
47
+ # Use the lxml ElementTree compatible parser so that, e.g.,
48
+ # we ignore comments.
49
+ try:
50
+ parser = etree_.ETCompatXMLParser()
51
+ except AttributeError:
52
+ # fallback to xml.etree
53
+ parser = etree_.XMLParser()
54
+ try:
55
+ if isinstance(infile, os.PathLike):
56
+ infile = os.path.join(infile)
57
+ except AttributeError:
58
+ pass
59
+ doc = etree_.parse(infile, parser=parser, **kwargs)
60
+ return doc
61
+
62
+ def parsexmlstring_(instring, parser=None, **kwargs):
63
+ if parser is None:
64
+ # Use the lxml ElementTree compatible parser so that, e.g.,
65
+ # we ignore comments.
66
+ try:
67
+ parser = etree_.ETCompatXMLParser()
68
+ except AttributeError:
69
+ # fallback to xml.etree
70
+ parser = etree_.XMLParser()
71
+ element = etree_.fromstring(instring, parser=parser, **kwargs)
72
+ return element
73
+
74
+ #
75
+ # Namespace prefix definition table (and other attributes, too)
76
+ #
77
+ # The module generatedsnamespaces, if it is importable, must contain
78
+ # a dictionary named GeneratedsNamespaceDefs. This Python dictionary
79
+ # should map element type names (strings) to XML schema namespace prefix
80
+ # definitions. The export method for any class for which there is
81
+ # a namespace prefix definition, will export that definition in the
82
+ # XML representation of that element. See the export method of
83
+ # any generated element type class for an example of the use of this
84
+ # table.
85
+ # A sample table is:
86
+ #
87
+ # # File: generatedsnamespaces.py
88
+ #
89
+ # GenerateDSNamespaceDefs = {
90
+ # "ElementtypeA": "http://www.xxx.com/namespaceA",
91
+ # "ElementtypeB": "http://www.xxx.com/namespaceB",
92
+ # }
93
+ #
94
+ # Additionally, the generatedsnamespaces module can contain a python
95
+ # dictionary named GenerateDSNamespaceTypePrefixes that associates element
96
+ # types with the namespace prefixes that are to be added to the
97
+ # "xsi:type" attribute value. See the _exportAttributes method of
98
+ # any generated element type and the generation of "xsi:type" for an
99
+ # example of the use of this table.
100
+ # An example table:
101
+ #
102
+ # # File: generatedsnamespaces.py
103
+ #
104
+ # GenerateDSNamespaceTypePrefixes = {
105
+ # "ElementtypeC": "aaa:",
106
+ # "ElementtypeD": "bbb:",
107
+ # }
108
+ #
109
+
110
+ try:
111
+ from generatedsnamespaces import GenerateDSNamespaceDefs as GenerateDSNamespaceDefs_
112
+ except ModulenotfoundExp_ :
113
+ GenerateDSNamespaceDefs_ = {}
114
+ try:
115
+ from generatedsnamespaces import GenerateDSNamespaceTypePrefixes as GenerateDSNamespaceTypePrefixes_
116
+ except ModulenotfoundExp_ :
117
+ GenerateDSNamespaceTypePrefixes_ = {}
118
+
119
+ #
120
+ # You can replace the following class definition by defining an
121
+ # importable module named "generatedscollector" containing a class
122
+ # named "GdsCollector". See the default class definition below for
123
+ # clues about the possible content of that class.
124
+ #
125
+ try:
126
+ from generatedscollector import GdsCollector as GdsCollector_
127
+ except ModulenotfoundExp_ :
128
+
129
+ class GdsCollector_(object):
130
+
131
+ def __init__(self, messages=None):
132
+ if messages is None:
133
+ self.messages = []
134
+ else:
135
+ self.messages = messages
136
+
137
+ def add_message(self, msg):
138
+ self.messages.append(msg)
139
+
140
+ def get_messages(self):
141
+ return self.messages
142
+
143
+ def clear_messages(self):
144
+ self.messages = []
145
+
146
+ def print_messages(self):
147
+ for msg in self.messages:
148
+ print("Warning: {}".format(msg))
149
+
150
+ def write_messages(self, outstream):
151
+ for msg in self.messages:
152
+ outstream.write("Warning: {}\n".format(msg))
153
+
154
+
155
+ #
156
+ # The super-class for enum types
157
+ #
158
+
159
+ try:
160
+ from enum import Enum
161
+ except ModulenotfoundExp_ :
162
+ Enum = object
163
+
164
+ #
165
+ # The root super-class for element type classes
166
+ #
167
+ # Calls to the methods in these classes are generated by generateDS.py.
168
+ # You can replace these methods by re-implementing the following class
169
+ # in a module named generatedssuper.py.
170
+
171
+ try:
172
+ from generatedssuper import GeneratedsSuper
173
+ except ModulenotfoundExp_ as exp:
174
+ try:
175
+ from generatedssupersuper import GeneratedsSuperSuper
176
+ except ModulenotfoundExp_ as exp:
177
+ class GeneratedsSuperSuper(object):
178
+ pass
179
+
180
+ class GeneratedsSuper(GeneratedsSuperSuper):
181
+ __hash__ = object.__hash__
182
+ tzoff_pattern = re_.compile(r'(\+|-)((0\d|1[0-3]):[0-5]\d|14:00)$')
183
+ class _FixedOffsetTZ(datetime_.tzinfo):
184
+ def __init__(self, offset, name):
185
+ self.__offset = datetime_.timedelta(minutes=offset)
186
+ self.__name = name
187
+ def utcoffset(self, dt):
188
+ return self.__offset
189
+ def tzname(self, dt):
190
+ return self.__name
191
+ def dst(self, dt):
192
+ return None
193
+ def __str__(self):
194
+ settings = {
195
+ 'str_pretty_print': True,
196
+ 'str_indent_level': 0,
197
+ 'str_namespaceprefix': '',
198
+ 'str_name': self.__class__.__name__,
199
+ 'str_namespacedefs': '',
200
+ }
201
+ for n in settings:
202
+ if hasattr(self, n):
203
+ settings[n] = getattr(self, n)
204
+ if sys.version_info.major == 2:
205
+ from StringIO import StringIO
206
+ else:
207
+ from io import StringIO
208
+ output = StringIO()
209
+ self.export(
210
+ output,
211
+ settings['str_indent_level'],
212
+ pretty_print=settings['str_pretty_print'],
213
+ namespaceprefix_=settings['str_namespaceprefix'],
214
+ name_=settings['str_name'],
215
+ namespacedef_=settings['str_namespacedefs']
216
+ )
217
+ strval = output.getvalue()
218
+ output.close()
219
+ return strval
220
+ def gds_format_string(self, input_data, input_name=''):
221
+ return input_data
222
+ def gds_parse_string(self, input_data, node=None, input_name=''):
223
+ return input_data
224
+ def gds_validate_string(self, input_data, node=None, input_name=''):
225
+ if not input_data:
226
+ return ''
227
+ else:
228
+ return input_data
229
+ def gds_format_base64(self, input_data, input_name=''):
230
+ return base64.b64encode(input_data).decode('ascii')
231
+ def gds_validate_base64(self, input_data, node=None, input_name=''):
232
+ return input_data
233
+ def gds_format_integer(self, input_data, input_name=''):
234
+ return '%d' % int(input_data)
235
+ def gds_parse_integer(self, input_data, node=None, input_name=''):
236
+ try:
237
+ ival = int(input_data)
238
+ except (TypeError, ValueError) as exp:
239
+ raise_parse_error(node, 'Requires integer value: %s' % exp)
240
+ return ival
241
+ def gds_validate_integer(self, input_data, node=None, input_name=''):
242
+ try:
243
+ value = int(input_data)
244
+ except (TypeError, ValueError):
245
+ raise_parse_error(node, 'Requires integer value')
246
+ return value
247
+ def gds_format_integer_list(self, input_data, input_name=''):
248
+ if len(input_data) > 0 and not isinstance(input_data[0], BaseStrType_):
249
+ input_data = [str(s) for s in input_data]
250
+ return '%s' % ' '.join(input_data)
251
+ def gds_validate_integer_list(
252
+ self, input_data, node=None, input_name=''):
253
+ values = input_data.split()
254
+ for value in values:
255
+ try:
256
+ int(value)
257
+ except (TypeError, ValueError):
258
+ raise_parse_error(node, 'Requires sequence of integer values')
259
+ return values
260
+ def gds_format_float(self, input_data, input_name=''):
261
+ value = ('%.15f' % float(input_data)).rstrip('0')
262
+ if value.endswith('.'):
263
+ value += '0'
264
+ return value
265
+
266
+ def gds_parse_float(self, input_data, node=None, input_name=''):
267
+ try:
268
+ fval_ = float(input_data)
269
+ except (TypeError, ValueError) as exp:
270
+ raise_parse_error(node, 'Requires float or double value: %s' % exp)
271
+ return fval_
272
+ def gds_validate_float(self, input_data, node=None, input_name=''):
273
+ try:
274
+ value = float(input_data)
275
+ except (TypeError, ValueError):
276
+ raise_parse_error(node, 'Requires float value')
277
+ return value
278
+ def gds_format_float_list(self, input_data, input_name=''):
279
+ if len(input_data) > 0 and not isinstance(input_data[0], BaseStrType_):
280
+ input_data = [str(s) for s in input_data]
281
+ return '%s' % ' '.join(input_data)
282
+ def gds_validate_float_list(
283
+ self, input_data, node=None, input_name=''):
284
+ values = input_data.split()
285
+ for value in values:
286
+ try:
287
+ float(value)
288
+ except (TypeError, ValueError):
289
+ raise_parse_error(node, 'Requires sequence of float values')
290
+ return values
291
+ def gds_format_decimal(self, input_data, input_name=''):
292
+ return_value = '%s' % input_data
293
+ if '.' in return_value:
294
+ return_value = return_value.rstrip('0')
295
+ if return_value.endswith('.'):
296
+ return_value = return_value.rstrip('.')
297
+ return return_value
298
+ def gds_parse_decimal(self, input_data, node=None, input_name=''):
299
+ try:
300
+ decimal_value = decimal_.Decimal(input_data)
301
+ except (TypeError, ValueError):
302
+ raise_parse_error(node, 'Requires decimal value')
303
+ return decimal_value
304
+ def gds_validate_decimal(self, input_data, node=None, input_name=''):
305
+ try:
306
+ value = decimal_.Decimal(input_data)
307
+ except (TypeError, ValueError):
308
+ raise_parse_error(node, 'Requires decimal value')
309
+ return value
310
+ def gds_format_decimal_list(self, input_data, input_name=''):
311
+ if len(input_data) > 0 and not isinstance(input_data[0], BaseStrType_):
312
+ input_data = [str(s) for s in input_data]
313
+ return ' '.join([self.gds_format_decimal(item) for item in input_data])
314
+ def gds_validate_decimal_list(
315
+ self, input_data, node=None, input_name=''):
316
+ values = input_data.split()
317
+ for value in values:
318
+ try:
319
+ decimal_.Decimal(value)
320
+ except (TypeError, ValueError):
321
+ raise_parse_error(node, 'Requires sequence of decimal values')
322
+ return values
323
+ def gds_format_double(self, input_data, input_name=''):
324
+ return '%s' % input_data
325
+ def gds_parse_double(self, input_data, node=None, input_name=''):
326
+ try:
327
+ fval_ = float(input_data)
328
+ except (TypeError, ValueError) as exp:
329
+ raise_parse_error(node, 'Requires double or float value: %s' % exp)
330
+ return fval_
331
+ def gds_validate_double(self, input_data, node=None, input_name=''):
332
+ try:
333
+ value = float(input_data)
334
+ except (TypeError, ValueError):
335
+ raise_parse_error(node, 'Requires double or float value')
336
+ return value
337
+ def gds_format_double_list(self, input_data, input_name=''):
338
+ if len(input_data) > 0 and not isinstance(input_data[0], BaseStrType_):
339
+ input_data = [str(s) for s in input_data]
340
+ return '%s' % ' '.join(input_data)
341
+ def gds_validate_double_list(
342
+ self, input_data, node=None, input_name=''):
343
+ values = input_data.split()
344
+ for value in values:
345
+ try:
346
+ float(value)
347
+ except (TypeError, ValueError):
348
+ raise_parse_error(
349
+ node, 'Requires sequence of double or float values')
350
+ return values
351
+ def gds_format_boolean(self, input_data, input_name=''):
352
+ return ('%s' % input_data).lower()
353
+ def gds_parse_boolean(self, input_data, node=None, input_name=''):
354
+ input_data = input_data.strip()
355
+ if input_data in ('true', '1'):
356
+ bval = True
357
+ elif input_data in ('false', '0'):
358
+ bval = False
359
+ else:
360
+ raise_parse_error(node, 'Requires boolean value')
361
+ return bval
362
+ def gds_validate_boolean(self, input_data, node=None, input_name=''):
363
+ if input_data not in (True, 1, False, 0, ):
364
+ raise_parse_error(
365
+ node,
366
+ 'Requires boolean value '
367
+ '(one of True, 1, False, 0)')
368
+ return input_data
369
+ def gds_format_boolean_list(self, input_data, input_name=''):
370
+ if len(input_data) > 0 and not isinstance(input_data[0], BaseStrType_):
371
+ input_data = [str(s) for s in input_data]
372
+ return '%s' % ' '.join(input_data)
373
+ def gds_validate_boolean_list(
374
+ self, input_data, node=None, input_name=''):
375
+ values = input_data.split()
376
+ for value in values:
377
+ value = self.gds_parse_boolean(value, node, input_name)
378
+ if value not in (True, 1, False, 0, ):
379
+ raise_parse_error(
380
+ node,
381
+ 'Requires sequence of boolean values '
382
+ '(one of True, 1, False, 0)')
383
+ return values
384
+ def gds_validate_datetime(self, input_data, node=None, input_name=''):
385
+ return input_data
386
+ def gds_format_datetime(self, input_data, input_name=''):
387
+ if input_data.microsecond == 0:
388
+ _svalue = '%04d-%02d-%02dT%02d:%02d:%02d' % (
389
+ input_data.year,
390
+ input_data.month,
391
+ input_data.day,
392
+ input_data.hour,
393
+ input_data.minute,
394
+ input_data.second,
395
+ )
396
+ else:
397
+ _svalue = '%04d-%02d-%02dT%02d:%02d:%02d.%s' % (
398
+ input_data.year,
399
+ input_data.month,
400
+ input_data.day,
401
+ input_data.hour,
402
+ input_data.minute,
403
+ input_data.second,
404
+ ('%f' % (float(input_data.microsecond) / 1000000))[2:],
405
+ )
406
+ if input_data.tzinfo is not None:
407
+ tzoff = input_data.tzinfo.utcoffset(input_data)
408
+ if tzoff is not None:
409
+ total_seconds = tzoff.seconds + (86400 * tzoff.days)
410
+ if total_seconds == 0:
411
+ _svalue += 'Z'
412
+ else:
413
+ if total_seconds < 0:
414
+ _svalue += '-'
415
+ total_seconds *= -1
416
+ else:
417
+ _svalue += '+'
418
+ hours = total_seconds // 3600
419
+ minutes = (total_seconds - (hours * 3600)) // 60
420
+ _svalue += '{0:02d}:{1:02d}'.format(hours, minutes)
421
+ return _svalue
422
+ @classmethod
423
+ def gds_parse_datetime(cls, input_data):
424
+ tz = None
425
+ if input_data[-1] == 'Z':
426
+ tz = GeneratedsSuper._FixedOffsetTZ(0, 'UTC')
427
+ input_data = input_data[:-1]
428
+ else:
429
+ results = GeneratedsSuper.tzoff_pattern.search(input_data)
430
+ if results is not None:
431
+ tzoff_parts = results.group(2).split(':')
432
+ tzoff = int(tzoff_parts[0]) * 60 + int(tzoff_parts[1])
433
+ if results.group(1) == '-':
434
+ tzoff *= -1
435
+ tz = GeneratedsSuper._FixedOffsetTZ(
436
+ tzoff, results.group(0))
437
+ input_data = input_data[:-6]
438
+ time_parts = input_data.split('.')
439
+ if len(time_parts) > 1:
440
+ micro_seconds = int(float('0.' + time_parts[1]) * 1000000)
441
+ input_data = '%s.%s' % (
442
+ time_parts[0], "{}".format(micro_seconds).rjust(6, "0"), )
443
+ dt = datetime_.datetime.strptime(
444
+ input_data, '%Y-%m-%dT%H:%M:%S.%f')
445
+ else:
446
+ dt = datetime_.datetime.strptime(
447
+ input_data, '%Y-%m-%dT%H:%M:%S')
448
+ dt = dt.replace(tzinfo=tz)
449
+ return dt
450
+ def gds_validate_date(self, input_data, node=None, input_name=''):
451
+ return input_data
452
+ def gds_format_date(self, input_data, input_name=''):
453
+ _svalue = '%04d-%02d-%02d' % (
454
+ input_data.year,
455
+ input_data.month,
456
+ input_data.day,
457
+ )
458
+ try:
459
+ if input_data.tzinfo is not None:
460
+ tzoff = input_data.tzinfo.utcoffset(input_data)
461
+ if tzoff is not None:
462
+ total_seconds = tzoff.seconds + (86400 * tzoff.days)
463
+ if total_seconds == 0:
464
+ _svalue += 'Z'
465
+ else:
466
+ if total_seconds < 0:
467
+ _svalue += '-'
468
+ total_seconds *= -1
469
+ else:
470
+ _svalue += '+'
471
+ hours = total_seconds // 3600
472
+ minutes = (total_seconds - (hours * 3600)) // 60
473
+ _svalue += '{0:02d}:{1:02d}'.format(
474
+ hours, minutes)
475
+ except AttributeError:
476
+ pass
477
+ return _svalue
478
+ @classmethod
479
+ def gds_parse_date(cls, input_data):
480
+ tz = None
481
+ if input_data[-1] == 'Z':
482
+ tz = GeneratedsSuper._FixedOffsetTZ(0, 'UTC')
483
+ input_data = input_data[:-1]
484
+ else:
485
+ results = GeneratedsSuper.tzoff_pattern.search(input_data)
486
+ if results is not None:
487
+ tzoff_parts = results.group(2).split(':')
488
+ tzoff = int(tzoff_parts[0]) * 60 + int(tzoff_parts[1])
489
+ if results.group(1) == '-':
490
+ tzoff *= -1
491
+ tz = GeneratedsSuper._FixedOffsetTZ(
492
+ tzoff, results.group(0))
493
+ input_data = input_data[:-6]
494
+ dt = datetime_.datetime.strptime(input_data, '%Y-%m-%d')
495
+ dt = dt.replace(tzinfo=tz)
496
+ return dt.date()
497
+ def gds_validate_time(self, input_data, node=None, input_name=''):
498
+ return input_data
499
+ def gds_format_time(self, input_data, input_name=''):
500
+ if input_data.microsecond == 0:
501
+ _svalue = '%02d:%02d:%02d' % (
502
+ input_data.hour,
503
+ input_data.minute,
504
+ input_data.second,
505
+ )
506
+ else:
507
+ _svalue = '%02d:%02d:%02d.%s' % (
508
+ input_data.hour,
509
+ input_data.minute,
510
+ input_data.second,
511
+ ('%f' % (float(input_data.microsecond) / 1000000))[2:],
512
+ )
513
+ if input_data.tzinfo is not None:
514
+ tzoff = input_data.tzinfo.utcoffset(input_data)
515
+ if tzoff is not None:
516
+ total_seconds = tzoff.seconds + (86400 * tzoff.days)
517
+ if total_seconds == 0:
518
+ _svalue += 'Z'
519
+ else:
520
+ if total_seconds < 0:
521
+ _svalue += '-'
522
+ total_seconds *= -1
523
+ else:
524
+ _svalue += '+'
525
+ hours = total_seconds // 3600
526
+ minutes = (total_seconds - (hours * 3600)) // 60
527
+ _svalue += '{0:02d}:{1:02d}'.format(hours, minutes)
528
+ return _svalue
529
+ def gds_validate_simple_patterns(self, patterns, target):
530
+ # pat is a list of lists of strings/patterns.
531
+ # The target value must match at least one of the patterns
532
+ # in order for the test to succeed.
533
+ found1 = True
534
+ target = str(target)
535
+ for patterns1 in patterns:
536
+ found2 = False
537
+ for patterns2 in patterns1:
538
+ mo = re_.search(patterns2, target)
539
+ if mo is not None and len(mo.group(0)) == len(target):
540
+ found2 = True
541
+ break
542
+ if not found2:
543
+ found1 = False
544
+ break
545
+ return found1
546
+ @classmethod
547
+ def gds_parse_time(cls, input_data):
548
+ tz = None
549
+ if input_data[-1] == 'Z':
550
+ tz = GeneratedsSuper._FixedOffsetTZ(0, 'UTC')
551
+ input_data = input_data[:-1]
552
+ else:
553
+ results = GeneratedsSuper.tzoff_pattern.search(input_data)
554
+ if results is not None:
555
+ tzoff_parts = results.group(2).split(':')
556
+ tzoff = int(tzoff_parts[0]) * 60 + int(tzoff_parts[1])
557
+ if results.group(1) == '-':
558
+ tzoff *= -1
559
+ tz = GeneratedsSuper._FixedOffsetTZ(
560
+ tzoff, results.group(0))
561
+ input_data = input_data[:-6]
562
+ if len(input_data.split('.')) > 1:
563
+ dt = datetime_.datetime.strptime(input_data, '%H:%M:%S.%f')
564
+ else:
565
+ dt = datetime_.datetime.strptime(input_data, '%H:%M:%S')
566
+ dt = dt.replace(tzinfo=tz)
567
+ return dt.time()
568
+ def gds_check_cardinality_(
569
+ self, value, input_name,
570
+ min_occurs=0, max_occurs=1, required=None):
571
+ if value is None:
572
+ length = 0
573
+ elif isinstance(value, list):
574
+ length = len(value)
575
+ else:
576
+ length = 1
577
+ if required is not None :
578
+ if required and length < 1:
579
+ self.gds_collector_.add_message(
580
+ "Required value {}{} is missing".format(
581
+ input_name, self.gds_get_node_lineno_()))
582
+ if length < min_occurs:
583
+ self.gds_collector_.add_message(
584
+ "Number of values for {}{} is below "
585
+ "the minimum allowed, "
586
+ "expected at least {}, found {}".format(
587
+ input_name, self.gds_get_node_lineno_(),
588
+ min_occurs, length))
589
+ elif length > max_occurs:
590
+ self.gds_collector_.add_message(
591
+ "Number of values for {}{} is above "
592
+ "the maximum allowed, "
593
+ "expected at most {}, found {}".format(
594
+ input_name, self.gds_get_node_lineno_(),
595
+ max_occurs, length))
596
+ def gds_validate_builtin_ST_(
597
+ self, validator, value, input_name,
598
+ min_occurs=None, max_occurs=None, required=None):
599
+ if value is not None:
600
+ try:
601
+ validator(value, input_name=input_name)
602
+ except GDSParseError as parse_error:
603
+ self.gds_collector_.add_message(str(parse_error))
604
+ def gds_validate_defined_ST_(
605
+ self, validator, value, input_name,
606
+ min_occurs=None, max_occurs=None, required=None):
607
+ if value is not None:
608
+ try:
609
+ validator(value)
610
+ except GDSParseError as parse_error:
611
+ self.gds_collector_.add_message(str(parse_error))
612
+ def gds_str_lower(self, instring):
613
+ return instring.lower()
614
+ def get_path_(self, node):
615
+ path_list = []
616
+ self.get_path_list_(node, path_list)
617
+ path_list.reverse()
618
+ path = '/'.join(path_list)
619
+ return path
620
+ Tag_strip_pattern_ = re_.compile(r'\{.*\}')
621
+ def get_path_list_(self, node, path_list):
622
+ if node is None:
623
+ return
624
+ tag = GeneratedsSuper.Tag_strip_pattern_.sub('', node.tag)
625
+ if tag:
626
+ path_list.append(tag)
627
+ self.get_path_list_(node.getparent(), path_list)
628
+ def get_class_obj_(self, node, default_class=None):
629
+ class_obj1 = default_class
630
+ if 'xsi' in node.nsmap:
631
+ classname = node.get('{%s}type' % node.nsmap['xsi'])
632
+ if classname is not None:
633
+ names = classname.split(':')
634
+ if len(names) == 2:
635
+ classname = names[1]
636
+ class_obj2 = globals().get(classname)
637
+ if class_obj2 is not None:
638
+ class_obj1 = class_obj2
639
+ return class_obj1
640
+ def gds_build_any(self, node, type_name=None):
641
+ # provide default value in case option --disable-xml is used.
642
+ content = ""
643
+ content = etree_.tostring(node, encoding="unicode")
644
+ return content
645
+ @classmethod
646
+ def gds_reverse_node_mapping(cls, mapping):
647
+ return dict(((v, k) for k, v in mapping.items()))
648
+ @staticmethod
649
+ def gds_encode(instring):
650
+ if sys.version_info.major == 2:
651
+ if ExternalEncoding:
652
+ encoding = ExternalEncoding
653
+ else:
654
+ encoding = 'utf-8'
655
+ return instring.encode(encoding)
656
+ else:
657
+ return instring
658
+ @staticmethod
659
+ def convert_unicode(instring):
660
+ if isinstance(instring, str):
661
+ result = quote_xml(instring)
662
+ elif sys.version_info.major == 2 and isinstance(instring, unicode):
663
+ result = quote_xml(instring).encode('utf8')
664
+ else:
665
+ result = GeneratedsSuper.gds_encode(str(instring))
666
+ return result
667
+ def __eq__(self, other):
668
+ def excl_select_objs_(obj):
669
+ return (obj[0] != 'parent_object_' and
670
+ obj[0] != 'gds_collector_')
671
+ if type(self) != type(other):
672
+ return False
673
+ return all(x == y for x, y in zip_longest(
674
+ filter(excl_select_objs_, self.__dict__.items()),
675
+ filter(excl_select_objs_, other.__dict__.items())))
676
+ def __ne__(self, other):
677
+ return not self.__eq__(other)
678
+ # Django ETL transform hooks.
679
+ def gds_djo_etl_transform(self):
680
+ pass
681
+ def gds_djo_etl_transform_db_obj(self, dbobj):
682
+ pass
683
+ # SQLAlchemy ETL transform hooks.
684
+ def gds_sqa_etl_transform(self):
685
+ return 0, None
686
+ def gds_sqa_etl_transform_db_obj(self, dbobj):
687
+ pass
688
+ def gds_get_node_lineno_(self):
689
+ if (hasattr(self, "gds_elementtree_node_") and
690
+ self.gds_elementtree_node_ is not None):
691
+ return ' near line {}'.format(
692
+ self.gds_elementtree_node_.sourceline)
693
+ else:
694
+ return ""
695
+
696
+
697
+ def getSubclassFromModule_(module, class_):
698
+ '''Get the subclass of a class from a specific module.'''
699
+ name = class_.__name__ + 'Sub'
700
+ if hasattr(module, name):
701
+ return getattr(module, name)
702
+ else:
703
+ return None
704
+
705
+
706
+ #
707
+ # If you have installed IPython you can uncomment and use the following.
708
+ # IPython is available from http://ipython.scipy.org/.
709
+ #
710
+
711
+ ## from IPython.Shell import IPShellEmbed
712
+ ## args = ''
713
+ ## ipshell = IPShellEmbed(args,
714
+ ## banner = 'Dropping into IPython',
715
+ ## exit_msg = 'Leaving Interpreter, back to program.')
716
+
717
+ # Then use the following line where and when you want to drop into the
718
+ # IPython shell:
719
+ # ipshell('<some message> -- Entering ipshell.\nHit Ctrl-D to exit')
720
+
721
+ #
722
+ # Globals
723
+ #
724
+
725
+ ExternalEncoding = ''
726
+ # Set this to false in order to deactivate during export, the use of
727
+ # name space prefixes captured from the input document.
728
+ UseCapturedNS_ = True
729
+ CapturedNsmap_ = {}
730
+ Tag_pattern_ = re_.compile(r'({.*})?(.*)')
731
+ String_cleanup_pat_ = re_.compile(r"[\n\r\s]+")
732
+ Namespace_extract_pat_ = re_.compile(r'{(.*)}(.*)')
733
+ CDATA_pattern_ = re_.compile(r"<!\[CDATA\[.*?\]\]>", re_.DOTALL)
734
+
735
+ # Change this to redirect the generated superclass module to use a
736
+ # specific subclass module.
737
+ CurrentSubclassModule_ = None
738
+
739
+ #
740
+ # Support/utility functions.
741
+ #
742
+
743
+
744
+ def showIndent(outfile, level, pretty_print=True):
745
+ if pretty_print:
746
+ for idx in range(level):
747
+ outfile.write(' ')
748
+
749
+
750
+ def quote_xml(inStr):
751
+ "Escape markup chars, but do not modify CDATA sections."
752
+ if not inStr:
753
+ return ''
754
+ s1 = (isinstance(inStr, BaseStrType_) and inStr or '%s' % inStr)
755
+ s2 = ''
756
+ pos = 0
757
+ matchobjects = CDATA_pattern_.finditer(s1)
758
+ for mo in matchobjects:
759
+ s3 = s1[pos:mo.start()]
760
+ s2 += quote_xml_aux(s3)
761
+ s2 += s1[mo.start():mo.end()]
762
+ pos = mo.end()
763
+ s3 = s1[pos:]
764
+ s2 += quote_xml_aux(s3)
765
+ return s2
766
+
767
+
768
+ def quote_xml_aux(inStr):
769
+ s1 = inStr.replace('&', '&amp;')
770
+ s1 = s1.replace('<', '&lt;')
771
+ s1 = s1.replace('>', '&gt;')
772
+ return s1
773
+
774
+
775
+ def quote_attrib(inStr):
776
+ s1 = (isinstance(inStr, BaseStrType_) and inStr or '%s' % inStr)
777
+ s1 = s1.replace('&', '&amp;')
778
+ s1 = s1.replace('<', '&lt;')
779
+ s1 = s1.replace('>', '&gt;')
780
+ s1 = s1.replace('\n', '&#10;')
781
+ if '"' in s1:
782
+ if "'" in s1:
783
+ s1 = '"%s"' % s1.replace('"', "&quot;")
784
+ else:
785
+ s1 = "'%s'" % s1
786
+ else:
787
+ s1 = '"%s"' % s1
788
+ return s1
789
+
790
+
791
+ def quote_python(inStr):
792
+ s1 = inStr
793
+ if s1.find("'") == -1:
794
+ if s1.find('\n') == -1:
795
+ return "'%s'" % s1
796
+ else:
797
+ return "'''%s'''" % s1
798
+ else:
799
+ if s1.find('"') != -1:
800
+ s1 = s1.replace('"', '\\"')
801
+ if s1.find('\n') == -1:
802
+ return '"%s"' % s1
803
+ else:
804
+ return '"""%s"""' % s1
805
+
806
+
807
+ def get_all_text_(node):
808
+ if node.text is not None:
809
+ text = node.text
810
+ else:
811
+ text = ''
812
+ for child in node:
813
+ if child.tail is not None:
814
+ text += child.tail
815
+ return text
816
+
817
+
818
+ def find_attr_value_(attr_name, node):
819
+ attrs = node.attrib
820
+ attr_parts = attr_name.split(':')
821
+ value = None
822
+ if len(attr_parts) == 1:
823
+ value = attrs.get(attr_name)
824
+ elif len(attr_parts) == 2:
825
+ prefix, name = attr_parts
826
+ if prefix == 'xml':
827
+ namespace = 'http://www.w3.org/XML/1998/namespace'
828
+ else:
829
+ namespace = node.nsmap.get(prefix)
830
+ if namespace is not None:
831
+ value = attrs.get('{%s}%s' % (namespace, name, ))
832
+ return value
833
+
834
+
835
+ def encode_str_2_3(instr):
836
+ return instr
837
+
838
+
839
+ class GDSParseError(Exception):
840
+ pass
841
+
842
+
843
+ def raise_parse_error(node, msg):
844
+ if node is not None:
845
+ msg = '%s (element %s/line %d)' % (msg, node.tag, node.sourceline, )
846
+ raise GDSParseError(msg)
847
+
848
+
849
+ class MixedContainer:
850
+ # Constants for category:
851
+ CategoryNone = 0
852
+ CategoryText = 1
853
+ CategorySimple = 2
854
+ CategoryComplex = 3
855
+ # Constants for content_type:
856
+ TypeNone = 0
857
+ TypeText = 1
858
+ TypeString = 2
859
+ TypeInteger = 3
860
+ TypeFloat = 4
861
+ TypeDecimal = 5
862
+ TypeDouble = 6
863
+ TypeBoolean = 7
864
+ TypeBase64 = 8
865
+ def __init__(self, category, content_type, name, value):
866
+ self.category = category
867
+ self.content_type = content_type
868
+ self.name = name
869
+ self.value = value
870
+ def getCategory(self):
871
+ return self.category
872
+ def getContenttype(self, content_type):
873
+ return self.content_type
874
+ def getValue(self):
875
+ return self.value
876
+ def getName(self):
877
+ return self.name
878
+ def export(self, outfile, level, name, namespace,
879
+ pretty_print=True):
880
+ if self.category == MixedContainer.CategoryText:
881
+ # Prevent exporting empty content as empty lines.
882
+ if self.value.strip():
883
+ outfile.write(self.value)
884
+ elif self.category == MixedContainer.CategorySimple:
885
+ self.exportSimple(outfile, level, name)
886
+ else: # category == MixedContainer.CategoryComplex
887
+ self.value.export(
888
+ outfile, level, namespace, name_=name,
889
+ pretty_print=pretty_print)
890
+ def exportSimple(self, outfile, level, name):
891
+ if self.content_type == MixedContainer.TypeString:
892
+ outfile.write('<%s>%s</%s>' % (
893
+ self.name, self.value, self.name))
894
+ elif self.content_type == MixedContainer.TypeInteger or \
895
+ self.content_type == MixedContainer.TypeBoolean:
896
+ outfile.write('<%s>%d</%s>' % (
897
+ self.name, self.value, self.name))
898
+ elif self.content_type == MixedContainer.TypeFloat or \
899
+ self.content_type == MixedContainer.TypeDecimal:
900
+ outfile.write('<%s>%f</%s>' % (
901
+ self.name, self.value, self.name))
902
+ elif self.content_type == MixedContainer.TypeDouble:
903
+ outfile.write('<%s>%g</%s>' % (
904
+ self.name, self.value, self.name))
905
+ elif self.content_type == MixedContainer.TypeBase64:
906
+ outfile.write('<%s>%s</%s>' % (
907
+ self.name,
908
+ base64.b64encode(self.value),
909
+ self.name))
910
+ def to_etree(self, element, mapping_=None, reverse_mapping_=None, nsmap_=None):
911
+ if self.category == MixedContainer.CategoryText:
912
+ # Prevent exporting empty content as empty lines.
913
+ if self.value.strip():
914
+ if len(element) > 0:
915
+ if element[-1].tail is None:
916
+ element[-1].tail = self.value
917
+ else:
918
+ element[-1].tail += self.value
919
+ else:
920
+ if element.text is None:
921
+ element.text = self.value
922
+ else:
923
+ element.text += self.value
924
+ elif self.category == MixedContainer.CategorySimple:
925
+ subelement = etree_.SubElement(
926
+ element, '%s' % self.name)
927
+ subelement.text = self.to_etree_simple()
928
+ else: # category == MixedContainer.CategoryComplex
929
+ self.value.to_etree(element)
930
+ def to_etree_simple(self, mapping_=None, reverse_mapping_=None, nsmap_=None):
931
+ if self.content_type == MixedContainer.TypeString:
932
+ text = self.value
933
+ elif (self.content_type == MixedContainer.TypeInteger or
934
+ self.content_type == MixedContainer.TypeBoolean):
935
+ text = '%d' % self.value
936
+ elif (self.content_type == MixedContainer.TypeFloat or
937
+ self.content_type == MixedContainer.TypeDecimal):
938
+ text = '%f' % self.value
939
+ elif self.content_type == MixedContainer.TypeDouble:
940
+ text = '%g' % self.value
941
+ elif self.content_type == MixedContainer.TypeBase64:
942
+ text = '%s' % base64.b64encode(self.value)
943
+ return text
944
+ def exportLiteral(self, outfile, level, name):
945
+ if self.category == MixedContainer.CategoryText:
946
+ showIndent(outfile, level)
947
+ outfile.write(
948
+ 'model_.MixedContainer(%d, %d, "%s", "%s"),\n' % (
949
+ self.category, self.content_type,
950
+ self.name, self.value))
951
+ elif self.category == MixedContainer.CategorySimple:
952
+ showIndent(outfile, level)
953
+ outfile.write(
954
+ 'model_.MixedContainer(%d, %d, "%s", "%s"),\n' % (
955
+ self.category, self.content_type,
956
+ self.name, self.value))
957
+ else: # category == MixedContainer.CategoryComplex
958
+ showIndent(outfile, level)
959
+ outfile.write(
960
+ 'model_.MixedContainer(%d, %d, "%s",\n' % (
961
+ self.category, self.content_type, self.name,))
962
+ self.value.exportLiteral(outfile, level + 1)
963
+ showIndent(outfile, level)
964
+ outfile.write(')\n')
965
+
966
+
967
+ class MemberSpec_(object):
968
+ def __init__(self, name='', data_type='', container=0,
969
+ optional=0, child_attrs=None, choice=None):
970
+ self.name = name
971
+ self.data_type = data_type
972
+ self.container = container
973
+ self.child_attrs = child_attrs
974
+ self.choice = choice
975
+ self.optional = optional
976
+ def set_name(self, name): self.name = name
977
+ def get_name(self): return self.name
978
+ def set_data_type(self, data_type): self.data_type = data_type
979
+ def get_data_type_chain(self): return self.data_type
980
+ def get_data_type(self):
981
+ if isinstance(self.data_type, list):
982
+ if len(self.data_type) > 0:
983
+ return self.data_type[-1]
984
+ else:
985
+ return 'xs:string'
986
+ else:
987
+ return self.data_type
988
+ def set_container(self, container): self.container = container
989
+ def get_container(self): return self.container
990
+ def set_child_attrs(self, child_attrs): self.child_attrs = child_attrs
991
+ def get_child_attrs(self): return self.child_attrs
992
+ def set_choice(self, choice): self.choice = choice
993
+ def get_choice(self): return self.choice
994
+ def set_optional(self, optional): self.optional = optional
995
+ def get_optional(self): return self.optional
996
+
997
+
998
+ def _cast(typ, value):
999
+ if typ is None or value is None:
1000
+ return value
1001
+ return typ(value)
1002
+
1003
+
1004
+ #
1005
+ # Start enum classes
1006
+ #
1007
+ class CcType(str, Enum):
1008
+ MC='MC'
1009
+ VIS='VIS'
1010
+ AME='AME'
1011
+ DC='DC'
1012
+ DIS='DIS'
1013
+ ER='ER'
1014
+
1015
+
1016
+ class ThirdPartyAccountCodeType(str, Enum):
1017
+ PB='PB'
1018
+ FP='FP'
1019
+ NE='NE'
1020
+
1021
+
1022
+ #
1023
+ # Start data representation classes
1024
+ #
1025
+ class links(GeneratedsSuper):
1026
+ __hash__ = GeneratedsSuper.__hash__
1027
+ subclass = None
1028
+ superclass = None
1029
+ def __init__(self, link=None, gds_collector_=None, **kwargs_):
1030
+ self.gds_collector_ = gds_collector_
1031
+ self.gds_elementtree_node_ = None
1032
+ self.original_tagname_ = None
1033
+ self.parent_object_ = kwargs_.get('parent_object_')
1034
+ self.ns_prefix_ = None
1035
+ if link is None:
1036
+ self.link = []
1037
+ else:
1038
+ self.link = link
1039
+ self.link_nsprefix_ = None
1040
+ def factory(*args_, **kwargs_):
1041
+ if CurrentSubclassModule_ is not None:
1042
+ subclass = getSubclassFromModule_(
1043
+ CurrentSubclassModule_, links)
1044
+ if subclass is not None:
1045
+ return subclass(*args_, **kwargs_)
1046
+ if links.subclass:
1047
+ return links.subclass(*args_, **kwargs_)
1048
+ else:
1049
+ return links(*args_, **kwargs_)
1050
+ factory = staticmethod(factory)
1051
+ def get_ns_prefix_(self):
1052
+ return self.ns_prefix_
1053
+ def set_ns_prefix_(self, ns_prefix):
1054
+ self.ns_prefix_ = ns_prefix
1055
+ def get_link(self):
1056
+ return self.link
1057
+ def set_link(self, link):
1058
+ self.link = link
1059
+ def add_link(self, value):
1060
+ self.link.append(value)
1061
+ def insert_link_at(self, index, value):
1062
+ self.link.insert(index, value)
1063
+ def replace_link_at(self, index, value):
1064
+ self.link[index] = value
1065
+ def has__content(self):
1066
+ if (
1067
+ self.link
1068
+ ):
1069
+ return True
1070
+ else:
1071
+ return False
1072
+ def export(self, outfile, level, namespaceprefix_='', namespacedef_='', name_='links', pretty_print=True):
1073
+ imported_ns_def_ = GenerateDSNamespaceDefs_.get('links')
1074
+ if imported_ns_def_ is not None:
1075
+ namespacedef_ = imported_ns_def_
1076
+ if pretty_print:
1077
+ eol_ = '\n'
1078
+ else:
1079
+ eol_ = ''
1080
+ if self.original_tagname_ is not None and name_ == 'links':
1081
+ name_ = self.original_tagname_
1082
+ if UseCapturedNS_ and self.ns_prefix_:
1083
+ namespaceprefix_ = self.ns_prefix_ + ':'
1084
+ showIndent(outfile, level, pretty_print)
1085
+ outfile.write('<%s%s%s' % (namespaceprefix_, name_, namespacedef_ and ' ' + namespacedef_ or '', ))
1086
+ already_processed = set()
1087
+ self._exportAttributes(outfile, level, already_processed, namespaceprefix_, name_='links')
1088
+ if self.has__content():
1089
+ outfile.write('>%s' % (eol_, ))
1090
+ self._exportChildren(outfile, level + 1, namespaceprefix_, namespacedef_, name_='links', pretty_print=pretty_print)
1091
+ showIndent(outfile, level, pretty_print)
1092
+ outfile.write('</%s%s>%s' % (namespaceprefix_, name_, eol_))
1093
+ else:
1094
+ outfile.write('/>%s' % (eol_, ))
1095
+ def _exportAttributes(self, outfile, level, already_processed, namespaceprefix_='', name_='links'):
1096
+ pass
1097
+ def _exportChildren(self, outfile, level, namespaceprefix_='', namespacedef_='', name_='links', fromsubclass_=False, pretty_print=True):
1098
+ if pretty_print:
1099
+ eol_ = '\n'
1100
+ else:
1101
+ eol_ = ''
1102
+ for link_ in self.link:
1103
+ namespaceprefix_ = self.link_nsprefix_ + ':' if (UseCapturedNS_ and self.link_nsprefix_) else ''
1104
+ link_.export(outfile, level, namespaceprefix_, namespacedef_='', name_='link', pretty_print=pretty_print)
1105
+ def build(self, node, gds_collector_=None):
1106
+ self.gds_collector_ = gds_collector_
1107
+ if SaveElementTreeNode:
1108
+ self.gds_elementtree_node_ = node
1109
+ already_processed = set()
1110
+ self.ns_prefix_ = node.prefix
1111
+ self._buildAttributes(node, node.attrib, already_processed)
1112
+ for child in node:
1113
+ nodeName_ = Tag_pattern_.match(child.tag).groups()[-1]
1114
+ self._buildChildren(child, node, nodeName_, gds_collector_=gds_collector_)
1115
+ return self
1116
+ def _buildAttributes(self, node, attrs, already_processed):
1117
+ pass
1118
+ def _buildChildren(self, child_, node, nodeName_, fromsubclass_=False, gds_collector_=None):
1119
+ if nodeName_ == 'link':
1120
+ obj_ = LinkType.factory(parent_object_=self)
1121
+ obj_.build(child_, gds_collector_=gds_collector_)
1122
+ self.link.append(obj_)
1123
+ obj_.original_tagname_ = 'link'
1124
+ # end class links
1125
+
1126
+
1127
+ class LinkType(GeneratedsSuper):
1128
+ __hash__ = GeneratedsSuper.__hash__
1129
+ subclass = None
1130
+ superclass = None
1131
+ def __init__(self, href=None, rel=None, index=None, media_type=None, gds_collector_=None, **kwargs_):
1132
+ self.gds_collector_ = gds_collector_
1133
+ self.gds_elementtree_node_ = None
1134
+ self.original_tagname_ = None
1135
+ self.parent_object_ = kwargs_.get('parent_object_')
1136
+ self.ns_prefix_ = None
1137
+ self.href = _cast(None, href)
1138
+ self.href_nsprefix_ = None
1139
+ self.rel = _cast(None, rel)
1140
+ self.rel_nsprefix_ = None
1141
+ self.index = _cast(int, index)
1142
+ self.index_nsprefix_ = None
1143
+ self.media_type = _cast(None, media_type)
1144
+ self.media_type_nsprefix_ = None
1145
+ def factory(*args_, **kwargs_):
1146
+ if CurrentSubclassModule_ is not None:
1147
+ subclass = getSubclassFromModule_(
1148
+ CurrentSubclassModule_, LinkType)
1149
+ if subclass is not None:
1150
+ return subclass(*args_, **kwargs_)
1151
+ if LinkType.subclass:
1152
+ return LinkType.subclass(*args_, **kwargs_)
1153
+ else:
1154
+ return LinkType(*args_, **kwargs_)
1155
+ factory = staticmethod(factory)
1156
+ def get_ns_prefix_(self):
1157
+ return self.ns_prefix_
1158
+ def set_ns_prefix_(self, ns_prefix):
1159
+ self.ns_prefix_ = ns_prefix
1160
+ def get_href(self):
1161
+ return self.href
1162
+ def set_href(self, href):
1163
+ self.href = href
1164
+ def get_rel(self):
1165
+ return self.rel
1166
+ def set_rel(self, rel):
1167
+ self.rel = rel
1168
+ def get_index(self):
1169
+ return self.index
1170
+ def set_index(self, index):
1171
+ self.index = index
1172
+ def get_media_type(self):
1173
+ return self.media_type
1174
+ def set_media_type(self, media_type):
1175
+ self.media_type = media_type
1176
+ def validate_RelType(self, value):
1177
+ # Validate type RelType, a restriction on xsd:string.
1178
+ if value is not None and Validate_simpletypes_ and self.gds_collector_ is not None:
1179
+ if not isinstance(value, str):
1180
+ lineno = self.gds_get_node_lineno_()
1181
+ self.gds_collector_.add_message('Value "%(value)s"%(lineno)s is not of the correct base simple type (str)' % {"value": value, "lineno": lineno, })
1182
+ return False
1183
+ pass
1184
+ def has__content(self):
1185
+ if (
1186
+
1187
+ ):
1188
+ return True
1189
+ else:
1190
+ return False
1191
+ def export(self, outfile, level, namespaceprefix_='', namespacedef_='', name_='LinkType', pretty_print=True):
1192
+ imported_ns_def_ = GenerateDSNamespaceDefs_.get('LinkType')
1193
+ if imported_ns_def_ is not None:
1194
+ namespacedef_ = imported_ns_def_
1195
+ if pretty_print:
1196
+ eol_ = '\n'
1197
+ else:
1198
+ eol_ = ''
1199
+ if self.original_tagname_ is not None and name_ == 'LinkType':
1200
+ name_ = self.original_tagname_
1201
+ if UseCapturedNS_ and self.ns_prefix_:
1202
+ namespaceprefix_ = self.ns_prefix_ + ':'
1203
+ showIndent(outfile, level, pretty_print)
1204
+ outfile.write('<%s%s%s' % (namespaceprefix_, name_, namespacedef_ and ' ' + namespacedef_ or '', ))
1205
+ already_processed = set()
1206
+ self._exportAttributes(outfile, level, already_processed, namespaceprefix_, name_='LinkType')
1207
+ if self.has__content():
1208
+ outfile.write('>%s' % (eol_, ))
1209
+ self._exportChildren(outfile, level + 1, namespaceprefix_, namespacedef_, name_='LinkType', pretty_print=pretty_print)
1210
+ outfile.write('</%s%s>%s' % (namespaceprefix_, name_, eol_))
1211
+ else:
1212
+ outfile.write('/>%s' % (eol_, ))
1213
+ def _exportAttributes(self, outfile, level, already_processed, namespaceprefix_='', name_='LinkType'):
1214
+ if self.href is not None and 'href' not in already_processed:
1215
+ already_processed.add('href')
1216
+ outfile.write(' href=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.href), input_name='href')), ))
1217
+ if self.rel is not None and 'rel' not in already_processed:
1218
+ already_processed.add('rel')
1219
+ outfile.write(' rel=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.rel), input_name='rel')), ))
1220
+ if self.index is not None and 'index' not in already_processed:
1221
+ already_processed.add('index')
1222
+ outfile.write(' index="%s"' % self.gds_format_integer(self.index, input_name='index'))
1223
+ if self.media_type is not None and 'media_type' not in already_processed:
1224
+ already_processed.add('media_type')
1225
+ outfile.write(' media-type=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.media_type), input_name='media-type')), ))
1226
+ def _exportChildren(self, outfile, level, namespaceprefix_='', namespacedef_='', name_='LinkType', fromsubclass_=False, pretty_print=True):
1227
+ pass
1228
+ def build(self, node, gds_collector_=None):
1229
+ self.gds_collector_ = gds_collector_
1230
+ if SaveElementTreeNode:
1231
+ self.gds_elementtree_node_ = node
1232
+ already_processed = set()
1233
+ self.ns_prefix_ = node.prefix
1234
+ self._buildAttributes(node, node.attrib, already_processed)
1235
+ for child in node:
1236
+ nodeName_ = Tag_pattern_.match(child.tag).groups()[-1]
1237
+ self._buildChildren(child, node, nodeName_, gds_collector_=gds_collector_)
1238
+ return self
1239
+ def _buildAttributes(self, node, attrs, already_processed):
1240
+ value = find_attr_value_('href', node)
1241
+ if value is not None and 'href' not in already_processed:
1242
+ already_processed.add('href')
1243
+ self.href = value
1244
+ value = find_attr_value_('rel', node)
1245
+ if value is not None and 'rel' not in already_processed:
1246
+ already_processed.add('rel')
1247
+ self.rel = value
1248
+ self.validate_RelType(self.rel) # validate type RelType
1249
+ value = find_attr_value_('index', node)
1250
+ if value is not None and 'index' not in already_processed:
1251
+ already_processed.add('index')
1252
+ self.index = self.gds_parse_integer(value, node, 'index')
1253
+ if self.index < 0:
1254
+ raise_parse_error(node, 'Invalid NonNegativeInteger')
1255
+ value = find_attr_value_('media-type', node)
1256
+ if value is not None and 'media-type' not in already_processed:
1257
+ already_processed.add('media-type')
1258
+ self.media_type = value
1259
+ def _buildChildren(self, child_, node, nodeName_, fromsubclass_=False, gds_collector_=None):
1260
+ pass
1261
+ # end class LinkType
1262
+
1263
+
1264
+ class CcDetailsType(GeneratedsSuper):
1265
+ __hash__ = GeneratedsSuper.__hash__
1266
+ subclass = None
1267
+ superclass = None
1268
+ def __init__(self, cc_type=None, cc_number=None, cc_name=None, cc_expiry=None, cc_cvv=None, cc_address_details=None, gds_collector_=None, **kwargs_):
1269
+ self.gds_collector_ = gds_collector_
1270
+ self.gds_elementtree_node_ = None
1271
+ self.original_tagname_ = None
1272
+ self.parent_object_ = kwargs_.get('parent_object_')
1273
+ self.ns_prefix_ = None
1274
+ self.cc_type = cc_type
1275
+ self.validate_CcType(self.cc_type)
1276
+ self.cc_type_nsprefix_ = None
1277
+ self.cc_number = cc_number
1278
+ self.validate_CcNumberType(self.cc_number)
1279
+ self.cc_number_nsprefix_ = None
1280
+ self.cc_name = cc_name
1281
+ self.validate_CcNameType(self.cc_name)
1282
+ self.cc_name_nsprefix_ = None
1283
+ self.cc_expiry = cc_expiry
1284
+ self.validate_CcExpiryType(self.cc_expiry)
1285
+ self.cc_expiry_nsprefix_ = None
1286
+ self.cc_cvv = cc_cvv
1287
+ self.validate_CcCvvType(self.cc_cvv)
1288
+ self.cc_cvv_nsprefix_ = None
1289
+ self.cc_address_details = cc_address_details
1290
+ self.cc_address_details_nsprefix_ = None
1291
+ def factory(*args_, **kwargs_):
1292
+ if CurrentSubclassModule_ is not None:
1293
+ subclass = getSubclassFromModule_(
1294
+ CurrentSubclassModule_, CcDetailsType)
1295
+ if subclass is not None:
1296
+ return subclass(*args_, **kwargs_)
1297
+ if CcDetailsType.subclass:
1298
+ return CcDetailsType.subclass(*args_, **kwargs_)
1299
+ else:
1300
+ return CcDetailsType(*args_, **kwargs_)
1301
+ factory = staticmethod(factory)
1302
+ def get_ns_prefix_(self):
1303
+ return self.ns_prefix_
1304
+ def set_ns_prefix_(self, ns_prefix):
1305
+ self.ns_prefix_ = ns_prefix
1306
+ def get_cc_type(self):
1307
+ return self.cc_type
1308
+ def set_cc_type(self, cc_type):
1309
+ self.cc_type = cc_type
1310
+ def get_cc_number(self):
1311
+ return self.cc_number
1312
+ def set_cc_number(self, cc_number):
1313
+ self.cc_number = cc_number
1314
+ def get_cc_name(self):
1315
+ return self.cc_name
1316
+ def set_cc_name(self, cc_name):
1317
+ self.cc_name = cc_name
1318
+ def get_cc_expiry(self):
1319
+ return self.cc_expiry
1320
+ def set_cc_expiry(self, cc_expiry):
1321
+ self.cc_expiry = cc_expiry
1322
+ def get_cc_cvv(self):
1323
+ return self.cc_cvv
1324
+ def set_cc_cvv(self, cc_cvv):
1325
+ self.cc_cvv = cc_cvv
1326
+ def get_cc_address_details(self):
1327
+ return self.cc_address_details
1328
+ def set_cc_address_details(self, cc_address_details):
1329
+ self.cc_address_details = cc_address_details
1330
+ def validate_CcType(self, value):
1331
+ result = True
1332
+ # Validate type CcType, a restriction on xsd:normalizedString.
1333
+ if value is not None and Validate_simpletypes_ and self.gds_collector_ is not None:
1334
+ if not isinstance(value, str):
1335
+ lineno = self.gds_get_node_lineno_()
1336
+ self.gds_collector_.add_message('Value "%(value)s"%(lineno)s is not of the correct base simple type (str)' % {"value": value, "lineno": lineno, })
1337
+ return False
1338
+ value = value
1339
+ enumerations = ['MC', 'VIS', 'AME', 'DC', 'DIS', 'ER']
1340
+ if value not in enumerations:
1341
+ lineno = self.gds_get_node_lineno_()
1342
+ self.gds_collector_.add_message('Value "%(value)s"%(lineno)s does not match xsd enumeration restriction on CcType' % {"value" : encode_str_2_3(value), "lineno": lineno} )
1343
+ result = False
1344
+ return result
1345
+ def validate_CcNumberType(self, value):
1346
+ result = True
1347
+ # Validate type CcNumberType, a restriction on xsd:normalizedString.
1348
+ if value is not None and Validate_simpletypes_ and self.gds_collector_ is not None:
1349
+ if not isinstance(value, str):
1350
+ lineno = self.gds_get_node_lineno_()
1351
+ self.gds_collector_.add_message('Value "%(value)s"%(lineno)s is not of the correct base simple type (str)' % {"value": value, "lineno": lineno, })
1352
+ return False
1353
+ if not self.gds_validate_simple_patterns(
1354
+ self.validate_CcNumberType_patterns_, value):
1355
+ self.gds_collector_.add_message('Value "%s" does not match xsd pattern restrictions: %s' % (encode_str_2_3(value), self.validate_CcNumberType_patterns_, ))
1356
+ result = False
1357
+ return result
1358
+ validate_CcNumberType_patterns_ = [['^(\\d{1,25})$']]
1359
+ def validate_CcNameType(self, value):
1360
+ result = True
1361
+ # Validate type CcNameType, a restriction on xsd:normalizedString.
1362
+ if value is not None and Validate_simpletypes_ and self.gds_collector_ is not None:
1363
+ if not isinstance(value, str):
1364
+ lineno = self.gds_get_node_lineno_()
1365
+ self.gds_collector_.add_message('Value "%(value)s"%(lineno)s is not of the correct base simple type (str)' % {"value": value, "lineno": lineno, })
1366
+ return False
1367
+ if len(value) > 40:
1368
+ lineno = self.gds_get_node_lineno_()
1369
+ self.gds_collector_.add_message('Value "%(value)s"%(lineno)s does not match xsd maxLength restriction on CcNameType' % {"value": value, "lineno": lineno} )
1370
+ result = False
1371
+ if len(value) < 1:
1372
+ lineno = self.gds_get_node_lineno_()
1373
+ self.gds_collector_.add_message('Value "%(value)s"%(lineno)s does not match xsd minLength restriction on CcNameType' % {"value" : value, "lineno": lineno} )
1374
+ result = False
1375
+ return result
1376
+ def validate_CcExpiryType(self, value):
1377
+ result = True
1378
+ # Validate type CcExpiryType, a restriction on xsd:normalizedString.
1379
+ if value is not None and Validate_simpletypes_ and self.gds_collector_ is not None:
1380
+ if not isinstance(value, str):
1381
+ lineno = self.gds_get_node_lineno_()
1382
+ self.gds_collector_.add_message('Value "%(value)s"%(lineno)s is not of the correct base simple type (str)' % {"value": value, "lineno": lineno, })
1383
+ return False
1384
+ if not self.gds_validate_simple_patterns(
1385
+ self.validate_CcExpiryType_patterns_, value):
1386
+ self.gds_collector_.add_message('Value "%s" does not match xsd pattern restrictions: %s' % (encode_str_2_3(value), self.validate_CcExpiryType_patterns_, ))
1387
+ result = False
1388
+ return result
1389
+ validate_CcExpiryType_patterns_ = [['^(\\d{2}/\\d{2})$']]
1390
+ def validate_CcCvvType(self, value):
1391
+ result = True
1392
+ # Validate type CcCvvType, a restriction on xsd:normalizedString.
1393
+ if value is not None and Validate_simpletypes_ and self.gds_collector_ is not None:
1394
+ if not isinstance(value, str):
1395
+ lineno = self.gds_get_node_lineno_()
1396
+ self.gds_collector_.add_message('Value "%(value)s"%(lineno)s is not of the correct base simple type (str)' % {"value": value, "lineno": lineno, })
1397
+ return False
1398
+ if len(value) > 6:
1399
+ lineno = self.gds_get_node_lineno_()
1400
+ self.gds_collector_.add_message('Value "%(value)s"%(lineno)s does not match xsd maxLength restriction on CcCvvType' % {"value": value, "lineno": lineno} )
1401
+ result = False
1402
+ if len(value) < 1:
1403
+ lineno = self.gds_get_node_lineno_()
1404
+ self.gds_collector_.add_message('Value "%(value)s"%(lineno)s does not match xsd minLength restriction on CcCvvType' % {"value" : value, "lineno": lineno} )
1405
+ result = False
1406
+ return result
1407
+ def has__content(self):
1408
+ if (
1409
+ self.cc_type is not None or
1410
+ self.cc_number is not None or
1411
+ self.cc_name is not None or
1412
+ self.cc_expiry is not None or
1413
+ self.cc_cvv is not None or
1414
+ self.cc_address_details is not None
1415
+ ):
1416
+ return True
1417
+ else:
1418
+ return False
1419
+ def export(self, outfile, level, namespaceprefix_='', namespacedef_='', name_='CcDetailsType', pretty_print=True):
1420
+ imported_ns_def_ = GenerateDSNamespaceDefs_.get('CcDetailsType')
1421
+ if imported_ns_def_ is not None:
1422
+ namespacedef_ = imported_ns_def_
1423
+ if pretty_print:
1424
+ eol_ = '\n'
1425
+ else:
1426
+ eol_ = ''
1427
+ if self.original_tagname_ is not None and name_ == 'CcDetailsType':
1428
+ name_ = self.original_tagname_
1429
+ if UseCapturedNS_ and self.ns_prefix_:
1430
+ namespaceprefix_ = self.ns_prefix_ + ':'
1431
+ showIndent(outfile, level, pretty_print)
1432
+ outfile.write('<%s%s%s' % (namespaceprefix_, name_, namespacedef_ and ' ' + namespacedef_ or '', ))
1433
+ already_processed = set()
1434
+ self._exportAttributes(outfile, level, already_processed, namespaceprefix_, name_='CcDetailsType')
1435
+ if self.has__content():
1436
+ outfile.write('>%s' % (eol_, ))
1437
+ self._exportChildren(outfile, level + 1, namespaceprefix_, namespacedef_, name_='CcDetailsType', pretty_print=pretty_print)
1438
+ showIndent(outfile, level, pretty_print)
1439
+ outfile.write('</%s%s>%s' % (namespaceprefix_, name_, eol_))
1440
+ else:
1441
+ outfile.write('/>%s' % (eol_, ))
1442
+ def _exportAttributes(self, outfile, level, already_processed, namespaceprefix_='', name_='CcDetailsType'):
1443
+ pass
1444
+ def _exportChildren(self, outfile, level, namespaceprefix_='', namespacedef_='', name_='CcDetailsType', fromsubclass_=False, pretty_print=True):
1445
+ if pretty_print:
1446
+ eol_ = '\n'
1447
+ else:
1448
+ eol_ = ''
1449
+ if self.cc_type is not None:
1450
+ namespaceprefix_ = self.cc_type_nsprefix_ + ':' if (UseCapturedNS_ and self.cc_type_nsprefix_) else ''
1451
+ showIndent(outfile, level, pretty_print)
1452
+ outfile.write('<%scc-type>%s</%scc-type>%s' % (namespaceprefix_ , self.gds_encode(self.gds_format_string(quote_xml(self.cc_type), input_name='cc-type')), namespaceprefix_ , eol_))
1453
+ if self.cc_number is not None:
1454
+ namespaceprefix_ = self.cc_number_nsprefix_ + ':' if (UseCapturedNS_ and self.cc_number_nsprefix_) else ''
1455
+ showIndent(outfile, level, pretty_print)
1456
+ outfile.write('<%scc-number>%s</%scc-number>%s' % (namespaceprefix_ , self.gds_encode(self.gds_format_string(quote_xml(self.cc_number), input_name='cc-number')), namespaceprefix_ , eol_))
1457
+ if self.cc_name is not None:
1458
+ namespaceprefix_ = self.cc_name_nsprefix_ + ':' if (UseCapturedNS_ and self.cc_name_nsprefix_) else ''
1459
+ showIndent(outfile, level, pretty_print)
1460
+ outfile.write('<%scc-name>%s</%scc-name>%s' % (namespaceprefix_ , self.gds_encode(self.gds_format_string(quote_xml(self.cc_name), input_name='cc-name')), namespaceprefix_ , eol_))
1461
+ if self.cc_expiry is not None:
1462
+ namespaceprefix_ = self.cc_expiry_nsprefix_ + ':' if (UseCapturedNS_ and self.cc_expiry_nsprefix_) else ''
1463
+ showIndent(outfile, level, pretty_print)
1464
+ outfile.write('<%scc-expiry>%s</%scc-expiry>%s' % (namespaceprefix_ , self.gds_encode(self.gds_format_string(quote_xml(self.cc_expiry), input_name='cc-expiry')), namespaceprefix_ , eol_))
1465
+ if self.cc_cvv is not None:
1466
+ namespaceprefix_ = self.cc_cvv_nsprefix_ + ':' if (UseCapturedNS_ and self.cc_cvv_nsprefix_) else ''
1467
+ showIndent(outfile, level, pretty_print)
1468
+ outfile.write('<%scc-cvv>%s</%scc-cvv>%s' % (namespaceprefix_ , self.gds_encode(self.gds_format_string(quote_xml(self.cc_cvv), input_name='cc-cvv')), namespaceprefix_ , eol_))
1469
+ if self.cc_address_details is not None:
1470
+ namespaceprefix_ = self.cc_address_details_nsprefix_ + ':' if (UseCapturedNS_ and self.cc_address_details_nsprefix_) else ''
1471
+ self.cc_address_details.export(outfile, level, namespaceprefix_, namespacedef_='', name_='cc-address-details', pretty_print=pretty_print)
1472
+ def build(self, node, gds_collector_=None):
1473
+ self.gds_collector_ = gds_collector_
1474
+ if SaveElementTreeNode:
1475
+ self.gds_elementtree_node_ = node
1476
+ already_processed = set()
1477
+ self.ns_prefix_ = node.prefix
1478
+ self._buildAttributes(node, node.attrib, already_processed)
1479
+ for child in node:
1480
+ nodeName_ = Tag_pattern_.match(child.tag).groups()[-1]
1481
+ self._buildChildren(child, node, nodeName_, gds_collector_=gds_collector_)
1482
+ return self
1483
+ def _buildAttributes(self, node, attrs, already_processed):
1484
+ pass
1485
+ def _buildChildren(self, child_, node, nodeName_, fromsubclass_=False, gds_collector_=None):
1486
+ if nodeName_ == 'cc-type':
1487
+ value_ = child_.text
1488
+ value_ = self.gds_parse_string(value_, node, 'cc_type')
1489
+ value_ = self.gds_validate_string(value_, node, 'cc_type')
1490
+ self.cc_type = value_
1491
+ self.cc_type_nsprefix_ = child_.prefix
1492
+ # validate type CcType
1493
+ self.validate_CcType(self.cc_type)
1494
+ elif nodeName_ == 'cc-number':
1495
+ value_ = child_.text
1496
+ value_ = self.gds_parse_string(value_, node, 'cc_number')
1497
+ value_ = self.gds_validate_string(value_, node, 'cc_number')
1498
+ self.cc_number = value_
1499
+ self.cc_number_nsprefix_ = child_.prefix
1500
+ # validate type CcNumberType
1501
+ self.validate_CcNumberType(self.cc_number)
1502
+ elif nodeName_ == 'cc-name':
1503
+ value_ = child_.text
1504
+ value_ = self.gds_parse_string(value_, node, 'cc_name')
1505
+ value_ = self.gds_validate_string(value_, node, 'cc_name')
1506
+ self.cc_name = value_
1507
+ self.cc_name_nsprefix_ = child_.prefix
1508
+ # validate type CcNameType
1509
+ self.validate_CcNameType(self.cc_name)
1510
+ elif nodeName_ == 'cc-expiry':
1511
+ value_ = child_.text
1512
+ value_ = self.gds_parse_string(value_, node, 'cc_expiry')
1513
+ value_ = self.gds_validate_string(value_, node, 'cc_expiry')
1514
+ self.cc_expiry = value_
1515
+ self.cc_expiry_nsprefix_ = child_.prefix
1516
+ # validate type CcExpiryType
1517
+ self.validate_CcExpiryType(self.cc_expiry)
1518
+ elif nodeName_ == 'cc-cvv':
1519
+ value_ = child_.text
1520
+ value_ = self.gds_parse_string(value_, node, 'cc_cvv')
1521
+ value_ = self.gds_validate_string(value_, node, 'cc_cvv')
1522
+ self.cc_cvv = value_
1523
+ self.cc_cvv_nsprefix_ = child_.prefix
1524
+ # validate type CcCvvType
1525
+ self.validate_CcCvvType(self.cc_cvv)
1526
+ elif nodeName_ == 'cc-address-details':
1527
+ obj_ = CcAddressDetailsType.factory(parent_object_=self)
1528
+ obj_.build(child_, gds_collector_=gds_collector_)
1529
+ self.cc_address_details = obj_
1530
+ obj_.original_tagname_ = 'cc-address-details'
1531
+ # end class CcDetailsType
1532
+
1533
+
1534
+ class CcAddressDetailsType(GeneratedsSuper):
1535
+ __hash__ = GeneratedsSuper.__hash__
1536
+ subclass = None
1537
+ superclass = None
1538
+ def __init__(self, address_line_1=None, address_line_2=None, city=None, prov_state=None, postal_zip_code=None, country_code=None, gds_collector_=None, **kwargs_):
1539
+ self.gds_collector_ = gds_collector_
1540
+ self.gds_elementtree_node_ = None
1541
+ self.original_tagname_ = None
1542
+ self.parent_object_ = kwargs_.get('parent_object_')
1543
+ self.ns_prefix_ = None
1544
+ self.address_line_1 = address_line_1
1545
+ self.validate_address_line_1Type(self.address_line_1)
1546
+ self.address_line_1_nsprefix_ = None
1547
+ self.address_line_2 = address_line_2
1548
+ self.validate_address_line_2Type(self.address_line_2)
1549
+ self.address_line_2_nsprefix_ = None
1550
+ self.city = city
1551
+ self.validate_cityType(self.city)
1552
+ self.city_nsprefix_ = None
1553
+ self.prov_state = prov_state
1554
+ self.validate_ProvinceStateOrInternationalType(self.prov_state)
1555
+ self.prov_state_nsprefix_ = None
1556
+ self.postal_zip_code = postal_zip_code
1557
+ self.validate_PostalCodeOrZipOrInternationalType(self.postal_zip_code)
1558
+ self.postal_zip_code_nsprefix_ = None
1559
+ self.country_code = country_code
1560
+ self.validate_CountryCodeType(self.country_code)
1561
+ self.country_code_nsprefix_ = None
1562
+ def factory(*args_, **kwargs_):
1563
+ if CurrentSubclassModule_ is not None:
1564
+ subclass = getSubclassFromModule_(
1565
+ CurrentSubclassModule_, CcAddressDetailsType)
1566
+ if subclass is not None:
1567
+ return subclass(*args_, **kwargs_)
1568
+ if CcAddressDetailsType.subclass:
1569
+ return CcAddressDetailsType.subclass(*args_, **kwargs_)
1570
+ else:
1571
+ return CcAddressDetailsType(*args_, **kwargs_)
1572
+ factory = staticmethod(factory)
1573
+ def get_ns_prefix_(self):
1574
+ return self.ns_prefix_
1575
+ def set_ns_prefix_(self, ns_prefix):
1576
+ self.ns_prefix_ = ns_prefix
1577
+ def get_address_line_1(self):
1578
+ return self.address_line_1
1579
+ def set_address_line_1(self, address_line_1):
1580
+ self.address_line_1 = address_line_1
1581
+ def get_address_line_2(self):
1582
+ return self.address_line_2
1583
+ def set_address_line_2(self, address_line_2):
1584
+ self.address_line_2 = address_line_2
1585
+ def get_city(self):
1586
+ return self.city
1587
+ def set_city(self, city):
1588
+ self.city = city
1589
+ def get_prov_state(self):
1590
+ return self.prov_state
1591
+ def set_prov_state(self, prov_state):
1592
+ self.prov_state = prov_state
1593
+ def get_postal_zip_code(self):
1594
+ return self.postal_zip_code
1595
+ def set_postal_zip_code(self, postal_zip_code):
1596
+ self.postal_zip_code = postal_zip_code
1597
+ def get_country_code(self):
1598
+ return self.country_code
1599
+ def set_country_code(self, country_code):
1600
+ self.country_code = country_code
1601
+ def validate_address_line_1Type(self, value):
1602
+ result = True
1603
+ # Validate type address-line-1Type, a restriction on xsd:normalizedString.
1604
+ if value is not None and Validate_simpletypes_ and self.gds_collector_ is not None:
1605
+ if not isinstance(value, str):
1606
+ lineno = self.gds_get_node_lineno_()
1607
+ self.gds_collector_.add_message('Value "%(value)s"%(lineno)s is not of the correct base simple type (str)' % {"value": value, "lineno": lineno, })
1608
+ return False
1609
+ if len(value) > 44:
1610
+ lineno = self.gds_get_node_lineno_()
1611
+ self.gds_collector_.add_message('Value "%(value)s"%(lineno)s does not match xsd maxLength restriction on address-line-1Type' % {"value": value, "lineno": lineno} )
1612
+ result = False
1613
+ if len(value) < 1:
1614
+ lineno = self.gds_get_node_lineno_()
1615
+ self.gds_collector_.add_message('Value "%(value)s"%(lineno)s does not match xsd minLength restriction on address-line-1Type' % {"value" : value, "lineno": lineno} )
1616
+ result = False
1617
+ return result
1618
+ def validate_address_line_2Type(self, value):
1619
+ result = True
1620
+ # Validate type address-line-2Type, a restriction on xsd:normalizedString.
1621
+ if value is not None and Validate_simpletypes_ and self.gds_collector_ is not None:
1622
+ if not isinstance(value, str):
1623
+ lineno = self.gds_get_node_lineno_()
1624
+ self.gds_collector_.add_message('Value "%(value)s"%(lineno)s is not of the correct base simple type (str)' % {"value": value, "lineno": lineno, })
1625
+ return False
1626
+ if len(value) > 44:
1627
+ lineno = self.gds_get_node_lineno_()
1628
+ self.gds_collector_.add_message('Value "%(value)s"%(lineno)s does not match xsd maxLength restriction on address-line-2Type' % {"value": value, "lineno": lineno} )
1629
+ result = False
1630
+ return result
1631
+ def validate_cityType(self, value):
1632
+ result = True
1633
+ # Validate type cityType, a restriction on xsd:normalizedString.
1634
+ if value is not None and Validate_simpletypes_ and self.gds_collector_ is not None:
1635
+ if not isinstance(value, str):
1636
+ lineno = self.gds_get_node_lineno_()
1637
+ self.gds_collector_.add_message('Value "%(value)s"%(lineno)s is not of the correct base simple type (str)' % {"value": value, "lineno": lineno, })
1638
+ return False
1639
+ if len(value) > 40:
1640
+ lineno = self.gds_get_node_lineno_()
1641
+ self.gds_collector_.add_message('Value "%(value)s"%(lineno)s does not match xsd maxLength restriction on cityType' % {"value": value, "lineno": lineno} )
1642
+ result = False
1643
+ if len(value) < 1:
1644
+ lineno = self.gds_get_node_lineno_()
1645
+ self.gds_collector_.add_message('Value "%(value)s"%(lineno)s does not match xsd minLength restriction on cityType' % {"value" : value, "lineno": lineno} )
1646
+ result = False
1647
+ return result
1648
+ def validate_ProvinceStateOrInternationalType(self, value):
1649
+ result = True
1650
+ # Validate type ProvinceStateOrInternationalType, a restriction on xsd:normalizedString.
1651
+ if value is not None and Validate_simpletypes_ and self.gds_collector_ is not None:
1652
+ if not isinstance(value, str):
1653
+ lineno = self.gds_get_node_lineno_()
1654
+ self.gds_collector_.add_message('Value "%(value)s"%(lineno)s is not of the correct base simple type (str)' % {"value": value, "lineno": lineno, })
1655
+ return False
1656
+ if len(value) > 20:
1657
+ lineno = self.gds_get_node_lineno_()
1658
+ self.gds_collector_.add_message('Value "%(value)s"%(lineno)s does not match xsd maxLength restriction on ProvinceStateOrInternationalType' % {"value": value, "lineno": lineno} )
1659
+ result = False
1660
+ if len(value) < 1:
1661
+ lineno = self.gds_get_node_lineno_()
1662
+ self.gds_collector_.add_message('Value "%(value)s"%(lineno)s does not match xsd minLength restriction on ProvinceStateOrInternationalType' % {"value" : value, "lineno": lineno} )
1663
+ result = False
1664
+ return result
1665
+ def validate_PostalCodeOrZipOrInternationalType(self, value):
1666
+ result = True
1667
+ # Validate type PostalCodeOrZipOrInternationalType, a restriction on xsd:normalizedString.
1668
+ if value is not None and Validate_simpletypes_ and self.gds_collector_ is not None:
1669
+ if not isinstance(value, str):
1670
+ lineno = self.gds_get_node_lineno_()
1671
+ self.gds_collector_.add_message('Value "%(value)s"%(lineno)s is not of the correct base simple type (str)' % {"value": value, "lineno": lineno, })
1672
+ return False
1673
+ if len(value) > 14:
1674
+ lineno = self.gds_get_node_lineno_()
1675
+ self.gds_collector_.add_message('Value "%(value)s"%(lineno)s does not match xsd maxLength restriction on PostalCodeOrZipOrInternationalType' % {"value": value, "lineno": lineno} )
1676
+ result = False
1677
+ if len(value) < 1:
1678
+ lineno = self.gds_get_node_lineno_()
1679
+ self.gds_collector_.add_message('Value "%(value)s"%(lineno)s does not match xsd minLength restriction on PostalCodeOrZipOrInternationalType' % {"value" : value, "lineno": lineno} )
1680
+ result = False
1681
+ return result
1682
+ def validate_CountryCodeType(self, value):
1683
+ result = True
1684
+ # Validate type CountryCodeType, a restriction on xsd:string.
1685
+ if value is not None and Validate_simpletypes_ and self.gds_collector_ is not None:
1686
+ if not isinstance(value, str):
1687
+ lineno = self.gds_get_node_lineno_()
1688
+ self.gds_collector_.add_message('Value "%(value)s"%(lineno)s is not of the correct base simple type (str)' % {"value": value, "lineno": lineno, })
1689
+ return False
1690
+ if not self.gds_validate_simple_patterns(
1691
+ self.validate_CountryCodeType_patterns_, value):
1692
+ self.gds_collector_.add_message('Value "%s" does not match xsd pattern restrictions: %s' % (encode_str_2_3(value), self.validate_CountryCodeType_patterns_, ))
1693
+ result = False
1694
+ return result
1695
+ validate_CountryCodeType_patterns_ = [['^([a-zA-Z][a-zA-Z])$']]
1696
+ def has__content(self):
1697
+ if (
1698
+ self.address_line_1 is not None or
1699
+ self.address_line_2 is not None or
1700
+ self.city is not None or
1701
+ self.prov_state is not None or
1702
+ self.postal_zip_code is not None or
1703
+ self.country_code is not None
1704
+ ):
1705
+ return True
1706
+ else:
1707
+ return False
1708
+ def export(self, outfile, level, namespaceprefix_='', namespacedef_='', name_='CcAddressDetailsType', pretty_print=True):
1709
+ imported_ns_def_ = GenerateDSNamespaceDefs_.get('CcAddressDetailsType')
1710
+ if imported_ns_def_ is not None:
1711
+ namespacedef_ = imported_ns_def_
1712
+ if pretty_print:
1713
+ eol_ = '\n'
1714
+ else:
1715
+ eol_ = ''
1716
+ if self.original_tagname_ is not None and name_ == 'CcAddressDetailsType':
1717
+ name_ = self.original_tagname_
1718
+ if UseCapturedNS_ and self.ns_prefix_:
1719
+ namespaceprefix_ = self.ns_prefix_ + ':'
1720
+ showIndent(outfile, level, pretty_print)
1721
+ outfile.write('<%s%s%s' % (namespaceprefix_, name_, namespacedef_ and ' ' + namespacedef_ or '', ))
1722
+ already_processed = set()
1723
+ self._exportAttributes(outfile, level, already_processed, namespaceprefix_, name_='CcAddressDetailsType')
1724
+ if self.has__content():
1725
+ outfile.write('>%s' % (eol_, ))
1726
+ self._exportChildren(outfile, level + 1, namespaceprefix_, namespacedef_, name_='CcAddressDetailsType', pretty_print=pretty_print)
1727
+ showIndent(outfile, level, pretty_print)
1728
+ outfile.write('</%s%s>%s' % (namespaceprefix_, name_, eol_))
1729
+ else:
1730
+ outfile.write('/>%s' % (eol_, ))
1731
+ def _exportAttributes(self, outfile, level, already_processed, namespaceprefix_='', name_='CcAddressDetailsType'):
1732
+ pass
1733
+ def _exportChildren(self, outfile, level, namespaceprefix_='', namespacedef_='', name_='CcAddressDetailsType', fromsubclass_=False, pretty_print=True):
1734
+ if pretty_print:
1735
+ eol_ = '\n'
1736
+ else:
1737
+ eol_ = ''
1738
+ if self.address_line_1 is not None:
1739
+ namespaceprefix_ = self.address_line_1_nsprefix_ + ':' if (UseCapturedNS_ and self.address_line_1_nsprefix_) else ''
1740
+ showIndent(outfile, level, pretty_print)
1741
+ outfile.write('<%saddress-line-1>%s</%saddress-line-1>%s' % (namespaceprefix_ , self.gds_encode(self.gds_format_string(quote_xml(self.address_line_1), input_name='address-line-1')), namespaceprefix_ , eol_))
1742
+ if self.address_line_2 is not None:
1743
+ namespaceprefix_ = self.address_line_2_nsprefix_ + ':' if (UseCapturedNS_ and self.address_line_2_nsprefix_) else ''
1744
+ showIndent(outfile, level, pretty_print)
1745
+ outfile.write('<%saddress-line-2>%s</%saddress-line-2>%s' % (namespaceprefix_ , self.gds_encode(self.gds_format_string(quote_xml(self.address_line_2), input_name='address-line-2')), namespaceprefix_ , eol_))
1746
+ if self.city is not None:
1747
+ namespaceprefix_ = self.city_nsprefix_ + ':' if (UseCapturedNS_ and self.city_nsprefix_) else ''
1748
+ showIndent(outfile, level, pretty_print)
1749
+ outfile.write('<%scity>%s</%scity>%s' % (namespaceprefix_ , self.gds_encode(self.gds_format_string(quote_xml(self.city), input_name='city')), namespaceprefix_ , eol_))
1750
+ if self.prov_state is not None:
1751
+ namespaceprefix_ = self.prov_state_nsprefix_ + ':' if (UseCapturedNS_ and self.prov_state_nsprefix_) else ''
1752
+ showIndent(outfile, level, pretty_print)
1753
+ outfile.write('<%sprov-state>%s</%sprov-state>%s' % (namespaceprefix_ , self.gds_encode(self.gds_format_string(quote_xml(self.prov_state), input_name='prov-state')), namespaceprefix_ , eol_))
1754
+ if self.postal_zip_code is not None:
1755
+ namespaceprefix_ = self.postal_zip_code_nsprefix_ + ':' if (UseCapturedNS_ and self.postal_zip_code_nsprefix_) else ''
1756
+ showIndent(outfile, level, pretty_print)
1757
+ outfile.write('<%spostal-zip-code>%s</%spostal-zip-code>%s' % (namespaceprefix_ , self.gds_encode(self.gds_format_string(quote_xml(self.postal_zip_code), input_name='postal-zip-code')), namespaceprefix_ , eol_))
1758
+ if self.country_code is not None:
1759
+ namespaceprefix_ = self.country_code_nsprefix_ + ':' if (UseCapturedNS_ and self.country_code_nsprefix_) else ''
1760
+ showIndent(outfile, level, pretty_print)
1761
+ outfile.write('<%scountry-code>%s</%scountry-code>%s' % (namespaceprefix_ , self.gds_encode(self.gds_format_string(quote_xml(self.country_code), input_name='country-code')), namespaceprefix_ , eol_))
1762
+ def build(self, node, gds_collector_=None):
1763
+ self.gds_collector_ = gds_collector_
1764
+ if SaveElementTreeNode:
1765
+ self.gds_elementtree_node_ = node
1766
+ already_processed = set()
1767
+ self.ns_prefix_ = node.prefix
1768
+ self._buildAttributes(node, node.attrib, already_processed)
1769
+ for child in node:
1770
+ nodeName_ = Tag_pattern_.match(child.tag).groups()[-1]
1771
+ self._buildChildren(child, node, nodeName_, gds_collector_=gds_collector_)
1772
+ return self
1773
+ def _buildAttributes(self, node, attrs, already_processed):
1774
+ pass
1775
+ def _buildChildren(self, child_, node, nodeName_, fromsubclass_=False, gds_collector_=None):
1776
+ if nodeName_ == 'address-line-1':
1777
+ value_ = child_.text
1778
+ value_ = self.gds_parse_string(value_, node, 'address_line_1')
1779
+ value_ = self.gds_validate_string(value_, node, 'address_line_1')
1780
+ self.address_line_1 = value_
1781
+ self.address_line_1_nsprefix_ = child_.prefix
1782
+ # validate type address-line-1Type
1783
+ self.validate_address_line_1Type(self.address_line_1)
1784
+ elif nodeName_ == 'address-line-2':
1785
+ value_ = child_.text
1786
+ value_ = self.gds_parse_string(value_, node, 'address_line_2')
1787
+ value_ = self.gds_validate_string(value_, node, 'address_line_2')
1788
+ self.address_line_2 = value_
1789
+ self.address_line_2_nsprefix_ = child_.prefix
1790
+ # validate type address-line-2Type
1791
+ self.validate_address_line_2Type(self.address_line_2)
1792
+ elif nodeName_ == 'city':
1793
+ value_ = child_.text
1794
+ value_ = self.gds_parse_string(value_, node, 'city')
1795
+ value_ = self.gds_validate_string(value_, node, 'city')
1796
+ self.city = value_
1797
+ self.city_nsprefix_ = child_.prefix
1798
+ # validate type cityType
1799
+ self.validate_cityType(self.city)
1800
+ elif nodeName_ == 'prov-state':
1801
+ value_ = child_.text
1802
+ value_ = self.gds_parse_string(value_, node, 'prov_state')
1803
+ value_ = self.gds_validate_string(value_, node, 'prov_state')
1804
+ self.prov_state = value_
1805
+ self.prov_state_nsprefix_ = child_.prefix
1806
+ # validate type ProvinceStateOrInternationalType
1807
+ self.validate_ProvinceStateOrInternationalType(self.prov_state)
1808
+ elif nodeName_ == 'postal-zip-code':
1809
+ value_ = child_.text
1810
+ value_ = self.gds_parse_string(value_, node, 'postal_zip_code')
1811
+ value_ = self.gds_validate_string(value_, node, 'postal_zip_code')
1812
+ self.postal_zip_code = value_
1813
+ self.postal_zip_code_nsprefix_ = child_.prefix
1814
+ # validate type PostalCodeOrZipOrInternationalType
1815
+ self.validate_PostalCodeOrZipOrInternationalType(self.postal_zip_code)
1816
+ elif nodeName_ == 'country-code':
1817
+ value_ = child_.text
1818
+ value_ = self.gds_parse_string(value_, node, 'country_code')
1819
+ value_ = self.gds_validate_string(value_, node, 'country_code')
1820
+ self.country_code = value_
1821
+ self.country_code_nsprefix_ = child_.prefix
1822
+ # validate type CountryCodeType
1823
+ self.validate_CountryCodeType(self.country_code)
1824
+ # end class CcAddressDetailsType
1825
+
1826
+
1827
+ #
1828
+ # End data representation classes.
1829
+ #
1830
+
1831
+
1832
+ GDSClassesMapping = {
1833
+ 'link': LinkType,
1834
+ }
1835
+
1836
+
1837
+ USAGE_TEXT = """
1838
+ Usage: python <Parser>.py [ -s ] <in_xml_file>
1839
+ """
1840
+
1841
+
1842
+ def usage():
1843
+ print(USAGE_TEXT)
1844
+ sys.exit(1)
1845
+
1846
+
1847
+ def get_root_tag(node):
1848
+ tag = Tag_pattern_.match(node.tag).groups()[-1]
1849
+ prefix_tag = TagNamePrefix + tag
1850
+ rootClass = GDSClassesMapping.get(prefix_tag)
1851
+ if rootClass is None:
1852
+ rootClass = globals().get(prefix_tag)
1853
+ return tag, rootClass
1854
+
1855
+
1856
+ def get_required_ns_prefix_defs(rootNode):
1857
+ '''Get all name space prefix definitions required in this XML doc.
1858
+ Return a dictionary of definitions and a char string of definitions.
1859
+ '''
1860
+ nsmap = {
1861
+ prefix: uri
1862
+ for node in rootNode.iter()
1863
+ for (prefix, uri) in node.nsmap.items()
1864
+ if prefix is not None
1865
+ }
1866
+ namespacedefs = ' '.join([
1867
+ 'xmlns:{}="{}"'.format(prefix, uri)
1868
+ for prefix, uri in nsmap.items()
1869
+ ])
1870
+ return nsmap, namespacedefs
1871
+
1872
+
1873
+ def parse(inFileName, silence=False, print_warnings=True):
1874
+ global CapturedNsmap_
1875
+ gds_collector = GdsCollector_()
1876
+ parser = None
1877
+ doc = parsexml_(inFileName, parser)
1878
+ rootNode = doc.getroot()
1879
+ rootTag, rootClass = get_root_tag(rootNode)
1880
+ if rootClass is None:
1881
+ rootTag = 'links'
1882
+ rootClass = links
1883
+ rootObj = rootClass.factory()
1884
+ rootObj.build(rootNode, gds_collector_=gds_collector)
1885
+ CapturedNsmap_, namespacedefs = get_required_ns_prefix_defs(rootNode)
1886
+ if not SaveElementTreeNode:
1887
+ doc = None
1888
+ rootNode = None
1889
+ if not silence:
1890
+ sys.stdout.write('<?xml version="1.0" ?>\n')
1891
+ rootObj.export(
1892
+ sys.stdout, 0, name_=rootTag,
1893
+ namespacedef_=namespacedefs,
1894
+ pretty_print=True)
1895
+ if print_warnings and len(gds_collector.get_messages()) > 0:
1896
+ separator = ('-' * 50) + '\n'
1897
+ sys.stderr.write(separator)
1898
+ sys.stderr.write('----- Warnings -- count: {} -----\n'.format(
1899
+ len(gds_collector.get_messages()), ))
1900
+ gds_collector.write_messages(sys.stderr)
1901
+ sys.stderr.write(separator)
1902
+ return rootObj
1903
+
1904
+
1905
+ def parseEtree(inFileName, silence=False, print_warnings=True,
1906
+ mapping=None, reverse_mapping=None, nsmap=None):
1907
+ parser = None
1908
+ doc = parsexml_(inFileName, parser)
1909
+ gds_collector = GdsCollector_()
1910
+ rootNode = doc.getroot()
1911
+ rootTag, rootClass = get_root_tag(rootNode)
1912
+ if rootClass is None:
1913
+ rootTag = 'links'
1914
+ rootClass = links
1915
+ rootObj = rootClass.factory()
1916
+ rootObj.build(rootNode, gds_collector_=gds_collector)
1917
+ if mapping is None:
1918
+ mapping = {}
1919
+ if reverse_mapping is None:
1920
+ reverse_mapping = {}
1921
+ rootElement = rootObj.to_etree(
1922
+ None, name_=rootTag, mapping_=mapping,
1923
+ reverse_mapping_=reverse_mapping, nsmap_=nsmap)
1924
+ reverse_node_mapping = rootObj.gds_reverse_node_mapping(mapping)
1925
+ # Enable Python to collect the space used by the DOM.
1926
+ if not SaveElementTreeNode:
1927
+ doc = None
1928
+ rootNode = None
1929
+ if not silence:
1930
+ content = etree_.tostring(
1931
+ rootElement, pretty_print=True,
1932
+ xml_declaration=True, encoding="utf-8")
1933
+ sys.stdout.write(str(content))
1934
+ sys.stdout.write('\n')
1935
+ if print_warnings and len(gds_collector.get_messages()) > 0:
1936
+ separator = ('-' * 50) + '\n'
1937
+ sys.stderr.write(separator)
1938
+ sys.stderr.write('----- Warnings -- count: {} -----\n'.format(
1939
+ len(gds_collector.get_messages()), ))
1940
+ gds_collector.write_messages(sys.stderr)
1941
+ sys.stderr.write(separator)
1942
+ return rootObj, rootElement, mapping, reverse_node_mapping
1943
+
1944
+
1945
+ def parseString(inString, silence=False, print_warnings=True):
1946
+ '''Parse a string, create the object tree, and export it.
1947
+
1948
+ Arguments:
1949
+ - inString -- A string. This XML fragment should not start
1950
+ with an XML declaration containing an encoding.
1951
+ - silence -- A boolean. If False, export the object.
1952
+ Returns -- The root object in the tree.
1953
+ '''
1954
+ parser = None
1955
+ rootNode= parsexmlstring_(inString, parser)
1956
+ gds_collector = GdsCollector_()
1957
+ rootTag, rootClass = get_root_tag(rootNode)
1958
+ if rootClass is None:
1959
+ rootTag = 'links'
1960
+ rootClass = links
1961
+ rootObj = rootClass.factory()
1962
+ rootObj.build(rootNode, gds_collector_=gds_collector)
1963
+ if not SaveElementTreeNode:
1964
+ rootNode = None
1965
+ if not silence:
1966
+ sys.stdout.write('<?xml version="1.0" ?>\n')
1967
+ rootObj.export(
1968
+ sys.stdout, 0, name_=rootTag,
1969
+ namespacedef_='')
1970
+ if print_warnings and len(gds_collector.get_messages()) > 0:
1971
+ separator = ('-' * 50) + '\n'
1972
+ sys.stderr.write(separator)
1973
+ sys.stderr.write('----- Warnings -- count: {} -----\n'.format(
1974
+ len(gds_collector.get_messages()), ))
1975
+ gds_collector.write_messages(sys.stderr)
1976
+ sys.stderr.write(separator)
1977
+ return rootObj
1978
+
1979
+
1980
+ def parseLiteral(inFileName, silence=False, print_warnings=True):
1981
+ parser = None
1982
+ doc = parsexml_(inFileName, parser)
1983
+ gds_collector = GdsCollector_()
1984
+ rootNode = doc.getroot()
1985
+ rootTag, rootClass = get_root_tag(rootNode)
1986
+ if rootClass is None:
1987
+ rootTag = 'links'
1988
+ rootClass = links
1989
+ rootObj = rootClass.factory()
1990
+ rootObj.build(rootNode, gds_collector_=gds_collector)
1991
+ # Enable Python to collect the space used by the DOM.
1992
+ if not SaveElementTreeNode:
1993
+ doc = None
1994
+ rootNode = None
1995
+ if not silence:
1996
+ sys.stdout.write('#from common import *\n\n')
1997
+ sys.stdout.write('import common as model_\n\n')
1998
+ sys.stdout.write('rootObj = model_.rootClass(\n')
1999
+ rootObj.exportLiteral(sys.stdout, 0, name_=rootTag)
2000
+ sys.stdout.write(')\n')
2001
+ if print_warnings and len(gds_collector.get_messages()) > 0:
2002
+ separator = ('-' * 50) + '\n'
2003
+ sys.stderr.write(separator)
2004
+ sys.stderr.write('----- Warnings -- count: {} -----\n'.format(
2005
+ len(gds_collector.get_messages()), ))
2006
+ gds_collector.write_messages(sys.stderr)
2007
+ sys.stderr.write(separator)
2008
+ return rootObj
2009
+
2010
+
2011
+ def main():
2012
+ args = sys.argv[1:]
2013
+ if len(args) == 1:
2014
+ parse(args[0])
2015
+ else:
2016
+ usage()
2017
+
2018
+
2019
+ if __name__ == '__main__':
2020
+ #import pdb; pdb.set_trace()
2021
+ main()
2022
+
2023
+ RenameMappings_ = {
2024
+ }
2025
+
2026
+ #
2027
+ # Mapping of namespaces to types defined in them
2028
+ # and the file in which each is defined.
2029
+ # simpleTypes are marked "ST" and complexTypes "CT".
2030
+ NamespaceToDefMappings_ = {}
2031
+
2032
+ __all__ = [
2033
+ "CcAddressDetailsType",
2034
+ "CcDetailsType",
2035
+ "LinkType",
2036
+ "links"
2037
+ ]