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,4409 @@
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_request.py')
11
+ #
12
+ # Command line arguments:
13
+ # ./schemas/label_request.xsd
14
+ #
15
+ # Command line:
16
+ # /home/kserver/Workspace/karrio/.venv/karrio/bin/generateDS --no-namespace-defs -o "./karrio/schemas/tnt/label_request.py" ./schemas/label_request.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 labelRequest(GeneratedsSuper):
1031
+ """labelRequest -- The root XML element for a LabelRequest message
1032
+ sent to
1033
+ ExpressLabel in order to produce a routing label per piece.
1034
+
1035
+ * consignment -- Data for up to 5 consignments may be supplied
1036
+ in one request.
1037
+
1038
+ """
1039
+ __hash__ = GeneratedsSuper.__hash__
1040
+ subclass = None
1041
+ superclass = None
1042
+ def __init__(self, consignment=None, gds_collector_=None, **kwargs_):
1043
+ self.gds_collector_ = gds_collector_
1044
+ self.gds_elementtree_node_ = None
1045
+ self.original_tagname_ = None
1046
+ self.parent_object_ = kwargs_.get('parent_object_')
1047
+ self.ns_prefix_ = None
1048
+ if consignment is None:
1049
+ self.consignment = []
1050
+ else:
1051
+ self.consignment = consignment
1052
+ self.consignment_nsprefix_ = None
1053
+ def factory(*args_, **kwargs_):
1054
+ if CurrentSubclassModule_ is not None:
1055
+ subclass = getSubclassFromModule_(
1056
+ CurrentSubclassModule_, labelRequest)
1057
+ if subclass is not None:
1058
+ return subclass(*args_, **kwargs_)
1059
+ if labelRequest.subclass:
1060
+ return labelRequest.subclass(*args_, **kwargs_)
1061
+ else:
1062
+ return labelRequest(*args_, **kwargs_)
1063
+ factory = staticmethod(factory)
1064
+ def get_ns_prefix_(self):
1065
+ return self.ns_prefix_
1066
+ def set_ns_prefix_(self, ns_prefix):
1067
+ self.ns_prefix_ = ns_prefix
1068
+ def get_consignment(self):
1069
+ return self.consignment
1070
+ def set_consignment(self, consignment):
1071
+ self.consignment = consignment
1072
+ def add_consignment(self, value):
1073
+ self.consignment.append(value)
1074
+ def insert_consignment_at(self, index, value):
1075
+ self.consignment.insert(index, value)
1076
+ def replace_consignment_at(self, index, value):
1077
+ self.consignment[index] = value
1078
+ def has__content(self):
1079
+ if (
1080
+ self.consignment
1081
+ ):
1082
+ return True
1083
+ else:
1084
+ return False
1085
+ def export(self, outfile, level, namespaceprefix_='', namespacedef_='', name_='labelRequest', pretty_print=True):
1086
+ imported_ns_def_ = GenerateDSNamespaceDefs_.get('labelRequest')
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_ == 'labelRequest':
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_='labelRequest')
1101
+ if self.has__content():
1102
+ outfile.write('>%s' % (eol_, ))
1103
+ self._exportChildren(outfile, level + 1, namespaceprefix_, namespacedef_, name_='labelRequest', 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_='labelRequest'):
1109
+ pass
1110
+ def _exportChildren(self, outfile, level, namespaceprefix_='', namespacedef_='', name_='labelRequest', fromsubclass_=False, pretty_print=True):
1111
+ if pretty_print:
1112
+ eol_ = '\n'
1113
+ else:
1114
+ eol_ = ''
1115
+ for consignment_ in self.consignment:
1116
+ namespaceprefix_ = self.consignment_nsprefix_ + ':' if (UseCapturedNS_ and self.consignment_nsprefix_) else ''
1117
+ consignment_.export(outfile, level, namespaceprefix_, namespacedef_='', name_='consignment', pretty_print=pretty_print)
1118
+ def build(self, node, gds_collector_=None):
1119
+ self.gds_collector_ = gds_collector_
1120
+ if SaveElementTreeNode:
1121
+ self.gds_elementtree_node_ = node
1122
+ already_processed = set()
1123
+ self.ns_prefix_ = node.prefix
1124
+ self._buildAttributes(node, node.attrib, already_processed)
1125
+ for child in node:
1126
+ nodeName_ = Tag_pattern_.match(child.tag).groups()[-1]
1127
+ self._buildChildren(child, node, nodeName_, gds_collector_=gds_collector_)
1128
+ return self
1129
+ def _buildAttributes(self, node, attrs, already_processed):
1130
+ pass
1131
+ def _buildChildren(self, child_, node, nodeName_, fromsubclass_=False, gds_collector_=None):
1132
+ if nodeName_ == 'consignment':
1133
+ obj_ = labelConsignmentsType.factory(parent_object_=self)
1134
+ obj_.build(child_, gds_collector_=gds_collector_)
1135
+ self.consignment.append(obj_)
1136
+ obj_.original_tagname_ = 'consignment'
1137
+ # end class labelRequest
1138
+
1139
+
1140
+ class labelConsignmentsType(GeneratedsSuper):
1141
+ """labelConsignmentsType -- The view of the consignments information that is
1142
+ necessary for
1143
+ ExpressLabel to be able to validate addresses,
1144
+ determine the routing
1145
+ and product availability and successfully
1146
+ produce the information
1147
+ required to allow routing labels to be
1148
+ rendered per piece required.
1149
+
1150
+ * consignmentIdentity -- This element contains a consignment number and
1151
+ optional
1152
+ customer reference. These values are used to identify a
1153
+ consignment from any other consignment.
1154
+ This value appears on a
1155
+ routing label and is used as
1156
+ the key for a consignment.
1157
+
1158
+ * collectionDateTime -- The date that the consignment will be collected,
1159
+ to be
1160
+ supplied as CCYY-MM-DD'T'hh:mm:ss e.g 5:30 p.m. on
1161
+ 30th
1162
+ December 2008 will be supplied as 2008-12-30T17:30:00.
1163
+ This
1164
+ datatype describes instances identified by the
1165
+ combination of a
1166
+ date and a time. Its value space is
1167
+ described as a combination of
1168
+ date and time of day in
1169
+ Chapter 5.4 of ISO 8601 and the W3C XML
1170
+ Schema
1171
+ Recommendation . Its lexical space is the extended format:
1172
+ [-]CCYY-MM-DDThh:mm:ss[Z|(+|-)hh:mm]
1173
+ * sender -- The origin is the address the consignment is
1174
+ physically collected
1175
+ from. This will be used to obtain a route for
1176
+ the consignment and
1177
+ will also appear on the label.
1178
+
1179
+ * delivery -- The delivery is the address the consignment is
1180
+ physically sent
1181
+ to. This will be used to obtain a route for the
1182
+ consignment and
1183
+ will also appear on the label.
1184
+ * contact -- This is the contact information for this
1185
+ delivery consignment.
1186
+ This information only appears on some labels
1187
+ but is present in the xml
1188
+ response.
1189
+
1190
+ * product -- Information relating to the TNT product chosen for this
1191
+ consignment. Example products are next day, before 10, etc.
1192
+ * account -- The TNT account paying for this consignment to
1193
+ be transported.
1194
+ * cashAmount -- The cost of the consignment. This will only
1195
+ appear on some labels
1196
+ and only then if it is cash on delivery
1197
+
1198
+ * cashCurrency -- The currency of the cost of the consignment.
1199
+ This is part of the 2D Barcode.
1200
+ * cashType -- The cashType of the consignment. This is part of
1201
+ the 2D Barcode.
1202
+ * ncolNumber -- The ncol number. This is part of the 2D Barcode.
1203
+
1204
+ * specialInstructions -- Any special instructions required to appear on
1205
+ the label.
1206
+ * bulkShipment -- This is a flag to show if this is a bulk
1207
+ shipment or not
1208
+ * customControlled -- This is a flag to show if this is a custom
1209
+ controlled consignment or not
1210
+ * termsOfPayment -- This is a flag to show if this is a Sender pays
1211
+ (S) or Receiver pays (R) consignment
1212
+ * totalNumberOfPieces -- The total number of pieces this consignment
1213
+ contains. This
1214
+ is used to print the sequence numbers on the labels,
1215
+ e.g.
1216
+ 1 of x, where x is the value provided here.
1217
+
1218
+ * pieceLine -- One pieceLine XML block to be provided per type
1219
+ of package in the
1220
+ consignment. Each pieceLine defines the common
1221
+ attributes that
1222
+ one or more actual pieces share. For example, if
1223
+ green boxes and
1224
+ blue boxes are required to be shipped, then one
1225
+ piece line per box
1226
+ type needs to be provided, i.e one pieceLine for
1227
+ green box
1228
+ attributes
1229
+ and one for blue box attributes. At least one
1230
+ pieceLine per
1231
+ consignment
1232
+ must be provided. Individual pieces are
1233
+ defined within the piece line.
1234
+
1235
+ """
1236
+ __hash__ = GeneratedsSuper.__hash__
1237
+ subclass = None
1238
+ superclass = None
1239
+ def __init__(self, key=None, consignmentIdentity=None, collectionDateTime=None, sender=None, delivery=None, contact=None, product=None, account=None, cashAmount=None, cashCurrency=None, cashType=None, ncolNumber=None, specialInstructions=None, bulkShipment=None, customControlled=None, termsOfPayment=None, totalNumberOfPieces=None, pieceLine=None, gds_collector_=None, **kwargs_):
1240
+ self.gds_collector_ = gds_collector_
1241
+ self.gds_elementtree_node_ = None
1242
+ self.original_tagname_ = None
1243
+ self.parent_object_ = kwargs_.get('parent_object_')
1244
+ self.ns_prefix_ = None
1245
+ self.key = _cast(None, key)
1246
+ self.key_nsprefix_ = None
1247
+ self.consignmentIdentity = consignmentIdentity
1248
+ self.consignmentIdentity_nsprefix_ = None
1249
+ if isinstance(collectionDateTime, BaseStrType_):
1250
+ initvalue_ = datetime_.datetime.strptime(collectionDateTime, '%Y-%m-%dT%H:%M:%S')
1251
+ else:
1252
+ initvalue_ = collectionDateTime
1253
+ self.collectionDateTime = initvalue_
1254
+ self.collectionDateTime_nsprefix_ = None
1255
+ self.sender = sender
1256
+ self.sender_nsprefix_ = None
1257
+ self.delivery = delivery
1258
+ self.delivery_nsprefix_ = None
1259
+ self.contact = contact
1260
+ self.contact_nsprefix_ = None
1261
+ self.product = product
1262
+ self.product_nsprefix_ = None
1263
+ self.account = account
1264
+ self.account_nsprefix_ = None
1265
+ self.cashAmount = cashAmount
1266
+ self.validate_doubleTwoDecimalPlaces(self.cashAmount)
1267
+ self.cashAmount_nsprefix_ = None
1268
+ self.cashCurrency = cashCurrency
1269
+ self.cashCurrency_nsprefix_ = None
1270
+ self.cashType = cashType
1271
+ self.validate_cashTypeEnum(self.cashType)
1272
+ self.cashType_nsprefix_ = None
1273
+ self.ncolNumber = ncolNumber
1274
+ self.ncolNumber_nsprefix_ = None
1275
+ self.specialInstructions = specialInstructions
1276
+ self.specialInstructions_nsprefix_ = None
1277
+ self.bulkShipment = bulkShipment
1278
+ self.validate_booleanEnum(self.bulkShipment)
1279
+ self.bulkShipment_nsprefix_ = None
1280
+ self.customControlled = customControlled
1281
+ self.validate_booleanEnum(self.customControlled)
1282
+ self.customControlled_nsprefix_ = None
1283
+ self.termsOfPayment = termsOfPayment
1284
+ self.validate_senderReceiverEnum(self.termsOfPayment)
1285
+ self.termsOfPayment_nsprefix_ = None
1286
+ self.totalNumberOfPieces = totalNumberOfPieces
1287
+ self.totalNumberOfPieces_nsprefix_ = None
1288
+ if pieceLine is None:
1289
+ self.pieceLine = []
1290
+ else:
1291
+ self.pieceLine = pieceLine
1292
+ self.pieceLine_nsprefix_ = None
1293
+ def factory(*args_, **kwargs_):
1294
+ if CurrentSubclassModule_ is not None:
1295
+ subclass = getSubclassFromModule_(
1296
+ CurrentSubclassModule_, labelConsignmentsType)
1297
+ if subclass is not None:
1298
+ return subclass(*args_, **kwargs_)
1299
+ if labelConsignmentsType.subclass:
1300
+ return labelConsignmentsType.subclass(*args_, **kwargs_)
1301
+ else:
1302
+ return labelConsignmentsType(*args_, **kwargs_)
1303
+ factory = staticmethod(factory)
1304
+ def get_ns_prefix_(self):
1305
+ return self.ns_prefix_
1306
+ def set_ns_prefix_(self, ns_prefix):
1307
+ self.ns_prefix_ = ns_prefix
1308
+ def get_consignmentIdentity(self):
1309
+ return self.consignmentIdentity
1310
+ def set_consignmentIdentity(self, consignmentIdentity):
1311
+ self.consignmentIdentity = consignmentIdentity
1312
+ def get_collectionDateTime(self):
1313
+ return self.collectionDateTime
1314
+ def set_collectionDateTime(self, collectionDateTime):
1315
+ self.collectionDateTime = collectionDateTime
1316
+ def get_sender(self):
1317
+ return self.sender
1318
+ def set_sender(self, sender):
1319
+ self.sender = sender
1320
+ def get_delivery(self):
1321
+ return self.delivery
1322
+ def set_delivery(self, delivery):
1323
+ self.delivery = delivery
1324
+ def get_contact(self):
1325
+ return self.contact
1326
+ def set_contact(self, contact):
1327
+ self.contact = contact
1328
+ def get_product(self):
1329
+ return self.product
1330
+ def set_product(self, product):
1331
+ self.product = product
1332
+ def get_account(self):
1333
+ return self.account
1334
+ def set_account(self, account):
1335
+ self.account = account
1336
+ def get_cashAmount(self):
1337
+ return self.cashAmount
1338
+ def set_cashAmount(self, cashAmount):
1339
+ self.cashAmount = cashAmount
1340
+ def get_cashCurrency(self):
1341
+ return self.cashCurrency
1342
+ def set_cashCurrency(self, cashCurrency):
1343
+ self.cashCurrency = cashCurrency
1344
+ def get_cashType(self):
1345
+ return self.cashType
1346
+ def set_cashType(self, cashType):
1347
+ self.cashType = cashType
1348
+ def get_ncolNumber(self):
1349
+ return self.ncolNumber
1350
+ def set_ncolNumber(self, ncolNumber):
1351
+ self.ncolNumber = ncolNumber
1352
+ def get_specialInstructions(self):
1353
+ return self.specialInstructions
1354
+ def set_specialInstructions(self, specialInstructions):
1355
+ self.specialInstructions = specialInstructions
1356
+ def get_bulkShipment(self):
1357
+ return self.bulkShipment
1358
+ def set_bulkShipment(self, bulkShipment):
1359
+ self.bulkShipment = bulkShipment
1360
+ def get_customControlled(self):
1361
+ return self.customControlled
1362
+ def set_customControlled(self, customControlled):
1363
+ self.customControlled = customControlled
1364
+ def get_termsOfPayment(self):
1365
+ return self.termsOfPayment
1366
+ def set_termsOfPayment(self, termsOfPayment):
1367
+ self.termsOfPayment = termsOfPayment
1368
+ def get_totalNumberOfPieces(self):
1369
+ return self.totalNumberOfPieces
1370
+ def set_totalNumberOfPieces(self, totalNumberOfPieces):
1371
+ self.totalNumberOfPieces = totalNumberOfPieces
1372
+ def get_pieceLine(self):
1373
+ return self.pieceLine
1374
+ def set_pieceLine(self, pieceLine):
1375
+ self.pieceLine = pieceLine
1376
+ def add_pieceLine(self, value):
1377
+ self.pieceLine.append(value)
1378
+ def insert_pieceLine_at(self, index, value):
1379
+ self.pieceLine.insert(index, value)
1380
+ def replace_pieceLine_at(self, index, value):
1381
+ self.pieceLine[index] = value
1382
+ def get_key(self):
1383
+ return self.key
1384
+ def set_key(self, key):
1385
+ self.key = key
1386
+ def validate_doubleTwoDecimalPlaces(self, value):
1387
+ result = True
1388
+ # Validate type doubleTwoDecimalPlaces, a restriction on xsd:decimal.
1389
+ if value is not None and Validate_simpletypes_ and self.gds_collector_ is not None:
1390
+ if not isinstance(value, decimal_.Decimal):
1391
+ lineno = self.gds_get_node_lineno_()
1392
+ self.gds_collector_.add_message('Value "%(value)s"%(lineno)s is not of the correct base simple type (decimal_.Decimal)' % {"value": value, "lineno": lineno, })
1393
+ return False
1394
+ pass
1395
+ return result
1396
+ def validate_cashTypeEnum(self, value):
1397
+ result = True
1398
+ # Validate type cashTypeEnum, a restriction on xsd:string.
1399
+ if value is not None and Validate_simpletypes_ and self.gds_collector_ is not None:
1400
+ if not isinstance(value, str):
1401
+ lineno = self.gds_get_node_lineno_()
1402
+ self.gds_collector_.add_message('Value "%(value)s"%(lineno)s is not of the correct base simple type (str)' % {"value": value, "lineno": lineno, })
1403
+ return False
1404
+ value = value
1405
+ enumerations = ['0', '1']
1406
+ if value not in enumerations:
1407
+ lineno = self.gds_get_node_lineno_()
1408
+ self.gds_collector_.add_message('Value "%(value)s"%(lineno)s does not match xsd enumeration restriction on cashTypeEnum' % {"value" : encode_str_2_3(value), "lineno": lineno} )
1409
+ result = False
1410
+ return result
1411
+ def validate_booleanEnum(self, value):
1412
+ result = True
1413
+ # Validate type booleanEnum, a restriction on xsd:string.
1414
+ if value is not None and Validate_simpletypes_ and self.gds_collector_ is not None:
1415
+ if not isinstance(value, str):
1416
+ lineno = self.gds_get_node_lineno_()
1417
+ self.gds_collector_.add_message('Value "%(value)s"%(lineno)s is not of the correct base simple type (str)' % {"value": value, "lineno": lineno, })
1418
+ return False
1419
+ value = value
1420
+ enumerations = ['N', 'Y']
1421
+ if value not in enumerations:
1422
+ lineno = self.gds_get_node_lineno_()
1423
+ 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} )
1424
+ result = False
1425
+ return result
1426
+ def validate_senderReceiverEnum(self, value):
1427
+ result = True
1428
+ # Validate type senderReceiverEnum, a restriction on xsd:string.
1429
+ if value is not None and Validate_simpletypes_ and self.gds_collector_ is not None:
1430
+ if not isinstance(value, str):
1431
+ lineno = self.gds_get_node_lineno_()
1432
+ self.gds_collector_.add_message('Value "%(value)s"%(lineno)s is not of the correct base simple type (str)' % {"value": value, "lineno": lineno, })
1433
+ return False
1434
+ value = value
1435
+ enumerations = ['S', 'R']
1436
+ if value not in enumerations:
1437
+ lineno = self.gds_get_node_lineno_()
1438
+ self.gds_collector_.add_message('Value "%(value)s"%(lineno)s does not match xsd enumeration restriction on senderReceiverEnum' % {"value" : encode_str_2_3(value), "lineno": lineno} )
1439
+ result = False
1440
+ return result
1441
+ def has__content(self):
1442
+ if (
1443
+ self.consignmentIdentity is not None or
1444
+ self.collectionDateTime is not None or
1445
+ self.sender is not None or
1446
+ self.delivery is not None or
1447
+ self.contact is not None or
1448
+ self.product is not None or
1449
+ self.account is not None or
1450
+ self.cashAmount is not None or
1451
+ self.cashCurrency is not None or
1452
+ self.cashType is not None or
1453
+ self.ncolNumber is not None or
1454
+ self.specialInstructions is not None or
1455
+ self.bulkShipment is not None or
1456
+ self.customControlled is not None or
1457
+ self.termsOfPayment is not None or
1458
+ self.totalNumberOfPieces is not None or
1459
+ self.pieceLine
1460
+ ):
1461
+ return True
1462
+ else:
1463
+ return False
1464
+ def export(self, outfile, level, namespaceprefix_='', namespacedef_='', name_='labelConsignmentsType', pretty_print=True):
1465
+ imported_ns_def_ = GenerateDSNamespaceDefs_.get('labelConsignmentsType')
1466
+ if imported_ns_def_ is not None:
1467
+ namespacedef_ = imported_ns_def_
1468
+ if pretty_print:
1469
+ eol_ = '\n'
1470
+ else:
1471
+ eol_ = ''
1472
+ if self.original_tagname_ is not None and name_ == 'labelConsignmentsType':
1473
+ name_ = self.original_tagname_
1474
+ if UseCapturedNS_ and self.ns_prefix_:
1475
+ namespaceprefix_ = self.ns_prefix_ + ':'
1476
+ showIndent(outfile, level, pretty_print)
1477
+ outfile.write('<%s%s%s' % (namespaceprefix_, name_, namespacedef_ and ' ' + namespacedef_ or '', ))
1478
+ already_processed = set()
1479
+ self._exportAttributes(outfile, level, already_processed, namespaceprefix_, name_='labelConsignmentsType')
1480
+ if self.has__content():
1481
+ outfile.write('>%s' % (eol_, ))
1482
+ self._exportChildren(outfile, level + 1, namespaceprefix_, namespacedef_, name_='labelConsignmentsType', pretty_print=pretty_print)
1483
+ showIndent(outfile, level, pretty_print)
1484
+ outfile.write('</%s%s>%s' % (namespaceprefix_, name_, eol_))
1485
+ else:
1486
+ outfile.write('/>%s' % (eol_, ))
1487
+ def _exportAttributes(self, outfile, level, already_processed, namespaceprefix_='', name_='labelConsignmentsType'):
1488
+ if self.key is not None and 'key' not in already_processed:
1489
+ already_processed.add('key')
1490
+ outfile.write(' key=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.key), input_name='key')), ))
1491
+ def _exportChildren(self, outfile, level, namespaceprefix_='', namespacedef_='', name_='labelConsignmentsType', fromsubclass_=False, pretty_print=True):
1492
+ if pretty_print:
1493
+ eol_ = '\n'
1494
+ else:
1495
+ eol_ = ''
1496
+ if self.consignmentIdentity is not None:
1497
+ namespaceprefix_ = self.consignmentIdentity_nsprefix_ + ':' if (UseCapturedNS_ and self.consignmentIdentity_nsprefix_) else ''
1498
+ self.consignmentIdentity.export(outfile, level, namespaceprefix_, namespacedef_='', name_='consignmentIdentity', pretty_print=pretty_print)
1499
+ if self.collectionDateTime is not None:
1500
+ namespaceprefix_ = self.collectionDateTime_nsprefix_ + ':' if (UseCapturedNS_ and self.collectionDateTime_nsprefix_) else ''
1501
+ showIndent(outfile, level, pretty_print)
1502
+ outfile.write('<%scollectionDateTime>%s</%scollectionDateTime>%s' % (namespaceprefix_ , self.gds_format_datetime(self.collectionDateTime, input_name='collectionDateTime'), namespaceprefix_ , eol_))
1503
+ if self.sender is not None:
1504
+ namespaceprefix_ = self.sender_nsprefix_ + ':' if (UseCapturedNS_ and self.sender_nsprefix_) else ''
1505
+ self.sender.export(outfile, level, namespaceprefix_, namespacedef_='', name_='sender', pretty_print=pretty_print)
1506
+ if self.delivery is not None:
1507
+ namespaceprefix_ = self.delivery_nsprefix_ + ':' if (UseCapturedNS_ and self.delivery_nsprefix_) else ''
1508
+ self.delivery.export(outfile, level, namespaceprefix_, namespacedef_='', name_='delivery', pretty_print=pretty_print)
1509
+ if self.contact is not None:
1510
+ namespaceprefix_ = self.contact_nsprefix_ + ':' if (UseCapturedNS_ and self.contact_nsprefix_) else ''
1511
+ self.contact.export(outfile, level, namespaceprefix_, namespacedef_='', name_='contact', pretty_print=pretty_print)
1512
+ if self.product is not None:
1513
+ namespaceprefix_ = self.product_nsprefix_ + ':' if (UseCapturedNS_ and self.product_nsprefix_) else ''
1514
+ self.product.export(outfile, level, namespaceprefix_, namespacedef_='', name_='product', pretty_print=pretty_print)
1515
+ if self.account is not None:
1516
+ namespaceprefix_ = self.account_nsprefix_ + ':' if (UseCapturedNS_ and self.account_nsprefix_) else ''
1517
+ self.account.export(outfile, level, namespaceprefix_, namespacedef_='', name_='account', pretty_print=pretty_print)
1518
+ if self.cashAmount is not None:
1519
+ namespaceprefix_ = self.cashAmount_nsprefix_ + ':' if (UseCapturedNS_ and self.cashAmount_nsprefix_) else ''
1520
+ showIndent(outfile, level, pretty_print)
1521
+ outfile.write('<%scashAmount>%s</%scashAmount>%s' % (namespaceprefix_ , self.gds_format_decimal(self.cashAmount, input_name='cashAmount'), namespaceprefix_ , eol_))
1522
+ if self.cashCurrency is not None:
1523
+ namespaceprefix_ = self.cashCurrency_nsprefix_ + ':' if (UseCapturedNS_ and self.cashCurrency_nsprefix_) else ''
1524
+ showIndent(outfile, level, pretty_print)
1525
+ outfile.write('<%scashCurrency>%s</%scashCurrency>%s' % (namespaceprefix_ , self.gds_encode(self.gds_format_string(quote_xml(self.cashCurrency), input_name='cashCurrency')), namespaceprefix_ , eol_))
1526
+ if self.cashType is not None:
1527
+ namespaceprefix_ = self.cashType_nsprefix_ + ':' if (UseCapturedNS_ and self.cashType_nsprefix_) else ''
1528
+ showIndent(outfile, level, pretty_print)
1529
+ outfile.write('<%scashType>%s</%scashType>%s' % (namespaceprefix_ , self.gds_encode(self.gds_format_string(quote_xml(self.cashType), input_name='cashType')), namespaceprefix_ , eol_))
1530
+ if self.ncolNumber is not None:
1531
+ namespaceprefix_ = self.ncolNumber_nsprefix_ + ':' if (UseCapturedNS_ and self.ncolNumber_nsprefix_) else ''
1532
+ showIndent(outfile, level, pretty_print)
1533
+ outfile.write('<%sncolNumber>%s</%sncolNumber>%s' % (namespaceprefix_ , self.gds_encode(self.gds_format_string(quote_xml(self.ncolNumber), input_name='ncolNumber')), namespaceprefix_ , eol_))
1534
+ if self.specialInstructions is not None:
1535
+ namespaceprefix_ = self.specialInstructions_nsprefix_ + ':' if (UseCapturedNS_ and self.specialInstructions_nsprefix_) else ''
1536
+ showIndent(outfile, level, pretty_print)
1537
+ outfile.write('<%sspecialInstructions>%s</%sspecialInstructions>%s' % (namespaceprefix_ , self.gds_encode(self.gds_format_string(quote_xml(self.specialInstructions), input_name='specialInstructions')), namespaceprefix_ , eol_))
1538
+ if self.bulkShipment is not None:
1539
+ namespaceprefix_ = self.bulkShipment_nsprefix_ + ':' if (UseCapturedNS_ and self.bulkShipment_nsprefix_) else ''
1540
+ showIndent(outfile, level, pretty_print)
1541
+ outfile.write('<%sbulkShipment>%s</%sbulkShipment>%s' % (namespaceprefix_ , self.gds_encode(self.gds_format_string(quote_xml(self.bulkShipment), input_name='bulkShipment')), namespaceprefix_ , eol_))
1542
+ if self.customControlled is not None:
1543
+ namespaceprefix_ = self.customControlled_nsprefix_ + ':' if (UseCapturedNS_ and self.customControlled_nsprefix_) else ''
1544
+ showIndent(outfile, level, pretty_print)
1545
+ outfile.write('<%scustomControlled>%s</%scustomControlled>%s' % (namespaceprefix_ , self.gds_encode(self.gds_format_string(quote_xml(self.customControlled), input_name='customControlled')), namespaceprefix_ , eol_))
1546
+ if self.termsOfPayment is not None:
1547
+ namespaceprefix_ = self.termsOfPayment_nsprefix_ + ':' if (UseCapturedNS_ and self.termsOfPayment_nsprefix_) else ''
1548
+ showIndent(outfile, level, pretty_print)
1549
+ outfile.write('<%stermsOfPayment>%s</%stermsOfPayment>%s' % (namespaceprefix_ , self.gds_encode(self.gds_format_string(quote_xml(self.termsOfPayment), input_name='termsOfPayment')), namespaceprefix_ , eol_))
1550
+ if self.totalNumberOfPieces is not None:
1551
+ namespaceprefix_ = self.totalNumberOfPieces_nsprefix_ + ':' if (UseCapturedNS_ and self.totalNumberOfPieces_nsprefix_) else ''
1552
+ showIndent(outfile, level, pretty_print)
1553
+ outfile.write('<%stotalNumberOfPieces>%s</%stotalNumberOfPieces>%s' % (namespaceprefix_ , self.gds_format_integer(self.totalNumberOfPieces, input_name='totalNumberOfPieces'), namespaceprefix_ , eol_))
1554
+ for pieceLine_ in self.pieceLine:
1555
+ namespaceprefix_ = self.pieceLine_nsprefix_ + ':' if (UseCapturedNS_ and self.pieceLine_nsprefix_) else ''
1556
+ pieceLine_.export(outfile, level, namespaceprefix_, namespacedef_='', name_='pieceLine', pretty_print=pretty_print)
1557
+ def build(self, node, gds_collector_=None):
1558
+ self.gds_collector_ = gds_collector_
1559
+ if SaveElementTreeNode:
1560
+ self.gds_elementtree_node_ = node
1561
+ already_processed = set()
1562
+ self.ns_prefix_ = node.prefix
1563
+ self._buildAttributes(node, node.attrib, already_processed)
1564
+ for child in node:
1565
+ nodeName_ = Tag_pattern_.match(child.tag).groups()[-1]
1566
+ self._buildChildren(child, node, nodeName_, gds_collector_=gds_collector_)
1567
+ return self
1568
+ def _buildAttributes(self, node, attrs, already_processed):
1569
+ value = find_attr_value_('key', node)
1570
+ if value is not None and 'key' not in already_processed:
1571
+ already_processed.add('key')
1572
+ self.key = value
1573
+ def _buildChildren(self, child_, node, nodeName_, fromsubclass_=False, gds_collector_=None):
1574
+ if nodeName_ == 'consignmentIdentity':
1575
+ obj_ = consignmentIdentityType.factory(parent_object_=self)
1576
+ obj_.build(child_, gds_collector_=gds_collector_)
1577
+ self.consignmentIdentity = obj_
1578
+ obj_.original_tagname_ = 'consignmentIdentity'
1579
+ elif nodeName_ == 'collectionDateTime':
1580
+ sval_ = child_.text
1581
+ dval_ = self.gds_parse_datetime(sval_)
1582
+ self.collectionDateTime = dval_
1583
+ self.collectionDateTime_nsprefix_ = child_.prefix
1584
+ elif nodeName_ == 'sender':
1585
+ obj_ = nameAndAddressRequestType.factory(parent_object_=self)
1586
+ obj_.build(child_, gds_collector_=gds_collector_)
1587
+ self.sender = obj_
1588
+ obj_.original_tagname_ = 'sender'
1589
+ elif nodeName_ == 'delivery':
1590
+ obj_ = nameAndAddressRequestType.factory(parent_object_=self)
1591
+ obj_.build(child_, gds_collector_=gds_collector_)
1592
+ self.delivery = obj_
1593
+ obj_.original_tagname_ = 'delivery'
1594
+ elif nodeName_ == 'contact':
1595
+ obj_ = contactType.factory(parent_object_=self)
1596
+ obj_.build(child_, gds_collector_=gds_collector_)
1597
+ self.contact = obj_
1598
+ obj_.original_tagname_ = 'contact'
1599
+ elif nodeName_ == 'product':
1600
+ obj_ = productType.factory(parent_object_=self)
1601
+ obj_.build(child_, gds_collector_=gds_collector_)
1602
+ self.product = obj_
1603
+ obj_.original_tagname_ = 'product'
1604
+ elif nodeName_ == 'account':
1605
+ obj_ = accountType.factory(parent_object_=self)
1606
+ obj_.build(child_, gds_collector_=gds_collector_)
1607
+ self.account = obj_
1608
+ obj_.original_tagname_ = 'account'
1609
+ elif nodeName_ == 'cashAmount' and child_.text:
1610
+ sval_ = child_.text
1611
+ fval_ = self.gds_parse_decimal(sval_, node, 'cashAmount')
1612
+ fval_ = self.gds_validate_decimal(fval_, node, 'cashAmount')
1613
+ self.cashAmount = fval_
1614
+ self.cashAmount_nsprefix_ = child_.prefix
1615
+ # validate type doubleTwoDecimalPlaces
1616
+ self.validate_doubleTwoDecimalPlaces(self.cashAmount)
1617
+ elif nodeName_ == 'cashCurrency':
1618
+ value_ = child_.text
1619
+ value_ = self.gds_parse_string(value_, node, 'cashCurrency')
1620
+ value_ = self.gds_validate_string(value_, node, 'cashCurrency')
1621
+ self.cashCurrency = value_
1622
+ self.cashCurrency_nsprefix_ = child_.prefix
1623
+ elif nodeName_ == 'cashType':
1624
+ value_ = child_.text
1625
+ value_ = self.gds_parse_string(value_, node, 'cashType')
1626
+ value_ = self.gds_validate_string(value_, node, 'cashType')
1627
+ self.cashType = value_
1628
+ self.cashType_nsprefix_ = child_.prefix
1629
+ # validate type cashTypeEnum
1630
+ self.validate_cashTypeEnum(self.cashType)
1631
+ elif nodeName_ == 'ncolNumber':
1632
+ value_ = child_.text
1633
+ value_ = self.gds_parse_string(value_, node, 'ncolNumber')
1634
+ value_ = self.gds_validate_string(value_, node, 'ncolNumber')
1635
+ self.ncolNumber = value_
1636
+ self.ncolNumber_nsprefix_ = child_.prefix
1637
+ elif nodeName_ == 'specialInstructions':
1638
+ value_ = child_.text
1639
+ value_ = self.gds_parse_string(value_, node, 'specialInstructions')
1640
+ value_ = self.gds_validate_string(value_, node, 'specialInstructions')
1641
+ self.specialInstructions = value_
1642
+ self.specialInstructions_nsprefix_ = child_.prefix
1643
+ elif nodeName_ == 'bulkShipment':
1644
+ value_ = child_.text
1645
+ value_ = self.gds_parse_string(value_, node, 'bulkShipment')
1646
+ value_ = self.gds_validate_string(value_, node, 'bulkShipment')
1647
+ self.bulkShipment = value_
1648
+ self.bulkShipment_nsprefix_ = child_.prefix
1649
+ # validate type booleanEnum
1650
+ self.validate_booleanEnum(self.bulkShipment)
1651
+ elif nodeName_ == 'customControlled':
1652
+ value_ = child_.text
1653
+ value_ = self.gds_parse_string(value_, node, 'customControlled')
1654
+ value_ = self.gds_validate_string(value_, node, 'customControlled')
1655
+ self.customControlled = value_
1656
+ self.customControlled_nsprefix_ = child_.prefix
1657
+ # validate type booleanEnum
1658
+ self.validate_booleanEnum(self.customControlled)
1659
+ elif nodeName_ == 'termsOfPayment':
1660
+ value_ = child_.text
1661
+ value_ = self.gds_parse_string(value_, node, 'termsOfPayment')
1662
+ value_ = self.gds_validate_string(value_, node, 'termsOfPayment')
1663
+ self.termsOfPayment = value_
1664
+ self.termsOfPayment_nsprefix_ = child_.prefix
1665
+ # validate type senderReceiverEnum
1666
+ self.validate_senderReceiverEnum(self.termsOfPayment)
1667
+ elif nodeName_ == 'totalNumberOfPieces' and child_.text:
1668
+ sval_ = child_.text
1669
+ ival_ = self.gds_parse_integer(sval_, node, 'totalNumberOfPieces')
1670
+ ival_ = self.gds_validate_integer(ival_, node, 'totalNumberOfPieces')
1671
+ self.totalNumberOfPieces = ival_
1672
+ self.totalNumberOfPieces_nsprefix_ = child_.prefix
1673
+ elif nodeName_ == 'pieceLine':
1674
+ obj_ = pieceLineType.factory(parent_object_=self)
1675
+ obj_.build(child_, gds_collector_=gds_collector_)
1676
+ self.pieceLine.append(obj_)
1677
+ obj_.original_tagname_ = 'pieceLine'
1678
+ # end class labelConsignmentsType
1679
+
1680
+
1681
+ class productType(GeneratedsSuper):
1682
+ """productType -- Information relating to the TNT product chosen for
1683
+ this consignment.
1684
+ Example products are next day, before 10, etc
1685
+
1686
+ """
1687
+ __hash__ = GeneratedsSuper.__hash__
1688
+ subclass = None
1689
+ superclass = None
1690
+ def __init__(self, lineOfBusiness=None, groupId=None, subGroupId=None, id=None, type_=None, option=None, gds_collector_=None, **kwargs_):
1691
+ self.gds_collector_ = gds_collector_
1692
+ self.gds_elementtree_node_ = None
1693
+ self.original_tagname_ = None
1694
+ self.parent_object_ = kwargs_.get('parent_object_')
1695
+ self.ns_prefix_ = None
1696
+ self.lineOfBusiness = lineOfBusiness
1697
+ self.validate_integerMin0Max9(self.lineOfBusiness)
1698
+ self.lineOfBusiness_nsprefix_ = None
1699
+ self.groupId = groupId
1700
+ self.validate_integerMin0Max9(self.groupId)
1701
+ self.groupId_nsprefix_ = None
1702
+ self.subGroupId = subGroupId
1703
+ self.validate_integerMin0Max9(self.subGroupId)
1704
+ self.subGroupId_nsprefix_ = None
1705
+ self.id = id
1706
+ self.validate_stringMaxLength4(self.id)
1707
+ self.id_nsprefix_ = None
1708
+ self.type_ = type_
1709
+ self.validate_productTypeEnum(self.type_)
1710
+ self.type__nsprefix_ = None
1711
+ if option is None:
1712
+ self.option = []
1713
+ else:
1714
+ self.option = option
1715
+ self.option_nsprefix_ = None
1716
+ def factory(*args_, **kwargs_):
1717
+ if CurrentSubclassModule_ is not None:
1718
+ subclass = getSubclassFromModule_(
1719
+ CurrentSubclassModule_, productType)
1720
+ if subclass is not None:
1721
+ return subclass(*args_, **kwargs_)
1722
+ if productType.subclass:
1723
+ return productType.subclass(*args_, **kwargs_)
1724
+ else:
1725
+ return productType(*args_, **kwargs_)
1726
+ factory = staticmethod(factory)
1727
+ def get_ns_prefix_(self):
1728
+ return self.ns_prefix_
1729
+ def set_ns_prefix_(self, ns_prefix):
1730
+ self.ns_prefix_ = ns_prefix
1731
+ def get_lineOfBusiness(self):
1732
+ return self.lineOfBusiness
1733
+ def set_lineOfBusiness(self, lineOfBusiness):
1734
+ self.lineOfBusiness = lineOfBusiness
1735
+ def get_groupId(self):
1736
+ return self.groupId
1737
+ def set_groupId(self, groupId):
1738
+ self.groupId = groupId
1739
+ def get_subGroupId(self):
1740
+ return self.subGroupId
1741
+ def set_subGroupId(self, subGroupId):
1742
+ self.subGroupId = subGroupId
1743
+ def get_id(self):
1744
+ return self.id
1745
+ def set_id(self, id):
1746
+ self.id = id
1747
+ def get_type(self):
1748
+ return self.type_
1749
+ def set_type(self, type_):
1750
+ self.type_ = type_
1751
+ def get_option(self):
1752
+ return self.option
1753
+ def set_option(self, option):
1754
+ self.option = option
1755
+ def add_option(self, value):
1756
+ self.option.append(value)
1757
+ def insert_option_at(self, index, value):
1758
+ self.option.insert(index, value)
1759
+ def replace_option_at(self, index, value):
1760
+ self.option[index] = value
1761
+ def validate_integerMin0Max9(self, value):
1762
+ result = True
1763
+ # Validate type integerMin0Max9, a restriction on xsd:int.
1764
+ if value is not None and Validate_simpletypes_ and self.gds_collector_ is not None:
1765
+ if not isinstance(value, int):
1766
+ lineno = self.gds_get_node_lineno_()
1767
+ self.gds_collector_.add_message('Value "%(value)s"%(lineno)s is not of the correct base simple type (int)' % {"value": value, "lineno": lineno, })
1768
+ return False
1769
+ if value < 0:
1770
+ lineno = self.gds_get_node_lineno_()
1771
+ self.gds_collector_.add_message('Value "%(value)s"%(lineno)s does not match xsd minInclusive restriction on integerMin0Max9' % {"value": value, "lineno": lineno} )
1772
+ result = False
1773
+ if value > 9:
1774
+ lineno = self.gds_get_node_lineno_()
1775
+ self.gds_collector_.add_message('Value "%(value)s"%(lineno)s does not match xsd maxInclusive restriction on integerMin0Max9' % {"value": value, "lineno": lineno} )
1776
+ result = False
1777
+ return result
1778
+ def validate_stringMaxLength4(self, value):
1779
+ result = True
1780
+ # Validate type stringMaxLength4, a restriction on xsd:string.
1781
+ if value is not None and Validate_simpletypes_ and self.gds_collector_ is not None:
1782
+ if not isinstance(value, str):
1783
+ lineno = self.gds_get_node_lineno_()
1784
+ self.gds_collector_.add_message('Value "%(value)s"%(lineno)s is not of the correct base simple type (str)' % {"value": value, "lineno": lineno, })
1785
+ return False
1786
+ if len(value) > 4:
1787
+ lineno = self.gds_get_node_lineno_()
1788
+ self.gds_collector_.add_message('Value "%(value)s"%(lineno)s does not match xsd maxLength restriction on stringMaxLength4' % {"value" : encode_str_2_3(value), "lineno": lineno} )
1789
+ result = False
1790
+ return result
1791
+ def validate_productTypeEnum(self, value):
1792
+ result = True
1793
+ # Validate type productTypeEnum, a restriction on xsd:string.
1794
+ if value is not None and Validate_simpletypes_ and self.gds_collector_ is not None:
1795
+ if not isinstance(value, str):
1796
+ lineno = self.gds_get_node_lineno_()
1797
+ self.gds_collector_.add_message('Value "%(value)s"%(lineno)s is not of the correct base simple type (str)' % {"value": value, "lineno": lineno, })
1798
+ return False
1799
+ value = value
1800
+ enumerations = ['N', 'D']
1801
+ if value not in enumerations:
1802
+ lineno = self.gds_get_node_lineno_()
1803
+ self.gds_collector_.add_message('Value "%(value)s"%(lineno)s does not match xsd enumeration restriction on productTypeEnum' % {"value" : encode_str_2_3(value), "lineno": lineno} )
1804
+ result = False
1805
+ return result
1806
+ def has__content(self):
1807
+ if (
1808
+ self.lineOfBusiness is not None or
1809
+ self.groupId is not None or
1810
+ self.subGroupId is not None or
1811
+ self.id is not None or
1812
+ self.type_ is not None or
1813
+ self.option
1814
+ ):
1815
+ return True
1816
+ else:
1817
+ return False
1818
+ def export(self, outfile, level, namespaceprefix_='', namespacedef_='', name_='productType', pretty_print=True):
1819
+ imported_ns_def_ = GenerateDSNamespaceDefs_.get('productType')
1820
+ if imported_ns_def_ is not None:
1821
+ namespacedef_ = imported_ns_def_
1822
+ if pretty_print:
1823
+ eol_ = '\n'
1824
+ else:
1825
+ eol_ = ''
1826
+ if self.original_tagname_ is not None and name_ == 'productType':
1827
+ name_ = self.original_tagname_
1828
+ if UseCapturedNS_ and self.ns_prefix_:
1829
+ namespaceprefix_ = self.ns_prefix_ + ':'
1830
+ showIndent(outfile, level, pretty_print)
1831
+ outfile.write('<%s%s%s' % (namespaceprefix_, name_, namespacedef_ and ' ' + namespacedef_ or '', ))
1832
+ already_processed = set()
1833
+ self._exportAttributes(outfile, level, already_processed, namespaceprefix_, name_='productType')
1834
+ if self.has__content():
1835
+ outfile.write('>%s' % (eol_, ))
1836
+ self._exportChildren(outfile, level + 1, namespaceprefix_, namespacedef_, name_='productType', pretty_print=pretty_print)
1837
+ showIndent(outfile, level, pretty_print)
1838
+ outfile.write('</%s%s>%s' % (namespaceprefix_, name_, eol_))
1839
+ else:
1840
+ outfile.write('/>%s' % (eol_, ))
1841
+ def _exportAttributes(self, outfile, level, already_processed, namespaceprefix_='', name_='productType'):
1842
+ pass
1843
+ def _exportChildren(self, outfile, level, namespaceprefix_='', namespacedef_='', name_='productType', fromsubclass_=False, pretty_print=True):
1844
+ if pretty_print:
1845
+ eol_ = '\n'
1846
+ else:
1847
+ eol_ = ''
1848
+ if self.lineOfBusiness is not None:
1849
+ namespaceprefix_ = self.lineOfBusiness_nsprefix_ + ':' if (UseCapturedNS_ and self.lineOfBusiness_nsprefix_) else ''
1850
+ showIndent(outfile, level, pretty_print)
1851
+ outfile.write('<%slineOfBusiness>%s</%slineOfBusiness>%s' % (namespaceprefix_ , self.gds_format_integer(self.lineOfBusiness, input_name='lineOfBusiness'), namespaceprefix_ , eol_))
1852
+ if self.groupId is not None:
1853
+ namespaceprefix_ = self.groupId_nsprefix_ + ':' if (UseCapturedNS_ and self.groupId_nsprefix_) else ''
1854
+ showIndent(outfile, level, pretty_print)
1855
+ outfile.write('<%sgroupId>%s</%sgroupId>%s' % (namespaceprefix_ , self.gds_format_integer(self.groupId, input_name='groupId'), namespaceprefix_ , eol_))
1856
+ if self.subGroupId is not None:
1857
+ namespaceprefix_ = self.subGroupId_nsprefix_ + ':' if (UseCapturedNS_ and self.subGroupId_nsprefix_) else ''
1858
+ showIndent(outfile, level, pretty_print)
1859
+ outfile.write('<%ssubGroupId>%s</%ssubGroupId>%s' % (namespaceprefix_ , self.gds_format_integer(self.subGroupId, input_name='subGroupId'), namespaceprefix_ , eol_))
1860
+ if self.id is not None:
1861
+ namespaceprefix_ = self.id_nsprefix_ + ':' if (UseCapturedNS_ and self.id_nsprefix_) else ''
1862
+ showIndent(outfile, level, pretty_print)
1863
+ outfile.write('<%sid>%s</%sid>%s' % (namespaceprefix_ , self.gds_encode(self.gds_format_string(quote_xml(self.id), input_name='id')), namespaceprefix_ , eol_))
1864
+ if self.type_ is not None:
1865
+ namespaceprefix_ = self.type__nsprefix_ + ':' if (UseCapturedNS_ and self.type__nsprefix_) else ''
1866
+ showIndent(outfile, level, pretty_print)
1867
+ outfile.write('<%stype>%s</%stype>%s' % (namespaceprefix_ , self.gds_encode(self.gds_format_string(quote_xml(self.type_), input_name='type')), namespaceprefix_ , eol_))
1868
+ for option_ in self.option:
1869
+ namespaceprefix_ = self.option_nsprefix_ + ':' if (UseCapturedNS_ and self.option_nsprefix_) else ''
1870
+ showIndent(outfile, level, pretty_print)
1871
+ outfile.write('<%soption>%s</%soption>%s' % (namespaceprefix_ , self.gds_encode(self.gds_format_string(quote_xml(option_), input_name='option')), namespaceprefix_ , eol_))
1872
+ def build(self, node, gds_collector_=None):
1873
+ self.gds_collector_ = gds_collector_
1874
+ if SaveElementTreeNode:
1875
+ self.gds_elementtree_node_ = node
1876
+ already_processed = set()
1877
+ self.ns_prefix_ = node.prefix
1878
+ self._buildAttributes(node, node.attrib, already_processed)
1879
+ for child in node:
1880
+ nodeName_ = Tag_pattern_.match(child.tag).groups()[-1]
1881
+ self._buildChildren(child, node, nodeName_, gds_collector_=gds_collector_)
1882
+ return self
1883
+ def _buildAttributes(self, node, attrs, already_processed):
1884
+ pass
1885
+ def _buildChildren(self, child_, node, nodeName_, fromsubclass_=False, gds_collector_=None):
1886
+ if nodeName_ == 'lineOfBusiness' and child_.text:
1887
+ sval_ = child_.text
1888
+ ival_ = self.gds_parse_integer(sval_, node, 'lineOfBusiness')
1889
+ ival_ = self.gds_validate_integer(ival_, node, 'lineOfBusiness')
1890
+ self.lineOfBusiness = ival_
1891
+ self.lineOfBusiness_nsprefix_ = child_.prefix
1892
+ # validate type integerMin0Max9
1893
+ self.validate_integerMin0Max9(self.lineOfBusiness)
1894
+ elif nodeName_ == 'groupId' and child_.text:
1895
+ sval_ = child_.text
1896
+ ival_ = self.gds_parse_integer(sval_, node, 'groupId')
1897
+ ival_ = self.gds_validate_integer(ival_, node, 'groupId')
1898
+ self.groupId = ival_
1899
+ self.groupId_nsprefix_ = child_.prefix
1900
+ # validate type integerMin0Max9
1901
+ self.validate_integerMin0Max9(self.groupId)
1902
+ elif nodeName_ == 'subGroupId' and child_.text:
1903
+ sval_ = child_.text
1904
+ ival_ = self.gds_parse_integer(sval_, node, 'subGroupId')
1905
+ ival_ = self.gds_validate_integer(ival_, node, 'subGroupId')
1906
+ self.subGroupId = ival_
1907
+ self.subGroupId_nsprefix_ = child_.prefix
1908
+ # validate type integerMin0Max9
1909
+ self.validate_integerMin0Max9(self.subGroupId)
1910
+ elif nodeName_ == 'id':
1911
+ value_ = child_.text
1912
+ value_ = self.gds_parse_string(value_, node, 'id')
1913
+ value_ = self.gds_validate_string(value_, node, 'id')
1914
+ self.id = value_
1915
+ self.id_nsprefix_ = child_.prefix
1916
+ # validate type stringMaxLength4
1917
+ self.validate_stringMaxLength4(self.id)
1918
+ elif nodeName_ == 'type':
1919
+ value_ = child_.text
1920
+ value_ = self.gds_parse_string(value_, node, 'type')
1921
+ value_ = self.gds_validate_string(value_, node, 'type')
1922
+ self.type_ = value_
1923
+ self.type_nsprefix_ = child_.prefix
1924
+ # validate type productTypeEnum
1925
+ self.validate_productTypeEnum(self.type_)
1926
+ elif nodeName_ == 'option':
1927
+ value_ = child_.text
1928
+ value_ = self.gds_parse_string(value_, node, 'option')
1929
+ value_ = self.gds_validate_string(value_, node, 'option')
1930
+ self.option.append(value_)
1931
+ self.option_nsprefix_ = child_.prefix
1932
+ # validate type stringMaxLength4
1933
+ self.validate_stringMaxLength4(self.option[-1])
1934
+ # end class productType
1935
+
1936
+
1937
+ class consignmentIdentityType(GeneratedsSuper):
1938
+ """consignmentIdentityType -- This element contains a consignment number and optional customer reference.
1939
+ These values are used to distinguish a consignment from any other consignment.
1940
+ This value appears on a routing label and is used as the key for a consignment.
1941
+ consignmentNumber -- The TNT consignment number in legacy (Global Link) format.
1942
+ customerReference -- Contains the optional customer reference for the consignment.
1943
+ A customer reference is a way for a customer to designate a name
1944
+ for the consignment.
1945
+ This value can be used to track the consignment at a later date.
1946
+
1947
+ """
1948
+ __hash__ = GeneratedsSuper.__hash__
1949
+ subclass = None
1950
+ superclass = None
1951
+ def __init__(self, consignmentNumber=None, customerReference=None, gds_collector_=None, **kwargs_):
1952
+ self.gds_collector_ = gds_collector_
1953
+ self.gds_elementtree_node_ = None
1954
+ self.original_tagname_ = None
1955
+ self.parent_object_ = kwargs_.get('parent_object_')
1956
+ self.ns_prefix_ = None
1957
+ self.consignmentNumber = consignmentNumber
1958
+ self.consignmentNumber_nsprefix_ = None
1959
+ self.customerReference = customerReference
1960
+ self.customerReference_nsprefix_ = None
1961
+ def factory(*args_, **kwargs_):
1962
+ if CurrentSubclassModule_ is not None:
1963
+ subclass = getSubclassFromModule_(
1964
+ CurrentSubclassModule_, consignmentIdentityType)
1965
+ if subclass is not None:
1966
+ return subclass(*args_, **kwargs_)
1967
+ if consignmentIdentityType.subclass:
1968
+ return consignmentIdentityType.subclass(*args_, **kwargs_)
1969
+ else:
1970
+ return consignmentIdentityType(*args_, **kwargs_)
1971
+ factory = staticmethod(factory)
1972
+ def get_ns_prefix_(self):
1973
+ return self.ns_prefix_
1974
+ def set_ns_prefix_(self, ns_prefix):
1975
+ self.ns_prefix_ = ns_prefix
1976
+ def get_consignmentNumber(self):
1977
+ return self.consignmentNumber
1978
+ def set_consignmentNumber(self, consignmentNumber):
1979
+ self.consignmentNumber = consignmentNumber
1980
+ def get_customerReference(self):
1981
+ return self.customerReference
1982
+ def set_customerReference(self, customerReference):
1983
+ self.customerReference = customerReference
1984
+ def has__content(self):
1985
+ if (
1986
+ self.consignmentNumber is not None or
1987
+ self.customerReference is not None
1988
+ ):
1989
+ return True
1990
+ else:
1991
+ return False
1992
+ def export(self, outfile, level, namespaceprefix_='', namespacedef_='', name_='consignmentIdentityType', pretty_print=True):
1993
+ imported_ns_def_ = GenerateDSNamespaceDefs_.get('consignmentIdentityType')
1994
+ if imported_ns_def_ is not None:
1995
+ namespacedef_ = imported_ns_def_
1996
+ if pretty_print:
1997
+ eol_ = '\n'
1998
+ else:
1999
+ eol_ = ''
2000
+ if self.original_tagname_ is not None and name_ == 'consignmentIdentityType':
2001
+ name_ = self.original_tagname_
2002
+ if UseCapturedNS_ and self.ns_prefix_:
2003
+ namespaceprefix_ = self.ns_prefix_ + ':'
2004
+ showIndent(outfile, level, pretty_print)
2005
+ outfile.write('<%s%s%s' % (namespaceprefix_, name_, namespacedef_ and ' ' + namespacedef_ or '', ))
2006
+ already_processed = set()
2007
+ self._exportAttributes(outfile, level, already_processed, namespaceprefix_, name_='consignmentIdentityType')
2008
+ if self.has__content():
2009
+ outfile.write('>%s' % (eol_, ))
2010
+ self._exportChildren(outfile, level + 1, namespaceprefix_, namespacedef_, name_='consignmentIdentityType', pretty_print=pretty_print)
2011
+ showIndent(outfile, level, pretty_print)
2012
+ outfile.write('</%s%s>%s' % (namespaceprefix_, name_, eol_))
2013
+ else:
2014
+ outfile.write('/>%s' % (eol_, ))
2015
+ def _exportAttributes(self, outfile, level, already_processed, namespaceprefix_='', name_='consignmentIdentityType'):
2016
+ pass
2017
+ def _exportChildren(self, outfile, level, namespaceprefix_='', namespacedef_='', name_='consignmentIdentityType', fromsubclass_=False, pretty_print=True):
2018
+ if pretty_print:
2019
+ eol_ = '\n'
2020
+ else:
2021
+ eol_ = ''
2022
+ if self.consignmentNumber is not None:
2023
+ namespaceprefix_ = self.consignmentNumber_nsprefix_ + ':' if (UseCapturedNS_ and self.consignmentNumber_nsprefix_) else ''
2024
+ showIndent(outfile, level, pretty_print)
2025
+ outfile.write('<%sconsignmentNumber>%s</%sconsignmentNumber>%s' % (namespaceprefix_ , self.gds_encode(self.gds_format_string(quote_xml(self.consignmentNumber), input_name='consignmentNumber')), namespaceprefix_ , eol_))
2026
+ if self.customerReference is not None:
2027
+ namespaceprefix_ = self.customerReference_nsprefix_ + ':' if (UseCapturedNS_ and self.customerReference_nsprefix_) else ''
2028
+ showIndent(outfile, level, pretty_print)
2029
+ outfile.write('<%scustomerReference>%s</%scustomerReference>%s' % (namespaceprefix_ , self.gds_encode(self.gds_format_string(quote_xml(self.customerReference), input_name='customerReference')), namespaceprefix_ , eol_))
2030
+ def build(self, node, gds_collector_=None):
2031
+ self.gds_collector_ = gds_collector_
2032
+ if SaveElementTreeNode:
2033
+ self.gds_elementtree_node_ = node
2034
+ already_processed = set()
2035
+ self.ns_prefix_ = node.prefix
2036
+ self._buildAttributes(node, node.attrib, already_processed)
2037
+ for child in node:
2038
+ nodeName_ = Tag_pattern_.match(child.tag).groups()[-1]
2039
+ self._buildChildren(child, node, nodeName_, gds_collector_=gds_collector_)
2040
+ return self
2041
+ def _buildAttributes(self, node, attrs, already_processed):
2042
+ pass
2043
+ def _buildChildren(self, child_, node, nodeName_, fromsubclass_=False, gds_collector_=None):
2044
+ if nodeName_ == 'consignmentNumber':
2045
+ value_ = child_.text
2046
+ value_ = self.gds_parse_string(value_, node, 'consignmentNumber')
2047
+ value_ = self.gds_validate_string(value_, node, 'consignmentNumber')
2048
+ self.consignmentNumber = value_
2049
+ self.consignmentNumber_nsprefix_ = child_.prefix
2050
+ elif nodeName_ == 'customerReference':
2051
+ value_ = child_.text
2052
+ value_ = self.gds_parse_string(value_, node, 'customerReference')
2053
+ value_ = self.gds_validate_string(value_, node, 'customerReference')
2054
+ self.customerReference = value_
2055
+ self.customerReference_nsprefix_ = child_.prefix
2056
+ # end class consignmentIdentityType
2057
+
2058
+
2059
+ class nameAndAddressRequestType(GeneratedsSuper):
2060
+ """nameAndAddressRequestType -- Information relating to name and address for a participant
2061
+ in the consignment.
2062
+ Examples of a participant are:
2063
+ The Sender - the company sending the consignment
2064
+ The Receiver - the company receiving the consignment
2065
+ The Collection Address - the address from which the consignment is picked up
2066
+ The Delivery Address - the address to which the consignment should be delivered
2067
+ name -- Either the name of the company as recognised by TNT, or the
2068
+ contact name at the address
2069
+ addressLine1 -- This address line is the most commonly used of the three
2070
+ address lines and is therefore mandatory.
2071
+ addressLine2 -- This address line may not be used by the supporting system
2072
+ and therefore should not contain information essential to the address.
2073
+ addressLine3 -- This address line may not be used by the supporting system
2074
+ and therefore should not contain information essential to the address.
2075
+ NOTE - this will not appear on any routingLabel produced.
2076
+ town -- The town name as recognised by TNT
2077
+ exactMatch -- Flag stating if an exact match on the town name should be used.
2078
+ If this flag is absent then the exact match value is 'Y'.
2079
+ province -- Optional field to contain the province, county, state, or area
2080
+ for the given address.
2081
+ postcode -- Postcode or zip code is considered a mandatory field where it is
2082
+ used in a given country. If the postcode is not provided, it may
2083
+ not be possible to deliver the consignment as indicated by your
2084
+ chosen service.
2085
+ country -- The ISO country code for the country of the given address.
2086
+
2087
+ """
2088
+ __hash__ = GeneratedsSuper.__hash__
2089
+ subclass = None
2090
+ superclass = None
2091
+ 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_):
2092
+ self.gds_collector_ = gds_collector_
2093
+ self.gds_elementtree_node_ = None
2094
+ self.original_tagname_ = None
2095
+ self.parent_object_ = kwargs_.get('parent_object_')
2096
+ self.ns_prefix_ = None
2097
+ self.name = name
2098
+ self.validate_stringMaxLength40(self.name)
2099
+ self.name_nsprefix_ = None
2100
+ self.addressLine1 = addressLine1
2101
+ self.validate_stringMaxLength30(self.addressLine1)
2102
+ self.addressLine1_nsprefix_ = None
2103
+ self.addressLine2 = addressLine2
2104
+ self.validate_stringMaxLength30(self.addressLine2)
2105
+ self.addressLine2_nsprefix_ = None
2106
+ self.addressLine3 = addressLine3
2107
+ self.validate_stringMaxLength30(self.addressLine3)
2108
+ self.addressLine3_nsprefix_ = None
2109
+ self.town = town
2110
+ self.validate_stringMaxLength40(self.town)
2111
+ self.town_nsprefix_ = None
2112
+ self.exactMatch = exactMatch
2113
+ self.validate_booleanEnum(self.exactMatch)
2114
+ self.exactMatch_nsprefix_ = None
2115
+ self.province = province
2116
+ self.validate_stringMaxLength30(self.province)
2117
+ self.province_nsprefix_ = None
2118
+ self.postcode = postcode
2119
+ self.validate_stringMaxLength9(self.postcode)
2120
+ self.postcode_nsprefix_ = None
2121
+ self.country = country
2122
+ self.validate_stringMinLength2MaxLength2(self.country)
2123
+ self.country_nsprefix_ = None
2124
+ def factory(*args_, **kwargs_):
2125
+ if CurrentSubclassModule_ is not None:
2126
+ subclass = getSubclassFromModule_(
2127
+ CurrentSubclassModule_, nameAndAddressRequestType)
2128
+ if subclass is not None:
2129
+ return subclass(*args_, **kwargs_)
2130
+ if nameAndAddressRequestType.subclass:
2131
+ return nameAndAddressRequestType.subclass(*args_, **kwargs_)
2132
+ else:
2133
+ return nameAndAddressRequestType(*args_, **kwargs_)
2134
+ factory = staticmethod(factory)
2135
+ def get_ns_prefix_(self):
2136
+ return self.ns_prefix_
2137
+ def set_ns_prefix_(self, ns_prefix):
2138
+ self.ns_prefix_ = ns_prefix
2139
+ def get_name(self):
2140
+ return self.name
2141
+ def set_name(self, name):
2142
+ self.name = name
2143
+ def get_addressLine1(self):
2144
+ return self.addressLine1
2145
+ def set_addressLine1(self, addressLine1):
2146
+ self.addressLine1 = addressLine1
2147
+ def get_addressLine2(self):
2148
+ return self.addressLine2
2149
+ def set_addressLine2(self, addressLine2):
2150
+ self.addressLine2 = addressLine2
2151
+ def get_addressLine3(self):
2152
+ return self.addressLine3
2153
+ def set_addressLine3(self, addressLine3):
2154
+ self.addressLine3 = addressLine3
2155
+ def get_town(self):
2156
+ return self.town
2157
+ def set_town(self, town):
2158
+ self.town = town
2159
+ def get_exactMatch(self):
2160
+ return self.exactMatch
2161
+ def set_exactMatch(self, exactMatch):
2162
+ self.exactMatch = exactMatch
2163
+ def get_province(self):
2164
+ return self.province
2165
+ def set_province(self, province):
2166
+ self.province = province
2167
+ def get_postcode(self):
2168
+ return self.postcode
2169
+ def set_postcode(self, postcode):
2170
+ self.postcode = postcode
2171
+ def get_country(self):
2172
+ return self.country
2173
+ def set_country(self, country):
2174
+ self.country = country
2175
+ def validate_stringMaxLength40(self, value):
2176
+ result = True
2177
+ # Validate type stringMaxLength40, a restriction on xsd:string.
2178
+ if value is not None and Validate_simpletypes_ and self.gds_collector_ is not None:
2179
+ if not isinstance(value, str):
2180
+ lineno = self.gds_get_node_lineno_()
2181
+ self.gds_collector_.add_message('Value "%(value)s"%(lineno)s is not of the correct base simple type (str)' % {"value": value, "lineno": lineno, })
2182
+ return False
2183
+ if len(value) > 40:
2184
+ lineno = self.gds_get_node_lineno_()
2185
+ 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} )
2186
+ result = False
2187
+ return result
2188
+ def validate_stringMaxLength30(self, value):
2189
+ result = True
2190
+ # Validate type stringMaxLength30, a restriction on xsd:string.
2191
+ if value is not None and Validate_simpletypes_ and self.gds_collector_ is not None:
2192
+ if not isinstance(value, str):
2193
+ lineno = self.gds_get_node_lineno_()
2194
+ self.gds_collector_.add_message('Value "%(value)s"%(lineno)s is not of the correct base simple type (str)' % {"value": value, "lineno": lineno, })
2195
+ return False
2196
+ if len(value) > 30:
2197
+ lineno = self.gds_get_node_lineno_()
2198
+ 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} )
2199
+ result = False
2200
+ return result
2201
+ def validate_booleanEnum(self, value):
2202
+ result = True
2203
+ # Validate type booleanEnum, a restriction on xsd:string.
2204
+ if value is not None and Validate_simpletypes_ and self.gds_collector_ is not None:
2205
+ if not isinstance(value, str):
2206
+ lineno = self.gds_get_node_lineno_()
2207
+ self.gds_collector_.add_message('Value "%(value)s"%(lineno)s is not of the correct base simple type (str)' % {"value": value, "lineno": lineno, })
2208
+ return False
2209
+ value = value
2210
+ enumerations = ['N', 'Y']
2211
+ if value not in enumerations:
2212
+ lineno = self.gds_get_node_lineno_()
2213
+ 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} )
2214
+ result = False
2215
+ return result
2216
+ def validate_stringMaxLength9(self, value):
2217
+ result = True
2218
+ # Validate type stringMaxLength9, a restriction on xsd:string.
2219
+ if value is not None and Validate_simpletypes_ and self.gds_collector_ is not None:
2220
+ if not isinstance(value, str):
2221
+ lineno = self.gds_get_node_lineno_()
2222
+ self.gds_collector_.add_message('Value "%(value)s"%(lineno)s is not of the correct base simple type (str)' % {"value": value, "lineno": lineno, })
2223
+ return False
2224
+ if len(value) > 9:
2225
+ lineno = self.gds_get_node_lineno_()
2226
+ 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} )
2227
+ result = False
2228
+ return result
2229
+ def validate_stringMinLength2MaxLength2(self, value):
2230
+ result = True
2231
+ # Validate type stringMinLength2MaxLength2, a restriction on xsd:string.
2232
+ if value is not None and Validate_simpletypes_ and self.gds_collector_ is not None:
2233
+ if not isinstance(value, str):
2234
+ lineno = self.gds_get_node_lineno_()
2235
+ self.gds_collector_.add_message('Value "%(value)s"%(lineno)s is not of the correct base simple type (str)' % {"value": value, "lineno": lineno, })
2236
+ return False
2237
+ if len(value) > 2:
2238
+ lineno = self.gds_get_node_lineno_()
2239
+ 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} )
2240
+ result = False
2241
+ if len(value) < 2:
2242
+ lineno = self.gds_get_node_lineno_()
2243
+ 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} )
2244
+ result = False
2245
+ return result
2246
+ def has__content(self):
2247
+ if (
2248
+ self.name is not None or
2249
+ self.addressLine1 is not None or
2250
+ self.addressLine2 is not None or
2251
+ self.addressLine3 is not None or
2252
+ self.town is not None or
2253
+ self.exactMatch != "Y" or
2254
+ self.province is not None or
2255
+ self.postcode is not None or
2256
+ self.country is not None
2257
+ ):
2258
+ return True
2259
+ else:
2260
+ return False
2261
+ def export(self, outfile, level, namespaceprefix_='', namespacedef_='', name_='nameAndAddressRequestType', pretty_print=True):
2262
+ imported_ns_def_ = GenerateDSNamespaceDefs_.get('nameAndAddressRequestType')
2263
+ if imported_ns_def_ is not None:
2264
+ namespacedef_ = imported_ns_def_
2265
+ if pretty_print:
2266
+ eol_ = '\n'
2267
+ else:
2268
+ eol_ = ''
2269
+ if self.original_tagname_ is not None and name_ == 'nameAndAddressRequestType':
2270
+ name_ = self.original_tagname_
2271
+ if UseCapturedNS_ and self.ns_prefix_:
2272
+ namespaceprefix_ = self.ns_prefix_ + ':'
2273
+ showIndent(outfile, level, pretty_print)
2274
+ outfile.write('<%s%s%s' % (namespaceprefix_, name_, namespacedef_ and ' ' + namespacedef_ or '', ))
2275
+ already_processed = set()
2276
+ self._exportAttributes(outfile, level, already_processed, namespaceprefix_, name_='nameAndAddressRequestType')
2277
+ if self.has__content():
2278
+ outfile.write('>%s' % (eol_, ))
2279
+ self._exportChildren(outfile, level + 1, namespaceprefix_, namespacedef_, name_='nameAndAddressRequestType', pretty_print=pretty_print)
2280
+ showIndent(outfile, level, pretty_print)
2281
+ outfile.write('</%s%s>%s' % (namespaceprefix_, name_, eol_))
2282
+ else:
2283
+ outfile.write('/>%s' % (eol_, ))
2284
+ def _exportAttributes(self, outfile, level, already_processed, namespaceprefix_='', name_='nameAndAddressRequestType'):
2285
+ pass
2286
+ def _exportChildren(self, outfile, level, namespaceprefix_='', namespacedef_='', name_='nameAndAddressRequestType', fromsubclass_=False, pretty_print=True):
2287
+ if pretty_print:
2288
+ eol_ = '\n'
2289
+ else:
2290
+ eol_ = ''
2291
+ if self.name is not None:
2292
+ namespaceprefix_ = self.name_nsprefix_ + ':' if (UseCapturedNS_ and self.name_nsprefix_) else ''
2293
+ showIndent(outfile, level, pretty_print)
2294
+ outfile.write('<%sname>%s</%sname>%s' % (namespaceprefix_ , self.gds_encode(self.gds_format_string(quote_xml(self.name), input_name='name')), namespaceprefix_ , eol_))
2295
+ if self.addressLine1 is not None:
2296
+ namespaceprefix_ = self.addressLine1_nsprefix_ + ':' if (UseCapturedNS_ and self.addressLine1_nsprefix_) else ''
2297
+ showIndent(outfile, level, pretty_print)
2298
+ outfile.write('<%saddressLine1>%s</%saddressLine1>%s' % (namespaceprefix_ , self.gds_encode(self.gds_format_string(quote_xml(self.addressLine1), input_name='addressLine1')), namespaceprefix_ , eol_))
2299
+ if self.addressLine2 is not None:
2300
+ namespaceprefix_ = self.addressLine2_nsprefix_ + ':' if (UseCapturedNS_ and self.addressLine2_nsprefix_) else ''
2301
+ showIndent(outfile, level, pretty_print)
2302
+ outfile.write('<%saddressLine2>%s</%saddressLine2>%s' % (namespaceprefix_ , self.gds_encode(self.gds_format_string(quote_xml(self.addressLine2), input_name='addressLine2')), namespaceprefix_ , eol_))
2303
+ if self.addressLine3 is not None:
2304
+ namespaceprefix_ = self.addressLine3_nsprefix_ + ':' if (UseCapturedNS_ and self.addressLine3_nsprefix_) else ''
2305
+ showIndent(outfile, level, pretty_print)
2306
+ outfile.write('<%saddressLine3>%s</%saddressLine3>%s' % (namespaceprefix_ , self.gds_encode(self.gds_format_string(quote_xml(self.addressLine3), input_name='addressLine3')), namespaceprefix_ , eol_))
2307
+ if self.town is not None:
2308
+ namespaceprefix_ = self.town_nsprefix_ + ':' if (UseCapturedNS_ and self.town_nsprefix_) else ''
2309
+ showIndent(outfile, level, pretty_print)
2310
+ outfile.write('<%stown>%s</%stown>%s' % (namespaceprefix_ , self.gds_encode(self.gds_format_string(quote_xml(self.town), input_name='town')), namespaceprefix_ , eol_))
2311
+ if self.exactMatch != "Y":
2312
+ namespaceprefix_ = self.exactMatch_nsprefix_ + ':' if (UseCapturedNS_ and self.exactMatch_nsprefix_) else ''
2313
+ showIndent(outfile, level, pretty_print)
2314
+ outfile.write('<%sexactMatch>%s</%sexactMatch>%s' % (namespaceprefix_ , self.gds_encode(self.gds_format_string(quote_xml(self.exactMatch), input_name='exactMatch')), namespaceprefix_ , eol_))
2315
+ if self.province is not None:
2316
+ namespaceprefix_ = self.province_nsprefix_ + ':' if (UseCapturedNS_ and self.province_nsprefix_) else ''
2317
+ showIndent(outfile, level, pretty_print)
2318
+ outfile.write('<%sprovince>%s</%sprovince>%s' % (namespaceprefix_ , self.gds_encode(self.gds_format_string(quote_xml(self.province), input_name='province')), namespaceprefix_ , eol_))
2319
+ if self.postcode is not None:
2320
+ namespaceprefix_ = self.postcode_nsprefix_ + ':' if (UseCapturedNS_ and self.postcode_nsprefix_) else ''
2321
+ showIndent(outfile, level, pretty_print)
2322
+ outfile.write('<%spostcode>%s</%spostcode>%s' % (namespaceprefix_ , self.gds_encode(self.gds_format_string(quote_xml(self.postcode), input_name='postcode')), namespaceprefix_ , eol_))
2323
+ if self.country is not None:
2324
+ namespaceprefix_ = self.country_nsprefix_ + ':' if (UseCapturedNS_ and self.country_nsprefix_) else ''
2325
+ showIndent(outfile, level, pretty_print)
2326
+ outfile.write('<%scountry>%s</%scountry>%s' % (namespaceprefix_ , self.gds_encode(self.gds_format_string(quote_xml(self.country), input_name='country')), namespaceprefix_ , eol_))
2327
+ def build(self, node, gds_collector_=None):
2328
+ self.gds_collector_ = gds_collector_
2329
+ if SaveElementTreeNode:
2330
+ self.gds_elementtree_node_ = node
2331
+ already_processed = set()
2332
+ self.ns_prefix_ = node.prefix
2333
+ self._buildAttributes(node, node.attrib, already_processed)
2334
+ for child in node:
2335
+ nodeName_ = Tag_pattern_.match(child.tag).groups()[-1]
2336
+ self._buildChildren(child, node, nodeName_, gds_collector_=gds_collector_)
2337
+ return self
2338
+ def _buildAttributes(self, node, attrs, already_processed):
2339
+ pass
2340
+ def _buildChildren(self, child_, node, nodeName_, fromsubclass_=False, gds_collector_=None):
2341
+ if nodeName_ == 'name':
2342
+ value_ = child_.text
2343
+ value_ = self.gds_parse_string(value_, node, 'name')
2344
+ value_ = self.gds_validate_string(value_, node, 'name')
2345
+ self.name = value_
2346
+ self.name_nsprefix_ = child_.prefix
2347
+ # validate type stringMaxLength40
2348
+ self.validate_stringMaxLength40(self.name)
2349
+ elif nodeName_ == 'addressLine1':
2350
+ value_ = child_.text
2351
+ value_ = self.gds_parse_string(value_, node, 'addressLine1')
2352
+ value_ = self.gds_validate_string(value_, node, 'addressLine1')
2353
+ self.addressLine1 = value_
2354
+ self.addressLine1_nsprefix_ = child_.prefix
2355
+ # validate type stringMaxLength30
2356
+ self.validate_stringMaxLength30(self.addressLine1)
2357
+ elif nodeName_ == 'addressLine2':
2358
+ value_ = child_.text
2359
+ value_ = self.gds_parse_string(value_, node, 'addressLine2')
2360
+ value_ = self.gds_validate_string(value_, node, 'addressLine2')
2361
+ self.addressLine2 = value_
2362
+ self.addressLine2_nsprefix_ = child_.prefix
2363
+ # validate type stringMaxLength30
2364
+ self.validate_stringMaxLength30(self.addressLine2)
2365
+ elif nodeName_ == 'addressLine3':
2366
+ value_ = child_.text
2367
+ value_ = self.gds_parse_string(value_, node, 'addressLine3')
2368
+ value_ = self.gds_validate_string(value_, node, 'addressLine3')
2369
+ self.addressLine3 = value_
2370
+ self.addressLine3_nsprefix_ = child_.prefix
2371
+ # validate type stringMaxLength30
2372
+ self.validate_stringMaxLength30(self.addressLine3)
2373
+ elif nodeName_ == 'town':
2374
+ value_ = child_.text
2375
+ value_ = self.gds_parse_string(value_, node, 'town')
2376
+ value_ = self.gds_validate_string(value_, node, 'town')
2377
+ self.town = value_
2378
+ self.town_nsprefix_ = child_.prefix
2379
+ # validate type stringMaxLength40
2380
+ self.validate_stringMaxLength40(self.town)
2381
+ elif nodeName_ == 'exactMatch':
2382
+ value_ = child_.text
2383
+ value_ = self.gds_parse_string(value_, node, 'exactMatch')
2384
+ value_ = self.gds_validate_string(value_, node, 'exactMatch')
2385
+ self.exactMatch = value_
2386
+ self.exactMatch_nsprefix_ = child_.prefix
2387
+ # validate type booleanEnum
2388
+ self.validate_booleanEnum(self.exactMatch)
2389
+ elif nodeName_ == 'province':
2390
+ value_ = child_.text
2391
+ value_ = self.gds_parse_string(value_, node, 'province')
2392
+ value_ = self.gds_validate_string(value_, node, 'province')
2393
+ self.province = value_
2394
+ self.province_nsprefix_ = child_.prefix
2395
+ # validate type stringMaxLength30
2396
+ self.validate_stringMaxLength30(self.province)
2397
+ elif nodeName_ == 'postcode':
2398
+ value_ = child_.text
2399
+ value_ = self.gds_parse_string(value_, node, 'postcode')
2400
+ value_ = self.gds_validate_string(value_, node, 'postcode')
2401
+ self.postcode = value_
2402
+ self.postcode_nsprefix_ = child_.prefix
2403
+ # validate type stringMaxLength9
2404
+ self.validate_stringMaxLength9(self.postcode)
2405
+ elif nodeName_ == 'country':
2406
+ value_ = child_.text
2407
+ value_ = self.gds_parse_string(value_, node, 'country')
2408
+ value_ = self.gds_validate_string(value_, node, 'country')
2409
+ self.country = value_
2410
+ self.country_nsprefix_ = child_.prefix
2411
+ # validate type stringMinLength2MaxLength2
2412
+ self.validate_stringMinLength2MaxLength2(self.country)
2413
+ # end class nameAndAddressRequestType
2414
+
2415
+
2416
+ class nameAndAddressResponseType(GeneratedsSuper):
2417
+ """nameAndAddressResponseType -- Information relating to name and address for a participant
2418
+ in the consignment.
2419
+ Examples of a participant are:
2420
+ The Sender - the company sending the consignment
2421
+ The Receiver - the company receiving the consignment
2422
+ The Collection Address - the address from which the consignment is picked up
2423
+ The Delivery Address - the address to which the consignment should be delivered
2424
+ name -- Either the name of the company as recognised by TNT, or the
2425
+ contact name at the address
2426
+ addressLine1 -- This address line is the most commonly used of the three
2427
+ address lines and is therefore mandatory.
2428
+ addressLine2 -- This address line may not be used by the supporting system
2429
+ and therefore should not contain information essential to the address.
2430
+ addressLine3 -- This address line may not be used by the supporting system
2431
+ and therefore should not contain information essential to the address.
2432
+ NOTE - this will not appear on any routingLabel produced.
2433
+ town -- The town name as recognised by TNT
2434
+ province -- Optional field to contain the province, county, state, or area
2435
+ for the given address.
2436
+ postcode -- Postcode or zip code is considered a mandatory field where it is
2437
+ used in a given country. If the postcode is not provided, it may
2438
+ not be possible to deliver the consignment as indicated by your
2439
+ chosen service.
2440
+ country -- The ISO country code for the country of the given address.
2441
+
2442
+ """
2443
+ __hash__ = GeneratedsSuper.__hash__
2444
+ subclass = None
2445
+ superclass = None
2446
+ def __init__(self, name=None, addressLine1=None, addressLine2=None, addressLine3=None, town=None, province=None, postcode=None, country=None, gds_collector_=None, **kwargs_):
2447
+ self.gds_collector_ = gds_collector_
2448
+ self.gds_elementtree_node_ = None
2449
+ self.original_tagname_ = None
2450
+ self.parent_object_ = kwargs_.get('parent_object_')
2451
+ self.ns_prefix_ = None
2452
+ self.name = name
2453
+ self.validate_stringMaxLength40(self.name)
2454
+ self.name_nsprefix_ = None
2455
+ self.addressLine1 = addressLine1
2456
+ self.validate_stringMaxLength30(self.addressLine1)
2457
+ self.addressLine1_nsprefix_ = None
2458
+ self.addressLine2 = addressLine2
2459
+ self.validate_stringMaxLength30(self.addressLine2)
2460
+ self.addressLine2_nsprefix_ = None
2461
+ self.addressLine3 = addressLine3
2462
+ self.validate_stringMaxLength30(self.addressLine3)
2463
+ self.addressLine3_nsprefix_ = None
2464
+ self.town = town
2465
+ self.validate_stringMaxLength40(self.town)
2466
+ self.town_nsprefix_ = None
2467
+ self.province = province
2468
+ self.validate_stringMaxLength30(self.province)
2469
+ self.province_nsprefix_ = None
2470
+ self.postcode = postcode
2471
+ self.validate_stringMaxLength9(self.postcode)
2472
+ self.postcode_nsprefix_ = None
2473
+ self.country = country
2474
+ self.validate_stringMinLength2MaxLength2(self.country)
2475
+ self.country_nsprefix_ = None
2476
+ def factory(*args_, **kwargs_):
2477
+ if CurrentSubclassModule_ is not None:
2478
+ subclass = getSubclassFromModule_(
2479
+ CurrentSubclassModule_, nameAndAddressResponseType)
2480
+ if subclass is not None:
2481
+ return subclass(*args_, **kwargs_)
2482
+ if nameAndAddressResponseType.subclass:
2483
+ return nameAndAddressResponseType.subclass(*args_, **kwargs_)
2484
+ else:
2485
+ return nameAndAddressResponseType(*args_, **kwargs_)
2486
+ factory = staticmethod(factory)
2487
+ def get_ns_prefix_(self):
2488
+ return self.ns_prefix_
2489
+ def set_ns_prefix_(self, ns_prefix):
2490
+ self.ns_prefix_ = ns_prefix
2491
+ def get_name(self):
2492
+ return self.name
2493
+ def set_name(self, name):
2494
+ self.name = name
2495
+ def get_addressLine1(self):
2496
+ return self.addressLine1
2497
+ def set_addressLine1(self, addressLine1):
2498
+ self.addressLine1 = addressLine1
2499
+ def get_addressLine2(self):
2500
+ return self.addressLine2
2501
+ def set_addressLine2(self, addressLine2):
2502
+ self.addressLine2 = addressLine2
2503
+ def get_addressLine3(self):
2504
+ return self.addressLine3
2505
+ def set_addressLine3(self, addressLine3):
2506
+ self.addressLine3 = addressLine3
2507
+ def get_town(self):
2508
+ return self.town
2509
+ def set_town(self, town):
2510
+ self.town = town
2511
+ def get_province(self):
2512
+ return self.province
2513
+ def set_province(self, province):
2514
+ self.province = province
2515
+ def get_postcode(self):
2516
+ return self.postcode
2517
+ def set_postcode(self, postcode):
2518
+ self.postcode = postcode
2519
+ def get_country(self):
2520
+ return self.country
2521
+ def set_country(self, country):
2522
+ self.country = country
2523
+ def validate_stringMaxLength40(self, value):
2524
+ result = True
2525
+ # Validate type stringMaxLength40, a restriction on xsd:string.
2526
+ if value is not None and Validate_simpletypes_ and self.gds_collector_ is not None:
2527
+ if not isinstance(value, str):
2528
+ lineno = self.gds_get_node_lineno_()
2529
+ self.gds_collector_.add_message('Value "%(value)s"%(lineno)s is not of the correct base simple type (str)' % {"value": value, "lineno": lineno, })
2530
+ return False
2531
+ if len(value) > 40:
2532
+ lineno = self.gds_get_node_lineno_()
2533
+ 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} )
2534
+ result = False
2535
+ return result
2536
+ def validate_stringMaxLength30(self, value):
2537
+ result = True
2538
+ # Validate type stringMaxLength30, a restriction on xsd:string.
2539
+ if value is not None and Validate_simpletypes_ and self.gds_collector_ is not None:
2540
+ if not isinstance(value, str):
2541
+ lineno = self.gds_get_node_lineno_()
2542
+ self.gds_collector_.add_message('Value "%(value)s"%(lineno)s is not of the correct base simple type (str)' % {"value": value, "lineno": lineno, })
2543
+ return False
2544
+ if len(value) > 30:
2545
+ lineno = self.gds_get_node_lineno_()
2546
+ 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} )
2547
+ result = False
2548
+ return result
2549
+ def validate_stringMaxLength9(self, value):
2550
+ result = True
2551
+ # Validate type stringMaxLength9, a restriction on xsd:string.
2552
+ if value is not None and Validate_simpletypes_ and self.gds_collector_ is not None:
2553
+ if not isinstance(value, str):
2554
+ lineno = self.gds_get_node_lineno_()
2555
+ self.gds_collector_.add_message('Value "%(value)s"%(lineno)s is not of the correct base simple type (str)' % {"value": value, "lineno": lineno, })
2556
+ return False
2557
+ if len(value) > 9:
2558
+ lineno = self.gds_get_node_lineno_()
2559
+ 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} )
2560
+ result = False
2561
+ return result
2562
+ def validate_stringMinLength2MaxLength2(self, value):
2563
+ result = True
2564
+ # Validate type stringMinLength2MaxLength2, a restriction on xsd:string.
2565
+ if value is not None and Validate_simpletypes_ and self.gds_collector_ is not None:
2566
+ if not isinstance(value, str):
2567
+ lineno = self.gds_get_node_lineno_()
2568
+ self.gds_collector_.add_message('Value "%(value)s"%(lineno)s is not of the correct base simple type (str)' % {"value": value, "lineno": lineno, })
2569
+ return False
2570
+ if len(value) > 2:
2571
+ lineno = self.gds_get_node_lineno_()
2572
+ 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} )
2573
+ result = False
2574
+ if len(value) < 2:
2575
+ lineno = self.gds_get_node_lineno_()
2576
+ 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} )
2577
+ result = False
2578
+ return result
2579
+ def has__content(self):
2580
+ if (
2581
+ self.name is not None or
2582
+ self.addressLine1 is not None or
2583
+ self.addressLine2 is not None or
2584
+ self.addressLine3 is not None or
2585
+ self.town is not None or
2586
+ self.province is not None or
2587
+ self.postcode is not None or
2588
+ self.country is not None
2589
+ ):
2590
+ return True
2591
+ else:
2592
+ return False
2593
+ def export(self, outfile, level, namespaceprefix_='', namespacedef_='', name_='nameAndAddressResponseType', pretty_print=True):
2594
+ imported_ns_def_ = GenerateDSNamespaceDefs_.get('nameAndAddressResponseType')
2595
+ if imported_ns_def_ is not None:
2596
+ namespacedef_ = imported_ns_def_
2597
+ if pretty_print:
2598
+ eol_ = '\n'
2599
+ else:
2600
+ eol_ = ''
2601
+ if self.original_tagname_ is not None and name_ == 'nameAndAddressResponseType':
2602
+ name_ = self.original_tagname_
2603
+ if UseCapturedNS_ and self.ns_prefix_:
2604
+ namespaceprefix_ = self.ns_prefix_ + ':'
2605
+ showIndent(outfile, level, pretty_print)
2606
+ outfile.write('<%s%s%s' % (namespaceprefix_, name_, namespacedef_ and ' ' + namespacedef_ or '', ))
2607
+ already_processed = set()
2608
+ self._exportAttributes(outfile, level, already_processed, namespaceprefix_, name_='nameAndAddressResponseType')
2609
+ if self.has__content():
2610
+ outfile.write('>%s' % (eol_, ))
2611
+ self._exportChildren(outfile, level + 1, namespaceprefix_, namespacedef_, name_='nameAndAddressResponseType', pretty_print=pretty_print)
2612
+ showIndent(outfile, level, pretty_print)
2613
+ outfile.write('</%s%s>%s' % (namespaceprefix_, name_, eol_))
2614
+ else:
2615
+ outfile.write('/>%s' % (eol_, ))
2616
+ def _exportAttributes(self, outfile, level, already_processed, namespaceprefix_='', name_='nameAndAddressResponseType'):
2617
+ pass
2618
+ def _exportChildren(self, outfile, level, namespaceprefix_='', namespacedef_='', name_='nameAndAddressResponseType', fromsubclass_=False, pretty_print=True):
2619
+ if pretty_print:
2620
+ eol_ = '\n'
2621
+ else:
2622
+ eol_ = ''
2623
+ if self.name is not None:
2624
+ namespaceprefix_ = self.name_nsprefix_ + ':' if (UseCapturedNS_ and self.name_nsprefix_) else ''
2625
+ showIndent(outfile, level, pretty_print)
2626
+ outfile.write('<%sname>%s</%sname>%s' % (namespaceprefix_ , self.gds_encode(self.gds_format_string(quote_xml(self.name), input_name='name')), namespaceprefix_ , eol_))
2627
+ if self.addressLine1 is not None:
2628
+ namespaceprefix_ = self.addressLine1_nsprefix_ + ':' if (UseCapturedNS_ and self.addressLine1_nsprefix_) else ''
2629
+ showIndent(outfile, level, pretty_print)
2630
+ outfile.write('<%saddressLine1>%s</%saddressLine1>%s' % (namespaceprefix_ , self.gds_encode(self.gds_format_string(quote_xml(self.addressLine1), input_name='addressLine1')), namespaceprefix_ , eol_))
2631
+ if self.addressLine2 is not None:
2632
+ namespaceprefix_ = self.addressLine2_nsprefix_ + ':' if (UseCapturedNS_ and self.addressLine2_nsprefix_) else ''
2633
+ showIndent(outfile, level, pretty_print)
2634
+ outfile.write('<%saddressLine2>%s</%saddressLine2>%s' % (namespaceprefix_ , self.gds_encode(self.gds_format_string(quote_xml(self.addressLine2), input_name='addressLine2')), namespaceprefix_ , eol_))
2635
+ if self.addressLine3 is not None:
2636
+ namespaceprefix_ = self.addressLine3_nsprefix_ + ':' if (UseCapturedNS_ and self.addressLine3_nsprefix_) else ''
2637
+ showIndent(outfile, level, pretty_print)
2638
+ outfile.write('<%saddressLine3>%s</%saddressLine3>%s' % (namespaceprefix_ , self.gds_encode(self.gds_format_string(quote_xml(self.addressLine3), input_name='addressLine3')), namespaceprefix_ , eol_))
2639
+ if self.town is not None:
2640
+ namespaceprefix_ = self.town_nsprefix_ + ':' if (UseCapturedNS_ and self.town_nsprefix_) else ''
2641
+ showIndent(outfile, level, pretty_print)
2642
+ outfile.write('<%stown>%s</%stown>%s' % (namespaceprefix_ , self.gds_encode(self.gds_format_string(quote_xml(self.town), input_name='town')), namespaceprefix_ , eol_))
2643
+ if self.province is not None:
2644
+ namespaceprefix_ = self.province_nsprefix_ + ':' if (UseCapturedNS_ and self.province_nsprefix_) else ''
2645
+ showIndent(outfile, level, pretty_print)
2646
+ outfile.write('<%sprovince>%s</%sprovince>%s' % (namespaceprefix_ , self.gds_encode(self.gds_format_string(quote_xml(self.province), input_name='province')), namespaceprefix_ , eol_))
2647
+ if self.postcode is not None:
2648
+ namespaceprefix_ = self.postcode_nsprefix_ + ':' if (UseCapturedNS_ and self.postcode_nsprefix_) else ''
2649
+ showIndent(outfile, level, pretty_print)
2650
+ outfile.write('<%spostcode>%s</%spostcode>%s' % (namespaceprefix_ , self.gds_encode(self.gds_format_string(quote_xml(self.postcode), input_name='postcode')), namespaceprefix_ , eol_))
2651
+ if self.country is not None:
2652
+ namespaceprefix_ = self.country_nsprefix_ + ':' if (UseCapturedNS_ and self.country_nsprefix_) else ''
2653
+ showIndent(outfile, level, pretty_print)
2654
+ outfile.write('<%scountry>%s</%scountry>%s' % (namespaceprefix_ , self.gds_encode(self.gds_format_string(quote_xml(self.country), input_name='country')), namespaceprefix_ , eol_))
2655
+ def build(self, node, gds_collector_=None):
2656
+ self.gds_collector_ = gds_collector_
2657
+ if SaveElementTreeNode:
2658
+ self.gds_elementtree_node_ = node
2659
+ already_processed = set()
2660
+ self.ns_prefix_ = node.prefix
2661
+ self._buildAttributes(node, node.attrib, already_processed)
2662
+ for child in node:
2663
+ nodeName_ = Tag_pattern_.match(child.tag).groups()[-1]
2664
+ self._buildChildren(child, node, nodeName_, gds_collector_=gds_collector_)
2665
+ return self
2666
+ def _buildAttributes(self, node, attrs, already_processed):
2667
+ pass
2668
+ def _buildChildren(self, child_, node, nodeName_, fromsubclass_=False, gds_collector_=None):
2669
+ if nodeName_ == 'name':
2670
+ value_ = child_.text
2671
+ value_ = self.gds_parse_string(value_, node, 'name')
2672
+ value_ = self.gds_validate_string(value_, node, 'name')
2673
+ self.name = value_
2674
+ self.name_nsprefix_ = child_.prefix
2675
+ # validate type stringMaxLength40
2676
+ self.validate_stringMaxLength40(self.name)
2677
+ elif nodeName_ == 'addressLine1':
2678
+ value_ = child_.text
2679
+ value_ = self.gds_parse_string(value_, node, 'addressLine1')
2680
+ value_ = self.gds_validate_string(value_, node, 'addressLine1')
2681
+ self.addressLine1 = value_
2682
+ self.addressLine1_nsprefix_ = child_.prefix
2683
+ # validate type stringMaxLength30
2684
+ self.validate_stringMaxLength30(self.addressLine1)
2685
+ elif nodeName_ == 'addressLine2':
2686
+ value_ = child_.text
2687
+ value_ = self.gds_parse_string(value_, node, 'addressLine2')
2688
+ value_ = self.gds_validate_string(value_, node, 'addressLine2')
2689
+ self.addressLine2 = value_
2690
+ self.addressLine2_nsprefix_ = child_.prefix
2691
+ # validate type stringMaxLength30
2692
+ self.validate_stringMaxLength30(self.addressLine2)
2693
+ elif nodeName_ == 'addressLine3':
2694
+ value_ = child_.text
2695
+ value_ = self.gds_parse_string(value_, node, 'addressLine3')
2696
+ value_ = self.gds_validate_string(value_, node, 'addressLine3')
2697
+ self.addressLine3 = value_
2698
+ self.addressLine3_nsprefix_ = child_.prefix
2699
+ # validate type stringMaxLength30
2700
+ self.validate_stringMaxLength30(self.addressLine3)
2701
+ elif nodeName_ == 'town':
2702
+ value_ = child_.text
2703
+ value_ = self.gds_parse_string(value_, node, 'town')
2704
+ value_ = self.gds_validate_string(value_, node, 'town')
2705
+ self.town = value_
2706
+ self.town_nsprefix_ = child_.prefix
2707
+ # validate type stringMaxLength40
2708
+ self.validate_stringMaxLength40(self.town)
2709
+ elif nodeName_ == 'province':
2710
+ value_ = child_.text
2711
+ value_ = self.gds_parse_string(value_, node, 'province')
2712
+ value_ = self.gds_validate_string(value_, node, 'province')
2713
+ self.province = value_
2714
+ self.province_nsprefix_ = child_.prefix
2715
+ # validate type stringMaxLength30
2716
+ self.validate_stringMaxLength30(self.province)
2717
+ elif nodeName_ == 'postcode':
2718
+ value_ = child_.text
2719
+ value_ = self.gds_parse_string(value_, node, 'postcode')
2720
+ value_ = self.gds_validate_string(value_, node, 'postcode')
2721
+ self.postcode = value_
2722
+ self.postcode_nsprefix_ = child_.prefix
2723
+ # validate type stringMaxLength9
2724
+ self.validate_stringMaxLength9(self.postcode)
2725
+ elif nodeName_ == 'country':
2726
+ value_ = child_.text
2727
+ value_ = self.gds_parse_string(value_, node, 'country')
2728
+ value_ = self.gds_validate_string(value_, node, 'country')
2729
+ self.country = value_
2730
+ self.country_nsprefix_ = child_.prefix
2731
+ # validate type stringMinLength2MaxLength2
2732
+ self.validate_stringMinLength2MaxLength2(self.country)
2733
+ # end class nameAndAddressResponseType
2734
+
2735
+
2736
+ class optionType(GeneratedsSuper):
2737
+ """optionType -- The type of option chosen for this consignment.
2738
+ Examples include insurance, priority.
2739
+ optionId -- Code that defines options for the consignment e.g. insurance,
2740
+ priority.
2741
+
2742
+ """
2743
+ __hash__ = GeneratedsSuper.__hash__
2744
+ subclass = None
2745
+ superclass = None
2746
+ def __init__(self, optionId=None, gds_collector_=None, **kwargs_):
2747
+ self.gds_collector_ = gds_collector_
2748
+ self.gds_elementtree_node_ = None
2749
+ self.original_tagname_ = None
2750
+ self.parent_object_ = kwargs_.get('parent_object_')
2751
+ self.ns_prefix_ = None
2752
+ if optionId is None:
2753
+ self.optionId = []
2754
+ else:
2755
+ self.optionId = optionId
2756
+ self.optionId_nsprefix_ = None
2757
+ def factory(*args_, **kwargs_):
2758
+ if CurrentSubclassModule_ is not None:
2759
+ subclass = getSubclassFromModule_(
2760
+ CurrentSubclassModule_, optionType)
2761
+ if subclass is not None:
2762
+ return subclass(*args_, **kwargs_)
2763
+ if optionType.subclass:
2764
+ return optionType.subclass(*args_, **kwargs_)
2765
+ else:
2766
+ return optionType(*args_, **kwargs_)
2767
+ factory = staticmethod(factory)
2768
+ def get_ns_prefix_(self):
2769
+ return self.ns_prefix_
2770
+ def set_ns_prefix_(self, ns_prefix):
2771
+ self.ns_prefix_ = ns_prefix
2772
+ def get_optionId(self):
2773
+ return self.optionId
2774
+ def set_optionId(self, optionId):
2775
+ self.optionId = optionId
2776
+ def add_optionId(self, value):
2777
+ self.optionId.append(value)
2778
+ def insert_optionId_at(self, index, value):
2779
+ self.optionId.insert(index, value)
2780
+ def replace_optionId_at(self, index, value):
2781
+ self.optionId[index] = value
2782
+ def has__content(self):
2783
+ if (
2784
+ self.optionId
2785
+ ):
2786
+ return True
2787
+ else:
2788
+ return False
2789
+ def export(self, outfile, level, namespaceprefix_='', namespacedef_='', name_='optionType', pretty_print=True):
2790
+ imported_ns_def_ = GenerateDSNamespaceDefs_.get('optionType')
2791
+ if imported_ns_def_ is not None:
2792
+ namespacedef_ = imported_ns_def_
2793
+ if pretty_print:
2794
+ eol_ = '\n'
2795
+ else:
2796
+ eol_ = ''
2797
+ if self.original_tagname_ is not None and name_ == 'optionType':
2798
+ name_ = self.original_tagname_
2799
+ if UseCapturedNS_ and self.ns_prefix_:
2800
+ namespaceprefix_ = self.ns_prefix_ + ':'
2801
+ showIndent(outfile, level, pretty_print)
2802
+ outfile.write('<%s%s%s' % (namespaceprefix_, name_, namespacedef_ and ' ' + namespacedef_ or '', ))
2803
+ already_processed = set()
2804
+ self._exportAttributes(outfile, level, already_processed, namespaceprefix_, name_='optionType')
2805
+ if self.has__content():
2806
+ outfile.write('>%s' % (eol_, ))
2807
+ self._exportChildren(outfile, level + 1, namespaceprefix_, namespacedef_, name_='optionType', pretty_print=pretty_print)
2808
+ showIndent(outfile, level, pretty_print)
2809
+ outfile.write('</%s%s>%s' % (namespaceprefix_, name_, eol_))
2810
+ else:
2811
+ outfile.write('/>%s' % (eol_, ))
2812
+ def _exportAttributes(self, outfile, level, already_processed, namespaceprefix_='', name_='optionType'):
2813
+ pass
2814
+ def _exportChildren(self, outfile, level, namespaceprefix_='', namespacedef_='', name_='optionType', fromsubclass_=False, pretty_print=True):
2815
+ if pretty_print:
2816
+ eol_ = '\n'
2817
+ else:
2818
+ eol_ = ''
2819
+ for optionId_ in self.optionId:
2820
+ namespaceprefix_ = self.optionId_nsprefix_ + ':' if (UseCapturedNS_ and self.optionId_nsprefix_) else ''
2821
+ showIndent(outfile, level, pretty_print)
2822
+ outfile.write('<%soptionId>%s</%soptionId>%s' % (namespaceprefix_ , self.gds_encode(self.gds_format_string(quote_xml(optionId_), input_name='optionId')), namespaceprefix_ , eol_))
2823
+ def build(self, node, gds_collector_=None):
2824
+ self.gds_collector_ = gds_collector_
2825
+ if SaveElementTreeNode:
2826
+ self.gds_elementtree_node_ = node
2827
+ already_processed = set()
2828
+ self.ns_prefix_ = node.prefix
2829
+ self._buildAttributes(node, node.attrib, already_processed)
2830
+ for child in node:
2831
+ nodeName_ = Tag_pattern_.match(child.tag).groups()[-1]
2832
+ self._buildChildren(child, node, nodeName_, gds_collector_=gds_collector_)
2833
+ return self
2834
+ def _buildAttributes(self, node, attrs, already_processed):
2835
+ pass
2836
+ def _buildChildren(self, child_, node, nodeName_, fromsubclass_=False, gds_collector_=None):
2837
+ if nodeName_ == 'optionId':
2838
+ value_ = child_.text
2839
+ value_ = self.gds_parse_string(value_, node, 'optionId')
2840
+ value_ = self.gds_validate_string(value_, node, 'optionId')
2841
+ self.optionId.append(value_)
2842
+ self.optionId_nsprefix_ = child_.prefix
2843
+ # end class optionType
2844
+
2845
+
2846
+ class measurementsType(GeneratedsSuper):
2847
+ """measurementsType -- The dimensions (height, width, length) and weight of the consignment,
2848
+ piece or article. Data must be provided in metres for dimensions,
2849
+ kilograms for weight.
2850
+ length -- The length in metres. The length is the longest dimension
2851
+ of the piece. (A piece is a box, envelope, or parcel -
2852
+ i.e. a separate item being shipped.)
2853
+ width -- The width in metres.
2854
+ height -- The height in metres.
2855
+ weight -- The weight in kilograms.
2856
+
2857
+ """
2858
+ __hash__ = GeneratedsSuper.__hash__
2859
+ subclass = None
2860
+ superclass = None
2861
+ def __init__(self, length=None, width=None, height=None, weight=None, gds_collector_=None, **kwargs_):
2862
+ self.gds_collector_ = gds_collector_
2863
+ self.gds_elementtree_node_ = None
2864
+ self.original_tagname_ = None
2865
+ self.parent_object_ = kwargs_.get('parent_object_')
2866
+ self.ns_prefix_ = None
2867
+ self.length = length
2868
+ self.validate_doubleMaxExclusive100MinInclusive0_01(self.length)
2869
+ self.length_nsprefix_ = None
2870
+ self.width = width
2871
+ self.validate_doubleMaxExclusive100MinInclusive0_01(self.width)
2872
+ self.width_nsprefix_ = None
2873
+ self.height = height
2874
+ self.validate_doubleMaxExclusive100MinInclusive0_01(self.height)
2875
+ self.height_nsprefix_ = None
2876
+ self.weight = weight
2877
+ self.validate_doubleMaxExclusive100000MinInclusive0_01(self.weight)
2878
+ self.weight_nsprefix_ = None
2879
+ def factory(*args_, **kwargs_):
2880
+ if CurrentSubclassModule_ is not None:
2881
+ subclass = getSubclassFromModule_(
2882
+ CurrentSubclassModule_, measurementsType)
2883
+ if subclass is not None:
2884
+ return subclass(*args_, **kwargs_)
2885
+ if measurementsType.subclass:
2886
+ return measurementsType.subclass(*args_, **kwargs_)
2887
+ else:
2888
+ return measurementsType(*args_, **kwargs_)
2889
+ factory = staticmethod(factory)
2890
+ def get_ns_prefix_(self):
2891
+ return self.ns_prefix_
2892
+ def set_ns_prefix_(self, ns_prefix):
2893
+ self.ns_prefix_ = ns_prefix
2894
+ def get_length(self):
2895
+ return self.length
2896
+ def set_length(self, length):
2897
+ self.length = length
2898
+ def get_width(self):
2899
+ return self.width
2900
+ def set_width(self, width):
2901
+ self.width = width
2902
+ def get_height(self):
2903
+ return self.height
2904
+ def set_height(self, height):
2905
+ self.height = height
2906
+ def get_weight(self):
2907
+ return self.weight
2908
+ def set_weight(self, weight):
2909
+ self.weight = weight
2910
+ def validate_doubleMaxExclusive100MinInclusive0_01(self, value):
2911
+ result = True
2912
+ # Validate type doubleMaxExclusive100MinInclusive0.01, a restriction on xsd:double.
2913
+ if value is not None and Validate_simpletypes_ and self.gds_collector_ is not None:
2914
+ if not isinstance(value, float):
2915
+ lineno = self.gds_get_node_lineno_()
2916
+ self.gds_collector_.add_message('Value "%(value)s"%(lineno)s is not of the correct base simple type (float)' % {"value": value, "lineno": lineno, })
2917
+ return False
2918
+ if value < 0.01:
2919
+ lineno = self.gds_get_node_lineno_()
2920
+ self.gds_collector_.add_message('Value "%(value)s"%(lineno)s does not match xsd minInclusive restriction on doubleMaxExclusive100MinInclusive0.01' % {"value": value, "lineno": lineno} )
2921
+ result = False
2922
+ if value >= 100:
2923
+ lineno = self.gds_get_node_lineno_()
2924
+ self.gds_collector_.add_message('Value "%(value)s"%(lineno)s does not match xsd maxExclusive restriction on doubleMaxExclusive100MinInclusive0.01' % {"value": value, "lineno": lineno} )
2925
+ result = False
2926
+ return result
2927
+ def validate_doubleMaxExclusive100000MinInclusive0_01(self, value):
2928
+ result = True
2929
+ # Validate type doubleMaxExclusive100000MinInclusive0.01, a restriction on xsd:double.
2930
+ if value is not None and Validate_simpletypes_ and self.gds_collector_ is not None:
2931
+ if not isinstance(value, float):
2932
+ lineno = self.gds_get_node_lineno_()
2933
+ self.gds_collector_.add_message('Value "%(value)s"%(lineno)s is not of the correct base simple type (float)' % {"value": value, "lineno": lineno, })
2934
+ return False
2935
+ if value < 0.01:
2936
+ lineno = self.gds_get_node_lineno_()
2937
+ self.gds_collector_.add_message('Value "%(value)s"%(lineno)s does not match xsd minInclusive restriction on doubleMaxExclusive100000MinInclusive0.01' % {"value": value, "lineno": lineno} )
2938
+ result = False
2939
+ if value >= 100000:
2940
+ lineno = self.gds_get_node_lineno_()
2941
+ self.gds_collector_.add_message('Value "%(value)s"%(lineno)s does not match xsd maxExclusive restriction on doubleMaxExclusive100000MinInclusive0.01' % {"value": value, "lineno": lineno} )
2942
+ result = False
2943
+ return result
2944
+ def has__content(self):
2945
+ if (
2946
+ self.length is not None or
2947
+ self.width is not None or
2948
+ self.height is not None or
2949
+ self.weight is not None
2950
+ ):
2951
+ return True
2952
+ else:
2953
+ return False
2954
+ def export(self, outfile, level, namespaceprefix_='', namespacedef_='', name_='measurementsType', pretty_print=True):
2955
+ imported_ns_def_ = GenerateDSNamespaceDefs_.get('measurementsType')
2956
+ if imported_ns_def_ is not None:
2957
+ namespacedef_ = imported_ns_def_
2958
+ if pretty_print:
2959
+ eol_ = '\n'
2960
+ else:
2961
+ eol_ = ''
2962
+ if self.original_tagname_ is not None and name_ == 'measurementsType':
2963
+ name_ = self.original_tagname_
2964
+ if UseCapturedNS_ and self.ns_prefix_:
2965
+ namespaceprefix_ = self.ns_prefix_ + ':'
2966
+ showIndent(outfile, level, pretty_print)
2967
+ outfile.write('<%s%s%s' % (namespaceprefix_, name_, namespacedef_ and ' ' + namespacedef_ or '', ))
2968
+ already_processed = set()
2969
+ self._exportAttributes(outfile, level, already_processed, namespaceprefix_, name_='measurementsType')
2970
+ if self.has__content():
2971
+ outfile.write('>%s' % (eol_, ))
2972
+ self._exportChildren(outfile, level + 1, namespaceprefix_, namespacedef_, name_='measurementsType', pretty_print=pretty_print)
2973
+ showIndent(outfile, level, pretty_print)
2974
+ outfile.write('</%s%s>%s' % (namespaceprefix_, name_, eol_))
2975
+ else:
2976
+ outfile.write('/>%s' % (eol_, ))
2977
+ def _exportAttributes(self, outfile, level, already_processed, namespaceprefix_='', name_='measurementsType'):
2978
+ pass
2979
+ def _exportChildren(self, outfile, level, namespaceprefix_='', namespacedef_='', name_='measurementsType', fromsubclass_=False, pretty_print=True):
2980
+ if pretty_print:
2981
+ eol_ = '\n'
2982
+ else:
2983
+ eol_ = ''
2984
+ if self.length is not None:
2985
+ namespaceprefix_ = self.length_nsprefix_ + ':' if (UseCapturedNS_ and self.length_nsprefix_) else ''
2986
+ showIndent(outfile, level, pretty_print)
2987
+ outfile.write('<%slength>%s</%slength>%s' % (namespaceprefix_ , self.gds_format_double(self.length, input_name='length'), namespaceprefix_ , eol_))
2988
+ if self.width is not None:
2989
+ namespaceprefix_ = self.width_nsprefix_ + ':' if (UseCapturedNS_ and self.width_nsprefix_) else ''
2990
+ showIndent(outfile, level, pretty_print)
2991
+ outfile.write('<%swidth>%s</%swidth>%s' % (namespaceprefix_ , self.gds_format_double(self.width, input_name='width'), namespaceprefix_ , eol_))
2992
+ if self.height is not None:
2993
+ namespaceprefix_ = self.height_nsprefix_ + ':' if (UseCapturedNS_ and self.height_nsprefix_) else ''
2994
+ showIndent(outfile, level, pretty_print)
2995
+ outfile.write('<%sheight>%s</%sheight>%s' % (namespaceprefix_ , self.gds_format_double(self.height, input_name='height'), namespaceprefix_ , eol_))
2996
+ if self.weight is not None:
2997
+ namespaceprefix_ = self.weight_nsprefix_ + ':' if (UseCapturedNS_ and self.weight_nsprefix_) else ''
2998
+ showIndent(outfile, level, pretty_print)
2999
+ outfile.write('<%sweight>%s</%sweight>%s' % (namespaceprefix_ , self.gds_format_double(self.weight, input_name='weight'), namespaceprefix_ , eol_))
3000
+ def build(self, node, gds_collector_=None):
3001
+ self.gds_collector_ = gds_collector_
3002
+ if SaveElementTreeNode:
3003
+ self.gds_elementtree_node_ = node
3004
+ already_processed = set()
3005
+ self.ns_prefix_ = node.prefix
3006
+ self._buildAttributes(node, node.attrib, already_processed)
3007
+ for child in node:
3008
+ nodeName_ = Tag_pattern_.match(child.tag).groups()[-1]
3009
+ self._buildChildren(child, node, nodeName_, gds_collector_=gds_collector_)
3010
+ return self
3011
+ def _buildAttributes(self, node, attrs, already_processed):
3012
+ pass
3013
+ def _buildChildren(self, child_, node, nodeName_, fromsubclass_=False, gds_collector_=None):
3014
+ if nodeName_ == 'length' and child_.text:
3015
+ sval_ = child_.text
3016
+ fval_ = self.gds_parse_double(sval_, node, 'length')
3017
+ fval_ = self.gds_validate_double(fval_, node, 'length')
3018
+ self.length = fval_
3019
+ self.length_nsprefix_ = child_.prefix
3020
+ # validate type doubleMaxExclusive100MinInclusive0.01
3021
+ self.validate_doubleMaxExclusive100MinInclusive0_01(self.length)
3022
+ elif nodeName_ == 'width' and child_.text:
3023
+ sval_ = child_.text
3024
+ fval_ = self.gds_parse_double(sval_, node, 'width')
3025
+ fval_ = self.gds_validate_double(fval_, node, 'width')
3026
+ self.width = fval_
3027
+ self.width_nsprefix_ = child_.prefix
3028
+ # validate type doubleMaxExclusive100MinInclusive0.01
3029
+ self.validate_doubleMaxExclusive100MinInclusive0_01(self.width)
3030
+ elif nodeName_ == 'height' and child_.text:
3031
+ sval_ = child_.text
3032
+ fval_ = self.gds_parse_double(sval_, node, 'height')
3033
+ fval_ = self.gds_validate_double(fval_, node, 'height')
3034
+ self.height = fval_
3035
+ self.height_nsprefix_ = child_.prefix
3036
+ # validate type doubleMaxExclusive100MinInclusive0.01
3037
+ self.validate_doubleMaxExclusive100MinInclusive0_01(self.height)
3038
+ elif nodeName_ == 'weight' and child_.text:
3039
+ sval_ = child_.text
3040
+ fval_ = self.gds_parse_double(sval_, node, 'weight')
3041
+ fval_ = self.gds_validate_double(fval_, node, 'weight')
3042
+ self.weight = fval_
3043
+ self.weight_nsprefix_ = child_.prefix
3044
+ # validate type doubleMaxExclusive100000MinInclusive0.01
3045
+ self.validate_doubleMaxExclusive100000MinInclusive0_01(self.weight)
3046
+ # end class measurementsType
3047
+
3048
+
3049
+ class pieceLineType(GeneratedsSuper):
3050
+ """pieceLineType -- A piece line describes a kind of piece sharing the same physical attributes.
3051
+ (A piece is a package, box, envelope or shippable unit. All pieces which are
3052
+ identical are defined for convenience as a piece line with a number of units.)
3053
+ For example if there are 5 boxes of 0.1m x 0.2m x 0.3m of weight 0.1kg and
3054
+ 1 box of 0.4m x 0.4m x 0.4 of weight 0.5kg this equates to two piece lines as
3055
+ follows:
3056
+ PieceLine1: 0.1m x 0.2m x 0.3m, weight 0.1kg, number of units=5
3057
+ PieceLine2: 0.4m x 0.4m x 0.4m, weight 0.5kg, number of units=1
3058
+ identifier -- Identifier for the pieceLine so that it can be referenced during
3059
+ processing. Each pieceLine type should have a unique number,
3060
+ starting at 1 and incrementing for each piece line type required
3061
+ goodsDescription -- Full description of goods being shipped (catalogue numbers or
3062
+ part numbers will not suffice. The Customs Authorities want to
3063
+ know what each item actually is so please carefully describe the
3064
+ goods).
3065
+ barcodeForCustomer -- A flag to state if a barcode for the customer
3066
+ reference should be created.
3067
+ pieceMeasurements -- Dimension and weight measurements relating to the pieces defined
3068
+ by this type.
3069
+ pieces -- At least one of these sections should be provided per consignment
3070
+ up to a maximum of one per piece.
3071
+
3072
+ """
3073
+ __hash__ = GeneratedsSuper.__hash__
3074
+ subclass = None
3075
+ superclass = None
3076
+ def __init__(self, identifier=None, goodsDescription=None, barcodeForCustomer=None, pieceMeasurements=None, pieces=None, gds_collector_=None, **kwargs_):
3077
+ self.gds_collector_ = gds_collector_
3078
+ self.gds_elementtree_node_ = None
3079
+ self.original_tagname_ = None
3080
+ self.parent_object_ = kwargs_.get('parent_object_')
3081
+ self.ns_prefix_ = None
3082
+ self.identifier = identifier
3083
+ self.identifier_nsprefix_ = None
3084
+ self.goodsDescription = goodsDescription
3085
+ self.validate_stringMaxLength30(self.goodsDescription)
3086
+ self.goodsDescription_nsprefix_ = None
3087
+ self.barcodeForCustomer = barcodeForCustomer
3088
+ self.validate_booleanEnum(self.barcodeForCustomer)
3089
+ self.barcodeForCustomer_nsprefix_ = None
3090
+ self.pieceMeasurements = pieceMeasurements
3091
+ self.pieceMeasurements_nsprefix_ = None
3092
+ if pieces is None:
3093
+ self.pieces = []
3094
+ else:
3095
+ self.pieces = pieces
3096
+ self.pieces_nsprefix_ = None
3097
+ def factory(*args_, **kwargs_):
3098
+ if CurrentSubclassModule_ is not None:
3099
+ subclass = getSubclassFromModule_(
3100
+ CurrentSubclassModule_, pieceLineType)
3101
+ if subclass is not None:
3102
+ return subclass(*args_, **kwargs_)
3103
+ if pieceLineType.subclass:
3104
+ return pieceLineType.subclass(*args_, **kwargs_)
3105
+ else:
3106
+ return pieceLineType(*args_, **kwargs_)
3107
+ factory = staticmethod(factory)
3108
+ def get_ns_prefix_(self):
3109
+ return self.ns_prefix_
3110
+ def set_ns_prefix_(self, ns_prefix):
3111
+ self.ns_prefix_ = ns_prefix
3112
+ def get_identifier(self):
3113
+ return self.identifier
3114
+ def set_identifier(self, identifier):
3115
+ self.identifier = identifier
3116
+ def get_goodsDescription(self):
3117
+ return self.goodsDescription
3118
+ def set_goodsDescription(self, goodsDescription):
3119
+ self.goodsDescription = goodsDescription
3120
+ def get_barcodeForCustomer(self):
3121
+ return self.barcodeForCustomer
3122
+ def set_barcodeForCustomer(self, barcodeForCustomer):
3123
+ self.barcodeForCustomer = barcodeForCustomer
3124
+ def get_pieceMeasurements(self):
3125
+ return self.pieceMeasurements
3126
+ def set_pieceMeasurements(self, pieceMeasurements):
3127
+ self.pieceMeasurements = pieceMeasurements
3128
+ def get_pieces(self):
3129
+ return self.pieces
3130
+ def set_pieces(self, pieces):
3131
+ self.pieces = pieces
3132
+ def add_pieces(self, value):
3133
+ self.pieces.append(value)
3134
+ def insert_pieces_at(self, index, value):
3135
+ self.pieces.insert(index, value)
3136
+ def replace_pieces_at(self, index, value):
3137
+ self.pieces[index] = value
3138
+ def validate_stringMaxLength30(self, value):
3139
+ result = True
3140
+ # Validate type stringMaxLength30, a restriction on xsd:string.
3141
+ if value is not None and Validate_simpletypes_ and self.gds_collector_ is not None:
3142
+ if not isinstance(value, str):
3143
+ lineno = self.gds_get_node_lineno_()
3144
+ self.gds_collector_.add_message('Value "%(value)s"%(lineno)s is not of the correct base simple type (str)' % {"value": value, "lineno": lineno, })
3145
+ return False
3146
+ if len(value) > 30:
3147
+ lineno = self.gds_get_node_lineno_()
3148
+ 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} )
3149
+ result = False
3150
+ return result
3151
+ def validate_booleanEnum(self, value):
3152
+ result = True
3153
+ # Validate type booleanEnum, a restriction on xsd:string.
3154
+ if value is not None and Validate_simpletypes_ and self.gds_collector_ is not None:
3155
+ if not isinstance(value, str):
3156
+ lineno = self.gds_get_node_lineno_()
3157
+ self.gds_collector_.add_message('Value "%(value)s"%(lineno)s is not of the correct base simple type (str)' % {"value": value, "lineno": lineno, })
3158
+ return False
3159
+ value = value
3160
+ enumerations = ['N', 'Y']
3161
+ if value not in enumerations:
3162
+ lineno = self.gds_get_node_lineno_()
3163
+ 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} )
3164
+ result = False
3165
+ return result
3166
+ def has__content(self):
3167
+ if (
3168
+ self.identifier is not None or
3169
+ self.goodsDescription is not None or
3170
+ self.barcodeForCustomer is not None or
3171
+ self.pieceMeasurements is not None or
3172
+ self.pieces
3173
+ ):
3174
+ return True
3175
+ else:
3176
+ return False
3177
+ def export(self, outfile, level, namespaceprefix_='', namespacedef_='', name_='pieceLineType', pretty_print=True):
3178
+ imported_ns_def_ = GenerateDSNamespaceDefs_.get('pieceLineType')
3179
+ if imported_ns_def_ is not None:
3180
+ namespacedef_ = imported_ns_def_
3181
+ if pretty_print:
3182
+ eol_ = '\n'
3183
+ else:
3184
+ eol_ = ''
3185
+ if self.original_tagname_ is not None and name_ == 'pieceLineType':
3186
+ name_ = self.original_tagname_
3187
+ if UseCapturedNS_ and self.ns_prefix_:
3188
+ namespaceprefix_ = self.ns_prefix_ + ':'
3189
+ showIndent(outfile, level, pretty_print)
3190
+ outfile.write('<%s%s%s' % (namespaceprefix_, name_, namespacedef_ and ' ' + namespacedef_ or '', ))
3191
+ already_processed = set()
3192
+ self._exportAttributes(outfile, level, already_processed, namespaceprefix_, name_='pieceLineType')
3193
+ if self.has__content():
3194
+ outfile.write('>%s' % (eol_, ))
3195
+ self._exportChildren(outfile, level + 1, namespaceprefix_, namespacedef_, name_='pieceLineType', pretty_print=pretty_print)
3196
+ showIndent(outfile, level, pretty_print)
3197
+ outfile.write('</%s%s>%s' % (namespaceprefix_, name_, eol_))
3198
+ else:
3199
+ outfile.write('/>%s' % (eol_, ))
3200
+ def _exportAttributes(self, outfile, level, already_processed, namespaceprefix_='', name_='pieceLineType'):
3201
+ pass
3202
+ def _exportChildren(self, outfile, level, namespaceprefix_='', namespacedef_='', name_='pieceLineType', fromsubclass_=False, pretty_print=True):
3203
+ if pretty_print:
3204
+ eol_ = '\n'
3205
+ else:
3206
+ eol_ = ''
3207
+ if self.identifier is not None:
3208
+ namespaceprefix_ = self.identifier_nsprefix_ + ':' if (UseCapturedNS_ and self.identifier_nsprefix_) else ''
3209
+ showIndent(outfile, level, pretty_print)
3210
+ outfile.write('<%sidentifier>%s</%sidentifier>%s' % (namespaceprefix_ , self.gds_format_integer(self.identifier, input_name='identifier'), namespaceprefix_ , eol_))
3211
+ if self.goodsDescription is not None:
3212
+ namespaceprefix_ = self.goodsDescription_nsprefix_ + ':' if (UseCapturedNS_ and self.goodsDescription_nsprefix_) else ''
3213
+ showIndent(outfile, level, pretty_print)
3214
+ outfile.write('<%sgoodsDescription>%s</%sgoodsDescription>%s' % (namespaceprefix_ , self.gds_encode(self.gds_format_string(quote_xml(self.goodsDescription), input_name='goodsDescription')), namespaceprefix_ , eol_))
3215
+ if self.barcodeForCustomer is not None:
3216
+ namespaceprefix_ = self.barcodeForCustomer_nsprefix_ + ':' if (UseCapturedNS_ and self.barcodeForCustomer_nsprefix_) else ''
3217
+ showIndent(outfile, level, pretty_print)
3218
+ outfile.write('<%sbarcodeForCustomer>%s</%sbarcodeForCustomer>%s' % (namespaceprefix_ , self.gds_encode(self.gds_format_string(quote_xml(self.barcodeForCustomer), input_name='barcodeForCustomer')), namespaceprefix_ , eol_))
3219
+ if self.pieceMeasurements is not None:
3220
+ namespaceprefix_ = self.pieceMeasurements_nsprefix_ + ':' if (UseCapturedNS_ and self.pieceMeasurements_nsprefix_) else ''
3221
+ self.pieceMeasurements.export(outfile, level, namespaceprefix_, namespacedef_='', name_='pieceMeasurements', pretty_print=pretty_print)
3222
+ for pieces_ in self.pieces:
3223
+ namespaceprefix_ = self.pieces_nsprefix_ + ':' if (UseCapturedNS_ and self.pieces_nsprefix_) else ''
3224
+ pieces_.export(outfile, level, namespaceprefix_, namespacedef_='', name_='pieces', pretty_print=pretty_print)
3225
+ def build(self, node, gds_collector_=None):
3226
+ self.gds_collector_ = gds_collector_
3227
+ if SaveElementTreeNode:
3228
+ self.gds_elementtree_node_ = node
3229
+ already_processed = set()
3230
+ self.ns_prefix_ = node.prefix
3231
+ self._buildAttributes(node, node.attrib, already_processed)
3232
+ for child in node:
3233
+ nodeName_ = Tag_pattern_.match(child.tag).groups()[-1]
3234
+ self._buildChildren(child, node, nodeName_, gds_collector_=gds_collector_)
3235
+ return self
3236
+ def _buildAttributes(self, node, attrs, already_processed):
3237
+ pass
3238
+ def _buildChildren(self, child_, node, nodeName_, fromsubclass_=False, gds_collector_=None):
3239
+ if nodeName_ == 'identifier' and child_.text:
3240
+ sval_ = child_.text
3241
+ ival_ = self.gds_parse_integer(sval_, node, 'identifier')
3242
+ ival_ = self.gds_validate_integer(ival_, node, 'identifier')
3243
+ self.identifier = ival_
3244
+ self.identifier_nsprefix_ = child_.prefix
3245
+ elif nodeName_ == 'goodsDescription':
3246
+ value_ = child_.text
3247
+ value_ = self.gds_parse_string(value_, node, 'goodsDescription')
3248
+ value_ = self.gds_validate_string(value_, node, 'goodsDescription')
3249
+ self.goodsDescription = value_
3250
+ self.goodsDescription_nsprefix_ = child_.prefix
3251
+ # validate type stringMaxLength30
3252
+ self.validate_stringMaxLength30(self.goodsDescription)
3253
+ elif nodeName_ == 'barcodeForCustomer':
3254
+ value_ = child_.text
3255
+ value_ = self.gds_parse_string(value_, node, 'barcodeForCustomer')
3256
+ value_ = self.gds_validate_string(value_, node, 'barcodeForCustomer')
3257
+ self.barcodeForCustomer = value_
3258
+ self.barcodeForCustomer_nsprefix_ = child_.prefix
3259
+ # validate type booleanEnum
3260
+ self.validate_booleanEnum(self.barcodeForCustomer)
3261
+ elif nodeName_ == 'pieceMeasurements':
3262
+ obj_ = measurementsType.factory(parent_object_=self)
3263
+ obj_.build(child_, gds_collector_=gds_collector_)
3264
+ self.pieceMeasurements = obj_
3265
+ obj_.original_tagname_ = 'pieceMeasurements'
3266
+ elif nodeName_ == 'pieces':
3267
+ obj_ = pieceType.factory(parent_object_=self)
3268
+ obj_.build(child_, gds_collector_=gds_collector_)
3269
+ self.pieces.append(obj_)
3270
+ obj_.original_tagname_ = 'pieces'
3271
+ # end class pieceLineType
3272
+
3273
+
3274
+ class pieceType(GeneratedsSuper):
3275
+ """pieceType -- This element is used to identify all the pieces that should be grouped
3276
+ together by the given reference. The list of sequence numbers is included
3277
+ (one sequenceNumber element per piece) with a single pieceReference element.
3278
+ sequenceNumbers -- List of the piece sequence numbers, i.e. 1,2,5,n out of a total of
3279
+ n pieces that share the same piece reference.
3280
+ pieceReference -- Reference for this piece or pieces.
3281
+
3282
+ """
3283
+ __hash__ = GeneratedsSuper.__hash__
3284
+ subclass = None
3285
+ superclass = None
3286
+ def __init__(self, sequenceNumbers=None, pieceReference=None, gds_collector_=None, **kwargs_):
3287
+ self.gds_collector_ = gds_collector_
3288
+ self.gds_elementtree_node_ = None
3289
+ self.original_tagname_ = None
3290
+ self.parent_object_ = kwargs_.get('parent_object_')
3291
+ self.ns_prefix_ = None
3292
+ self.sequenceNumbers = sequenceNumbers
3293
+ self.sequenceNumbers_nsprefix_ = None
3294
+ self.pieceReference = pieceReference
3295
+ self.pieceReference_nsprefix_ = None
3296
+ def factory(*args_, **kwargs_):
3297
+ if CurrentSubclassModule_ is not None:
3298
+ subclass = getSubclassFromModule_(
3299
+ CurrentSubclassModule_, pieceType)
3300
+ if subclass is not None:
3301
+ return subclass(*args_, **kwargs_)
3302
+ if pieceType.subclass:
3303
+ return pieceType.subclass(*args_, **kwargs_)
3304
+ else:
3305
+ return pieceType(*args_, **kwargs_)
3306
+ factory = staticmethod(factory)
3307
+ def get_ns_prefix_(self):
3308
+ return self.ns_prefix_
3309
+ def set_ns_prefix_(self, ns_prefix):
3310
+ self.ns_prefix_ = ns_prefix
3311
+ def get_sequenceNumbers(self):
3312
+ return self.sequenceNumbers
3313
+ def set_sequenceNumbers(self, sequenceNumbers):
3314
+ self.sequenceNumbers = sequenceNumbers
3315
+ def get_pieceReference(self):
3316
+ return self.pieceReference
3317
+ def set_pieceReference(self, pieceReference):
3318
+ self.pieceReference = pieceReference
3319
+ def has__content(self):
3320
+ if (
3321
+ self.sequenceNumbers is not None or
3322
+ self.pieceReference is not None
3323
+ ):
3324
+ return True
3325
+ else:
3326
+ return False
3327
+ def export(self, outfile, level, namespaceprefix_='', namespacedef_='', name_='pieceType', pretty_print=True):
3328
+ imported_ns_def_ = GenerateDSNamespaceDefs_.get('pieceType')
3329
+ if imported_ns_def_ is not None:
3330
+ namespacedef_ = imported_ns_def_
3331
+ if pretty_print:
3332
+ eol_ = '\n'
3333
+ else:
3334
+ eol_ = ''
3335
+ if self.original_tagname_ is not None and name_ == 'pieceType':
3336
+ name_ = self.original_tagname_
3337
+ if UseCapturedNS_ and self.ns_prefix_:
3338
+ namespaceprefix_ = self.ns_prefix_ + ':'
3339
+ showIndent(outfile, level, pretty_print)
3340
+ outfile.write('<%s%s%s' % (namespaceprefix_, name_, namespacedef_ and ' ' + namespacedef_ or '', ))
3341
+ already_processed = set()
3342
+ self._exportAttributes(outfile, level, already_processed, namespaceprefix_, name_='pieceType')
3343
+ if self.has__content():
3344
+ outfile.write('>%s' % (eol_, ))
3345
+ self._exportChildren(outfile, level + 1, namespaceprefix_, namespacedef_, name_='pieceType', pretty_print=pretty_print)
3346
+ showIndent(outfile, level, pretty_print)
3347
+ outfile.write('</%s%s>%s' % (namespaceprefix_, name_, eol_))
3348
+ else:
3349
+ outfile.write('/>%s' % (eol_, ))
3350
+ def _exportAttributes(self, outfile, level, already_processed, namespaceprefix_='', name_='pieceType'):
3351
+ pass
3352
+ def _exportChildren(self, outfile, level, namespaceprefix_='', namespacedef_='', name_='pieceType', fromsubclass_=False, pretty_print=True):
3353
+ if pretty_print:
3354
+ eol_ = '\n'
3355
+ else:
3356
+ eol_ = ''
3357
+ if self.sequenceNumbers is not None:
3358
+ namespaceprefix_ = self.sequenceNumbers_nsprefix_ + ':' if (UseCapturedNS_ and self.sequenceNumbers_nsprefix_) else ''
3359
+ showIndent(outfile, level, pretty_print)
3360
+ outfile.write('<%ssequenceNumbers>%s</%ssequenceNumbers>%s' % (namespaceprefix_ , self.gds_encode(self.gds_format_string(quote_xml(self.sequenceNumbers), input_name='sequenceNumbers')), namespaceprefix_ , eol_))
3361
+ if self.pieceReference is not None:
3362
+ namespaceprefix_ = self.pieceReference_nsprefix_ + ':' if (UseCapturedNS_ and self.pieceReference_nsprefix_) else ''
3363
+ showIndent(outfile, level, pretty_print)
3364
+ outfile.write('<%spieceReference>%s</%spieceReference>%s' % (namespaceprefix_ , self.gds_encode(self.gds_format_string(quote_xml(self.pieceReference), input_name='pieceReference')), namespaceprefix_ , eol_))
3365
+ def build(self, node, gds_collector_=None):
3366
+ self.gds_collector_ = gds_collector_
3367
+ if SaveElementTreeNode:
3368
+ self.gds_elementtree_node_ = node
3369
+ already_processed = set()
3370
+ self.ns_prefix_ = node.prefix
3371
+ self._buildAttributes(node, node.attrib, already_processed)
3372
+ for child in node:
3373
+ nodeName_ = Tag_pattern_.match(child.tag).groups()[-1]
3374
+ self._buildChildren(child, node, nodeName_, gds_collector_=gds_collector_)
3375
+ return self
3376
+ def _buildAttributes(self, node, attrs, already_processed):
3377
+ pass
3378
+ def _buildChildren(self, child_, node, nodeName_, fromsubclass_=False, gds_collector_=None):
3379
+ if nodeName_ == 'sequenceNumbers':
3380
+ value_ = child_.text
3381
+ value_ = self.gds_parse_string(value_, node, 'sequenceNumbers')
3382
+ value_ = self.gds_validate_string(value_, node, 'sequenceNumbers')
3383
+ self.sequenceNumbers = value_
3384
+ self.sequenceNumbers_nsprefix_ = child_.prefix
3385
+ elif nodeName_ == 'pieceReference':
3386
+ value_ = child_.text
3387
+ value_ = self.gds_parse_string(value_, node, 'pieceReference')
3388
+ value_ = self.gds_validate_string(value_, node, 'pieceReference')
3389
+ self.pieceReference = value_
3390
+ self.pieceReference_nsprefix_ = child_.prefix
3391
+ # end class pieceType
3392
+
3393
+
3394
+ class contactType(GeneratedsSuper):
3395
+ """contactType -- Information about the contact person at the relevant address.
3396
+ name -- Name of the contact person at the relevant address.
3397
+ telephoneNumber -- The full telephone number for the contact person.
3398
+ emailAddress -- Email address for the contact person.
3399
+
3400
+ """
3401
+ __hash__ = GeneratedsSuper.__hash__
3402
+ subclass = None
3403
+ superclass = None
3404
+ def __init__(self, name=None, telephoneNumber=None, emailAddress=None, gds_collector_=None, **kwargs_):
3405
+ self.gds_collector_ = gds_collector_
3406
+ self.gds_elementtree_node_ = None
3407
+ self.original_tagname_ = None
3408
+ self.parent_object_ = kwargs_.get('parent_object_')
3409
+ self.ns_prefix_ = None
3410
+ self.name = name
3411
+ self.validate_stringMaxLength30(self.name)
3412
+ self.name_nsprefix_ = None
3413
+ self.telephoneNumber = telephoneNumber
3414
+ self.validate_stringMaxLength30(self.telephoneNumber)
3415
+ self.telephoneNumber_nsprefix_ = None
3416
+ self.emailAddress = emailAddress
3417
+ self.emailAddress_nsprefix_ = None
3418
+ def factory(*args_, **kwargs_):
3419
+ if CurrentSubclassModule_ is not None:
3420
+ subclass = getSubclassFromModule_(
3421
+ CurrentSubclassModule_, contactType)
3422
+ if subclass is not None:
3423
+ return subclass(*args_, **kwargs_)
3424
+ if contactType.subclass:
3425
+ return contactType.subclass(*args_, **kwargs_)
3426
+ else:
3427
+ return contactType(*args_, **kwargs_)
3428
+ factory = staticmethod(factory)
3429
+ def get_ns_prefix_(self):
3430
+ return self.ns_prefix_
3431
+ def set_ns_prefix_(self, ns_prefix):
3432
+ self.ns_prefix_ = ns_prefix
3433
+ def get_name(self):
3434
+ return self.name
3435
+ def set_name(self, name):
3436
+ self.name = name
3437
+ def get_telephoneNumber(self):
3438
+ return self.telephoneNumber
3439
+ def set_telephoneNumber(self, telephoneNumber):
3440
+ self.telephoneNumber = telephoneNumber
3441
+ def get_emailAddress(self):
3442
+ return self.emailAddress
3443
+ def set_emailAddress(self, emailAddress):
3444
+ self.emailAddress = emailAddress
3445
+ def validate_stringMaxLength30(self, value):
3446
+ result = True
3447
+ # Validate type stringMaxLength30, a restriction on xsd:string.
3448
+ if value is not None and Validate_simpletypes_ and self.gds_collector_ is not None:
3449
+ if not isinstance(value, str):
3450
+ lineno = self.gds_get_node_lineno_()
3451
+ self.gds_collector_.add_message('Value "%(value)s"%(lineno)s is not of the correct base simple type (str)' % {"value": value, "lineno": lineno, })
3452
+ return False
3453
+ if len(value) > 30:
3454
+ lineno = self.gds_get_node_lineno_()
3455
+ 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} )
3456
+ result = False
3457
+ return result
3458
+ def has__content(self):
3459
+ if (
3460
+ self.name is not None or
3461
+ self.telephoneNumber is not None or
3462
+ self.emailAddress is not None
3463
+ ):
3464
+ return True
3465
+ else:
3466
+ return False
3467
+ def export(self, outfile, level, namespaceprefix_='', namespacedef_='', name_='contactType', pretty_print=True):
3468
+ imported_ns_def_ = GenerateDSNamespaceDefs_.get('contactType')
3469
+ if imported_ns_def_ is not None:
3470
+ namespacedef_ = imported_ns_def_
3471
+ if pretty_print:
3472
+ eol_ = '\n'
3473
+ else:
3474
+ eol_ = ''
3475
+ if self.original_tagname_ is not None and name_ == 'contactType':
3476
+ name_ = self.original_tagname_
3477
+ if UseCapturedNS_ and self.ns_prefix_:
3478
+ namespaceprefix_ = self.ns_prefix_ + ':'
3479
+ showIndent(outfile, level, pretty_print)
3480
+ outfile.write('<%s%s%s' % (namespaceprefix_, name_, namespacedef_ and ' ' + namespacedef_ or '', ))
3481
+ already_processed = set()
3482
+ self._exportAttributes(outfile, level, already_processed, namespaceprefix_, name_='contactType')
3483
+ if self.has__content():
3484
+ outfile.write('>%s' % (eol_, ))
3485
+ self._exportChildren(outfile, level + 1, namespaceprefix_, namespacedef_, name_='contactType', pretty_print=pretty_print)
3486
+ showIndent(outfile, level, pretty_print)
3487
+ outfile.write('</%s%s>%s' % (namespaceprefix_, name_, eol_))
3488
+ else:
3489
+ outfile.write('/>%s' % (eol_, ))
3490
+ def _exportAttributes(self, outfile, level, already_processed, namespaceprefix_='', name_='contactType'):
3491
+ pass
3492
+ def _exportChildren(self, outfile, level, namespaceprefix_='', namespacedef_='', name_='contactType', fromsubclass_=False, pretty_print=True):
3493
+ if pretty_print:
3494
+ eol_ = '\n'
3495
+ else:
3496
+ eol_ = ''
3497
+ if self.name is not None:
3498
+ namespaceprefix_ = self.name_nsprefix_ + ':' if (UseCapturedNS_ and self.name_nsprefix_) else ''
3499
+ showIndent(outfile, level, pretty_print)
3500
+ outfile.write('<%sname>%s</%sname>%s' % (namespaceprefix_ , self.gds_encode(self.gds_format_string(quote_xml(self.name), input_name='name')), namespaceprefix_ , eol_))
3501
+ if self.telephoneNumber is not None:
3502
+ namespaceprefix_ = self.telephoneNumber_nsprefix_ + ':' if (UseCapturedNS_ and self.telephoneNumber_nsprefix_) else ''
3503
+ showIndent(outfile, level, pretty_print)
3504
+ outfile.write('<%stelephoneNumber>%s</%stelephoneNumber>%s' % (namespaceprefix_ , self.gds_encode(self.gds_format_string(quote_xml(self.telephoneNumber), input_name='telephoneNumber')), namespaceprefix_ , eol_))
3505
+ if self.emailAddress is not None:
3506
+ namespaceprefix_ = self.emailAddress_nsprefix_ + ':' if (UseCapturedNS_ and self.emailAddress_nsprefix_) else ''
3507
+ showIndent(outfile, level, pretty_print)
3508
+ outfile.write('<%semailAddress>%s</%semailAddress>%s' % (namespaceprefix_ , self.gds_encode(self.gds_format_string(quote_xml(self.emailAddress), input_name='emailAddress')), namespaceprefix_ , eol_))
3509
+ def build(self, node, gds_collector_=None):
3510
+ self.gds_collector_ = gds_collector_
3511
+ if SaveElementTreeNode:
3512
+ self.gds_elementtree_node_ = node
3513
+ already_processed = set()
3514
+ self.ns_prefix_ = node.prefix
3515
+ self._buildAttributes(node, node.attrib, already_processed)
3516
+ for child in node:
3517
+ nodeName_ = Tag_pattern_.match(child.tag).groups()[-1]
3518
+ self._buildChildren(child, node, nodeName_, gds_collector_=gds_collector_)
3519
+ return self
3520
+ def _buildAttributes(self, node, attrs, already_processed):
3521
+ pass
3522
+ def _buildChildren(self, child_, node, nodeName_, fromsubclass_=False, gds_collector_=None):
3523
+ if nodeName_ == 'name':
3524
+ value_ = child_.text
3525
+ value_ = self.gds_parse_string(value_, node, 'name')
3526
+ value_ = self.gds_validate_string(value_, node, 'name')
3527
+ self.name = value_
3528
+ self.name_nsprefix_ = child_.prefix
3529
+ # validate type stringMaxLength30
3530
+ self.validate_stringMaxLength30(self.name)
3531
+ elif nodeName_ == 'telephoneNumber':
3532
+ value_ = child_.text
3533
+ value_ = self.gds_parse_string(value_, node, 'telephoneNumber')
3534
+ value_ = self.gds_validate_string(value_, node, 'telephoneNumber')
3535
+ self.telephoneNumber = value_
3536
+ self.telephoneNumber_nsprefix_ = child_.prefix
3537
+ # validate type stringMaxLength30
3538
+ self.validate_stringMaxLength30(self.telephoneNumber)
3539
+ elif nodeName_ == 'emailAddress':
3540
+ value_ = child_.text
3541
+ value_ = self.gds_parse_string(value_, node, 'emailAddress')
3542
+ value_ = self.gds_validate_string(value_, node, 'emailAddress')
3543
+ self.emailAddress = value_
3544
+ self.emailAddress_nsprefix_ = child_.prefix
3545
+ # end class contactType
3546
+
3547
+
3548
+ class accountType(GeneratedsSuper):
3549
+ """accountType -- Information about a TNT account which includes the account number
3550
+ and country code.
3551
+ accountNumber -- TNT legacy (global link) account number, which is the 9 digit
3552
+ number assigned by the TNT sales person.
3553
+ accountCountry -- ISO country code for the country the TNT account is in.
3554
+
3555
+ """
3556
+ __hash__ = GeneratedsSuper.__hash__
3557
+ subclass = None
3558
+ superclass = None
3559
+ def __init__(self, accountNumber=None, accountCountry=None, gds_collector_=None, **kwargs_):
3560
+ self.gds_collector_ = gds_collector_
3561
+ self.gds_elementtree_node_ = None
3562
+ self.original_tagname_ = None
3563
+ self.parent_object_ = kwargs_.get('parent_object_')
3564
+ self.ns_prefix_ = None
3565
+ self.accountNumber = accountNumber
3566
+ self.validate_stringMaxLength10(self.accountNumber)
3567
+ self.accountNumber_nsprefix_ = None
3568
+ self.accountCountry = accountCountry
3569
+ self.validate_stringMinLength2MaxLength2(self.accountCountry)
3570
+ self.accountCountry_nsprefix_ = None
3571
+ def factory(*args_, **kwargs_):
3572
+ if CurrentSubclassModule_ is not None:
3573
+ subclass = getSubclassFromModule_(
3574
+ CurrentSubclassModule_, accountType)
3575
+ if subclass is not None:
3576
+ return subclass(*args_, **kwargs_)
3577
+ if accountType.subclass:
3578
+ return accountType.subclass(*args_, **kwargs_)
3579
+ else:
3580
+ return accountType(*args_, **kwargs_)
3581
+ factory = staticmethod(factory)
3582
+ def get_ns_prefix_(self):
3583
+ return self.ns_prefix_
3584
+ def set_ns_prefix_(self, ns_prefix):
3585
+ self.ns_prefix_ = ns_prefix
3586
+ def get_accountNumber(self):
3587
+ return self.accountNumber
3588
+ def set_accountNumber(self, accountNumber):
3589
+ self.accountNumber = accountNumber
3590
+ def get_accountCountry(self):
3591
+ return self.accountCountry
3592
+ def set_accountCountry(self, accountCountry):
3593
+ self.accountCountry = accountCountry
3594
+ def validate_stringMaxLength10(self, value):
3595
+ result = True
3596
+ # Validate type stringMaxLength10, a restriction on xsd:string.
3597
+ if value is not None and Validate_simpletypes_ and self.gds_collector_ is not None:
3598
+ if not isinstance(value, str):
3599
+ lineno = self.gds_get_node_lineno_()
3600
+ self.gds_collector_.add_message('Value "%(value)s"%(lineno)s is not of the correct base simple type (str)' % {"value": value, "lineno": lineno, })
3601
+ return False
3602
+ if len(value) > 10:
3603
+ lineno = self.gds_get_node_lineno_()
3604
+ 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} )
3605
+ result = False
3606
+ return result
3607
+ def validate_stringMinLength2MaxLength2(self, value):
3608
+ result = True
3609
+ # Validate type stringMinLength2MaxLength2, a restriction on xsd:string.
3610
+ if value is not None and Validate_simpletypes_ and self.gds_collector_ is not None:
3611
+ if not isinstance(value, str):
3612
+ lineno = self.gds_get_node_lineno_()
3613
+ self.gds_collector_.add_message('Value "%(value)s"%(lineno)s is not of the correct base simple type (str)' % {"value": value, "lineno": lineno, })
3614
+ return False
3615
+ if len(value) > 2:
3616
+ lineno = self.gds_get_node_lineno_()
3617
+ 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} )
3618
+ result = False
3619
+ if len(value) < 2:
3620
+ lineno = self.gds_get_node_lineno_()
3621
+ 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} )
3622
+ result = False
3623
+ return result
3624
+ def has__content(self):
3625
+ if (
3626
+ self.accountNumber is not None or
3627
+ self.accountCountry is not None
3628
+ ):
3629
+ return True
3630
+ else:
3631
+ return False
3632
+ def export(self, outfile, level, namespaceprefix_='', namespacedef_='', name_='accountType', pretty_print=True):
3633
+ imported_ns_def_ = GenerateDSNamespaceDefs_.get('accountType')
3634
+ if imported_ns_def_ is not None:
3635
+ namespacedef_ = imported_ns_def_
3636
+ if pretty_print:
3637
+ eol_ = '\n'
3638
+ else:
3639
+ eol_ = ''
3640
+ if self.original_tagname_ is not None and name_ == 'accountType':
3641
+ name_ = self.original_tagname_
3642
+ if UseCapturedNS_ and self.ns_prefix_:
3643
+ namespaceprefix_ = self.ns_prefix_ + ':'
3644
+ showIndent(outfile, level, pretty_print)
3645
+ outfile.write('<%s%s%s' % (namespaceprefix_, name_, namespacedef_ and ' ' + namespacedef_ or '', ))
3646
+ already_processed = set()
3647
+ self._exportAttributes(outfile, level, already_processed, namespaceprefix_, name_='accountType')
3648
+ if self.has__content():
3649
+ outfile.write('>%s' % (eol_, ))
3650
+ self._exportChildren(outfile, level + 1, namespaceprefix_, namespacedef_, name_='accountType', pretty_print=pretty_print)
3651
+ showIndent(outfile, level, pretty_print)
3652
+ outfile.write('</%s%s>%s' % (namespaceprefix_, name_, eol_))
3653
+ else:
3654
+ outfile.write('/>%s' % (eol_, ))
3655
+ def _exportAttributes(self, outfile, level, already_processed, namespaceprefix_='', name_='accountType'):
3656
+ pass
3657
+ def _exportChildren(self, outfile, level, namespaceprefix_='', namespacedef_='', name_='accountType', fromsubclass_=False, pretty_print=True):
3658
+ if pretty_print:
3659
+ eol_ = '\n'
3660
+ else:
3661
+ eol_ = ''
3662
+ if self.accountNumber is not None:
3663
+ namespaceprefix_ = self.accountNumber_nsprefix_ + ':' if (UseCapturedNS_ and self.accountNumber_nsprefix_) else ''
3664
+ showIndent(outfile, level, pretty_print)
3665
+ outfile.write('<%saccountNumber>%s</%saccountNumber>%s' % (namespaceprefix_ , self.gds_encode(self.gds_format_string(quote_xml(self.accountNumber), input_name='accountNumber')), namespaceprefix_ , eol_))
3666
+ if self.accountCountry is not None:
3667
+ namespaceprefix_ = self.accountCountry_nsprefix_ + ':' if (UseCapturedNS_ and self.accountCountry_nsprefix_) else ''
3668
+ showIndent(outfile, level, pretty_print)
3669
+ outfile.write('<%saccountCountry>%s</%saccountCountry>%s' % (namespaceprefix_ , self.gds_encode(self.gds_format_string(quote_xml(self.accountCountry), input_name='accountCountry')), namespaceprefix_ , eol_))
3670
+ def build(self, node, gds_collector_=None):
3671
+ self.gds_collector_ = gds_collector_
3672
+ if SaveElementTreeNode:
3673
+ self.gds_elementtree_node_ = node
3674
+ already_processed = set()
3675
+ self.ns_prefix_ = node.prefix
3676
+ self._buildAttributes(node, node.attrib, already_processed)
3677
+ for child in node:
3678
+ nodeName_ = Tag_pattern_.match(child.tag).groups()[-1]
3679
+ self._buildChildren(child, node, nodeName_, gds_collector_=gds_collector_)
3680
+ return self
3681
+ def _buildAttributes(self, node, attrs, already_processed):
3682
+ pass
3683
+ def _buildChildren(self, child_, node, nodeName_, fromsubclass_=False, gds_collector_=None):
3684
+ if nodeName_ == 'accountNumber':
3685
+ value_ = child_.text
3686
+ value_ = self.gds_parse_string(value_, node, 'accountNumber')
3687
+ value_ = self.gds_validate_string(value_, node, 'accountNumber')
3688
+ self.accountNumber = value_
3689
+ self.accountNumber_nsprefix_ = child_.prefix
3690
+ # validate type stringMaxLength10
3691
+ self.validate_stringMaxLength10(self.accountNumber)
3692
+ elif nodeName_ == 'accountCountry':
3693
+ value_ = child_.text
3694
+ value_ = self.gds_parse_string(value_, node, 'accountCountry')
3695
+ value_ = self.gds_validate_string(value_, node, 'accountCountry')
3696
+ self.accountCountry = value_
3697
+ self.accountCountry_nsprefix_ = child_.prefix
3698
+ # validate type stringMinLength2MaxLength2
3699
+ self.validate_stringMinLength2MaxLength2(self.accountCountry)
3700
+ # end class accountType
3701
+
3702
+
3703
+ class depotType(GeneratedsSuper):
3704
+ """depotType -- Details relating to a TNT depot which could be the origin,
3705
+ destination or transit depot on the route calculated by TNT to deliver
3706
+ a consignment.
3707
+ depotCode -- The three character TNT code for the depot.
3708
+
3709
+ """
3710
+ __hash__ = GeneratedsSuper.__hash__
3711
+ subclass = None
3712
+ superclass = None
3713
+ def __init__(self, depotCode=None, gds_collector_=None, **kwargs_):
3714
+ self.gds_collector_ = gds_collector_
3715
+ self.gds_elementtree_node_ = None
3716
+ self.original_tagname_ = None
3717
+ self.parent_object_ = kwargs_.get('parent_object_')
3718
+ self.ns_prefix_ = None
3719
+ self.depotCode = depotCode
3720
+ self.validate_stringMinLength3MaxLength3(self.depotCode)
3721
+ self.depotCode_nsprefix_ = None
3722
+ def factory(*args_, **kwargs_):
3723
+ if CurrentSubclassModule_ is not None:
3724
+ subclass = getSubclassFromModule_(
3725
+ CurrentSubclassModule_, depotType)
3726
+ if subclass is not None:
3727
+ return subclass(*args_, **kwargs_)
3728
+ if depotType.subclass:
3729
+ return depotType.subclass(*args_, **kwargs_)
3730
+ else:
3731
+ return depotType(*args_, **kwargs_)
3732
+ factory = staticmethod(factory)
3733
+ def get_ns_prefix_(self):
3734
+ return self.ns_prefix_
3735
+ def set_ns_prefix_(self, ns_prefix):
3736
+ self.ns_prefix_ = ns_prefix
3737
+ def get_depotCode(self):
3738
+ return self.depotCode
3739
+ def set_depotCode(self, depotCode):
3740
+ self.depotCode = depotCode
3741
+ def validate_stringMinLength3MaxLength3(self, value):
3742
+ result = True
3743
+ # Validate type stringMinLength3MaxLength3, a restriction on xsd:string.
3744
+ if value is not None and Validate_simpletypes_ and self.gds_collector_ is not None:
3745
+ if not isinstance(value, str):
3746
+ lineno = self.gds_get_node_lineno_()
3747
+ self.gds_collector_.add_message('Value "%(value)s"%(lineno)s is not of the correct base simple type (str)' % {"value": value, "lineno": lineno, })
3748
+ return False
3749
+ if len(value) > 3:
3750
+ lineno = self.gds_get_node_lineno_()
3751
+ 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} )
3752
+ result = False
3753
+ if len(value) < 3:
3754
+ lineno = self.gds_get_node_lineno_()
3755
+ 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} )
3756
+ result = False
3757
+ return result
3758
+ def has__content(self):
3759
+ if (
3760
+ self.depotCode is not None
3761
+ ):
3762
+ return True
3763
+ else:
3764
+ return False
3765
+ def export(self, outfile, level, namespaceprefix_='', namespacedef_='', name_='depotType', pretty_print=True):
3766
+ imported_ns_def_ = GenerateDSNamespaceDefs_.get('depotType')
3767
+ if imported_ns_def_ is not None:
3768
+ namespacedef_ = imported_ns_def_
3769
+ if pretty_print:
3770
+ eol_ = '\n'
3771
+ else:
3772
+ eol_ = ''
3773
+ if self.original_tagname_ is not None and name_ == 'depotType':
3774
+ name_ = self.original_tagname_
3775
+ if UseCapturedNS_ and self.ns_prefix_:
3776
+ namespaceprefix_ = self.ns_prefix_ + ':'
3777
+ showIndent(outfile, level, pretty_print)
3778
+ outfile.write('<%s%s%s' % (namespaceprefix_, name_, namespacedef_ and ' ' + namespacedef_ or '', ))
3779
+ already_processed = set()
3780
+ self._exportAttributes(outfile, level, already_processed, namespaceprefix_, name_='depotType')
3781
+ if self.has__content():
3782
+ outfile.write('>%s' % (eol_, ))
3783
+ self._exportChildren(outfile, level + 1, namespaceprefix_, namespacedef_, name_='depotType', pretty_print=pretty_print)
3784
+ showIndent(outfile, level, pretty_print)
3785
+ outfile.write('</%s%s>%s' % (namespaceprefix_, name_, eol_))
3786
+ else:
3787
+ outfile.write('/>%s' % (eol_, ))
3788
+ def _exportAttributes(self, outfile, level, already_processed, namespaceprefix_='', name_='depotType'):
3789
+ pass
3790
+ def _exportChildren(self, outfile, level, namespaceprefix_='', namespacedef_='', name_='depotType', fromsubclass_=False, pretty_print=True):
3791
+ if pretty_print:
3792
+ eol_ = '\n'
3793
+ else:
3794
+ eol_ = ''
3795
+ if self.depotCode is not None:
3796
+ namespaceprefix_ = self.depotCode_nsprefix_ + ':' if (UseCapturedNS_ and self.depotCode_nsprefix_) else ''
3797
+ showIndent(outfile, level, pretty_print)
3798
+ outfile.write('<%sdepotCode>%s</%sdepotCode>%s' % (namespaceprefix_ , self.gds_encode(self.gds_format_string(quote_xml(self.depotCode), input_name='depotCode')), namespaceprefix_ , eol_))
3799
+ def build(self, node, gds_collector_=None):
3800
+ self.gds_collector_ = gds_collector_
3801
+ if SaveElementTreeNode:
3802
+ self.gds_elementtree_node_ = node
3803
+ already_processed = set()
3804
+ self.ns_prefix_ = node.prefix
3805
+ self._buildAttributes(node, node.attrib, already_processed)
3806
+ for child in node:
3807
+ nodeName_ = Tag_pattern_.match(child.tag).groups()[-1]
3808
+ self._buildChildren(child, node, nodeName_, gds_collector_=gds_collector_)
3809
+ return self
3810
+ def _buildAttributes(self, node, attrs, already_processed):
3811
+ pass
3812
+ def _buildChildren(self, child_, node, nodeName_, fromsubclass_=False, gds_collector_=None):
3813
+ if nodeName_ == 'depotCode':
3814
+ value_ = child_.text
3815
+ value_ = self.gds_parse_string(value_, node, 'depotCode')
3816
+ value_ = self.gds_validate_string(value_, node, 'depotCode')
3817
+ self.depotCode = value_
3818
+ self.depotCode_nsprefix_ = child_.prefix
3819
+ # validate type stringMinLength3MaxLength3
3820
+ self.validate_stringMinLength3MaxLength3(self.depotCode)
3821
+ # end class depotType
3822
+
3823
+
3824
+ class marketType(GeneratedsSuper):
3825
+ """marketType -- This identifies the market type for the consignment comprising the origin
3826
+ country and whether the consignment is being shipped domestically or
3827
+ internationally and within which international trading block, e.g. 'EU'.
3828
+ originCountryCode -- The ISO country code for the origin country of the consignment.
3829
+ marketSpecification -- The market for the consignment - i.e. whether it is being shipped
3830
+ domestically or internationally, and, if the latter, in which trade
3831
+ block, e.g. EU, ROW, etc.
3832
+
3833
+ """
3834
+ __hash__ = GeneratedsSuper.__hash__
3835
+ subclass = None
3836
+ superclass = None
3837
+ def __init__(self, originCountryCode=None, marketSpecification=None, gds_collector_=None, **kwargs_):
3838
+ self.gds_collector_ = gds_collector_
3839
+ self.gds_elementtree_node_ = None
3840
+ self.original_tagname_ = None
3841
+ self.parent_object_ = kwargs_.get('parent_object_')
3842
+ self.ns_prefix_ = None
3843
+ self.originCountryCode = originCountryCode
3844
+ self.validate_stringMinLength2MaxLength2(self.originCountryCode)
3845
+ self.originCountryCode_nsprefix_ = None
3846
+ self.marketSpecification = marketSpecification
3847
+ self.marketSpecification_nsprefix_ = None
3848
+ def factory(*args_, **kwargs_):
3849
+ if CurrentSubclassModule_ is not None:
3850
+ subclass = getSubclassFromModule_(
3851
+ CurrentSubclassModule_, marketType)
3852
+ if subclass is not None:
3853
+ return subclass(*args_, **kwargs_)
3854
+ if marketType.subclass:
3855
+ return marketType.subclass(*args_, **kwargs_)
3856
+ else:
3857
+ return marketType(*args_, **kwargs_)
3858
+ factory = staticmethod(factory)
3859
+ def get_ns_prefix_(self):
3860
+ return self.ns_prefix_
3861
+ def set_ns_prefix_(self, ns_prefix):
3862
+ self.ns_prefix_ = ns_prefix
3863
+ def get_originCountryCode(self):
3864
+ return self.originCountryCode
3865
+ def set_originCountryCode(self, originCountryCode):
3866
+ self.originCountryCode = originCountryCode
3867
+ def get_marketSpecification(self):
3868
+ return self.marketSpecification
3869
+ def set_marketSpecification(self, marketSpecification):
3870
+ self.marketSpecification = marketSpecification
3871
+ def validate_stringMinLength2MaxLength2(self, value):
3872
+ result = True
3873
+ # Validate type stringMinLength2MaxLength2, a restriction on xsd:string.
3874
+ if value is not None and Validate_simpletypes_ and self.gds_collector_ is not None:
3875
+ if not isinstance(value, str):
3876
+ lineno = self.gds_get_node_lineno_()
3877
+ self.gds_collector_.add_message('Value "%(value)s"%(lineno)s is not of the correct base simple type (str)' % {"value": value, "lineno": lineno, })
3878
+ return False
3879
+ if len(value) > 2:
3880
+ lineno = self.gds_get_node_lineno_()
3881
+ 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} )
3882
+ result = False
3883
+ if len(value) < 2:
3884
+ lineno = self.gds_get_node_lineno_()
3885
+ 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} )
3886
+ result = False
3887
+ return result
3888
+ def has__content(self):
3889
+ if (
3890
+ self.originCountryCode is not None or
3891
+ self.marketSpecification is not None
3892
+ ):
3893
+ return True
3894
+ else:
3895
+ return False
3896
+ def export(self, outfile, level, namespaceprefix_='', namespacedef_='', name_='marketType', pretty_print=True):
3897
+ imported_ns_def_ = GenerateDSNamespaceDefs_.get('marketType')
3898
+ if imported_ns_def_ is not None:
3899
+ namespacedef_ = imported_ns_def_
3900
+ if pretty_print:
3901
+ eol_ = '\n'
3902
+ else:
3903
+ eol_ = ''
3904
+ if self.original_tagname_ is not None and name_ == 'marketType':
3905
+ name_ = self.original_tagname_
3906
+ if UseCapturedNS_ and self.ns_prefix_:
3907
+ namespaceprefix_ = self.ns_prefix_ + ':'
3908
+ showIndent(outfile, level, pretty_print)
3909
+ outfile.write('<%s%s%s' % (namespaceprefix_, name_, namespacedef_ and ' ' + namespacedef_ or '', ))
3910
+ already_processed = set()
3911
+ self._exportAttributes(outfile, level, already_processed, namespaceprefix_, name_='marketType')
3912
+ if self.has__content():
3913
+ outfile.write('>%s' % (eol_, ))
3914
+ self._exportChildren(outfile, level + 1, namespaceprefix_, namespacedef_, name_='marketType', pretty_print=pretty_print)
3915
+ showIndent(outfile, level, pretty_print)
3916
+ outfile.write('</%s%s>%s' % (namespaceprefix_, name_, eol_))
3917
+ else:
3918
+ outfile.write('/>%s' % (eol_, ))
3919
+ def _exportAttributes(self, outfile, level, already_processed, namespaceprefix_='', name_='marketType'):
3920
+ pass
3921
+ def _exportChildren(self, outfile, level, namespaceprefix_='', namespacedef_='', name_='marketType', fromsubclass_=False, pretty_print=True):
3922
+ if pretty_print:
3923
+ eol_ = '\n'
3924
+ else:
3925
+ eol_ = ''
3926
+ if self.originCountryCode is not None:
3927
+ namespaceprefix_ = self.originCountryCode_nsprefix_ + ':' if (UseCapturedNS_ and self.originCountryCode_nsprefix_) else ''
3928
+ showIndent(outfile, level, pretty_print)
3929
+ outfile.write('<%soriginCountryCode>%s</%soriginCountryCode>%s' % (namespaceprefix_ , self.gds_encode(self.gds_format_string(quote_xml(self.originCountryCode), input_name='originCountryCode')), namespaceprefix_ , eol_))
3930
+ if self.marketSpecification is not None:
3931
+ namespaceprefix_ = self.marketSpecification_nsprefix_ + ':' if (UseCapturedNS_ and self.marketSpecification_nsprefix_) else ''
3932
+ showIndent(outfile, level, pretty_print)
3933
+ outfile.write('<%smarketSpecification>%s</%smarketSpecification>%s' % (namespaceprefix_ , self.gds_encode(self.gds_format_string(quote_xml(self.marketSpecification), input_name='marketSpecification')), namespaceprefix_ , eol_))
3934
+ def build(self, node, gds_collector_=None):
3935
+ self.gds_collector_ = gds_collector_
3936
+ if SaveElementTreeNode:
3937
+ self.gds_elementtree_node_ = node
3938
+ already_processed = set()
3939
+ self.ns_prefix_ = node.prefix
3940
+ self._buildAttributes(node, node.attrib, already_processed)
3941
+ for child in node:
3942
+ nodeName_ = Tag_pattern_.match(child.tag).groups()[-1]
3943
+ self._buildChildren(child, node, nodeName_, gds_collector_=gds_collector_)
3944
+ return self
3945
+ def _buildAttributes(self, node, attrs, already_processed):
3946
+ pass
3947
+ def _buildChildren(self, child_, node, nodeName_, fromsubclass_=False, gds_collector_=None):
3948
+ if nodeName_ == 'originCountryCode':
3949
+ value_ = child_.text
3950
+ value_ = self.gds_parse_string(value_, node, 'originCountryCode')
3951
+ value_ = self.gds_validate_string(value_, node, 'originCountryCode')
3952
+ self.originCountryCode = value_
3953
+ self.originCountryCode_nsprefix_ = child_.prefix
3954
+ # validate type stringMinLength2MaxLength2
3955
+ self.validate_stringMinLength2MaxLength2(self.originCountryCode)
3956
+ elif nodeName_ == 'marketSpecification':
3957
+ value_ = child_.text
3958
+ value_ = self.gds_parse_string(value_, node, 'marketSpecification')
3959
+ value_ = self.gds_validate_string(value_, node, 'marketSpecification')
3960
+ self.marketSpecification = value_
3961
+ self.marketSpecification_nsprefix_ = child_.prefix
3962
+ # end class marketType
3963
+
3964
+
3965
+ class brokenRules(GeneratedsSuper):
3966
+ """brokenRules -- List of business rules that have been breached by the input and that will
3967
+ require the user to correct in order to print labels on resubmission of
3968
+ XML input file.
3969
+ key -- RequestId number to which the error relates.
3970
+ errorCode -- Error code returned by the system to identify the error message.
3971
+ errorDescription -- Error description returned by the system to signify the data
3972
+ that needs to be corrected in order to print labels.
3973
+
3974
+ """
3975
+ __hash__ = GeneratedsSuper.__hash__
3976
+ subclass = None
3977
+ superclass = None
3978
+ def __init__(self, key=None, errorCode=None, errorDescription=None, gds_collector_=None, **kwargs_):
3979
+ self.gds_collector_ = gds_collector_
3980
+ self.gds_elementtree_node_ = None
3981
+ self.original_tagname_ = None
3982
+ self.parent_object_ = kwargs_.get('parent_object_')
3983
+ self.ns_prefix_ = None
3984
+ self.key = _cast(None, key)
3985
+ self.key_nsprefix_ = None
3986
+ self.errorCode = errorCode
3987
+ self.errorCode_nsprefix_ = None
3988
+ self.errorDescription = errorDescription
3989
+ self.errorDescription_nsprefix_ = None
3990
+ def factory(*args_, **kwargs_):
3991
+ if CurrentSubclassModule_ is not None:
3992
+ subclass = getSubclassFromModule_(
3993
+ CurrentSubclassModule_, brokenRules)
3994
+ if subclass is not None:
3995
+ return subclass(*args_, **kwargs_)
3996
+ if brokenRules.subclass:
3997
+ return brokenRules.subclass(*args_, **kwargs_)
3998
+ else:
3999
+ return brokenRules(*args_, **kwargs_)
4000
+ factory = staticmethod(factory)
4001
+ def get_ns_prefix_(self):
4002
+ return self.ns_prefix_
4003
+ def set_ns_prefix_(self, ns_prefix):
4004
+ self.ns_prefix_ = ns_prefix
4005
+ def get_errorCode(self):
4006
+ return self.errorCode
4007
+ def set_errorCode(self, errorCode):
4008
+ self.errorCode = errorCode
4009
+ def get_errorDescription(self):
4010
+ return self.errorDescription
4011
+ def set_errorDescription(self, errorDescription):
4012
+ self.errorDescription = errorDescription
4013
+ def get_key(self):
4014
+ return self.key
4015
+ def set_key(self, key):
4016
+ self.key = key
4017
+ def has__content(self):
4018
+ if (
4019
+ self.errorCode is not None or
4020
+ self.errorDescription is not None
4021
+ ):
4022
+ return True
4023
+ else:
4024
+ return False
4025
+ def export(self, outfile, level, namespaceprefix_='', namespacedef_='', name_='brokenRules', pretty_print=True):
4026
+ imported_ns_def_ = GenerateDSNamespaceDefs_.get('brokenRules')
4027
+ if imported_ns_def_ is not None:
4028
+ namespacedef_ = imported_ns_def_
4029
+ if pretty_print:
4030
+ eol_ = '\n'
4031
+ else:
4032
+ eol_ = ''
4033
+ if self.original_tagname_ is not None and name_ == 'brokenRules':
4034
+ name_ = self.original_tagname_
4035
+ if UseCapturedNS_ and self.ns_prefix_:
4036
+ namespaceprefix_ = self.ns_prefix_ + ':'
4037
+ showIndent(outfile, level, pretty_print)
4038
+ outfile.write('<%s%s%s' % (namespaceprefix_, name_, namespacedef_ and ' ' + namespacedef_ or '', ))
4039
+ already_processed = set()
4040
+ self._exportAttributes(outfile, level, already_processed, namespaceprefix_, name_='brokenRules')
4041
+ if self.has__content():
4042
+ outfile.write('>%s' % (eol_, ))
4043
+ self._exportChildren(outfile, level + 1, namespaceprefix_, namespacedef_, name_='brokenRules', pretty_print=pretty_print)
4044
+ showIndent(outfile, level, pretty_print)
4045
+ outfile.write('</%s%s>%s' % (namespaceprefix_, name_, eol_))
4046
+ else:
4047
+ outfile.write('/>%s' % (eol_, ))
4048
+ def _exportAttributes(self, outfile, level, already_processed, namespaceprefix_='', name_='brokenRules'):
4049
+ if self.key is not None and 'key' not in already_processed:
4050
+ already_processed.add('key')
4051
+ outfile.write(' key=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.key), input_name='key')), ))
4052
+ def _exportChildren(self, outfile, level, namespaceprefix_='', namespacedef_='', name_='brokenRules', fromsubclass_=False, pretty_print=True):
4053
+ if pretty_print:
4054
+ eol_ = '\n'
4055
+ else:
4056
+ eol_ = ''
4057
+ if self.errorCode is not None:
4058
+ namespaceprefix_ = self.errorCode_nsprefix_ + ':' if (UseCapturedNS_ and self.errorCode_nsprefix_) else ''
4059
+ showIndent(outfile, level, pretty_print)
4060
+ outfile.write('<%serrorCode>%s</%serrorCode>%s' % (namespaceprefix_ , self.gds_format_integer(self.errorCode, input_name='errorCode'), namespaceprefix_ , eol_))
4061
+ if self.errorDescription is not None:
4062
+ namespaceprefix_ = self.errorDescription_nsprefix_ + ':' if (UseCapturedNS_ and self.errorDescription_nsprefix_) else ''
4063
+ showIndent(outfile, level, pretty_print)
4064
+ outfile.write('<%serrorDescription>%s</%serrorDescription>%s' % (namespaceprefix_ , self.gds_encode(self.gds_format_string(quote_xml(self.errorDescription), input_name='errorDescription')), namespaceprefix_ , eol_))
4065
+ def build(self, node, gds_collector_=None):
4066
+ self.gds_collector_ = gds_collector_
4067
+ if SaveElementTreeNode:
4068
+ self.gds_elementtree_node_ = node
4069
+ already_processed = set()
4070
+ self.ns_prefix_ = node.prefix
4071
+ self._buildAttributes(node, node.attrib, already_processed)
4072
+ for child in node:
4073
+ nodeName_ = Tag_pattern_.match(child.tag).groups()[-1]
4074
+ self._buildChildren(child, node, nodeName_, gds_collector_=gds_collector_)
4075
+ return self
4076
+ def _buildAttributes(self, node, attrs, already_processed):
4077
+ value = find_attr_value_('key', node)
4078
+ if value is not None and 'key' not in already_processed:
4079
+ already_processed.add('key')
4080
+ self.key = value
4081
+ def _buildChildren(self, child_, node, nodeName_, fromsubclass_=False, gds_collector_=None):
4082
+ if nodeName_ == 'errorCode' and child_.text:
4083
+ sval_ = child_.text
4084
+ ival_ = self.gds_parse_integer(sval_, node, 'errorCode')
4085
+ ival_ = self.gds_validate_integer(ival_, node, 'errorCode')
4086
+ self.errorCode = ival_
4087
+ self.errorCode_nsprefix_ = child_.prefix
4088
+ elif nodeName_ == 'errorDescription':
4089
+ value_ = child_.text
4090
+ value_ = self.gds_parse_string(value_, node, 'errorDescription')
4091
+ value_ = self.gds_validate_string(value_, node, 'errorDescription')
4092
+ self.errorDescription = value_
4093
+ self.errorDescription_nsprefix_ = child_.prefix
4094
+ # end class brokenRules
4095
+
4096
+
4097
+ class fault(GeneratedsSuper):
4098
+ """fault -- List of faults that have occured during teh processign of multiple requests
4099
+ key -- RequestId number to which the fault relates.
4100
+
4101
+ """
4102
+ __hash__ = GeneratedsSuper.__hash__
4103
+ subclass = None
4104
+ superclass = None
4105
+ def __init__(self, key=None, gds_collector_=None, **kwargs_):
4106
+ self.gds_collector_ = gds_collector_
4107
+ self.gds_elementtree_node_ = None
4108
+ self.original_tagname_ = None
4109
+ self.parent_object_ = kwargs_.get('parent_object_')
4110
+ self.ns_prefix_ = None
4111
+ self.key = _cast(None, key)
4112
+ self.key_nsprefix_ = None
4113
+ def factory(*args_, **kwargs_):
4114
+ if CurrentSubclassModule_ is not None:
4115
+ subclass = getSubclassFromModule_(
4116
+ CurrentSubclassModule_, fault)
4117
+ if subclass is not None:
4118
+ return subclass(*args_, **kwargs_)
4119
+ if fault.subclass:
4120
+ return fault.subclass(*args_, **kwargs_)
4121
+ else:
4122
+ return fault(*args_, **kwargs_)
4123
+ factory = staticmethod(factory)
4124
+ def get_ns_prefix_(self):
4125
+ return self.ns_prefix_
4126
+ def set_ns_prefix_(self, ns_prefix):
4127
+ self.ns_prefix_ = ns_prefix
4128
+ def get_key(self):
4129
+ return self.key
4130
+ def set_key(self, key):
4131
+ self.key = key
4132
+ def has__content(self):
4133
+ if (
4134
+
4135
+ ):
4136
+ return True
4137
+ else:
4138
+ return False
4139
+ def export(self, outfile, level, namespaceprefix_='', namespacedef_='', name_='fault', pretty_print=True):
4140
+ imported_ns_def_ = GenerateDSNamespaceDefs_.get('fault')
4141
+ if imported_ns_def_ is not None:
4142
+ namespacedef_ = imported_ns_def_
4143
+ if pretty_print:
4144
+ eol_ = '\n'
4145
+ else:
4146
+ eol_ = ''
4147
+ if self.original_tagname_ is not None and name_ == 'fault':
4148
+ name_ = self.original_tagname_
4149
+ if UseCapturedNS_ and self.ns_prefix_:
4150
+ namespaceprefix_ = self.ns_prefix_ + ':'
4151
+ showIndent(outfile, level, pretty_print)
4152
+ outfile.write('<%s%s%s' % (namespaceprefix_, name_, namespacedef_ and ' ' + namespacedef_ or '', ))
4153
+ already_processed = set()
4154
+ self._exportAttributes(outfile, level, already_processed, namespaceprefix_, name_='fault')
4155
+ if self.has__content():
4156
+ outfile.write('>%s' % (eol_, ))
4157
+ self._exportChildren(outfile, level + 1, namespaceprefix_, namespacedef_, name_='fault', pretty_print=pretty_print)
4158
+ outfile.write('</%s%s>%s' % (namespaceprefix_, name_, eol_))
4159
+ else:
4160
+ outfile.write('/>%s' % (eol_, ))
4161
+ def _exportAttributes(self, outfile, level, already_processed, namespaceprefix_='', name_='fault'):
4162
+ if self.key is not None and 'key' not in already_processed:
4163
+ already_processed.add('key')
4164
+ outfile.write(' key=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.key), input_name='key')), ))
4165
+ def _exportChildren(self, outfile, level, namespaceprefix_='', namespacedef_='', name_='fault', fromsubclass_=False, pretty_print=True):
4166
+ pass
4167
+ def build(self, node, gds_collector_=None):
4168
+ self.gds_collector_ = gds_collector_
4169
+ if SaveElementTreeNode:
4170
+ self.gds_elementtree_node_ = node
4171
+ already_processed = set()
4172
+ self.ns_prefix_ = node.prefix
4173
+ self._buildAttributes(node, node.attrib, already_processed)
4174
+ for child in node:
4175
+ nodeName_ = Tag_pattern_.match(child.tag).groups()[-1]
4176
+ self._buildChildren(child, node, nodeName_, gds_collector_=gds_collector_)
4177
+ return self
4178
+ def _buildAttributes(self, node, attrs, already_processed):
4179
+ value = find_attr_value_('key', node)
4180
+ if value is not None and 'key' not in already_processed:
4181
+ already_processed.add('key')
4182
+ self.key = value
4183
+ def _buildChildren(self, child_, node, nodeName_, fromsubclass_=False, gds_collector_=None):
4184
+ pass
4185
+ # end class fault
4186
+
4187
+
4188
+ #
4189
+ # End data representation classes.
4190
+ #
4191
+
4192
+
4193
+ GDSClassesMapping = {
4194
+ }
4195
+
4196
+
4197
+ USAGE_TEXT = """
4198
+ Usage: python <Parser>.py [ -s ] <in_xml_file>
4199
+ """
4200
+
4201
+
4202
+ def usage():
4203
+ print(USAGE_TEXT)
4204
+ sys.exit(1)
4205
+
4206
+
4207
+ def get_root_tag(node):
4208
+ tag = Tag_pattern_.match(node.tag).groups()[-1]
4209
+ prefix_tag = TagNamePrefix + tag
4210
+ rootClass = GDSClassesMapping.get(prefix_tag)
4211
+ if rootClass is None:
4212
+ rootClass = globals().get(prefix_tag)
4213
+ return tag, rootClass
4214
+
4215
+
4216
+ def get_required_ns_prefix_defs(rootNode):
4217
+ '''Get all name space prefix definitions required in this XML doc.
4218
+ Return a dictionary of definitions and a char string of definitions.
4219
+ '''
4220
+ nsmap = {
4221
+ prefix: uri
4222
+ for node in rootNode.iter()
4223
+ for (prefix, uri) in node.nsmap.items()
4224
+ if prefix is not None
4225
+ }
4226
+ namespacedefs = ' '.join([
4227
+ 'xmlns:{}="{}"'.format(prefix, uri)
4228
+ for prefix, uri in nsmap.items()
4229
+ ])
4230
+ return nsmap, namespacedefs
4231
+
4232
+
4233
+ def parse(inFileName, silence=False, print_warnings=True):
4234
+ global CapturedNsmap_
4235
+ gds_collector = GdsCollector_()
4236
+ parser = None
4237
+ doc = parsexml_(inFileName, parser)
4238
+ rootNode = doc.getroot()
4239
+ rootTag, rootClass = get_root_tag(rootNode)
4240
+ if rootClass is None:
4241
+ rootTag = 'labelRequest'
4242
+ rootClass = labelRequest
4243
+ rootObj = rootClass.factory()
4244
+ rootObj.build(rootNode, gds_collector_=gds_collector)
4245
+ CapturedNsmap_, namespacedefs = get_required_ns_prefix_defs(rootNode)
4246
+ if not SaveElementTreeNode:
4247
+ doc = None
4248
+ rootNode = None
4249
+ if not silence:
4250
+ sys.stdout.write('<?xml version="1.0" ?>\n')
4251
+ rootObj.export(
4252
+ sys.stdout, 0, name_=rootTag,
4253
+ namespacedef_=namespacedefs,
4254
+ pretty_print=True)
4255
+ if print_warnings and len(gds_collector.get_messages()) > 0:
4256
+ separator = ('-' * 50) + '\n'
4257
+ sys.stderr.write(separator)
4258
+ sys.stderr.write('----- Warnings -- count: {} -----\n'.format(
4259
+ len(gds_collector.get_messages()), ))
4260
+ gds_collector.write_messages(sys.stderr)
4261
+ sys.stderr.write(separator)
4262
+ return rootObj
4263
+
4264
+
4265
+ def parseEtree(inFileName, silence=False, print_warnings=True,
4266
+ mapping=None, reverse_mapping=None, nsmap=None):
4267
+ parser = None
4268
+ doc = parsexml_(inFileName, parser)
4269
+ gds_collector = GdsCollector_()
4270
+ rootNode = doc.getroot()
4271
+ rootTag, rootClass = get_root_tag(rootNode)
4272
+ if rootClass is None:
4273
+ rootTag = 'labelRequest'
4274
+ rootClass = labelRequest
4275
+ rootObj = rootClass.factory()
4276
+ rootObj.build(rootNode, gds_collector_=gds_collector)
4277
+ if mapping is None:
4278
+ mapping = {}
4279
+ if reverse_mapping is None:
4280
+ reverse_mapping = {}
4281
+ rootElement = rootObj.to_etree(
4282
+ None, name_=rootTag, mapping_=mapping,
4283
+ reverse_mapping_=reverse_mapping, nsmap_=nsmap)
4284
+ reverse_node_mapping = rootObj.gds_reverse_node_mapping(mapping)
4285
+ # Enable Python to collect the space used by the DOM.
4286
+ if not SaveElementTreeNode:
4287
+ doc = None
4288
+ rootNode = None
4289
+ if not silence:
4290
+ content = etree_.tostring(
4291
+ rootElement, pretty_print=True,
4292
+ xml_declaration=True, encoding="utf-8")
4293
+ sys.stdout.write(str(content))
4294
+ sys.stdout.write('\n')
4295
+ if print_warnings and len(gds_collector.get_messages()) > 0:
4296
+ separator = ('-' * 50) + '\n'
4297
+ sys.stderr.write(separator)
4298
+ sys.stderr.write('----- Warnings -- count: {} -----\n'.format(
4299
+ len(gds_collector.get_messages()), ))
4300
+ gds_collector.write_messages(sys.stderr)
4301
+ sys.stderr.write(separator)
4302
+ return rootObj, rootElement, mapping, reverse_node_mapping
4303
+
4304
+
4305
+ def parseString(inString, silence=False, print_warnings=True):
4306
+ '''Parse a string, create the object tree, and export it.
4307
+
4308
+ Arguments:
4309
+ - inString -- A string. This XML fragment should not start
4310
+ with an XML declaration containing an encoding.
4311
+ - silence -- A boolean. If False, export the object.
4312
+ Returns -- The root object in the tree.
4313
+ '''
4314
+ parser = None
4315
+ rootNode= parsexmlstring_(inString, parser)
4316
+ gds_collector = GdsCollector_()
4317
+ rootTag, rootClass = get_root_tag(rootNode)
4318
+ if rootClass is None:
4319
+ rootTag = 'labelRequest'
4320
+ rootClass = labelRequest
4321
+ rootObj = rootClass.factory()
4322
+ rootObj.build(rootNode, gds_collector_=gds_collector)
4323
+ if not SaveElementTreeNode:
4324
+ rootNode = None
4325
+ if not silence:
4326
+ sys.stdout.write('<?xml version="1.0" ?>\n')
4327
+ rootObj.export(
4328
+ sys.stdout, 0, name_=rootTag,
4329
+ namespacedef_='')
4330
+ if print_warnings and len(gds_collector.get_messages()) > 0:
4331
+ separator = ('-' * 50) + '\n'
4332
+ sys.stderr.write(separator)
4333
+ sys.stderr.write('----- Warnings -- count: {} -----\n'.format(
4334
+ len(gds_collector.get_messages()), ))
4335
+ gds_collector.write_messages(sys.stderr)
4336
+ sys.stderr.write(separator)
4337
+ return rootObj
4338
+
4339
+
4340
+ def parseLiteral(inFileName, silence=False, print_warnings=True):
4341
+ parser = None
4342
+ doc = parsexml_(inFileName, parser)
4343
+ gds_collector = GdsCollector_()
4344
+ rootNode = doc.getroot()
4345
+ rootTag, rootClass = get_root_tag(rootNode)
4346
+ if rootClass is None:
4347
+ rootTag = 'labelRequest'
4348
+ rootClass = labelRequest
4349
+ rootObj = rootClass.factory()
4350
+ rootObj.build(rootNode, gds_collector_=gds_collector)
4351
+ # Enable Python to collect the space used by the DOM.
4352
+ if not SaveElementTreeNode:
4353
+ doc = None
4354
+ rootNode = None
4355
+ if not silence:
4356
+ sys.stdout.write('#from label_request import *\n\n')
4357
+ sys.stdout.write('import label_request as model_\n\n')
4358
+ sys.stdout.write('rootObj = model_.rootClass(\n')
4359
+ rootObj.exportLiteral(sys.stdout, 0, name_=rootTag)
4360
+ sys.stdout.write(')\n')
4361
+ if print_warnings and len(gds_collector.get_messages()) > 0:
4362
+ separator = ('-' * 50) + '\n'
4363
+ sys.stderr.write(separator)
4364
+ sys.stderr.write('----- Warnings -- count: {} -----\n'.format(
4365
+ len(gds_collector.get_messages()), ))
4366
+ gds_collector.write_messages(sys.stderr)
4367
+ sys.stderr.write(separator)
4368
+ return rootObj
4369
+
4370
+
4371
+ def main():
4372
+ args = sys.argv[1:]
4373
+ if len(args) == 1:
4374
+ parse(args[0])
4375
+ else:
4376
+ usage()
4377
+
4378
+
4379
+ if __name__ == '__main__':
4380
+ #import pdb; pdb.set_trace()
4381
+ main()
4382
+
4383
+ RenameMappings_ = {
4384
+ }
4385
+
4386
+ #
4387
+ # Mapping of namespaces to types defined in them
4388
+ # and the file in which each is defined.
4389
+ # simpleTypes are marked "ST" and complexTypes "CT".
4390
+ NamespaceToDefMappings_ = {}
4391
+
4392
+ __all__ = [
4393
+ "accountType",
4394
+ "brokenRules",
4395
+ "consignmentIdentityType",
4396
+ "contactType",
4397
+ "depotType",
4398
+ "fault",
4399
+ "labelConsignmentsType",
4400
+ "labelRequest",
4401
+ "marketType",
4402
+ "measurementsType",
4403
+ "nameAndAddressRequestType",
4404
+ "nameAndAddressResponseType",
4405
+ "optionType",
4406
+ "pieceLineType",
4407
+ "pieceType",
4408
+ "productType"
4409
+ ]