karrio-tnt 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.
@@ -0,0 +1,3499 @@
1
+ #!/usr/bin/env python
2
+ # -*- coding: utf-8 -*-
3
+
4
+ #
5
+ # Generated Sun Oct 22 20:42:02 2023 by generateDS.py version 2.43.2.
6
+ # Python 3.10.12 (main, Jun 11 2023, 05:26:28) [GCC 11.4.0]
7
+ #
8
+ # Command line options:
9
+ # ('--no-namespace-defs', '')
10
+ # ('-o', './karrio/schemas/tnt/label_common_definitions.py')
11
+ #
12
+ # Command line arguments:
13
+ # ./schemas/label_common_definitions.xsd
14
+ #
15
+ # Command line:
16
+ # /home/kserver/Workspace/karrio/.venv/karrio/bin/generateDS --no-namespace-defs -o "./karrio/schemas/tnt/label_common_definitions.py" ./schemas/label_common_definitions.xsd
17
+ #
18
+ # Current working directory (os.getcwd()):
19
+ # tnt
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 booleanEnum(str, Enum):
1008
+ N='N'
1009
+ Y='Y'
1010
+
1011
+
1012
+ class cashTypeEnum(str, Enum):
1013
+ _0='0'
1014
+ _1='1'
1015
+
1016
+
1017
+ class productTypeEnum(str, Enum):
1018
+ N='N'
1019
+ D='D'
1020
+
1021
+
1022
+ class senderReceiverEnum(str, Enum):
1023
+ S='S'
1024
+ R='R'
1025
+
1026
+
1027
+ #
1028
+ # Start data representation classes
1029
+ #
1030
+ class consignmentIdentityType(GeneratedsSuper):
1031
+ """consignmentIdentityType -- This element contains a consignment number and optional customer reference.
1032
+ These values are used to distinguish a consignment from any other consignment.
1033
+ This value appears on a routing label and is used as the key for a consignment.
1034
+ consignmentNumber -- The TNT consignment number in legacy (Global Link) format.
1035
+ customerReference -- Contains the optional customer reference for the consignment.
1036
+ A customer reference is a way for a customer to designate a name
1037
+ for the consignment.
1038
+ This value can be used to track the consignment at a later date.
1039
+
1040
+ """
1041
+ __hash__ = GeneratedsSuper.__hash__
1042
+ subclass = None
1043
+ superclass = None
1044
+ def __init__(self, consignmentNumber=None, customerReference=None, gds_collector_=None, **kwargs_):
1045
+ self.gds_collector_ = gds_collector_
1046
+ self.gds_elementtree_node_ = None
1047
+ self.original_tagname_ = None
1048
+ self.parent_object_ = kwargs_.get('parent_object_')
1049
+ self.ns_prefix_ = None
1050
+ self.consignmentNumber = consignmentNumber
1051
+ self.consignmentNumber_nsprefix_ = None
1052
+ self.customerReference = customerReference
1053
+ self.customerReference_nsprefix_ = None
1054
+ def factory(*args_, **kwargs_):
1055
+ if CurrentSubclassModule_ is not None:
1056
+ subclass = getSubclassFromModule_(
1057
+ CurrentSubclassModule_, consignmentIdentityType)
1058
+ if subclass is not None:
1059
+ return subclass(*args_, **kwargs_)
1060
+ if consignmentIdentityType.subclass:
1061
+ return consignmentIdentityType.subclass(*args_, **kwargs_)
1062
+ else:
1063
+ return consignmentIdentityType(*args_, **kwargs_)
1064
+ factory = staticmethod(factory)
1065
+ def get_ns_prefix_(self):
1066
+ return self.ns_prefix_
1067
+ def set_ns_prefix_(self, ns_prefix):
1068
+ self.ns_prefix_ = ns_prefix
1069
+ def get_consignmentNumber(self):
1070
+ return self.consignmentNumber
1071
+ def set_consignmentNumber(self, consignmentNumber):
1072
+ self.consignmentNumber = consignmentNumber
1073
+ def get_customerReference(self):
1074
+ return self.customerReference
1075
+ def set_customerReference(self, customerReference):
1076
+ self.customerReference = customerReference
1077
+ def has__content(self):
1078
+ if (
1079
+ self.consignmentNumber is not None or
1080
+ self.customerReference is not None
1081
+ ):
1082
+ return True
1083
+ else:
1084
+ return False
1085
+ def export(self, outfile, level, namespaceprefix_='', namespacedef_='', name_='consignmentIdentityType', pretty_print=True):
1086
+ imported_ns_def_ = GenerateDSNamespaceDefs_.get('consignmentIdentityType')
1087
+ if imported_ns_def_ is not None:
1088
+ namespacedef_ = imported_ns_def_
1089
+ if pretty_print:
1090
+ eol_ = '\n'
1091
+ else:
1092
+ eol_ = ''
1093
+ if self.original_tagname_ is not None and name_ == 'consignmentIdentityType':
1094
+ name_ = self.original_tagname_
1095
+ if UseCapturedNS_ and self.ns_prefix_:
1096
+ namespaceprefix_ = self.ns_prefix_ + ':'
1097
+ showIndent(outfile, level, pretty_print)
1098
+ outfile.write('<%s%s%s' % (namespaceprefix_, name_, namespacedef_ and ' ' + namespacedef_ or '', ))
1099
+ already_processed = set()
1100
+ self._exportAttributes(outfile, level, already_processed, namespaceprefix_, name_='consignmentIdentityType')
1101
+ if self.has__content():
1102
+ outfile.write('>%s' % (eol_, ))
1103
+ self._exportChildren(outfile, level + 1, namespaceprefix_, namespacedef_, name_='consignmentIdentityType', pretty_print=pretty_print)
1104
+ showIndent(outfile, level, pretty_print)
1105
+ outfile.write('</%s%s>%s' % (namespaceprefix_, name_, eol_))
1106
+ else:
1107
+ outfile.write('/>%s' % (eol_, ))
1108
+ def _exportAttributes(self, outfile, level, already_processed, namespaceprefix_='', name_='consignmentIdentityType'):
1109
+ pass
1110
+ def _exportChildren(self, outfile, level, namespaceprefix_='', namespacedef_='', name_='consignmentIdentityType', fromsubclass_=False, pretty_print=True):
1111
+ if pretty_print:
1112
+ eol_ = '\n'
1113
+ else:
1114
+ eol_ = ''
1115
+ if self.consignmentNumber is not None:
1116
+ namespaceprefix_ = self.consignmentNumber_nsprefix_ + ':' if (UseCapturedNS_ and self.consignmentNumber_nsprefix_) else ''
1117
+ showIndent(outfile, level, pretty_print)
1118
+ outfile.write('<%sconsignmentNumber>%s</%sconsignmentNumber>%s' % (namespaceprefix_ , self.gds_encode(self.gds_format_string(quote_xml(self.consignmentNumber), input_name='consignmentNumber')), namespaceprefix_ , eol_))
1119
+ if self.customerReference is not None:
1120
+ namespaceprefix_ = self.customerReference_nsprefix_ + ':' if (UseCapturedNS_ and self.customerReference_nsprefix_) else ''
1121
+ showIndent(outfile, level, pretty_print)
1122
+ outfile.write('<%scustomerReference>%s</%scustomerReference>%s' % (namespaceprefix_ , self.gds_encode(self.gds_format_string(quote_xml(self.customerReference), input_name='customerReference')), namespaceprefix_ , eol_))
1123
+ def build(self, node, gds_collector_=None):
1124
+ self.gds_collector_ = gds_collector_
1125
+ if SaveElementTreeNode:
1126
+ self.gds_elementtree_node_ = node
1127
+ already_processed = set()
1128
+ self.ns_prefix_ = node.prefix
1129
+ self._buildAttributes(node, node.attrib, already_processed)
1130
+ for child in node:
1131
+ nodeName_ = Tag_pattern_.match(child.tag).groups()[-1]
1132
+ self._buildChildren(child, node, nodeName_, gds_collector_=gds_collector_)
1133
+ return self
1134
+ def _buildAttributes(self, node, attrs, already_processed):
1135
+ pass
1136
+ def _buildChildren(self, child_, node, nodeName_, fromsubclass_=False, gds_collector_=None):
1137
+ if nodeName_ == 'consignmentNumber':
1138
+ value_ = child_.text
1139
+ value_ = self.gds_parse_string(value_, node, 'consignmentNumber')
1140
+ value_ = self.gds_validate_string(value_, node, 'consignmentNumber')
1141
+ self.consignmentNumber = value_
1142
+ self.consignmentNumber_nsprefix_ = child_.prefix
1143
+ elif nodeName_ == 'customerReference':
1144
+ value_ = child_.text
1145
+ value_ = self.gds_parse_string(value_, node, 'customerReference')
1146
+ value_ = self.gds_validate_string(value_, node, 'customerReference')
1147
+ self.customerReference = value_
1148
+ self.customerReference_nsprefix_ = child_.prefix
1149
+ # end class consignmentIdentityType
1150
+
1151
+
1152
+ class nameAndAddressRequestType(GeneratedsSuper):
1153
+ """nameAndAddressRequestType -- Information relating to name and address for a participant
1154
+ in the consignment.
1155
+ Examples of a participant are:
1156
+ The Sender - the company sending the consignment
1157
+ The Receiver - the company receiving the consignment
1158
+ The Collection Address - the address from which the consignment is picked up
1159
+ The Delivery Address - the address to which the consignment should be delivered
1160
+ name -- Either the name of the company as recognised by TNT, or the
1161
+ contact name at the address
1162
+ addressLine1 -- This address line is the most commonly used of the three
1163
+ address lines and is therefore mandatory.
1164
+ addressLine2 -- This address line may not be used by the supporting system
1165
+ and therefore should not contain information essential to the address.
1166
+ addressLine3 -- This address line may not be used by the supporting system
1167
+ and therefore should not contain information essential to the address.
1168
+ NOTE - this will not appear on any routingLabel produced.
1169
+ town -- The town name as recognised by TNT
1170
+ exactMatch -- Flag stating if an exact match on the town name should be used.
1171
+ If this flag is absent then the exact match value is 'Y'.
1172
+ province -- Optional field to contain the province, county, state, or area
1173
+ for the given address.
1174
+ postcode -- Postcode or zip code is considered a mandatory field where it is
1175
+ used in a given country. If the postcode is not provided, it may
1176
+ not be possible to deliver the consignment as indicated by your
1177
+ chosen service.
1178
+ country -- The ISO country code for the country of the given address.
1179
+
1180
+ """
1181
+ __hash__ = GeneratedsSuper.__hash__
1182
+ subclass = None
1183
+ superclass = None
1184
+ def __init__(self, name=None, addressLine1=None, addressLine2=None, addressLine3=None, town=None, exactMatch='Y', province=None, postcode=None, country=None, gds_collector_=None, **kwargs_):
1185
+ self.gds_collector_ = gds_collector_
1186
+ self.gds_elementtree_node_ = None
1187
+ self.original_tagname_ = None
1188
+ self.parent_object_ = kwargs_.get('parent_object_')
1189
+ self.ns_prefix_ = None
1190
+ self.name = name
1191
+ self.validate_stringMaxLength40(self.name)
1192
+ self.name_nsprefix_ = None
1193
+ self.addressLine1 = addressLine1
1194
+ self.validate_stringMaxLength30(self.addressLine1)
1195
+ self.addressLine1_nsprefix_ = None
1196
+ self.addressLine2 = addressLine2
1197
+ self.validate_stringMaxLength30(self.addressLine2)
1198
+ self.addressLine2_nsprefix_ = None
1199
+ self.addressLine3 = addressLine3
1200
+ self.validate_stringMaxLength30(self.addressLine3)
1201
+ self.addressLine3_nsprefix_ = None
1202
+ self.town = town
1203
+ self.validate_stringMaxLength40(self.town)
1204
+ self.town_nsprefix_ = None
1205
+ self.exactMatch = exactMatch
1206
+ self.validate_booleanEnum(self.exactMatch)
1207
+ self.exactMatch_nsprefix_ = None
1208
+ self.province = province
1209
+ self.validate_stringMaxLength30(self.province)
1210
+ self.province_nsprefix_ = None
1211
+ self.postcode = postcode
1212
+ self.validate_stringMaxLength9(self.postcode)
1213
+ self.postcode_nsprefix_ = None
1214
+ self.country = country
1215
+ self.validate_stringMinLength2MaxLength2(self.country)
1216
+ self.country_nsprefix_ = None
1217
+ def factory(*args_, **kwargs_):
1218
+ if CurrentSubclassModule_ is not None:
1219
+ subclass = getSubclassFromModule_(
1220
+ CurrentSubclassModule_, nameAndAddressRequestType)
1221
+ if subclass is not None:
1222
+ return subclass(*args_, **kwargs_)
1223
+ if nameAndAddressRequestType.subclass:
1224
+ return nameAndAddressRequestType.subclass(*args_, **kwargs_)
1225
+ else:
1226
+ return nameAndAddressRequestType(*args_, **kwargs_)
1227
+ factory = staticmethod(factory)
1228
+ def get_ns_prefix_(self):
1229
+ return self.ns_prefix_
1230
+ def set_ns_prefix_(self, ns_prefix):
1231
+ self.ns_prefix_ = ns_prefix
1232
+ def get_name(self):
1233
+ return self.name
1234
+ def set_name(self, name):
1235
+ self.name = name
1236
+ def get_addressLine1(self):
1237
+ return self.addressLine1
1238
+ def set_addressLine1(self, addressLine1):
1239
+ self.addressLine1 = addressLine1
1240
+ def get_addressLine2(self):
1241
+ return self.addressLine2
1242
+ def set_addressLine2(self, addressLine2):
1243
+ self.addressLine2 = addressLine2
1244
+ def get_addressLine3(self):
1245
+ return self.addressLine3
1246
+ def set_addressLine3(self, addressLine3):
1247
+ self.addressLine3 = addressLine3
1248
+ def get_town(self):
1249
+ return self.town
1250
+ def set_town(self, town):
1251
+ self.town = town
1252
+ def get_exactMatch(self):
1253
+ return self.exactMatch
1254
+ def set_exactMatch(self, exactMatch):
1255
+ self.exactMatch = exactMatch
1256
+ def get_province(self):
1257
+ return self.province
1258
+ def set_province(self, province):
1259
+ self.province = province
1260
+ def get_postcode(self):
1261
+ return self.postcode
1262
+ def set_postcode(self, postcode):
1263
+ self.postcode = postcode
1264
+ def get_country(self):
1265
+ return self.country
1266
+ def set_country(self, country):
1267
+ self.country = country
1268
+ def validate_stringMaxLength40(self, value):
1269
+ result = True
1270
+ # Validate type stringMaxLength40, a restriction on xsd:string.
1271
+ if value is not None and Validate_simpletypes_ and self.gds_collector_ is not None:
1272
+ if not isinstance(value, str):
1273
+ lineno = self.gds_get_node_lineno_()
1274
+ self.gds_collector_.add_message('Value "%(value)s"%(lineno)s is not of the correct base simple type (str)' % {"value": value, "lineno": lineno, })
1275
+ return False
1276
+ if len(value) > 40:
1277
+ lineno = self.gds_get_node_lineno_()
1278
+ self.gds_collector_.add_message('Value "%(value)s"%(lineno)s does not match xsd maxLength restriction on stringMaxLength40' % {"value" : encode_str_2_3(value), "lineno": lineno} )
1279
+ result = False
1280
+ return result
1281
+ def validate_stringMaxLength30(self, value):
1282
+ result = True
1283
+ # Validate type stringMaxLength30, a restriction on xsd:string.
1284
+ if value is not None and Validate_simpletypes_ and self.gds_collector_ is not None:
1285
+ if not isinstance(value, str):
1286
+ lineno = self.gds_get_node_lineno_()
1287
+ self.gds_collector_.add_message('Value "%(value)s"%(lineno)s is not of the correct base simple type (str)' % {"value": value, "lineno": lineno, })
1288
+ return False
1289
+ if len(value) > 30:
1290
+ lineno = self.gds_get_node_lineno_()
1291
+ self.gds_collector_.add_message('Value "%(value)s"%(lineno)s does not match xsd maxLength restriction on stringMaxLength30' % {"value" : encode_str_2_3(value), "lineno": lineno} )
1292
+ result = False
1293
+ return result
1294
+ def validate_booleanEnum(self, value):
1295
+ result = True
1296
+ # Validate type booleanEnum, a restriction on xsd:string.
1297
+ if value is not None and Validate_simpletypes_ and self.gds_collector_ is not None:
1298
+ if not isinstance(value, str):
1299
+ lineno = self.gds_get_node_lineno_()
1300
+ self.gds_collector_.add_message('Value "%(value)s"%(lineno)s is not of the correct base simple type (str)' % {"value": value, "lineno": lineno, })
1301
+ return False
1302
+ value = value
1303
+ enumerations = ['N', 'Y']
1304
+ if value not in enumerations:
1305
+ lineno = self.gds_get_node_lineno_()
1306
+ self.gds_collector_.add_message('Value "%(value)s"%(lineno)s does not match xsd enumeration restriction on booleanEnum' % {"value" : encode_str_2_3(value), "lineno": lineno} )
1307
+ result = False
1308
+ return result
1309
+ def validate_stringMaxLength9(self, value):
1310
+ result = True
1311
+ # Validate type stringMaxLength9, a restriction on xsd:string.
1312
+ if value is not None and Validate_simpletypes_ and self.gds_collector_ is not None:
1313
+ if not isinstance(value, str):
1314
+ lineno = self.gds_get_node_lineno_()
1315
+ self.gds_collector_.add_message('Value "%(value)s"%(lineno)s is not of the correct base simple type (str)' % {"value": value, "lineno": lineno, })
1316
+ return False
1317
+ if len(value) > 9:
1318
+ lineno = self.gds_get_node_lineno_()
1319
+ self.gds_collector_.add_message('Value "%(value)s"%(lineno)s does not match xsd maxLength restriction on stringMaxLength9' % {"value" : encode_str_2_3(value), "lineno": lineno} )
1320
+ result = False
1321
+ return result
1322
+ def validate_stringMinLength2MaxLength2(self, value):
1323
+ result = True
1324
+ # Validate type stringMinLength2MaxLength2, a restriction on xsd:string.
1325
+ if value is not None and Validate_simpletypes_ and self.gds_collector_ is not None:
1326
+ if not isinstance(value, str):
1327
+ lineno = self.gds_get_node_lineno_()
1328
+ self.gds_collector_.add_message('Value "%(value)s"%(lineno)s is not of the correct base simple type (str)' % {"value": value, "lineno": lineno, })
1329
+ return False
1330
+ if len(value) > 2:
1331
+ lineno = self.gds_get_node_lineno_()
1332
+ self.gds_collector_.add_message('Value "%(value)s"%(lineno)s does not match xsd maxLength restriction on stringMinLength2MaxLength2' % {"value" : encode_str_2_3(value), "lineno": lineno} )
1333
+ result = False
1334
+ if len(value) < 2:
1335
+ lineno = self.gds_get_node_lineno_()
1336
+ self.gds_collector_.add_message('Value "%(value)s"%(lineno)s does not match xsd minLength restriction on stringMinLength2MaxLength2' % {"value" : encode_str_2_3(value), "lineno": lineno} )
1337
+ result = False
1338
+ return result
1339
+ def has__content(self):
1340
+ if (
1341
+ self.name is not None or
1342
+ self.addressLine1 is not None or
1343
+ self.addressLine2 is not None or
1344
+ self.addressLine3 is not None or
1345
+ self.town is not None or
1346
+ self.exactMatch != "Y" or
1347
+ self.province is not None or
1348
+ self.postcode is not None or
1349
+ self.country is not None
1350
+ ):
1351
+ return True
1352
+ else:
1353
+ return False
1354
+ def export(self, outfile, level, namespaceprefix_='', namespacedef_='', name_='nameAndAddressRequestType', pretty_print=True):
1355
+ imported_ns_def_ = GenerateDSNamespaceDefs_.get('nameAndAddressRequestType')
1356
+ if imported_ns_def_ is not None:
1357
+ namespacedef_ = imported_ns_def_
1358
+ if pretty_print:
1359
+ eol_ = '\n'
1360
+ else:
1361
+ eol_ = ''
1362
+ if self.original_tagname_ is not None and name_ == 'nameAndAddressRequestType':
1363
+ name_ = self.original_tagname_
1364
+ if UseCapturedNS_ and self.ns_prefix_:
1365
+ namespaceprefix_ = self.ns_prefix_ + ':'
1366
+ showIndent(outfile, level, pretty_print)
1367
+ outfile.write('<%s%s%s' % (namespaceprefix_, name_, namespacedef_ and ' ' + namespacedef_ or '', ))
1368
+ already_processed = set()
1369
+ self._exportAttributes(outfile, level, already_processed, namespaceprefix_, name_='nameAndAddressRequestType')
1370
+ if self.has__content():
1371
+ outfile.write('>%s' % (eol_, ))
1372
+ self._exportChildren(outfile, level + 1, namespaceprefix_, namespacedef_, name_='nameAndAddressRequestType', pretty_print=pretty_print)
1373
+ showIndent(outfile, level, pretty_print)
1374
+ outfile.write('</%s%s>%s' % (namespaceprefix_, name_, eol_))
1375
+ else:
1376
+ outfile.write('/>%s' % (eol_, ))
1377
+ def _exportAttributes(self, outfile, level, already_processed, namespaceprefix_='', name_='nameAndAddressRequestType'):
1378
+ pass
1379
+ def _exportChildren(self, outfile, level, namespaceprefix_='', namespacedef_='', name_='nameAndAddressRequestType', fromsubclass_=False, pretty_print=True):
1380
+ if pretty_print:
1381
+ eol_ = '\n'
1382
+ else:
1383
+ eol_ = ''
1384
+ if self.name is not None:
1385
+ namespaceprefix_ = self.name_nsprefix_ + ':' if (UseCapturedNS_ and self.name_nsprefix_) else ''
1386
+ showIndent(outfile, level, pretty_print)
1387
+ outfile.write('<%sname>%s</%sname>%s' % (namespaceprefix_ , self.gds_encode(self.gds_format_string(quote_xml(self.name), input_name='name')), namespaceprefix_ , eol_))
1388
+ if self.addressLine1 is not None:
1389
+ namespaceprefix_ = self.addressLine1_nsprefix_ + ':' if (UseCapturedNS_ and self.addressLine1_nsprefix_) else ''
1390
+ showIndent(outfile, level, pretty_print)
1391
+ outfile.write('<%saddressLine1>%s</%saddressLine1>%s' % (namespaceprefix_ , self.gds_encode(self.gds_format_string(quote_xml(self.addressLine1), input_name='addressLine1')), namespaceprefix_ , eol_))
1392
+ if self.addressLine2 is not None:
1393
+ namespaceprefix_ = self.addressLine2_nsprefix_ + ':' if (UseCapturedNS_ and self.addressLine2_nsprefix_) else ''
1394
+ showIndent(outfile, level, pretty_print)
1395
+ outfile.write('<%saddressLine2>%s</%saddressLine2>%s' % (namespaceprefix_ , self.gds_encode(self.gds_format_string(quote_xml(self.addressLine2), input_name='addressLine2')), namespaceprefix_ , eol_))
1396
+ if self.addressLine3 is not None:
1397
+ namespaceprefix_ = self.addressLine3_nsprefix_ + ':' if (UseCapturedNS_ and self.addressLine3_nsprefix_) else ''
1398
+ showIndent(outfile, level, pretty_print)
1399
+ outfile.write('<%saddressLine3>%s</%saddressLine3>%s' % (namespaceprefix_ , self.gds_encode(self.gds_format_string(quote_xml(self.addressLine3), input_name='addressLine3')), namespaceprefix_ , eol_))
1400
+ if self.town is not None:
1401
+ namespaceprefix_ = self.town_nsprefix_ + ':' if (UseCapturedNS_ and self.town_nsprefix_) else ''
1402
+ showIndent(outfile, level, pretty_print)
1403
+ outfile.write('<%stown>%s</%stown>%s' % (namespaceprefix_ , self.gds_encode(self.gds_format_string(quote_xml(self.town), input_name='town')), namespaceprefix_ , eol_))
1404
+ if self.exactMatch != "Y":
1405
+ namespaceprefix_ = self.exactMatch_nsprefix_ + ':' if (UseCapturedNS_ and self.exactMatch_nsprefix_) else ''
1406
+ showIndent(outfile, level, pretty_print)
1407
+ outfile.write('<%sexactMatch>%s</%sexactMatch>%s' % (namespaceprefix_ , self.gds_encode(self.gds_format_string(quote_xml(self.exactMatch), input_name='exactMatch')), namespaceprefix_ , eol_))
1408
+ if self.province is not None:
1409
+ namespaceprefix_ = self.province_nsprefix_ + ':' if (UseCapturedNS_ and self.province_nsprefix_) else ''
1410
+ showIndent(outfile, level, pretty_print)
1411
+ outfile.write('<%sprovince>%s</%sprovince>%s' % (namespaceprefix_ , self.gds_encode(self.gds_format_string(quote_xml(self.province), input_name='province')), namespaceprefix_ , eol_))
1412
+ if self.postcode is not None:
1413
+ namespaceprefix_ = self.postcode_nsprefix_ + ':' if (UseCapturedNS_ and self.postcode_nsprefix_) else ''
1414
+ showIndent(outfile, level, pretty_print)
1415
+ outfile.write('<%spostcode>%s</%spostcode>%s' % (namespaceprefix_ , self.gds_encode(self.gds_format_string(quote_xml(self.postcode), input_name='postcode')), namespaceprefix_ , eol_))
1416
+ if self.country is not None:
1417
+ namespaceprefix_ = self.country_nsprefix_ + ':' if (UseCapturedNS_ and self.country_nsprefix_) else ''
1418
+ showIndent(outfile, level, pretty_print)
1419
+ outfile.write('<%scountry>%s</%scountry>%s' % (namespaceprefix_ , self.gds_encode(self.gds_format_string(quote_xml(self.country), input_name='country')), namespaceprefix_ , eol_))
1420
+ def build(self, node, gds_collector_=None):
1421
+ self.gds_collector_ = gds_collector_
1422
+ if SaveElementTreeNode:
1423
+ self.gds_elementtree_node_ = node
1424
+ already_processed = set()
1425
+ self.ns_prefix_ = node.prefix
1426
+ self._buildAttributes(node, node.attrib, already_processed)
1427
+ for child in node:
1428
+ nodeName_ = Tag_pattern_.match(child.tag).groups()[-1]
1429
+ self._buildChildren(child, node, nodeName_, gds_collector_=gds_collector_)
1430
+ return self
1431
+ def _buildAttributes(self, node, attrs, already_processed):
1432
+ pass
1433
+ def _buildChildren(self, child_, node, nodeName_, fromsubclass_=False, gds_collector_=None):
1434
+ if nodeName_ == 'name':
1435
+ value_ = child_.text
1436
+ value_ = self.gds_parse_string(value_, node, 'name')
1437
+ value_ = self.gds_validate_string(value_, node, 'name')
1438
+ self.name = value_
1439
+ self.name_nsprefix_ = child_.prefix
1440
+ # validate type stringMaxLength40
1441
+ self.validate_stringMaxLength40(self.name)
1442
+ elif nodeName_ == 'addressLine1':
1443
+ value_ = child_.text
1444
+ value_ = self.gds_parse_string(value_, node, 'addressLine1')
1445
+ value_ = self.gds_validate_string(value_, node, 'addressLine1')
1446
+ self.addressLine1 = value_
1447
+ self.addressLine1_nsprefix_ = child_.prefix
1448
+ # validate type stringMaxLength30
1449
+ self.validate_stringMaxLength30(self.addressLine1)
1450
+ elif nodeName_ == 'addressLine2':
1451
+ value_ = child_.text
1452
+ value_ = self.gds_parse_string(value_, node, 'addressLine2')
1453
+ value_ = self.gds_validate_string(value_, node, 'addressLine2')
1454
+ self.addressLine2 = value_
1455
+ self.addressLine2_nsprefix_ = child_.prefix
1456
+ # validate type stringMaxLength30
1457
+ self.validate_stringMaxLength30(self.addressLine2)
1458
+ elif nodeName_ == 'addressLine3':
1459
+ value_ = child_.text
1460
+ value_ = self.gds_parse_string(value_, node, 'addressLine3')
1461
+ value_ = self.gds_validate_string(value_, node, 'addressLine3')
1462
+ self.addressLine3 = value_
1463
+ self.addressLine3_nsprefix_ = child_.prefix
1464
+ # validate type stringMaxLength30
1465
+ self.validate_stringMaxLength30(self.addressLine3)
1466
+ elif nodeName_ == 'town':
1467
+ value_ = child_.text
1468
+ value_ = self.gds_parse_string(value_, node, 'town')
1469
+ value_ = self.gds_validate_string(value_, node, 'town')
1470
+ self.town = value_
1471
+ self.town_nsprefix_ = child_.prefix
1472
+ # validate type stringMaxLength40
1473
+ self.validate_stringMaxLength40(self.town)
1474
+ elif nodeName_ == 'exactMatch':
1475
+ value_ = child_.text
1476
+ value_ = self.gds_parse_string(value_, node, 'exactMatch')
1477
+ value_ = self.gds_validate_string(value_, node, 'exactMatch')
1478
+ self.exactMatch = value_
1479
+ self.exactMatch_nsprefix_ = child_.prefix
1480
+ # validate type booleanEnum
1481
+ self.validate_booleanEnum(self.exactMatch)
1482
+ elif nodeName_ == 'province':
1483
+ value_ = child_.text
1484
+ value_ = self.gds_parse_string(value_, node, 'province')
1485
+ value_ = self.gds_validate_string(value_, node, 'province')
1486
+ self.province = value_
1487
+ self.province_nsprefix_ = child_.prefix
1488
+ # validate type stringMaxLength30
1489
+ self.validate_stringMaxLength30(self.province)
1490
+ elif nodeName_ == 'postcode':
1491
+ value_ = child_.text
1492
+ value_ = self.gds_parse_string(value_, node, 'postcode')
1493
+ value_ = self.gds_validate_string(value_, node, 'postcode')
1494
+ self.postcode = value_
1495
+ self.postcode_nsprefix_ = child_.prefix
1496
+ # validate type stringMaxLength9
1497
+ self.validate_stringMaxLength9(self.postcode)
1498
+ elif nodeName_ == 'country':
1499
+ value_ = child_.text
1500
+ value_ = self.gds_parse_string(value_, node, 'country')
1501
+ value_ = self.gds_validate_string(value_, node, 'country')
1502
+ self.country = value_
1503
+ self.country_nsprefix_ = child_.prefix
1504
+ # validate type stringMinLength2MaxLength2
1505
+ self.validate_stringMinLength2MaxLength2(self.country)
1506
+ # end class nameAndAddressRequestType
1507
+
1508
+
1509
+ class nameAndAddressResponseType(GeneratedsSuper):
1510
+ """nameAndAddressResponseType -- Information relating to name and address for a participant
1511
+ in the consignment.
1512
+ Examples of a participant are:
1513
+ The Sender - the company sending the consignment
1514
+ The Receiver - the company receiving the consignment
1515
+ The Collection Address - the address from which the consignment is picked up
1516
+ The Delivery Address - the address to which the consignment should be delivered
1517
+ name -- Either the name of the company as recognised by TNT, or the
1518
+ contact name at the address
1519
+ addressLine1 -- This address line is the most commonly used of the three
1520
+ address lines and is therefore mandatory.
1521
+ addressLine2 -- This address line may not be used by the supporting system
1522
+ and therefore should not contain information essential to the address.
1523
+ addressLine3 -- This address line may not be used by the supporting system
1524
+ and therefore should not contain information essential to the address.
1525
+ NOTE - this will not appear on any routingLabel produced.
1526
+ town -- The town name as recognised by TNT
1527
+ province -- Optional field to contain the province, county, state, or area
1528
+ for the given address.
1529
+ postcode -- Postcode or zip code is considered a mandatory field where it is
1530
+ used in a given country. If the postcode is not provided, it may
1531
+ not be possible to deliver the consignment as indicated by your
1532
+ chosen service.
1533
+ country -- The ISO country code for the country of the given address.
1534
+
1535
+ """
1536
+ __hash__ = GeneratedsSuper.__hash__
1537
+ subclass = None
1538
+ superclass = None
1539
+ def __init__(self, name=None, addressLine1=None, addressLine2=None, addressLine3=None, town=None, province=None, postcode=None, country=None, gds_collector_=None, **kwargs_):
1540
+ self.gds_collector_ = gds_collector_
1541
+ self.gds_elementtree_node_ = None
1542
+ self.original_tagname_ = None
1543
+ self.parent_object_ = kwargs_.get('parent_object_')
1544
+ self.ns_prefix_ = None
1545
+ self.name = name
1546
+ self.validate_stringMaxLength40(self.name)
1547
+ self.name_nsprefix_ = None
1548
+ self.addressLine1 = addressLine1
1549
+ self.validate_stringMaxLength30(self.addressLine1)
1550
+ self.addressLine1_nsprefix_ = None
1551
+ self.addressLine2 = addressLine2
1552
+ self.validate_stringMaxLength30(self.addressLine2)
1553
+ self.addressLine2_nsprefix_ = None
1554
+ self.addressLine3 = addressLine3
1555
+ self.validate_stringMaxLength30(self.addressLine3)
1556
+ self.addressLine3_nsprefix_ = None
1557
+ self.town = town
1558
+ self.validate_stringMaxLength40(self.town)
1559
+ self.town_nsprefix_ = None
1560
+ self.province = province
1561
+ self.validate_stringMaxLength30(self.province)
1562
+ self.province_nsprefix_ = None
1563
+ self.postcode = postcode
1564
+ self.validate_stringMaxLength9(self.postcode)
1565
+ self.postcode_nsprefix_ = None
1566
+ self.country = country
1567
+ self.validate_stringMinLength2MaxLength2(self.country)
1568
+ self.country_nsprefix_ = None
1569
+ def factory(*args_, **kwargs_):
1570
+ if CurrentSubclassModule_ is not None:
1571
+ subclass = getSubclassFromModule_(
1572
+ CurrentSubclassModule_, nameAndAddressResponseType)
1573
+ if subclass is not None:
1574
+ return subclass(*args_, **kwargs_)
1575
+ if nameAndAddressResponseType.subclass:
1576
+ return nameAndAddressResponseType.subclass(*args_, **kwargs_)
1577
+ else:
1578
+ return nameAndAddressResponseType(*args_, **kwargs_)
1579
+ factory = staticmethod(factory)
1580
+ def get_ns_prefix_(self):
1581
+ return self.ns_prefix_
1582
+ def set_ns_prefix_(self, ns_prefix):
1583
+ self.ns_prefix_ = ns_prefix
1584
+ def get_name(self):
1585
+ return self.name
1586
+ def set_name(self, name):
1587
+ self.name = name
1588
+ def get_addressLine1(self):
1589
+ return self.addressLine1
1590
+ def set_addressLine1(self, addressLine1):
1591
+ self.addressLine1 = addressLine1
1592
+ def get_addressLine2(self):
1593
+ return self.addressLine2
1594
+ def set_addressLine2(self, addressLine2):
1595
+ self.addressLine2 = addressLine2
1596
+ def get_addressLine3(self):
1597
+ return self.addressLine3
1598
+ def set_addressLine3(self, addressLine3):
1599
+ self.addressLine3 = addressLine3
1600
+ def get_town(self):
1601
+ return self.town
1602
+ def set_town(self, town):
1603
+ self.town = town
1604
+ def get_province(self):
1605
+ return self.province
1606
+ def set_province(self, province):
1607
+ self.province = province
1608
+ def get_postcode(self):
1609
+ return self.postcode
1610
+ def set_postcode(self, postcode):
1611
+ self.postcode = postcode
1612
+ def get_country(self):
1613
+ return self.country
1614
+ def set_country(self, country):
1615
+ self.country = country
1616
+ def validate_stringMaxLength40(self, value):
1617
+ result = True
1618
+ # Validate type stringMaxLength40, a restriction on xsd:string.
1619
+ if value is not None and Validate_simpletypes_ and self.gds_collector_ is not None:
1620
+ if not isinstance(value, str):
1621
+ lineno = self.gds_get_node_lineno_()
1622
+ self.gds_collector_.add_message('Value "%(value)s"%(lineno)s is not of the correct base simple type (str)' % {"value": value, "lineno": lineno, })
1623
+ return False
1624
+ if len(value) > 40:
1625
+ lineno = self.gds_get_node_lineno_()
1626
+ self.gds_collector_.add_message('Value "%(value)s"%(lineno)s does not match xsd maxLength restriction on stringMaxLength40' % {"value" : encode_str_2_3(value), "lineno": lineno} )
1627
+ result = False
1628
+ return result
1629
+ def validate_stringMaxLength30(self, value):
1630
+ result = True
1631
+ # Validate type stringMaxLength30, a restriction on xsd:string.
1632
+ if value is not None and Validate_simpletypes_ and self.gds_collector_ is not None:
1633
+ if not isinstance(value, str):
1634
+ lineno = self.gds_get_node_lineno_()
1635
+ self.gds_collector_.add_message('Value "%(value)s"%(lineno)s is not of the correct base simple type (str)' % {"value": value, "lineno": lineno, })
1636
+ return False
1637
+ if len(value) > 30:
1638
+ lineno = self.gds_get_node_lineno_()
1639
+ self.gds_collector_.add_message('Value "%(value)s"%(lineno)s does not match xsd maxLength restriction on stringMaxLength30' % {"value" : encode_str_2_3(value), "lineno": lineno} )
1640
+ result = False
1641
+ return result
1642
+ def validate_stringMaxLength9(self, value):
1643
+ result = True
1644
+ # Validate type stringMaxLength9, a restriction on xsd:string.
1645
+ if value is not None and Validate_simpletypes_ and self.gds_collector_ is not None:
1646
+ if not isinstance(value, str):
1647
+ lineno = self.gds_get_node_lineno_()
1648
+ self.gds_collector_.add_message('Value "%(value)s"%(lineno)s is not of the correct base simple type (str)' % {"value": value, "lineno": lineno, })
1649
+ return False
1650
+ if len(value) > 9:
1651
+ lineno = self.gds_get_node_lineno_()
1652
+ self.gds_collector_.add_message('Value "%(value)s"%(lineno)s does not match xsd maxLength restriction on stringMaxLength9' % {"value" : encode_str_2_3(value), "lineno": lineno} )
1653
+ result = False
1654
+ return result
1655
+ def validate_stringMinLength2MaxLength2(self, value):
1656
+ result = True
1657
+ # Validate type stringMinLength2MaxLength2, a restriction on xsd:string.
1658
+ if value is not None and Validate_simpletypes_ and self.gds_collector_ is not None:
1659
+ if not isinstance(value, str):
1660
+ lineno = self.gds_get_node_lineno_()
1661
+ self.gds_collector_.add_message('Value "%(value)s"%(lineno)s is not of the correct base simple type (str)' % {"value": value, "lineno": lineno, })
1662
+ return False
1663
+ if len(value) > 2:
1664
+ lineno = self.gds_get_node_lineno_()
1665
+ self.gds_collector_.add_message('Value "%(value)s"%(lineno)s does not match xsd maxLength restriction on stringMinLength2MaxLength2' % {"value" : encode_str_2_3(value), "lineno": lineno} )
1666
+ result = False
1667
+ if len(value) < 2:
1668
+ lineno = self.gds_get_node_lineno_()
1669
+ self.gds_collector_.add_message('Value "%(value)s"%(lineno)s does not match xsd minLength restriction on stringMinLength2MaxLength2' % {"value" : encode_str_2_3(value), "lineno": lineno} )
1670
+ result = False
1671
+ return result
1672
+ def has__content(self):
1673
+ if (
1674
+ self.name is not None or
1675
+ self.addressLine1 is not None or
1676
+ self.addressLine2 is not None or
1677
+ self.addressLine3 is not None or
1678
+ self.town is not None or
1679
+ self.province is not None or
1680
+ self.postcode is not None or
1681
+ self.country is not None
1682
+ ):
1683
+ return True
1684
+ else:
1685
+ return False
1686
+ def export(self, outfile, level, namespaceprefix_='', namespacedef_='', name_='nameAndAddressResponseType', pretty_print=True):
1687
+ imported_ns_def_ = GenerateDSNamespaceDefs_.get('nameAndAddressResponseType')
1688
+ if imported_ns_def_ is not None:
1689
+ namespacedef_ = imported_ns_def_
1690
+ if pretty_print:
1691
+ eol_ = '\n'
1692
+ else:
1693
+ eol_ = ''
1694
+ if self.original_tagname_ is not None and name_ == 'nameAndAddressResponseType':
1695
+ name_ = self.original_tagname_
1696
+ if UseCapturedNS_ and self.ns_prefix_:
1697
+ namespaceprefix_ = self.ns_prefix_ + ':'
1698
+ showIndent(outfile, level, pretty_print)
1699
+ outfile.write('<%s%s%s' % (namespaceprefix_, name_, namespacedef_ and ' ' + namespacedef_ or '', ))
1700
+ already_processed = set()
1701
+ self._exportAttributes(outfile, level, already_processed, namespaceprefix_, name_='nameAndAddressResponseType')
1702
+ if self.has__content():
1703
+ outfile.write('>%s' % (eol_, ))
1704
+ self._exportChildren(outfile, level + 1, namespaceprefix_, namespacedef_, name_='nameAndAddressResponseType', pretty_print=pretty_print)
1705
+ showIndent(outfile, level, pretty_print)
1706
+ outfile.write('</%s%s>%s' % (namespaceprefix_, name_, eol_))
1707
+ else:
1708
+ outfile.write('/>%s' % (eol_, ))
1709
+ def _exportAttributes(self, outfile, level, already_processed, namespaceprefix_='', name_='nameAndAddressResponseType'):
1710
+ pass
1711
+ def _exportChildren(self, outfile, level, namespaceprefix_='', namespacedef_='', name_='nameAndAddressResponseType', fromsubclass_=False, pretty_print=True):
1712
+ if pretty_print:
1713
+ eol_ = '\n'
1714
+ else:
1715
+ eol_ = ''
1716
+ if self.name is not None:
1717
+ namespaceprefix_ = self.name_nsprefix_ + ':' if (UseCapturedNS_ and self.name_nsprefix_) else ''
1718
+ showIndent(outfile, level, pretty_print)
1719
+ outfile.write('<%sname>%s</%sname>%s' % (namespaceprefix_ , self.gds_encode(self.gds_format_string(quote_xml(self.name), input_name='name')), namespaceprefix_ , eol_))
1720
+ if self.addressLine1 is not None:
1721
+ namespaceprefix_ = self.addressLine1_nsprefix_ + ':' if (UseCapturedNS_ and self.addressLine1_nsprefix_) else ''
1722
+ showIndent(outfile, level, pretty_print)
1723
+ outfile.write('<%saddressLine1>%s</%saddressLine1>%s' % (namespaceprefix_ , self.gds_encode(self.gds_format_string(quote_xml(self.addressLine1), input_name='addressLine1')), namespaceprefix_ , eol_))
1724
+ if self.addressLine2 is not None:
1725
+ namespaceprefix_ = self.addressLine2_nsprefix_ + ':' if (UseCapturedNS_ and self.addressLine2_nsprefix_) else ''
1726
+ showIndent(outfile, level, pretty_print)
1727
+ outfile.write('<%saddressLine2>%s</%saddressLine2>%s' % (namespaceprefix_ , self.gds_encode(self.gds_format_string(quote_xml(self.addressLine2), input_name='addressLine2')), namespaceprefix_ , eol_))
1728
+ if self.addressLine3 is not None:
1729
+ namespaceprefix_ = self.addressLine3_nsprefix_ + ':' if (UseCapturedNS_ and self.addressLine3_nsprefix_) else ''
1730
+ showIndent(outfile, level, pretty_print)
1731
+ outfile.write('<%saddressLine3>%s</%saddressLine3>%s' % (namespaceprefix_ , self.gds_encode(self.gds_format_string(quote_xml(self.addressLine3), input_name='addressLine3')), namespaceprefix_ , eol_))
1732
+ if self.town is not None:
1733
+ namespaceprefix_ = self.town_nsprefix_ + ':' if (UseCapturedNS_ and self.town_nsprefix_) else ''
1734
+ showIndent(outfile, level, pretty_print)
1735
+ outfile.write('<%stown>%s</%stown>%s' % (namespaceprefix_ , self.gds_encode(self.gds_format_string(quote_xml(self.town), input_name='town')), namespaceprefix_ , eol_))
1736
+ if self.province is not None:
1737
+ namespaceprefix_ = self.province_nsprefix_ + ':' if (UseCapturedNS_ and self.province_nsprefix_) else ''
1738
+ showIndent(outfile, level, pretty_print)
1739
+ outfile.write('<%sprovince>%s</%sprovince>%s' % (namespaceprefix_ , self.gds_encode(self.gds_format_string(quote_xml(self.province), input_name='province')), namespaceprefix_ , eol_))
1740
+ if self.postcode is not None:
1741
+ namespaceprefix_ = self.postcode_nsprefix_ + ':' if (UseCapturedNS_ and self.postcode_nsprefix_) else ''
1742
+ showIndent(outfile, level, pretty_print)
1743
+ outfile.write('<%spostcode>%s</%spostcode>%s' % (namespaceprefix_ , self.gds_encode(self.gds_format_string(quote_xml(self.postcode), input_name='postcode')), namespaceprefix_ , eol_))
1744
+ if self.country is not None:
1745
+ namespaceprefix_ = self.country_nsprefix_ + ':' if (UseCapturedNS_ and self.country_nsprefix_) else ''
1746
+ showIndent(outfile, level, pretty_print)
1747
+ outfile.write('<%scountry>%s</%scountry>%s' % (namespaceprefix_ , self.gds_encode(self.gds_format_string(quote_xml(self.country), input_name='country')), namespaceprefix_ , eol_))
1748
+ def build(self, node, gds_collector_=None):
1749
+ self.gds_collector_ = gds_collector_
1750
+ if SaveElementTreeNode:
1751
+ self.gds_elementtree_node_ = node
1752
+ already_processed = set()
1753
+ self.ns_prefix_ = node.prefix
1754
+ self._buildAttributes(node, node.attrib, already_processed)
1755
+ for child in node:
1756
+ nodeName_ = Tag_pattern_.match(child.tag).groups()[-1]
1757
+ self._buildChildren(child, node, nodeName_, gds_collector_=gds_collector_)
1758
+ return self
1759
+ def _buildAttributes(self, node, attrs, already_processed):
1760
+ pass
1761
+ def _buildChildren(self, child_, node, nodeName_, fromsubclass_=False, gds_collector_=None):
1762
+ if nodeName_ == 'name':
1763
+ value_ = child_.text
1764
+ value_ = self.gds_parse_string(value_, node, 'name')
1765
+ value_ = self.gds_validate_string(value_, node, 'name')
1766
+ self.name = value_
1767
+ self.name_nsprefix_ = child_.prefix
1768
+ # validate type stringMaxLength40
1769
+ self.validate_stringMaxLength40(self.name)
1770
+ elif nodeName_ == 'addressLine1':
1771
+ value_ = child_.text
1772
+ value_ = self.gds_parse_string(value_, node, 'addressLine1')
1773
+ value_ = self.gds_validate_string(value_, node, 'addressLine1')
1774
+ self.addressLine1 = value_
1775
+ self.addressLine1_nsprefix_ = child_.prefix
1776
+ # validate type stringMaxLength30
1777
+ self.validate_stringMaxLength30(self.addressLine1)
1778
+ elif nodeName_ == 'addressLine2':
1779
+ value_ = child_.text
1780
+ value_ = self.gds_parse_string(value_, node, 'addressLine2')
1781
+ value_ = self.gds_validate_string(value_, node, 'addressLine2')
1782
+ self.addressLine2 = value_
1783
+ self.addressLine2_nsprefix_ = child_.prefix
1784
+ # validate type stringMaxLength30
1785
+ self.validate_stringMaxLength30(self.addressLine2)
1786
+ elif nodeName_ == 'addressLine3':
1787
+ value_ = child_.text
1788
+ value_ = self.gds_parse_string(value_, node, 'addressLine3')
1789
+ value_ = self.gds_validate_string(value_, node, 'addressLine3')
1790
+ self.addressLine3 = value_
1791
+ self.addressLine3_nsprefix_ = child_.prefix
1792
+ # validate type stringMaxLength30
1793
+ self.validate_stringMaxLength30(self.addressLine3)
1794
+ elif nodeName_ == 'town':
1795
+ value_ = child_.text
1796
+ value_ = self.gds_parse_string(value_, node, 'town')
1797
+ value_ = self.gds_validate_string(value_, node, 'town')
1798
+ self.town = value_
1799
+ self.town_nsprefix_ = child_.prefix
1800
+ # validate type stringMaxLength40
1801
+ self.validate_stringMaxLength40(self.town)
1802
+ elif nodeName_ == 'province':
1803
+ value_ = child_.text
1804
+ value_ = self.gds_parse_string(value_, node, 'province')
1805
+ value_ = self.gds_validate_string(value_, node, 'province')
1806
+ self.province = value_
1807
+ self.province_nsprefix_ = child_.prefix
1808
+ # validate type stringMaxLength30
1809
+ self.validate_stringMaxLength30(self.province)
1810
+ elif nodeName_ == 'postcode':
1811
+ value_ = child_.text
1812
+ value_ = self.gds_parse_string(value_, node, 'postcode')
1813
+ value_ = self.gds_validate_string(value_, node, 'postcode')
1814
+ self.postcode = value_
1815
+ self.postcode_nsprefix_ = child_.prefix
1816
+ # validate type stringMaxLength9
1817
+ self.validate_stringMaxLength9(self.postcode)
1818
+ elif nodeName_ == 'country':
1819
+ value_ = child_.text
1820
+ value_ = self.gds_parse_string(value_, node, 'country')
1821
+ value_ = self.gds_validate_string(value_, node, 'country')
1822
+ self.country = value_
1823
+ self.country_nsprefix_ = child_.prefix
1824
+ # validate type stringMinLength2MaxLength2
1825
+ self.validate_stringMinLength2MaxLength2(self.country)
1826
+ # end class nameAndAddressResponseType
1827
+
1828
+
1829
+ class optionType(GeneratedsSuper):
1830
+ """optionType -- The type of option chosen for this consignment.
1831
+ Examples include insurance, priority.
1832
+ optionId -- Code that defines options for the consignment e.g. insurance,
1833
+ priority.
1834
+
1835
+ """
1836
+ __hash__ = GeneratedsSuper.__hash__
1837
+ subclass = None
1838
+ superclass = None
1839
+ def __init__(self, optionId=None, gds_collector_=None, **kwargs_):
1840
+ self.gds_collector_ = gds_collector_
1841
+ self.gds_elementtree_node_ = None
1842
+ self.original_tagname_ = None
1843
+ self.parent_object_ = kwargs_.get('parent_object_')
1844
+ self.ns_prefix_ = None
1845
+ if optionId is None:
1846
+ self.optionId = []
1847
+ else:
1848
+ self.optionId = optionId
1849
+ self.optionId_nsprefix_ = None
1850
+ def factory(*args_, **kwargs_):
1851
+ if CurrentSubclassModule_ is not None:
1852
+ subclass = getSubclassFromModule_(
1853
+ CurrentSubclassModule_, optionType)
1854
+ if subclass is not None:
1855
+ return subclass(*args_, **kwargs_)
1856
+ if optionType.subclass:
1857
+ return optionType.subclass(*args_, **kwargs_)
1858
+ else:
1859
+ return optionType(*args_, **kwargs_)
1860
+ factory = staticmethod(factory)
1861
+ def get_ns_prefix_(self):
1862
+ return self.ns_prefix_
1863
+ def set_ns_prefix_(self, ns_prefix):
1864
+ self.ns_prefix_ = ns_prefix
1865
+ def get_optionId(self):
1866
+ return self.optionId
1867
+ def set_optionId(self, optionId):
1868
+ self.optionId = optionId
1869
+ def add_optionId(self, value):
1870
+ self.optionId.append(value)
1871
+ def insert_optionId_at(self, index, value):
1872
+ self.optionId.insert(index, value)
1873
+ def replace_optionId_at(self, index, value):
1874
+ self.optionId[index] = value
1875
+ def has__content(self):
1876
+ if (
1877
+ self.optionId
1878
+ ):
1879
+ return True
1880
+ else:
1881
+ return False
1882
+ def export(self, outfile, level, namespaceprefix_='', namespacedef_='', name_='optionType', pretty_print=True):
1883
+ imported_ns_def_ = GenerateDSNamespaceDefs_.get('optionType')
1884
+ if imported_ns_def_ is not None:
1885
+ namespacedef_ = imported_ns_def_
1886
+ if pretty_print:
1887
+ eol_ = '\n'
1888
+ else:
1889
+ eol_ = ''
1890
+ if self.original_tagname_ is not None and name_ == 'optionType':
1891
+ name_ = self.original_tagname_
1892
+ if UseCapturedNS_ and self.ns_prefix_:
1893
+ namespaceprefix_ = self.ns_prefix_ + ':'
1894
+ showIndent(outfile, level, pretty_print)
1895
+ outfile.write('<%s%s%s' % (namespaceprefix_, name_, namespacedef_ and ' ' + namespacedef_ or '', ))
1896
+ already_processed = set()
1897
+ self._exportAttributes(outfile, level, already_processed, namespaceprefix_, name_='optionType')
1898
+ if self.has__content():
1899
+ outfile.write('>%s' % (eol_, ))
1900
+ self._exportChildren(outfile, level + 1, namespaceprefix_, namespacedef_, name_='optionType', pretty_print=pretty_print)
1901
+ showIndent(outfile, level, pretty_print)
1902
+ outfile.write('</%s%s>%s' % (namespaceprefix_, name_, eol_))
1903
+ else:
1904
+ outfile.write('/>%s' % (eol_, ))
1905
+ def _exportAttributes(self, outfile, level, already_processed, namespaceprefix_='', name_='optionType'):
1906
+ pass
1907
+ def _exportChildren(self, outfile, level, namespaceprefix_='', namespacedef_='', name_='optionType', fromsubclass_=False, pretty_print=True):
1908
+ if pretty_print:
1909
+ eol_ = '\n'
1910
+ else:
1911
+ eol_ = ''
1912
+ for optionId_ in self.optionId:
1913
+ namespaceprefix_ = self.optionId_nsprefix_ + ':' if (UseCapturedNS_ and self.optionId_nsprefix_) else ''
1914
+ showIndent(outfile, level, pretty_print)
1915
+ outfile.write('<%soptionId>%s</%soptionId>%s' % (namespaceprefix_ , self.gds_encode(self.gds_format_string(quote_xml(optionId_), input_name='optionId')), namespaceprefix_ , eol_))
1916
+ def build(self, node, gds_collector_=None):
1917
+ self.gds_collector_ = gds_collector_
1918
+ if SaveElementTreeNode:
1919
+ self.gds_elementtree_node_ = node
1920
+ already_processed = set()
1921
+ self.ns_prefix_ = node.prefix
1922
+ self._buildAttributes(node, node.attrib, already_processed)
1923
+ for child in node:
1924
+ nodeName_ = Tag_pattern_.match(child.tag).groups()[-1]
1925
+ self._buildChildren(child, node, nodeName_, gds_collector_=gds_collector_)
1926
+ return self
1927
+ def _buildAttributes(self, node, attrs, already_processed):
1928
+ pass
1929
+ def _buildChildren(self, child_, node, nodeName_, fromsubclass_=False, gds_collector_=None):
1930
+ if nodeName_ == 'optionId':
1931
+ value_ = child_.text
1932
+ value_ = self.gds_parse_string(value_, node, 'optionId')
1933
+ value_ = self.gds_validate_string(value_, node, 'optionId')
1934
+ self.optionId.append(value_)
1935
+ self.optionId_nsprefix_ = child_.prefix
1936
+ # end class optionType
1937
+
1938
+
1939
+ class measurementsType(GeneratedsSuper):
1940
+ """measurementsType -- The dimensions (height, width, length) and weight of the consignment,
1941
+ piece or article. Data must be provided in metres for dimensions,
1942
+ kilograms for weight.
1943
+ length -- The length in metres. The length is the longest dimension
1944
+ of the piece. (A piece is a box, envelope, or parcel -
1945
+ i.e. a separate item being shipped.)
1946
+ width -- The width in metres.
1947
+ height -- The height in metres.
1948
+ weight -- The weight in kilograms.
1949
+
1950
+ """
1951
+ __hash__ = GeneratedsSuper.__hash__
1952
+ subclass = None
1953
+ superclass = None
1954
+ def __init__(self, length=None, width=None, height=None, weight=None, gds_collector_=None, **kwargs_):
1955
+ self.gds_collector_ = gds_collector_
1956
+ self.gds_elementtree_node_ = None
1957
+ self.original_tagname_ = None
1958
+ self.parent_object_ = kwargs_.get('parent_object_')
1959
+ self.ns_prefix_ = None
1960
+ self.length = length
1961
+ self.validate_doubleMaxExclusive100MinInclusive0_01(self.length)
1962
+ self.length_nsprefix_ = None
1963
+ self.width = width
1964
+ self.validate_doubleMaxExclusive100MinInclusive0_01(self.width)
1965
+ self.width_nsprefix_ = None
1966
+ self.height = height
1967
+ self.validate_doubleMaxExclusive100MinInclusive0_01(self.height)
1968
+ self.height_nsprefix_ = None
1969
+ self.weight = weight
1970
+ self.validate_doubleMaxExclusive100000MinInclusive0_01(self.weight)
1971
+ self.weight_nsprefix_ = None
1972
+ def factory(*args_, **kwargs_):
1973
+ if CurrentSubclassModule_ is not None:
1974
+ subclass = getSubclassFromModule_(
1975
+ CurrentSubclassModule_, measurementsType)
1976
+ if subclass is not None:
1977
+ return subclass(*args_, **kwargs_)
1978
+ if measurementsType.subclass:
1979
+ return measurementsType.subclass(*args_, **kwargs_)
1980
+ else:
1981
+ return measurementsType(*args_, **kwargs_)
1982
+ factory = staticmethod(factory)
1983
+ def get_ns_prefix_(self):
1984
+ return self.ns_prefix_
1985
+ def set_ns_prefix_(self, ns_prefix):
1986
+ self.ns_prefix_ = ns_prefix
1987
+ def get_length(self):
1988
+ return self.length
1989
+ def set_length(self, length):
1990
+ self.length = length
1991
+ def get_width(self):
1992
+ return self.width
1993
+ def set_width(self, width):
1994
+ self.width = width
1995
+ def get_height(self):
1996
+ return self.height
1997
+ def set_height(self, height):
1998
+ self.height = height
1999
+ def get_weight(self):
2000
+ return self.weight
2001
+ def set_weight(self, weight):
2002
+ self.weight = weight
2003
+ def validate_doubleMaxExclusive100MinInclusive0_01(self, value):
2004
+ result = True
2005
+ # Validate type doubleMaxExclusive100MinInclusive0.01, a restriction on xsd:double.
2006
+ if value is not None and Validate_simpletypes_ and self.gds_collector_ is not None:
2007
+ if not isinstance(value, float):
2008
+ lineno = self.gds_get_node_lineno_()
2009
+ self.gds_collector_.add_message('Value "%(value)s"%(lineno)s is not of the correct base simple type (float)' % {"value": value, "lineno": lineno, })
2010
+ return False
2011
+ if value < 0.01:
2012
+ lineno = self.gds_get_node_lineno_()
2013
+ self.gds_collector_.add_message('Value "%(value)s"%(lineno)s does not match xsd minInclusive restriction on doubleMaxExclusive100MinInclusive0.01' % {"value": value, "lineno": lineno} )
2014
+ result = False
2015
+ if value >= 100:
2016
+ lineno = self.gds_get_node_lineno_()
2017
+ self.gds_collector_.add_message('Value "%(value)s"%(lineno)s does not match xsd maxExclusive restriction on doubleMaxExclusive100MinInclusive0.01' % {"value": value, "lineno": lineno} )
2018
+ result = False
2019
+ return result
2020
+ def validate_doubleMaxExclusive100000MinInclusive0_01(self, value):
2021
+ result = True
2022
+ # Validate type doubleMaxExclusive100000MinInclusive0.01, a restriction on xsd:double.
2023
+ if value is not None and Validate_simpletypes_ and self.gds_collector_ is not None:
2024
+ if not isinstance(value, float):
2025
+ lineno = self.gds_get_node_lineno_()
2026
+ self.gds_collector_.add_message('Value "%(value)s"%(lineno)s is not of the correct base simple type (float)' % {"value": value, "lineno": lineno, })
2027
+ return False
2028
+ if value < 0.01:
2029
+ lineno = self.gds_get_node_lineno_()
2030
+ self.gds_collector_.add_message('Value "%(value)s"%(lineno)s does not match xsd minInclusive restriction on doubleMaxExclusive100000MinInclusive0.01' % {"value": value, "lineno": lineno} )
2031
+ result = False
2032
+ if value >= 100000:
2033
+ lineno = self.gds_get_node_lineno_()
2034
+ self.gds_collector_.add_message('Value "%(value)s"%(lineno)s does not match xsd maxExclusive restriction on doubleMaxExclusive100000MinInclusive0.01' % {"value": value, "lineno": lineno} )
2035
+ result = False
2036
+ return result
2037
+ def has__content(self):
2038
+ if (
2039
+ self.length is not None or
2040
+ self.width is not None or
2041
+ self.height is not None or
2042
+ self.weight is not None
2043
+ ):
2044
+ return True
2045
+ else:
2046
+ return False
2047
+ def export(self, outfile, level, namespaceprefix_='', namespacedef_='', name_='measurementsType', pretty_print=True):
2048
+ imported_ns_def_ = GenerateDSNamespaceDefs_.get('measurementsType')
2049
+ if imported_ns_def_ is not None:
2050
+ namespacedef_ = imported_ns_def_
2051
+ if pretty_print:
2052
+ eol_ = '\n'
2053
+ else:
2054
+ eol_ = ''
2055
+ if self.original_tagname_ is not None and name_ == 'measurementsType':
2056
+ name_ = self.original_tagname_
2057
+ if UseCapturedNS_ and self.ns_prefix_:
2058
+ namespaceprefix_ = self.ns_prefix_ + ':'
2059
+ showIndent(outfile, level, pretty_print)
2060
+ outfile.write('<%s%s%s' % (namespaceprefix_, name_, namespacedef_ and ' ' + namespacedef_ or '', ))
2061
+ already_processed = set()
2062
+ self._exportAttributes(outfile, level, already_processed, namespaceprefix_, name_='measurementsType')
2063
+ if self.has__content():
2064
+ outfile.write('>%s' % (eol_, ))
2065
+ self._exportChildren(outfile, level + 1, namespaceprefix_, namespacedef_, name_='measurementsType', pretty_print=pretty_print)
2066
+ showIndent(outfile, level, pretty_print)
2067
+ outfile.write('</%s%s>%s' % (namespaceprefix_, name_, eol_))
2068
+ else:
2069
+ outfile.write('/>%s' % (eol_, ))
2070
+ def _exportAttributes(self, outfile, level, already_processed, namespaceprefix_='', name_='measurementsType'):
2071
+ pass
2072
+ def _exportChildren(self, outfile, level, namespaceprefix_='', namespacedef_='', name_='measurementsType', fromsubclass_=False, pretty_print=True):
2073
+ if pretty_print:
2074
+ eol_ = '\n'
2075
+ else:
2076
+ eol_ = ''
2077
+ if self.length is not None:
2078
+ namespaceprefix_ = self.length_nsprefix_ + ':' if (UseCapturedNS_ and self.length_nsprefix_) else ''
2079
+ showIndent(outfile, level, pretty_print)
2080
+ outfile.write('<%slength>%s</%slength>%s' % (namespaceprefix_ , self.gds_format_double(self.length, input_name='length'), namespaceprefix_ , eol_))
2081
+ if self.width is not None:
2082
+ namespaceprefix_ = self.width_nsprefix_ + ':' if (UseCapturedNS_ and self.width_nsprefix_) else ''
2083
+ showIndent(outfile, level, pretty_print)
2084
+ outfile.write('<%swidth>%s</%swidth>%s' % (namespaceprefix_ , self.gds_format_double(self.width, input_name='width'), namespaceprefix_ , eol_))
2085
+ if self.height is not None:
2086
+ namespaceprefix_ = self.height_nsprefix_ + ':' if (UseCapturedNS_ and self.height_nsprefix_) else ''
2087
+ showIndent(outfile, level, pretty_print)
2088
+ outfile.write('<%sheight>%s</%sheight>%s' % (namespaceprefix_ , self.gds_format_double(self.height, input_name='height'), namespaceprefix_ , eol_))
2089
+ if self.weight is not None:
2090
+ namespaceprefix_ = self.weight_nsprefix_ + ':' if (UseCapturedNS_ and self.weight_nsprefix_) else ''
2091
+ showIndent(outfile, level, pretty_print)
2092
+ outfile.write('<%sweight>%s</%sweight>%s' % (namespaceprefix_ , self.gds_format_double(self.weight, input_name='weight'), namespaceprefix_ , eol_))
2093
+ def build(self, node, gds_collector_=None):
2094
+ self.gds_collector_ = gds_collector_
2095
+ if SaveElementTreeNode:
2096
+ self.gds_elementtree_node_ = node
2097
+ already_processed = set()
2098
+ self.ns_prefix_ = node.prefix
2099
+ self._buildAttributes(node, node.attrib, already_processed)
2100
+ for child in node:
2101
+ nodeName_ = Tag_pattern_.match(child.tag).groups()[-1]
2102
+ self._buildChildren(child, node, nodeName_, gds_collector_=gds_collector_)
2103
+ return self
2104
+ def _buildAttributes(self, node, attrs, already_processed):
2105
+ pass
2106
+ def _buildChildren(self, child_, node, nodeName_, fromsubclass_=False, gds_collector_=None):
2107
+ if nodeName_ == 'length' and child_.text:
2108
+ sval_ = child_.text
2109
+ fval_ = self.gds_parse_double(sval_, node, 'length')
2110
+ fval_ = self.gds_validate_double(fval_, node, 'length')
2111
+ self.length = fval_
2112
+ self.length_nsprefix_ = child_.prefix
2113
+ # validate type doubleMaxExclusive100MinInclusive0.01
2114
+ self.validate_doubleMaxExclusive100MinInclusive0_01(self.length)
2115
+ elif nodeName_ == 'width' and child_.text:
2116
+ sval_ = child_.text
2117
+ fval_ = self.gds_parse_double(sval_, node, 'width')
2118
+ fval_ = self.gds_validate_double(fval_, node, 'width')
2119
+ self.width = fval_
2120
+ self.width_nsprefix_ = child_.prefix
2121
+ # validate type doubleMaxExclusive100MinInclusive0.01
2122
+ self.validate_doubleMaxExclusive100MinInclusive0_01(self.width)
2123
+ elif nodeName_ == 'height' and child_.text:
2124
+ sval_ = child_.text
2125
+ fval_ = self.gds_parse_double(sval_, node, 'height')
2126
+ fval_ = self.gds_validate_double(fval_, node, 'height')
2127
+ self.height = fval_
2128
+ self.height_nsprefix_ = child_.prefix
2129
+ # validate type doubleMaxExclusive100MinInclusive0.01
2130
+ self.validate_doubleMaxExclusive100MinInclusive0_01(self.height)
2131
+ elif nodeName_ == 'weight' and child_.text:
2132
+ sval_ = child_.text
2133
+ fval_ = self.gds_parse_double(sval_, node, 'weight')
2134
+ fval_ = self.gds_validate_double(fval_, node, 'weight')
2135
+ self.weight = fval_
2136
+ self.weight_nsprefix_ = child_.prefix
2137
+ # validate type doubleMaxExclusive100000MinInclusive0.01
2138
+ self.validate_doubleMaxExclusive100000MinInclusive0_01(self.weight)
2139
+ # end class measurementsType
2140
+
2141
+
2142
+ class pieceLineType(GeneratedsSuper):
2143
+ """pieceLineType -- A piece line describes a kind of piece sharing the same physical attributes.
2144
+ (A piece is a package, box, envelope or shippable unit. All pieces which are
2145
+ identical are defined for convenience as a piece line with a number of units.)
2146
+ For example if there are 5 boxes of 0.1m x 0.2m x 0.3m of weight 0.1kg and
2147
+ 1 box of 0.4m x 0.4m x 0.4 of weight 0.5kg this equates to two piece lines as
2148
+ follows:
2149
+ PieceLine1: 0.1m x 0.2m x 0.3m, weight 0.1kg, number of units=5
2150
+ PieceLine2: 0.4m x 0.4m x 0.4m, weight 0.5kg, number of units=1
2151
+ identifier -- Identifier for the pieceLine so that it can be referenced during
2152
+ processing. Each pieceLine type should have a unique number,
2153
+ starting at 1 and incrementing for each piece line type required
2154
+ goodsDescription -- Full description of goods being shipped (catalogue numbers or
2155
+ part numbers will not suffice. The Customs Authorities want to
2156
+ know what each item actually is so please carefully describe the
2157
+ goods).
2158
+ barcodeForCustomer -- A flag to state if a barcode for the customer
2159
+ reference should be created.
2160
+ pieceMeasurements -- Dimension and weight measurements relating to the pieces defined
2161
+ by this type.
2162
+ pieces -- At least one of these sections should be provided per consignment
2163
+ up to a maximum of one per piece.
2164
+
2165
+ """
2166
+ __hash__ = GeneratedsSuper.__hash__
2167
+ subclass = None
2168
+ superclass = None
2169
+ def __init__(self, identifier=None, goodsDescription=None, barcodeForCustomer=None, pieceMeasurements=None, pieces=None, gds_collector_=None, **kwargs_):
2170
+ self.gds_collector_ = gds_collector_
2171
+ self.gds_elementtree_node_ = None
2172
+ self.original_tagname_ = None
2173
+ self.parent_object_ = kwargs_.get('parent_object_')
2174
+ self.ns_prefix_ = None
2175
+ self.identifier = identifier
2176
+ self.identifier_nsprefix_ = None
2177
+ self.goodsDescription = goodsDescription
2178
+ self.validate_stringMaxLength30(self.goodsDescription)
2179
+ self.goodsDescription_nsprefix_ = None
2180
+ self.barcodeForCustomer = barcodeForCustomer
2181
+ self.validate_booleanEnum(self.barcodeForCustomer)
2182
+ self.barcodeForCustomer_nsprefix_ = None
2183
+ self.pieceMeasurements = pieceMeasurements
2184
+ self.pieceMeasurements_nsprefix_ = None
2185
+ if pieces is None:
2186
+ self.pieces = []
2187
+ else:
2188
+ self.pieces = pieces
2189
+ self.pieces_nsprefix_ = None
2190
+ def factory(*args_, **kwargs_):
2191
+ if CurrentSubclassModule_ is not None:
2192
+ subclass = getSubclassFromModule_(
2193
+ CurrentSubclassModule_, pieceLineType)
2194
+ if subclass is not None:
2195
+ return subclass(*args_, **kwargs_)
2196
+ if pieceLineType.subclass:
2197
+ return pieceLineType.subclass(*args_, **kwargs_)
2198
+ else:
2199
+ return pieceLineType(*args_, **kwargs_)
2200
+ factory = staticmethod(factory)
2201
+ def get_ns_prefix_(self):
2202
+ return self.ns_prefix_
2203
+ def set_ns_prefix_(self, ns_prefix):
2204
+ self.ns_prefix_ = ns_prefix
2205
+ def get_identifier(self):
2206
+ return self.identifier
2207
+ def set_identifier(self, identifier):
2208
+ self.identifier = identifier
2209
+ def get_goodsDescription(self):
2210
+ return self.goodsDescription
2211
+ def set_goodsDescription(self, goodsDescription):
2212
+ self.goodsDescription = goodsDescription
2213
+ def get_barcodeForCustomer(self):
2214
+ return self.barcodeForCustomer
2215
+ def set_barcodeForCustomer(self, barcodeForCustomer):
2216
+ self.barcodeForCustomer = barcodeForCustomer
2217
+ def get_pieceMeasurements(self):
2218
+ return self.pieceMeasurements
2219
+ def set_pieceMeasurements(self, pieceMeasurements):
2220
+ self.pieceMeasurements = pieceMeasurements
2221
+ def get_pieces(self):
2222
+ return self.pieces
2223
+ def set_pieces(self, pieces):
2224
+ self.pieces = pieces
2225
+ def add_pieces(self, value):
2226
+ self.pieces.append(value)
2227
+ def insert_pieces_at(self, index, value):
2228
+ self.pieces.insert(index, value)
2229
+ def replace_pieces_at(self, index, value):
2230
+ self.pieces[index] = value
2231
+ def validate_stringMaxLength30(self, value):
2232
+ result = True
2233
+ # Validate type stringMaxLength30, a restriction on xsd:string.
2234
+ if value is not None and Validate_simpletypes_ and self.gds_collector_ is not None:
2235
+ if not isinstance(value, str):
2236
+ lineno = self.gds_get_node_lineno_()
2237
+ self.gds_collector_.add_message('Value "%(value)s"%(lineno)s is not of the correct base simple type (str)' % {"value": value, "lineno": lineno, })
2238
+ return False
2239
+ if len(value) > 30:
2240
+ lineno = self.gds_get_node_lineno_()
2241
+ self.gds_collector_.add_message('Value "%(value)s"%(lineno)s does not match xsd maxLength restriction on stringMaxLength30' % {"value" : encode_str_2_3(value), "lineno": lineno} )
2242
+ result = False
2243
+ return result
2244
+ def validate_booleanEnum(self, value):
2245
+ result = True
2246
+ # Validate type booleanEnum, a restriction on xsd:string.
2247
+ if value is not None and Validate_simpletypes_ and self.gds_collector_ is not None:
2248
+ if not isinstance(value, str):
2249
+ lineno = self.gds_get_node_lineno_()
2250
+ self.gds_collector_.add_message('Value "%(value)s"%(lineno)s is not of the correct base simple type (str)' % {"value": value, "lineno": lineno, })
2251
+ return False
2252
+ value = value
2253
+ enumerations = ['N', 'Y']
2254
+ if value not in enumerations:
2255
+ lineno = self.gds_get_node_lineno_()
2256
+ self.gds_collector_.add_message('Value "%(value)s"%(lineno)s does not match xsd enumeration restriction on booleanEnum' % {"value" : encode_str_2_3(value), "lineno": lineno} )
2257
+ result = False
2258
+ return result
2259
+ def has__content(self):
2260
+ if (
2261
+ self.identifier is not None or
2262
+ self.goodsDescription is not None or
2263
+ self.barcodeForCustomer is not None or
2264
+ self.pieceMeasurements is not None or
2265
+ self.pieces
2266
+ ):
2267
+ return True
2268
+ else:
2269
+ return False
2270
+ def export(self, outfile, level, namespaceprefix_='', namespacedef_='', name_='pieceLineType', pretty_print=True):
2271
+ imported_ns_def_ = GenerateDSNamespaceDefs_.get('pieceLineType')
2272
+ if imported_ns_def_ is not None:
2273
+ namespacedef_ = imported_ns_def_
2274
+ if pretty_print:
2275
+ eol_ = '\n'
2276
+ else:
2277
+ eol_ = ''
2278
+ if self.original_tagname_ is not None and name_ == 'pieceLineType':
2279
+ name_ = self.original_tagname_
2280
+ if UseCapturedNS_ and self.ns_prefix_:
2281
+ namespaceprefix_ = self.ns_prefix_ + ':'
2282
+ showIndent(outfile, level, pretty_print)
2283
+ outfile.write('<%s%s%s' % (namespaceprefix_, name_, namespacedef_ and ' ' + namespacedef_ or '', ))
2284
+ already_processed = set()
2285
+ self._exportAttributes(outfile, level, already_processed, namespaceprefix_, name_='pieceLineType')
2286
+ if self.has__content():
2287
+ outfile.write('>%s' % (eol_, ))
2288
+ self._exportChildren(outfile, level + 1, namespaceprefix_, namespacedef_, name_='pieceLineType', pretty_print=pretty_print)
2289
+ showIndent(outfile, level, pretty_print)
2290
+ outfile.write('</%s%s>%s' % (namespaceprefix_, name_, eol_))
2291
+ else:
2292
+ outfile.write('/>%s' % (eol_, ))
2293
+ def _exportAttributes(self, outfile, level, already_processed, namespaceprefix_='', name_='pieceLineType'):
2294
+ pass
2295
+ def _exportChildren(self, outfile, level, namespaceprefix_='', namespacedef_='', name_='pieceLineType', fromsubclass_=False, pretty_print=True):
2296
+ if pretty_print:
2297
+ eol_ = '\n'
2298
+ else:
2299
+ eol_ = ''
2300
+ if self.identifier is not None:
2301
+ namespaceprefix_ = self.identifier_nsprefix_ + ':' if (UseCapturedNS_ and self.identifier_nsprefix_) else ''
2302
+ showIndent(outfile, level, pretty_print)
2303
+ outfile.write('<%sidentifier>%s</%sidentifier>%s' % (namespaceprefix_ , self.gds_format_integer(self.identifier, input_name='identifier'), namespaceprefix_ , eol_))
2304
+ if self.goodsDescription is not None:
2305
+ namespaceprefix_ = self.goodsDescription_nsprefix_ + ':' if (UseCapturedNS_ and self.goodsDescription_nsprefix_) else ''
2306
+ showIndent(outfile, level, pretty_print)
2307
+ outfile.write('<%sgoodsDescription>%s</%sgoodsDescription>%s' % (namespaceprefix_ , self.gds_encode(self.gds_format_string(quote_xml(self.goodsDescription), input_name='goodsDescription')), namespaceprefix_ , eol_))
2308
+ if self.barcodeForCustomer is not None:
2309
+ namespaceprefix_ = self.barcodeForCustomer_nsprefix_ + ':' if (UseCapturedNS_ and self.barcodeForCustomer_nsprefix_) else ''
2310
+ showIndent(outfile, level, pretty_print)
2311
+ outfile.write('<%sbarcodeForCustomer>%s</%sbarcodeForCustomer>%s' % (namespaceprefix_ , self.gds_encode(self.gds_format_string(quote_xml(self.barcodeForCustomer), input_name='barcodeForCustomer')), namespaceprefix_ , eol_))
2312
+ if self.pieceMeasurements is not None:
2313
+ namespaceprefix_ = self.pieceMeasurements_nsprefix_ + ':' if (UseCapturedNS_ and self.pieceMeasurements_nsprefix_) else ''
2314
+ self.pieceMeasurements.export(outfile, level, namespaceprefix_, namespacedef_='', name_='pieceMeasurements', pretty_print=pretty_print)
2315
+ for pieces_ in self.pieces:
2316
+ namespaceprefix_ = self.pieces_nsprefix_ + ':' if (UseCapturedNS_ and self.pieces_nsprefix_) else ''
2317
+ pieces_.export(outfile, level, namespaceprefix_, namespacedef_='', name_='pieces', pretty_print=pretty_print)
2318
+ def build(self, node, gds_collector_=None):
2319
+ self.gds_collector_ = gds_collector_
2320
+ if SaveElementTreeNode:
2321
+ self.gds_elementtree_node_ = node
2322
+ already_processed = set()
2323
+ self.ns_prefix_ = node.prefix
2324
+ self._buildAttributes(node, node.attrib, already_processed)
2325
+ for child in node:
2326
+ nodeName_ = Tag_pattern_.match(child.tag).groups()[-1]
2327
+ self._buildChildren(child, node, nodeName_, gds_collector_=gds_collector_)
2328
+ return self
2329
+ def _buildAttributes(self, node, attrs, already_processed):
2330
+ pass
2331
+ def _buildChildren(self, child_, node, nodeName_, fromsubclass_=False, gds_collector_=None):
2332
+ if nodeName_ == 'identifier' and child_.text:
2333
+ sval_ = child_.text
2334
+ ival_ = self.gds_parse_integer(sval_, node, 'identifier')
2335
+ ival_ = self.gds_validate_integer(ival_, node, 'identifier')
2336
+ self.identifier = ival_
2337
+ self.identifier_nsprefix_ = child_.prefix
2338
+ elif nodeName_ == 'goodsDescription':
2339
+ value_ = child_.text
2340
+ value_ = self.gds_parse_string(value_, node, 'goodsDescription')
2341
+ value_ = self.gds_validate_string(value_, node, 'goodsDescription')
2342
+ self.goodsDescription = value_
2343
+ self.goodsDescription_nsprefix_ = child_.prefix
2344
+ # validate type stringMaxLength30
2345
+ self.validate_stringMaxLength30(self.goodsDescription)
2346
+ elif nodeName_ == 'barcodeForCustomer':
2347
+ value_ = child_.text
2348
+ value_ = self.gds_parse_string(value_, node, 'barcodeForCustomer')
2349
+ value_ = self.gds_validate_string(value_, node, 'barcodeForCustomer')
2350
+ self.barcodeForCustomer = value_
2351
+ self.barcodeForCustomer_nsprefix_ = child_.prefix
2352
+ # validate type booleanEnum
2353
+ self.validate_booleanEnum(self.barcodeForCustomer)
2354
+ elif nodeName_ == 'pieceMeasurements':
2355
+ obj_ = measurementsType.factory(parent_object_=self)
2356
+ obj_.build(child_, gds_collector_=gds_collector_)
2357
+ self.pieceMeasurements = obj_
2358
+ obj_.original_tagname_ = 'pieceMeasurements'
2359
+ elif nodeName_ == 'pieces':
2360
+ obj_ = pieceType.factory(parent_object_=self)
2361
+ obj_.build(child_, gds_collector_=gds_collector_)
2362
+ self.pieces.append(obj_)
2363
+ obj_.original_tagname_ = 'pieces'
2364
+ # end class pieceLineType
2365
+
2366
+
2367
+ class pieceType(GeneratedsSuper):
2368
+ """pieceType -- This element is used to identify all the pieces that should be grouped
2369
+ together by the given reference. The list of sequence numbers is included
2370
+ (one sequenceNumber element per piece) with a single pieceReference element.
2371
+ sequenceNumbers -- List of the piece sequence numbers, i.e. 1,2,5,n out of a total of
2372
+ n pieces that share the same piece reference.
2373
+ pieceReference -- Reference for this piece or pieces.
2374
+
2375
+ """
2376
+ __hash__ = GeneratedsSuper.__hash__
2377
+ subclass = None
2378
+ superclass = None
2379
+ def __init__(self, sequenceNumbers=None, pieceReference=None, gds_collector_=None, **kwargs_):
2380
+ self.gds_collector_ = gds_collector_
2381
+ self.gds_elementtree_node_ = None
2382
+ self.original_tagname_ = None
2383
+ self.parent_object_ = kwargs_.get('parent_object_')
2384
+ self.ns_prefix_ = None
2385
+ self.sequenceNumbers = sequenceNumbers
2386
+ self.sequenceNumbers_nsprefix_ = None
2387
+ self.pieceReference = pieceReference
2388
+ self.pieceReference_nsprefix_ = None
2389
+ def factory(*args_, **kwargs_):
2390
+ if CurrentSubclassModule_ is not None:
2391
+ subclass = getSubclassFromModule_(
2392
+ CurrentSubclassModule_, pieceType)
2393
+ if subclass is not None:
2394
+ return subclass(*args_, **kwargs_)
2395
+ if pieceType.subclass:
2396
+ return pieceType.subclass(*args_, **kwargs_)
2397
+ else:
2398
+ return pieceType(*args_, **kwargs_)
2399
+ factory = staticmethod(factory)
2400
+ def get_ns_prefix_(self):
2401
+ return self.ns_prefix_
2402
+ def set_ns_prefix_(self, ns_prefix):
2403
+ self.ns_prefix_ = ns_prefix
2404
+ def get_sequenceNumbers(self):
2405
+ return self.sequenceNumbers
2406
+ def set_sequenceNumbers(self, sequenceNumbers):
2407
+ self.sequenceNumbers = sequenceNumbers
2408
+ def get_pieceReference(self):
2409
+ return self.pieceReference
2410
+ def set_pieceReference(self, pieceReference):
2411
+ self.pieceReference = pieceReference
2412
+ def has__content(self):
2413
+ if (
2414
+ self.sequenceNumbers is not None or
2415
+ self.pieceReference is not None
2416
+ ):
2417
+ return True
2418
+ else:
2419
+ return False
2420
+ def export(self, outfile, level, namespaceprefix_='', namespacedef_='', name_='pieceType', pretty_print=True):
2421
+ imported_ns_def_ = GenerateDSNamespaceDefs_.get('pieceType')
2422
+ if imported_ns_def_ is not None:
2423
+ namespacedef_ = imported_ns_def_
2424
+ if pretty_print:
2425
+ eol_ = '\n'
2426
+ else:
2427
+ eol_ = ''
2428
+ if self.original_tagname_ is not None and name_ == 'pieceType':
2429
+ name_ = self.original_tagname_
2430
+ if UseCapturedNS_ and self.ns_prefix_:
2431
+ namespaceprefix_ = self.ns_prefix_ + ':'
2432
+ showIndent(outfile, level, pretty_print)
2433
+ outfile.write('<%s%s%s' % (namespaceprefix_, name_, namespacedef_ and ' ' + namespacedef_ or '', ))
2434
+ already_processed = set()
2435
+ self._exportAttributes(outfile, level, already_processed, namespaceprefix_, name_='pieceType')
2436
+ if self.has__content():
2437
+ outfile.write('>%s' % (eol_, ))
2438
+ self._exportChildren(outfile, level + 1, namespaceprefix_, namespacedef_, name_='pieceType', pretty_print=pretty_print)
2439
+ showIndent(outfile, level, pretty_print)
2440
+ outfile.write('</%s%s>%s' % (namespaceprefix_, name_, eol_))
2441
+ else:
2442
+ outfile.write('/>%s' % (eol_, ))
2443
+ def _exportAttributes(self, outfile, level, already_processed, namespaceprefix_='', name_='pieceType'):
2444
+ pass
2445
+ def _exportChildren(self, outfile, level, namespaceprefix_='', namespacedef_='', name_='pieceType', fromsubclass_=False, pretty_print=True):
2446
+ if pretty_print:
2447
+ eol_ = '\n'
2448
+ else:
2449
+ eol_ = ''
2450
+ if self.sequenceNumbers is not None:
2451
+ namespaceprefix_ = self.sequenceNumbers_nsprefix_ + ':' if (UseCapturedNS_ and self.sequenceNumbers_nsprefix_) else ''
2452
+ showIndent(outfile, level, pretty_print)
2453
+ outfile.write('<%ssequenceNumbers>%s</%ssequenceNumbers>%s' % (namespaceprefix_ , self.gds_encode(self.gds_format_string(quote_xml(self.sequenceNumbers), input_name='sequenceNumbers')), namespaceprefix_ , eol_))
2454
+ if self.pieceReference is not None:
2455
+ namespaceprefix_ = self.pieceReference_nsprefix_ + ':' if (UseCapturedNS_ and self.pieceReference_nsprefix_) else ''
2456
+ showIndent(outfile, level, pretty_print)
2457
+ outfile.write('<%spieceReference>%s</%spieceReference>%s' % (namespaceprefix_ , self.gds_encode(self.gds_format_string(quote_xml(self.pieceReference), input_name='pieceReference')), namespaceprefix_ , eol_))
2458
+ def build(self, node, gds_collector_=None):
2459
+ self.gds_collector_ = gds_collector_
2460
+ if SaveElementTreeNode:
2461
+ self.gds_elementtree_node_ = node
2462
+ already_processed = set()
2463
+ self.ns_prefix_ = node.prefix
2464
+ self._buildAttributes(node, node.attrib, already_processed)
2465
+ for child in node:
2466
+ nodeName_ = Tag_pattern_.match(child.tag).groups()[-1]
2467
+ self._buildChildren(child, node, nodeName_, gds_collector_=gds_collector_)
2468
+ return self
2469
+ def _buildAttributes(self, node, attrs, already_processed):
2470
+ pass
2471
+ def _buildChildren(self, child_, node, nodeName_, fromsubclass_=False, gds_collector_=None):
2472
+ if nodeName_ == 'sequenceNumbers':
2473
+ value_ = child_.text
2474
+ value_ = self.gds_parse_string(value_, node, 'sequenceNumbers')
2475
+ value_ = self.gds_validate_string(value_, node, 'sequenceNumbers')
2476
+ self.sequenceNumbers = value_
2477
+ self.sequenceNumbers_nsprefix_ = child_.prefix
2478
+ elif nodeName_ == 'pieceReference':
2479
+ value_ = child_.text
2480
+ value_ = self.gds_parse_string(value_, node, 'pieceReference')
2481
+ value_ = self.gds_validate_string(value_, node, 'pieceReference')
2482
+ self.pieceReference = value_
2483
+ self.pieceReference_nsprefix_ = child_.prefix
2484
+ # end class pieceType
2485
+
2486
+
2487
+ class contactType(GeneratedsSuper):
2488
+ """contactType -- Information about the contact person at the relevant address.
2489
+ name -- Name of the contact person at the relevant address.
2490
+ telephoneNumber -- The full telephone number for the contact person.
2491
+ emailAddress -- Email address for the contact person.
2492
+
2493
+ """
2494
+ __hash__ = GeneratedsSuper.__hash__
2495
+ subclass = None
2496
+ superclass = None
2497
+ def __init__(self, name=None, telephoneNumber=None, emailAddress=None, gds_collector_=None, **kwargs_):
2498
+ self.gds_collector_ = gds_collector_
2499
+ self.gds_elementtree_node_ = None
2500
+ self.original_tagname_ = None
2501
+ self.parent_object_ = kwargs_.get('parent_object_')
2502
+ self.ns_prefix_ = None
2503
+ self.name = name
2504
+ self.validate_stringMaxLength30(self.name)
2505
+ self.name_nsprefix_ = None
2506
+ self.telephoneNumber = telephoneNumber
2507
+ self.validate_stringMaxLength30(self.telephoneNumber)
2508
+ self.telephoneNumber_nsprefix_ = None
2509
+ self.emailAddress = emailAddress
2510
+ self.emailAddress_nsprefix_ = None
2511
+ def factory(*args_, **kwargs_):
2512
+ if CurrentSubclassModule_ is not None:
2513
+ subclass = getSubclassFromModule_(
2514
+ CurrentSubclassModule_, contactType)
2515
+ if subclass is not None:
2516
+ return subclass(*args_, **kwargs_)
2517
+ if contactType.subclass:
2518
+ return contactType.subclass(*args_, **kwargs_)
2519
+ else:
2520
+ return contactType(*args_, **kwargs_)
2521
+ factory = staticmethod(factory)
2522
+ def get_ns_prefix_(self):
2523
+ return self.ns_prefix_
2524
+ def set_ns_prefix_(self, ns_prefix):
2525
+ self.ns_prefix_ = ns_prefix
2526
+ def get_name(self):
2527
+ return self.name
2528
+ def set_name(self, name):
2529
+ self.name = name
2530
+ def get_telephoneNumber(self):
2531
+ return self.telephoneNumber
2532
+ def set_telephoneNumber(self, telephoneNumber):
2533
+ self.telephoneNumber = telephoneNumber
2534
+ def get_emailAddress(self):
2535
+ return self.emailAddress
2536
+ def set_emailAddress(self, emailAddress):
2537
+ self.emailAddress = emailAddress
2538
+ def validate_stringMaxLength30(self, value):
2539
+ result = True
2540
+ # Validate type stringMaxLength30, a restriction on xsd:string.
2541
+ if value is not None and Validate_simpletypes_ and self.gds_collector_ is not None:
2542
+ if not isinstance(value, str):
2543
+ lineno = self.gds_get_node_lineno_()
2544
+ self.gds_collector_.add_message('Value "%(value)s"%(lineno)s is not of the correct base simple type (str)' % {"value": value, "lineno": lineno, })
2545
+ return False
2546
+ if len(value) > 30:
2547
+ lineno = self.gds_get_node_lineno_()
2548
+ self.gds_collector_.add_message('Value "%(value)s"%(lineno)s does not match xsd maxLength restriction on stringMaxLength30' % {"value" : encode_str_2_3(value), "lineno": lineno} )
2549
+ result = False
2550
+ return result
2551
+ def has__content(self):
2552
+ if (
2553
+ self.name is not None or
2554
+ self.telephoneNumber is not None or
2555
+ self.emailAddress is not None
2556
+ ):
2557
+ return True
2558
+ else:
2559
+ return False
2560
+ def export(self, outfile, level, namespaceprefix_='', namespacedef_='', name_='contactType', pretty_print=True):
2561
+ imported_ns_def_ = GenerateDSNamespaceDefs_.get('contactType')
2562
+ if imported_ns_def_ is not None:
2563
+ namespacedef_ = imported_ns_def_
2564
+ if pretty_print:
2565
+ eol_ = '\n'
2566
+ else:
2567
+ eol_ = ''
2568
+ if self.original_tagname_ is not None and name_ == 'contactType':
2569
+ name_ = self.original_tagname_
2570
+ if UseCapturedNS_ and self.ns_prefix_:
2571
+ namespaceprefix_ = self.ns_prefix_ + ':'
2572
+ showIndent(outfile, level, pretty_print)
2573
+ outfile.write('<%s%s%s' % (namespaceprefix_, name_, namespacedef_ and ' ' + namespacedef_ or '', ))
2574
+ already_processed = set()
2575
+ self._exportAttributes(outfile, level, already_processed, namespaceprefix_, name_='contactType')
2576
+ if self.has__content():
2577
+ outfile.write('>%s' % (eol_, ))
2578
+ self._exportChildren(outfile, level + 1, namespaceprefix_, namespacedef_, name_='contactType', pretty_print=pretty_print)
2579
+ showIndent(outfile, level, pretty_print)
2580
+ outfile.write('</%s%s>%s' % (namespaceprefix_, name_, eol_))
2581
+ else:
2582
+ outfile.write('/>%s' % (eol_, ))
2583
+ def _exportAttributes(self, outfile, level, already_processed, namespaceprefix_='', name_='contactType'):
2584
+ pass
2585
+ def _exportChildren(self, outfile, level, namespaceprefix_='', namespacedef_='', name_='contactType', fromsubclass_=False, pretty_print=True):
2586
+ if pretty_print:
2587
+ eol_ = '\n'
2588
+ else:
2589
+ eol_ = ''
2590
+ if self.name is not None:
2591
+ namespaceprefix_ = self.name_nsprefix_ + ':' if (UseCapturedNS_ and self.name_nsprefix_) else ''
2592
+ showIndent(outfile, level, pretty_print)
2593
+ outfile.write('<%sname>%s</%sname>%s' % (namespaceprefix_ , self.gds_encode(self.gds_format_string(quote_xml(self.name), input_name='name')), namespaceprefix_ , eol_))
2594
+ if self.telephoneNumber is not None:
2595
+ namespaceprefix_ = self.telephoneNumber_nsprefix_ + ':' if (UseCapturedNS_ and self.telephoneNumber_nsprefix_) else ''
2596
+ showIndent(outfile, level, pretty_print)
2597
+ outfile.write('<%stelephoneNumber>%s</%stelephoneNumber>%s' % (namespaceprefix_ , self.gds_encode(self.gds_format_string(quote_xml(self.telephoneNumber), input_name='telephoneNumber')), namespaceprefix_ , eol_))
2598
+ if self.emailAddress is not None:
2599
+ namespaceprefix_ = self.emailAddress_nsprefix_ + ':' if (UseCapturedNS_ and self.emailAddress_nsprefix_) else ''
2600
+ showIndent(outfile, level, pretty_print)
2601
+ outfile.write('<%semailAddress>%s</%semailAddress>%s' % (namespaceprefix_ , self.gds_encode(self.gds_format_string(quote_xml(self.emailAddress), input_name='emailAddress')), namespaceprefix_ , eol_))
2602
+ def build(self, node, gds_collector_=None):
2603
+ self.gds_collector_ = gds_collector_
2604
+ if SaveElementTreeNode:
2605
+ self.gds_elementtree_node_ = node
2606
+ already_processed = set()
2607
+ self.ns_prefix_ = node.prefix
2608
+ self._buildAttributes(node, node.attrib, already_processed)
2609
+ for child in node:
2610
+ nodeName_ = Tag_pattern_.match(child.tag).groups()[-1]
2611
+ self._buildChildren(child, node, nodeName_, gds_collector_=gds_collector_)
2612
+ return self
2613
+ def _buildAttributes(self, node, attrs, already_processed):
2614
+ pass
2615
+ def _buildChildren(self, child_, node, nodeName_, fromsubclass_=False, gds_collector_=None):
2616
+ if nodeName_ == 'name':
2617
+ value_ = child_.text
2618
+ value_ = self.gds_parse_string(value_, node, 'name')
2619
+ value_ = self.gds_validate_string(value_, node, 'name')
2620
+ self.name = value_
2621
+ self.name_nsprefix_ = child_.prefix
2622
+ # validate type stringMaxLength30
2623
+ self.validate_stringMaxLength30(self.name)
2624
+ elif nodeName_ == 'telephoneNumber':
2625
+ value_ = child_.text
2626
+ value_ = self.gds_parse_string(value_, node, 'telephoneNumber')
2627
+ value_ = self.gds_validate_string(value_, node, 'telephoneNumber')
2628
+ self.telephoneNumber = value_
2629
+ self.telephoneNumber_nsprefix_ = child_.prefix
2630
+ # validate type stringMaxLength30
2631
+ self.validate_stringMaxLength30(self.telephoneNumber)
2632
+ elif nodeName_ == 'emailAddress':
2633
+ value_ = child_.text
2634
+ value_ = self.gds_parse_string(value_, node, 'emailAddress')
2635
+ value_ = self.gds_validate_string(value_, node, 'emailAddress')
2636
+ self.emailAddress = value_
2637
+ self.emailAddress_nsprefix_ = child_.prefix
2638
+ # end class contactType
2639
+
2640
+
2641
+ class accountType(GeneratedsSuper):
2642
+ """accountType -- Information about a TNT account which includes the account number
2643
+ and country code.
2644
+ accountNumber -- TNT legacy (global link) account number, which is the 9 digit
2645
+ number assigned by the TNT sales person.
2646
+ accountCountry -- ISO country code for the country the TNT account is in.
2647
+
2648
+ """
2649
+ __hash__ = GeneratedsSuper.__hash__
2650
+ subclass = None
2651
+ superclass = None
2652
+ def __init__(self, accountNumber=None, accountCountry=None, gds_collector_=None, **kwargs_):
2653
+ self.gds_collector_ = gds_collector_
2654
+ self.gds_elementtree_node_ = None
2655
+ self.original_tagname_ = None
2656
+ self.parent_object_ = kwargs_.get('parent_object_')
2657
+ self.ns_prefix_ = None
2658
+ self.accountNumber = accountNumber
2659
+ self.validate_stringMaxLength10(self.accountNumber)
2660
+ self.accountNumber_nsprefix_ = None
2661
+ self.accountCountry = accountCountry
2662
+ self.validate_stringMinLength2MaxLength2(self.accountCountry)
2663
+ self.accountCountry_nsprefix_ = None
2664
+ def factory(*args_, **kwargs_):
2665
+ if CurrentSubclassModule_ is not None:
2666
+ subclass = getSubclassFromModule_(
2667
+ CurrentSubclassModule_, accountType)
2668
+ if subclass is not None:
2669
+ return subclass(*args_, **kwargs_)
2670
+ if accountType.subclass:
2671
+ return accountType.subclass(*args_, **kwargs_)
2672
+ else:
2673
+ return accountType(*args_, **kwargs_)
2674
+ factory = staticmethod(factory)
2675
+ def get_ns_prefix_(self):
2676
+ return self.ns_prefix_
2677
+ def set_ns_prefix_(self, ns_prefix):
2678
+ self.ns_prefix_ = ns_prefix
2679
+ def get_accountNumber(self):
2680
+ return self.accountNumber
2681
+ def set_accountNumber(self, accountNumber):
2682
+ self.accountNumber = accountNumber
2683
+ def get_accountCountry(self):
2684
+ return self.accountCountry
2685
+ def set_accountCountry(self, accountCountry):
2686
+ self.accountCountry = accountCountry
2687
+ def validate_stringMaxLength10(self, value):
2688
+ result = True
2689
+ # Validate type stringMaxLength10, a restriction on xsd:string.
2690
+ if value is not None and Validate_simpletypes_ and self.gds_collector_ is not None:
2691
+ if not isinstance(value, str):
2692
+ lineno = self.gds_get_node_lineno_()
2693
+ self.gds_collector_.add_message('Value "%(value)s"%(lineno)s is not of the correct base simple type (str)' % {"value": value, "lineno": lineno, })
2694
+ return False
2695
+ if len(value) > 10:
2696
+ lineno = self.gds_get_node_lineno_()
2697
+ self.gds_collector_.add_message('Value "%(value)s"%(lineno)s does not match xsd maxLength restriction on stringMaxLength10' % {"value" : encode_str_2_3(value), "lineno": lineno} )
2698
+ result = False
2699
+ return result
2700
+ def validate_stringMinLength2MaxLength2(self, value):
2701
+ result = True
2702
+ # Validate type stringMinLength2MaxLength2, a restriction on xsd:string.
2703
+ if value is not None and Validate_simpletypes_ and self.gds_collector_ is not None:
2704
+ if not isinstance(value, str):
2705
+ lineno = self.gds_get_node_lineno_()
2706
+ self.gds_collector_.add_message('Value "%(value)s"%(lineno)s is not of the correct base simple type (str)' % {"value": value, "lineno": lineno, })
2707
+ return False
2708
+ if len(value) > 2:
2709
+ lineno = self.gds_get_node_lineno_()
2710
+ self.gds_collector_.add_message('Value "%(value)s"%(lineno)s does not match xsd maxLength restriction on stringMinLength2MaxLength2' % {"value" : encode_str_2_3(value), "lineno": lineno} )
2711
+ result = False
2712
+ if len(value) < 2:
2713
+ lineno = self.gds_get_node_lineno_()
2714
+ self.gds_collector_.add_message('Value "%(value)s"%(lineno)s does not match xsd minLength restriction on stringMinLength2MaxLength2' % {"value" : encode_str_2_3(value), "lineno": lineno} )
2715
+ result = False
2716
+ return result
2717
+ def has__content(self):
2718
+ if (
2719
+ self.accountNumber is not None or
2720
+ self.accountCountry is not None
2721
+ ):
2722
+ return True
2723
+ else:
2724
+ return False
2725
+ def export(self, outfile, level, namespaceprefix_='', namespacedef_='', name_='accountType', pretty_print=True):
2726
+ imported_ns_def_ = GenerateDSNamespaceDefs_.get('accountType')
2727
+ if imported_ns_def_ is not None:
2728
+ namespacedef_ = imported_ns_def_
2729
+ if pretty_print:
2730
+ eol_ = '\n'
2731
+ else:
2732
+ eol_ = ''
2733
+ if self.original_tagname_ is not None and name_ == 'accountType':
2734
+ name_ = self.original_tagname_
2735
+ if UseCapturedNS_ and self.ns_prefix_:
2736
+ namespaceprefix_ = self.ns_prefix_ + ':'
2737
+ showIndent(outfile, level, pretty_print)
2738
+ outfile.write('<%s%s%s' % (namespaceprefix_, name_, namespacedef_ and ' ' + namespacedef_ or '', ))
2739
+ already_processed = set()
2740
+ self._exportAttributes(outfile, level, already_processed, namespaceprefix_, name_='accountType')
2741
+ if self.has__content():
2742
+ outfile.write('>%s' % (eol_, ))
2743
+ self._exportChildren(outfile, level + 1, namespaceprefix_, namespacedef_, name_='accountType', pretty_print=pretty_print)
2744
+ showIndent(outfile, level, pretty_print)
2745
+ outfile.write('</%s%s>%s' % (namespaceprefix_, name_, eol_))
2746
+ else:
2747
+ outfile.write('/>%s' % (eol_, ))
2748
+ def _exportAttributes(self, outfile, level, already_processed, namespaceprefix_='', name_='accountType'):
2749
+ pass
2750
+ def _exportChildren(self, outfile, level, namespaceprefix_='', namespacedef_='', name_='accountType', fromsubclass_=False, pretty_print=True):
2751
+ if pretty_print:
2752
+ eol_ = '\n'
2753
+ else:
2754
+ eol_ = ''
2755
+ if self.accountNumber is not None:
2756
+ namespaceprefix_ = self.accountNumber_nsprefix_ + ':' if (UseCapturedNS_ and self.accountNumber_nsprefix_) else ''
2757
+ showIndent(outfile, level, pretty_print)
2758
+ outfile.write('<%saccountNumber>%s</%saccountNumber>%s' % (namespaceprefix_ , self.gds_encode(self.gds_format_string(quote_xml(self.accountNumber), input_name='accountNumber')), namespaceprefix_ , eol_))
2759
+ if self.accountCountry is not None:
2760
+ namespaceprefix_ = self.accountCountry_nsprefix_ + ':' if (UseCapturedNS_ and self.accountCountry_nsprefix_) else ''
2761
+ showIndent(outfile, level, pretty_print)
2762
+ outfile.write('<%saccountCountry>%s</%saccountCountry>%s' % (namespaceprefix_ , self.gds_encode(self.gds_format_string(quote_xml(self.accountCountry), input_name='accountCountry')), namespaceprefix_ , eol_))
2763
+ def build(self, node, gds_collector_=None):
2764
+ self.gds_collector_ = gds_collector_
2765
+ if SaveElementTreeNode:
2766
+ self.gds_elementtree_node_ = node
2767
+ already_processed = set()
2768
+ self.ns_prefix_ = node.prefix
2769
+ self._buildAttributes(node, node.attrib, already_processed)
2770
+ for child in node:
2771
+ nodeName_ = Tag_pattern_.match(child.tag).groups()[-1]
2772
+ self._buildChildren(child, node, nodeName_, gds_collector_=gds_collector_)
2773
+ return self
2774
+ def _buildAttributes(self, node, attrs, already_processed):
2775
+ pass
2776
+ def _buildChildren(self, child_, node, nodeName_, fromsubclass_=False, gds_collector_=None):
2777
+ if nodeName_ == 'accountNumber':
2778
+ value_ = child_.text
2779
+ value_ = self.gds_parse_string(value_, node, 'accountNumber')
2780
+ value_ = self.gds_validate_string(value_, node, 'accountNumber')
2781
+ self.accountNumber = value_
2782
+ self.accountNumber_nsprefix_ = child_.prefix
2783
+ # validate type stringMaxLength10
2784
+ self.validate_stringMaxLength10(self.accountNumber)
2785
+ elif nodeName_ == 'accountCountry':
2786
+ value_ = child_.text
2787
+ value_ = self.gds_parse_string(value_, node, 'accountCountry')
2788
+ value_ = self.gds_validate_string(value_, node, 'accountCountry')
2789
+ self.accountCountry = value_
2790
+ self.accountCountry_nsprefix_ = child_.prefix
2791
+ # validate type stringMinLength2MaxLength2
2792
+ self.validate_stringMinLength2MaxLength2(self.accountCountry)
2793
+ # end class accountType
2794
+
2795
+
2796
+ class depotType(GeneratedsSuper):
2797
+ """depotType -- Details relating to a TNT depot which could be the origin,
2798
+ destination or transit depot on the route calculated by TNT to deliver
2799
+ a consignment.
2800
+ depotCode -- The three character TNT code for the depot.
2801
+
2802
+ """
2803
+ __hash__ = GeneratedsSuper.__hash__
2804
+ subclass = None
2805
+ superclass = None
2806
+ def __init__(self, depotCode=None, gds_collector_=None, **kwargs_):
2807
+ self.gds_collector_ = gds_collector_
2808
+ self.gds_elementtree_node_ = None
2809
+ self.original_tagname_ = None
2810
+ self.parent_object_ = kwargs_.get('parent_object_')
2811
+ self.ns_prefix_ = None
2812
+ self.depotCode = depotCode
2813
+ self.validate_stringMinLength3MaxLength3(self.depotCode)
2814
+ self.depotCode_nsprefix_ = None
2815
+ def factory(*args_, **kwargs_):
2816
+ if CurrentSubclassModule_ is not None:
2817
+ subclass = getSubclassFromModule_(
2818
+ CurrentSubclassModule_, depotType)
2819
+ if subclass is not None:
2820
+ return subclass(*args_, **kwargs_)
2821
+ if depotType.subclass:
2822
+ return depotType.subclass(*args_, **kwargs_)
2823
+ else:
2824
+ return depotType(*args_, **kwargs_)
2825
+ factory = staticmethod(factory)
2826
+ def get_ns_prefix_(self):
2827
+ return self.ns_prefix_
2828
+ def set_ns_prefix_(self, ns_prefix):
2829
+ self.ns_prefix_ = ns_prefix
2830
+ def get_depotCode(self):
2831
+ return self.depotCode
2832
+ def set_depotCode(self, depotCode):
2833
+ self.depotCode = depotCode
2834
+ def validate_stringMinLength3MaxLength3(self, value):
2835
+ result = True
2836
+ # Validate type stringMinLength3MaxLength3, a restriction on xsd:string.
2837
+ if value is not None and Validate_simpletypes_ and self.gds_collector_ is not None:
2838
+ if not isinstance(value, str):
2839
+ lineno = self.gds_get_node_lineno_()
2840
+ self.gds_collector_.add_message('Value "%(value)s"%(lineno)s is not of the correct base simple type (str)' % {"value": value, "lineno": lineno, })
2841
+ return False
2842
+ if len(value) > 3:
2843
+ lineno = self.gds_get_node_lineno_()
2844
+ self.gds_collector_.add_message('Value "%(value)s"%(lineno)s does not match xsd maxLength restriction on stringMinLength3MaxLength3' % {"value" : encode_str_2_3(value), "lineno": lineno} )
2845
+ result = False
2846
+ if len(value) < 3:
2847
+ lineno = self.gds_get_node_lineno_()
2848
+ self.gds_collector_.add_message('Value "%(value)s"%(lineno)s does not match xsd minLength restriction on stringMinLength3MaxLength3' % {"value" : encode_str_2_3(value), "lineno": lineno} )
2849
+ result = False
2850
+ return result
2851
+ def has__content(self):
2852
+ if (
2853
+ self.depotCode is not None
2854
+ ):
2855
+ return True
2856
+ else:
2857
+ return False
2858
+ def export(self, outfile, level, namespaceprefix_='', namespacedef_='', name_='depotType', pretty_print=True):
2859
+ imported_ns_def_ = GenerateDSNamespaceDefs_.get('depotType')
2860
+ if imported_ns_def_ is not None:
2861
+ namespacedef_ = imported_ns_def_
2862
+ if pretty_print:
2863
+ eol_ = '\n'
2864
+ else:
2865
+ eol_ = ''
2866
+ if self.original_tagname_ is not None and name_ == 'depotType':
2867
+ name_ = self.original_tagname_
2868
+ if UseCapturedNS_ and self.ns_prefix_:
2869
+ namespaceprefix_ = self.ns_prefix_ + ':'
2870
+ showIndent(outfile, level, pretty_print)
2871
+ outfile.write('<%s%s%s' % (namespaceprefix_, name_, namespacedef_ and ' ' + namespacedef_ or '', ))
2872
+ already_processed = set()
2873
+ self._exportAttributes(outfile, level, already_processed, namespaceprefix_, name_='depotType')
2874
+ if self.has__content():
2875
+ outfile.write('>%s' % (eol_, ))
2876
+ self._exportChildren(outfile, level + 1, namespaceprefix_, namespacedef_, name_='depotType', pretty_print=pretty_print)
2877
+ showIndent(outfile, level, pretty_print)
2878
+ outfile.write('</%s%s>%s' % (namespaceprefix_, name_, eol_))
2879
+ else:
2880
+ outfile.write('/>%s' % (eol_, ))
2881
+ def _exportAttributes(self, outfile, level, already_processed, namespaceprefix_='', name_='depotType'):
2882
+ pass
2883
+ def _exportChildren(self, outfile, level, namespaceprefix_='', namespacedef_='', name_='depotType', fromsubclass_=False, pretty_print=True):
2884
+ if pretty_print:
2885
+ eol_ = '\n'
2886
+ else:
2887
+ eol_ = ''
2888
+ if self.depotCode is not None:
2889
+ namespaceprefix_ = self.depotCode_nsprefix_ + ':' if (UseCapturedNS_ and self.depotCode_nsprefix_) else ''
2890
+ showIndent(outfile, level, pretty_print)
2891
+ outfile.write('<%sdepotCode>%s</%sdepotCode>%s' % (namespaceprefix_ , self.gds_encode(self.gds_format_string(quote_xml(self.depotCode), input_name='depotCode')), namespaceprefix_ , eol_))
2892
+ def build(self, node, gds_collector_=None):
2893
+ self.gds_collector_ = gds_collector_
2894
+ if SaveElementTreeNode:
2895
+ self.gds_elementtree_node_ = node
2896
+ already_processed = set()
2897
+ self.ns_prefix_ = node.prefix
2898
+ self._buildAttributes(node, node.attrib, already_processed)
2899
+ for child in node:
2900
+ nodeName_ = Tag_pattern_.match(child.tag).groups()[-1]
2901
+ self._buildChildren(child, node, nodeName_, gds_collector_=gds_collector_)
2902
+ return self
2903
+ def _buildAttributes(self, node, attrs, already_processed):
2904
+ pass
2905
+ def _buildChildren(self, child_, node, nodeName_, fromsubclass_=False, gds_collector_=None):
2906
+ if nodeName_ == 'depotCode':
2907
+ value_ = child_.text
2908
+ value_ = self.gds_parse_string(value_, node, 'depotCode')
2909
+ value_ = self.gds_validate_string(value_, node, 'depotCode')
2910
+ self.depotCode = value_
2911
+ self.depotCode_nsprefix_ = child_.prefix
2912
+ # validate type stringMinLength3MaxLength3
2913
+ self.validate_stringMinLength3MaxLength3(self.depotCode)
2914
+ # end class depotType
2915
+
2916
+
2917
+ class marketType(GeneratedsSuper):
2918
+ """marketType -- This identifies the market type for the consignment comprising the origin
2919
+ country and whether the consignment is being shipped domestically or
2920
+ internationally and within which international trading block, e.g. 'EU'.
2921
+ originCountryCode -- The ISO country code for the origin country of the consignment.
2922
+ marketSpecification -- The market for the consignment - i.e. whether it is being shipped
2923
+ domestically or internationally, and, if the latter, in which trade
2924
+ block, e.g. EU, ROW, etc.
2925
+
2926
+ """
2927
+ __hash__ = GeneratedsSuper.__hash__
2928
+ subclass = None
2929
+ superclass = None
2930
+ def __init__(self, originCountryCode=None, marketSpecification=None, gds_collector_=None, **kwargs_):
2931
+ self.gds_collector_ = gds_collector_
2932
+ self.gds_elementtree_node_ = None
2933
+ self.original_tagname_ = None
2934
+ self.parent_object_ = kwargs_.get('parent_object_')
2935
+ self.ns_prefix_ = None
2936
+ self.originCountryCode = originCountryCode
2937
+ self.validate_stringMinLength2MaxLength2(self.originCountryCode)
2938
+ self.originCountryCode_nsprefix_ = None
2939
+ self.marketSpecification = marketSpecification
2940
+ self.marketSpecification_nsprefix_ = None
2941
+ def factory(*args_, **kwargs_):
2942
+ if CurrentSubclassModule_ is not None:
2943
+ subclass = getSubclassFromModule_(
2944
+ CurrentSubclassModule_, marketType)
2945
+ if subclass is not None:
2946
+ return subclass(*args_, **kwargs_)
2947
+ if marketType.subclass:
2948
+ return marketType.subclass(*args_, **kwargs_)
2949
+ else:
2950
+ return marketType(*args_, **kwargs_)
2951
+ factory = staticmethod(factory)
2952
+ def get_ns_prefix_(self):
2953
+ return self.ns_prefix_
2954
+ def set_ns_prefix_(self, ns_prefix):
2955
+ self.ns_prefix_ = ns_prefix
2956
+ def get_originCountryCode(self):
2957
+ return self.originCountryCode
2958
+ def set_originCountryCode(self, originCountryCode):
2959
+ self.originCountryCode = originCountryCode
2960
+ def get_marketSpecification(self):
2961
+ return self.marketSpecification
2962
+ def set_marketSpecification(self, marketSpecification):
2963
+ self.marketSpecification = marketSpecification
2964
+ def validate_stringMinLength2MaxLength2(self, value):
2965
+ result = True
2966
+ # Validate type stringMinLength2MaxLength2, a restriction on xsd:string.
2967
+ if value is not None and Validate_simpletypes_ and self.gds_collector_ is not None:
2968
+ if not isinstance(value, str):
2969
+ lineno = self.gds_get_node_lineno_()
2970
+ self.gds_collector_.add_message('Value "%(value)s"%(lineno)s is not of the correct base simple type (str)' % {"value": value, "lineno": lineno, })
2971
+ return False
2972
+ if len(value) > 2:
2973
+ lineno = self.gds_get_node_lineno_()
2974
+ self.gds_collector_.add_message('Value "%(value)s"%(lineno)s does not match xsd maxLength restriction on stringMinLength2MaxLength2' % {"value" : encode_str_2_3(value), "lineno": lineno} )
2975
+ result = False
2976
+ if len(value) < 2:
2977
+ lineno = self.gds_get_node_lineno_()
2978
+ self.gds_collector_.add_message('Value "%(value)s"%(lineno)s does not match xsd minLength restriction on stringMinLength2MaxLength2' % {"value" : encode_str_2_3(value), "lineno": lineno} )
2979
+ result = False
2980
+ return result
2981
+ def has__content(self):
2982
+ if (
2983
+ self.originCountryCode is not None or
2984
+ self.marketSpecification is not None
2985
+ ):
2986
+ return True
2987
+ else:
2988
+ return False
2989
+ def export(self, outfile, level, namespaceprefix_='', namespacedef_='', name_='marketType', pretty_print=True):
2990
+ imported_ns_def_ = GenerateDSNamespaceDefs_.get('marketType')
2991
+ if imported_ns_def_ is not None:
2992
+ namespacedef_ = imported_ns_def_
2993
+ if pretty_print:
2994
+ eol_ = '\n'
2995
+ else:
2996
+ eol_ = ''
2997
+ if self.original_tagname_ is not None and name_ == 'marketType':
2998
+ name_ = self.original_tagname_
2999
+ if UseCapturedNS_ and self.ns_prefix_:
3000
+ namespaceprefix_ = self.ns_prefix_ + ':'
3001
+ showIndent(outfile, level, pretty_print)
3002
+ outfile.write('<%s%s%s' % (namespaceprefix_, name_, namespacedef_ and ' ' + namespacedef_ or '', ))
3003
+ already_processed = set()
3004
+ self._exportAttributes(outfile, level, already_processed, namespaceprefix_, name_='marketType')
3005
+ if self.has__content():
3006
+ outfile.write('>%s' % (eol_, ))
3007
+ self._exportChildren(outfile, level + 1, namespaceprefix_, namespacedef_, name_='marketType', pretty_print=pretty_print)
3008
+ showIndent(outfile, level, pretty_print)
3009
+ outfile.write('</%s%s>%s' % (namespaceprefix_, name_, eol_))
3010
+ else:
3011
+ outfile.write('/>%s' % (eol_, ))
3012
+ def _exportAttributes(self, outfile, level, already_processed, namespaceprefix_='', name_='marketType'):
3013
+ pass
3014
+ def _exportChildren(self, outfile, level, namespaceprefix_='', namespacedef_='', name_='marketType', fromsubclass_=False, pretty_print=True):
3015
+ if pretty_print:
3016
+ eol_ = '\n'
3017
+ else:
3018
+ eol_ = ''
3019
+ if self.originCountryCode is not None:
3020
+ namespaceprefix_ = self.originCountryCode_nsprefix_ + ':' if (UseCapturedNS_ and self.originCountryCode_nsprefix_) else ''
3021
+ showIndent(outfile, level, pretty_print)
3022
+ outfile.write('<%soriginCountryCode>%s</%soriginCountryCode>%s' % (namespaceprefix_ , self.gds_encode(self.gds_format_string(quote_xml(self.originCountryCode), input_name='originCountryCode')), namespaceprefix_ , eol_))
3023
+ if self.marketSpecification is not None:
3024
+ namespaceprefix_ = self.marketSpecification_nsprefix_ + ':' if (UseCapturedNS_ and self.marketSpecification_nsprefix_) else ''
3025
+ showIndent(outfile, level, pretty_print)
3026
+ outfile.write('<%smarketSpecification>%s</%smarketSpecification>%s' % (namespaceprefix_ , self.gds_encode(self.gds_format_string(quote_xml(self.marketSpecification), input_name='marketSpecification')), namespaceprefix_ , eol_))
3027
+ def build(self, node, gds_collector_=None):
3028
+ self.gds_collector_ = gds_collector_
3029
+ if SaveElementTreeNode:
3030
+ self.gds_elementtree_node_ = node
3031
+ already_processed = set()
3032
+ self.ns_prefix_ = node.prefix
3033
+ self._buildAttributes(node, node.attrib, already_processed)
3034
+ for child in node:
3035
+ nodeName_ = Tag_pattern_.match(child.tag).groups()[-1]
3036
+ self._buildChildren(child, node, nodeName_, gds_collector_=gds_collector_)
3037
+ return self
3038
+ def _buildAttributes(self, node, attrs, already_processed):
3039
+ pass
3040
+ def _buildChildren(self, child_, node, nodeName_, fromsubclass_=False, gds_collector_=None):
3041
+ if nodeName_ == 'originCountryCode':
3042
+ value_ = child_.text
3043
+ value_ = self.gds_parse_string(value_, node, 'originCountryCode')
3044
+ value_ = self.gds_validate_string(value_, node, 'originCountryCode')
3045
+ self.originCountryCode = value_
3046
+ self.originCountryCode_nsprefix_ = child_.prefix
3047
+ # validate type stringMinLength2MaxLength2
3048
+ self.validate_stringMinLength2MaxLength2(self.originCountryCode)
3049
+ elif nodeName_ == 'marketSpecification':
3050
+ value_ = child_.text
3051
+ value_ = self.gds_parse_string(value_, node, 'marketSpecification')
3052
+ value_ = self.gds_validate_string(value_, node, 'marketSpecification')
3053
+ self.marketSpecification = value_
3054
+ self.marketSpecification_nsprefix_ = child_.prefix
3055
+ # end class marketType
3056
+
3057
+
3058
+ class brokenRules(GeneratedsSuper):
3059
+ """brokenRules -- List of business rules that have been breached by the input and that will
3060
+ require the user to correct in order to print labels on resubmission of
3061
+ XML input file.
3062
+ key -- RequestId number to which the error relates.
3063
+ errorCode -- Error code returned by the system to identify the error message.
3064
+ errorDescription -- Error description returned by the system to signify the data
3065
+ that needs to be corrected in order to print labels.
3066
+
3067
+ """
3068
+ __hash__ = GeneratedsSuper.__hash__
3069
+ subclass = None
3070
+ superclass = None
3071
+ def __init__(self, key=None, errorCode=None, errorDescription=None, gds_collector_=None, **kwargs_):
3072
+ self.gds_collector_ = gds_collector_
3073
+ self.gds_elementtree_node_ = None
3074
+ self.original_tagname_ = None
3075
+ self.parent_object_ = kwargs_.get('parent_object_')
3076
+ self.ns_prefix_ = None
3077
+ self.key = _cast(None, key)
3078
+ self.key_nsprefix_ = None
3079
+ self.errorCode = errorCode
3080
+ self.errorCode_nsprefix_ = None
3081
+ self.errorDescription = errorDescription
3082
+ self.errorDescription_nsprefix_ = None
3083
+ def factory(*args_, **kwargs_):
3084
+ if CurrentSubclassModule_ is not None:
3085
+ subclass = getSubclassFromModule_(
3086
+ CurrentSubclassModule_, brokenRules)
3087
+ if subclass is not None:
3088
+ return subclass(*args_, **kwargs_)
3089
+ if brokenRules.subclass:
3090
+ return brokenRules.subclass(*args_, **kwargs_)
3091
+ else:
3092
+ return brokenRules(*args_, **kwargs_)
3093
+ factory = staticmethod(factory)
3094
+ def get_ns_prefix_(self):
3095
+ return self.ns_prefix_
3096
+ def set_ns_prefix_(self, ns_prefix):
3097
+ self.ns_prefix_ = ns_prefix
3098
+ def get_errorCode(self):
3099
+ return self.errorCode
3100
+ def set_errorCode(self, errorCode):
3101
+ self.errorCode = errorCode
3102
+ def get_errorDescription(self):
3103
+ return self.errorDescription
3104
+ def set_errorDescription(self, errorDescription):
3105
+ self.errorDescription = errorDescription
3106
+ def get_key(self):
3107
+ return self.key
3108
+ def set_key(self, key):
3109
+ self.key = key
3110
+ def has__content(self):
3111
+ if (
3112
+ self.errorCode is not None or
3113
+ self.errorDescription is not None
3114
+ ):
3115
+ return True
3116
+ else:
3117
+ return False
3118
+ def export(self, outfile, level, namespaceprefix_='', namespacedef_='', name_='brokenRules', pretty_print=True):
3119
+ imported_ns_def_ = GenerateDSNamespaceDefs_.get('brokenRules')
3120
+ if imported_ns_def_ is not None:
3121
+ namespacedef_ = imported_ns_def_
3122
+ if pretty_print:
3123
+ eol_ = '\n'
3124
+ else:
3125
+ eol_ = ''
3126
+ if self.original_tagname_ is not None and name_ == 'brokenRules':
3127
+ name_ = self.original_tagname_
3128
+ if UseCapturedNS_ and self.ns_prefix_:
3129
+ namespaceprefix_ = self.ns_prefix_ + ':'
3130
+ showIndent(outfile, level, pretty_print)
3131
+ outfile.write('<%s%s%s' % (namespaceprefix_, name_, namespacedef_ and ' ' + namespacedef_ or '', ))
3132
+ already_processed = set()
3133
+ self._exportAttributes(outfile, level, already_processed, namespaceprefix_, name_='brokenRules')
3134
+ if self.has__content():
3135
+ outfile.write('>%s' % (eol_, ))
3136
+ self._exportChildren(outfile, level + 1, namespaceprefix_, namespacedef_, name_='brokenRules', pretty_print=pretty_print)
3137
+ showIndent(outfile, level, pretty_print)
3138
+ outfile.write('</%s%s>%s' % (namespaceprefix_, name_, eol_))
3139
+ else:
3140
+ outfile.write('/>%s' % (eol_, ))
3141
+ def _exportAttributes(self, outfile, level, already_processed, namespaceprefix_='', name_='brokenRules'):
3142
+ if self.key is not None and 'key' not in already_processed:
3143
+ already_processed.add('key')
3144
+ outfile.write(' key=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.key), input_name='key')), ))
3145
+ def _exportChildren(self, outfile, level, namespaceprefix_='', namespacedef_='', name_='brokenRules', fromsubclass_=False, pretty_print=True):
3146
+ if pretty_print:
3147
+ eol_ = '\n'
3148
+ else:
3149
+ eol_ = ''
3150
+ if self.errorCode is not None:
3151
+ namespaceprefix_ = self.errorCode_nsprefix_ + ':' if (UseCapturedNS_ and self.errorCode_nsprefix_) else ''
3152
+ showIndent(outfile, level, pretty_print)
3153
+ outfile.write('<%serrorCode>%s</%serrorCode>%s' % (namespaceprefix_ , self.gds_format_integer(self.errorCode, input_name='errorCode'), namespaceprefix_ , eol_))
3154
+ if self.errorDescription is not None:
3155
+ namespaceprefix_ = self.errorDescription_nsprefix_ + ':' if (UseCapturedNS_ and self.errorDescription_nsprefix_) else ''
3156
+ showIndent(outfile, level, pretty_print)
3157
+ outfile.write('<%serrorDescription>%s</%serrorDescription>%s' % (namespaceprefix_ , self.gds_encode(self.gds_format_string(quote_xml(self.errorDescription), input_name='errorDescription')), namespaceprefix_ , eol_))
3158
+ def build(self, node, gds_collector_=None):
3159
+ self.gds_collector_ = gds_collector_
3160
+ if SaveElementTreeNode:
3161
+ self.gds_elementtree_node_ = node
3162
+ already_processed = set()
3163
+ self.ns_prefix_ = node.prefix
3164
+ self._buildAttributes(node, node.attrib, already_processed)
3165
+ for child in node:
3166
+ nodeName_ = Tag_pattern_.match(child.tag).groups()[-1]
3167
+ self._buildChildren(child, node, nodeName_, gds_collector_=gds_collector_)
3168
+ return self
3169
+ def _buildAttributes(self, node, attrs, already_processed):
3170
+ value = find_attr_value_('key', node)
3171
+ if value is not None and 'key' not in already_processed:
3172
+ already_processed.add('key')
3173
+ self.key = value
3174
+ def _buildChildren(self, child_, node, nodeName_, fromsubclass_=False, gds_collector_=None):
3175
+ if nodeName_ == 'errorCode' and child_.text:
3176
+ sval_ = child_.text
3177
+ ival_ = self.gds_parse_integer(sval_, node, 'errorCode')
3178
+ ival_ = self.gds_validate_integer(ival_, node, 'errorCode')
3179
+ self.errorCode = ival_
3180
+ self.errorCode_nsprefix_ = child_.prefix
3181
+ elif nodeName_ == 'errorDescription':
3182
+ value_ = child_.text
3183
+ value_ = self.gds_parse_string(value_, node, 'errorDescription')
3184
+ value_ = self.gds_validate_string(value_, node, 'errorDescription')
3185
+ self.errorDescription = value_
3186
+ self.errorDescription_nsprefix_ = child_.prefix
3187
+ # end class brokenRules
3188
+
3189
+
3190
+ class fault(GeneratedsSuper):
3191
+ """fault -- List of faults that have occured during teh processign of multiple requests
3192
+ key -- RequestId number to which the fault relates.
3193
+
3194
+ """
3195
+ __hash__ = GeneratedsSuper.__hash__
3196
+ subclass = None
3197
+ superclass = None
3198
+ def __init__(self, key=None, gds_collector_=None, **kwargs_):
3199
+ self.gds_collector_ = gds_collector_
3200
+ self.gds_elementtree_node_ = None
3201
+ self.original_tagname_ = None
3202
+ self.parent_object_ = kwargs_.get('parent_object_')
3203
+ self.ns_prefix_ = None
3204
+ self.key = _cast(None, key)
3205
+ self.key_nsprefix_ = None
3206
+ def factory(*args_, **kwargs_):
3207
+ if CurrentSubclassModule_ is not None:
3208
+ subclass = getSubclassFromModule_(
3209
+ CurrentSubclassModule_, fault)
3210
+ if subclass is not None:
3211
+ return subclass(*args_, **kwargs_)
3212
+ if fault.subclass:
3213
+ return fault.subclass(*args_, **kwargs_)
3214
+ else:
3215
+ return fault(*args_, **kwargs_)
3216
+ factory = staticmethod(factory)
3217
+ def get_ns_prefix_(self):
3218
+ return self.ns_prefix_
3219
+ def set_ns_prefix_(self, ns_prefix):
3220
+ self.ns_prefix_ = ns_prefix
3221
+ def get_key(self):
3222
+ return self.key
3223
+ def set_key(self, key):
3224
+ self.key = key
3225
+ def has__content(self):
3226
+ if (
3227
+
3228
+ ):
3229
+ return True
3230
+ else:
3231
+ return False
3232
+ def export(self, outfile, level, namespaceprefix_='', namespacedef_='', name_='fault', pretty_print=True):
3233
+ imported_ns_def_ = GenerateDSNamespaceDefs_.get('fault')
3234
+ if imported_ns_def_ is not None:
3235
+ namespacedef_ = imported_ns_def_
3236
+ if pretty_print:
3237
+ eol_ = '\n'
3238
+ else:
3239
+ eol_ = ''
3240
+ if self.original_tagname_ is not None and name_ == 'fault':
3241
+ name_ = self.original_tagname_
3242
+ if UseCapturedNS_ and self.ns_prefix_:
3243
+ namespaceprefix_ = self.ns_prefix_ + ':'
3244
+ showIndent(outfile, level, pretty_print)
3245
+ outfile.write('<%s%s%s' % (namespaceprefix_, name_, namespacedef_ and ' ' + namespacedef_ or '', ))
3246
+ already_processed = set()
3247
+ self._exportAttributes(outfile, level, already_processed, namespaceprefix_, name_='fault')
3248
+ if self.has__content():
3249
+ outfile.write('>%s' % (eol_, ))
3250
+ self._exportChildren(outfile, level + 1, namespaceprefix_, namespacedef_, name_='fault', pretty_print=pretty_print)
3251
+ outfile.write('</%s%s>%s' % (namespaceprefix_, name_, eol_))
3252
+ else:
3253
+ outfile.write('/>%s' % (eol_, ))
3254
+ def _exportAttributes(self, outfile, level, already_processed, namespaceprefix_='', name_='fault'):
3255
+ if self.key is not None and 'key' not in already_processed:
3256
+ already_processed.add('key')
3257
+ outfile.write(' key=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.key), input_name='key')), ))
3258
+ def _exportChildren(self, outfile, level, namespaceprefix_='', namespacedef_='', name_='fault', fromsubclass_=False, pretty_print=True):
3259
+ pass
3260
+ def build(self, node, gds_collector_=None):
3261
+ self.gds_collector_ = gds_collector_
3262
+ if SaveElementTreeNode:
3263
+ self.gds_elementtree_node_ = node
3264
+ already_processed = set()
3265
+ self.ns_prefix_ = node.prefix
3266
+ self._buildAttributes(node, node.attrib, already_processed)
3267
+ for child in node:
3268
+ nodeName_ = Tag_pattern_.match(child.tag).groups()[-1]
3269
+ self._buildChildren(child, node, nodeName_, gds_collector_=gds_collector_)
3270
+ return self
3271
+ def _buildAttributes(self, node, attrs, already_processed):
3272
+ value = find_attr_value_('key', node)
3273
+ if value is not None and 'key' not in already_processed:
3274
+ already_processed.add('key')
3275
+ self.key = value
3276
+ def _buildChildren(self, child_, node, nodeName_, fromsubclass_=False, gds_collector_=None):
3277
+ pass
3278
+ # end class fault
3279
+
3280
+
3281
+ #
3282
+ # End data representation classes.
3283
+ #
3284
+
3285
+
3286
+ GDSClassesMapping = {
3287
+ }
3288
+
3289
+
3290
+ USAGE_TEXT = """
3291
+ Usage: python <Parser>.py [ -s ] <in_xml_file>
3292
+ """
3293
+
3294
+
3295
+ def usage():
3296
+ print(USAGE_TEXT)
3297
+ sys.exit(1)
3298
+
3299
+
3300
+ def get_root_tag(node):
3301
+ tag = Tag_pattern_.match(node.tag).groups()[-1]
3302
+ prefix_tag = TagNamePrefix + tag
3303
+ rootClass = GDSClassesMapping.get(prefix_tag)
3304
+ if rootClass is None:
3305
+ rootClass = globals().get(prefix_tag)
3306
+ return tag, rootClass
3307
+
3308
+
3309
+ def get_required_ns_prefix_defs(rootNode):
3310
+ '''Get all name space prefix definitions required in this XML doc.
3311
+ Return a dictionary of definitions and a char string of definitions.
3312
+ '''
3313
+ nsmap = {
3314
+ prefix: uri
3315
+ for node in rootNode.iter()
3316
+ for (prefix, uri) in node.nsmap.items()
3317
+ if prefix is not None
3318
+ }
3319
+ namespacedefs = ' '.join([
3320
+ 'xmlns:{}="{}"'.format(prefix, uri)
3321
+ for prefix, uri in nsmap.items()
3322
+ ])
3323
+ return nsmap, namespacedefs
3324
+
3325
+
3326
+ def parse(inFileName, silence=False, print_warnings=True):
3327
+ global CapturedNsmap_
3328
+ gds_collector = GdsCollector_()
3329
+ parser = None
3330
+ doc = parsexml_(inFileName, parser)
3331
+ rootNode = doc.getroot()
3332
+ rootTag, rootClass = get_root_tag(rootNode)
3333
+ if rootClass is None:
3334
+ rootTag = 'consignmentIdentityType'
3335
+ rootClass = consignmentIdentityType
3336
+ rootObj = rootClass.factory()
3337
+ rootObj.build(rootNode, gds_collector_=gds_collector)
3338
+ CapturedNsmap_, namespacedefs = get_required_ns_prefix_defs(rootNode)
3339
+ if not SaveElementTreeNode:
3340
+ doc = None
3341
+ rootNode = None
3342
+ if not silence:
3343
+ sys.stdout.write('<?xml version="1.0" ?>\n')
3344
+ rootObj.export(
3345
+ sys.stdout, 0, name_=rootTag,
3346
+ namespacedef_=namespacedefs,
3347
+ pretty_print=True)
3348
+ if print_warnings and len(gds_collector.get_messages()) > 0:
3349
+ separator = ('-' * 50) + '\n'
3350
+ sys.stderr.write(separator)
3351
+ sys.stderr.write('----- Warnings -- count: {} -----\n'.format(
3352
+ len(gds_collector.get_messages()), ))
3353
+ gds_collector.write_messages(sys.stderr)
3354
+ sys.stderr.write(separator)
3355
+ return rootObj
3356
+
3357
+
3358
+ def parseEtree(inFileName, silence=False, print_warnings=True,
3359
+ mapping=None, reverse_mapping=None, nsmap=None):
3360
+ parser = None
3361
+ doc = parsexml_(inFileName, parser)
3362
+ gds_collector = GdsCollector_()
3363
+ rootNode = doc.getroot()
3364
+ rootTag, rootClass = get_root_tag(rootNode)
3365
+ if rootClass is None:
3366
+ rootTag = 'consignmentIdentityType'
3367
+ rootClass = consignmentIdentityType
3368
+ rootObj = rootClass.factory()
3369
+ rootObj.build(rootNode, gds_collector_=gds_collector)
3370
+ if mapping is None:
3371
+ mapping = {}
3372
+ if reverse_mapping is None:
3373
+ reverse_mapping = {}
3374
+ rootElement = rootObj.to_etree(
3375
+ None, name_=rootTag, mapping_=mapping,
3376
+ reverse_mapping_=reverse_mapping, nsmap_=nsmap)
3377
+ reverse_node_mapping = rootObj.gds_reverse_node_mapping(mapping)
3378
+ # Enable Python to collect the space used by the DOM.
3379
+ if not SaveElementTreeNode:
3380
+ doc = None
3381
+ rootNode = None
3382
+ if not silence:
3383
+ content = etree_.tostring(
3384
+ rootElement, pretty_print=True,
3385
+ xml_declaration=True, encoding="utf-8")
3386
+ sys.stdout.write(str(content))
3387
+ sys.stdout.write('\n')
3388
+ if print_warnings and len(gds_collector.get_messages()) > 0:
3389
+ separator = ('-' * 50) + '\n'
3390
+ sys.stderr.write(separator)
3391
+ sys.stderr.write('----- Warnings -- count: {} -----\n'.format(
3392
+ len(gds_collector.get_messages()), ))
3393
+ gds_collector.write_messages(sys.stderr)
3394
+ sys.stderr.write(separator)
3395
+ return rootObj, rootElement, mapping, reverse_node_mapping
3396
+
3397
+
3398
+ def parseString(inString, silence=False, print_warnings=True):
3399
+ '''Parse a string, create the object tree, and export it.
3400
+
3401
+ Arguments:
3402
+ - inString -- A string. This XML fragment should not start
3403
+ with an XML declaration containing an encoding.
3404
+ - silence -- A boolean. If False, export the object.
3405
+ Returns -- The root object in the tree.
3406
+ '''
3407
+ parser = None
3408
+ rootNode= parsexmlstring_(inString, parser)
3409
+ gds_collector = GdsCollector_()
3410
+ rootTag, rootClass = get_root_tag(rootNode)
3411
+ if rootClass is None:
3412
+ rootTag = 'consignmentIdentityType'
3413
+ rootClass = consignmentIdentityType
3414
+ rootObj = rootClass.factory()
3415
+ rootObj.build(rootNode, gds_collector_=gds_collector)
3416
+ if not SaveElementTreeNode:
3417
+ rootNode = None
3418
+ if not silence:
3419
+ sys.stdout.write('<?xml version="1.0" ?>\n')
3420
+ rootObj.export(
3421
+ sys.stdout, 0, name_=rootTag,
3422
+ namespacedef_='')
3423
+ if print_warnings and len(gds_collector.get_messages()) > 0:
3424
+ separator = ('-' * 50) + '\n'
3425
+ sys.stderr.write(separator)
3426
+ sys.stderr.write('----- Warnings -- count: {} -----\n'.format(
3427
+ len(gds_collector.get_messages()), ))
3428
+ gds_collector.write_messages(sys.stderr)
3429
+ sys.stderr.write(separator)
3430
+ return rootObj
3431
+
3432
+
3433
+ def parseLiteral(inFileName, silence=False, print_warnings=True):
3434
+ parser = None
3435
+ doc = parsexml_(inFileName, parser)
3436
+ gds_collector = GdsCollector_()
3437
+ rootNode = doc.getroot()
3438
+ rootTag, rootClass = get_root_tag(rootNode)
3439
+ if rootClass is None:
3440
+ rootTag = 'consignmentIdentityType'
3441
+ rootClass = consignmentIdentityType
3442
+ rootObj = rootClass.factory()
3443
+ rootObj.build(rootNode, gds_collector_=gds_collector)
3444
+ # Enable Python to collect the space used by the DOM.
3445
+ if not SaveElementTreeNode:
3446
+ doc = None
3447
+ rootNode = None
3448
+ if not silence:
3449
+ sys.stdout.write('#from label_common_definitions import *\n\n')
3450
+ sys.stdout.write('import label_common_definitions as model_\n\n')
3451
+ sys.stdout.write('rootObj = model_.rootClass(\n')
3452
+ rootObj.exportLiteral(sys.stdout, 0, name_=rootTag)
3453
+ sys.stdout.write(')\n')
3454
+ if print_warnings and len(gds_collector.get_messages()) > 0:
3455
+ separator = ('-' * 50) + '\n'
3456
+ sys.stderr.write(separator)
3457
+ sys.stderr.write('----- Warnings -- count: {} -----\n'.format(
3458
+ len(gds_collector.get_messages()), ))
3459
+ gds_collector.write_messages(sys.stderr)
3460
+ sys.stderr.write(separator)
3461
+ return rootObj
3462
+
3463
+
3464
+ def main():
3465
+ args = sys.argv[1:]
3466
+ if len(args) == 1:
3467
+ parse(args[0])
3468
+ else:
3469
+ usage()
3470
+
3471
+
3472
+ if __name__ == '__main__':
3473
+ #import pdb; pdb.set_trace()
3474
+ main()
3475
+
3476
+ RenameMappings_ = {
3477
+ }
3478
+
3479
+ #
3480
+ # Mapping of namespaces to types defined in them
3481
+ # and the file in which each is defined.
3482
+ # simpleTypes are marked "ST" and complexTypes "CT".
3483
+ NamespaceToDefMappings_ = {}
3484
+
3485
+ __all__ = [
3486
+ "accountType",
3487
+ "brokenRules",
3488
+ "consignmentIdentityType",
3489
+ "contactType",
3490
+ "depotType",
3491
+ "fault",
3492
+ "marketType",
3493
+ "measurementsType",
3494
+ "nameAndAddressRequestType",
3495
+ "nameAndAddressResponseType",
3496
+ "optionType",
3497
+ "pieceLineType",
3498
+ "pieceType"
3499
+ ]