ocrd_models.ocrd_page_generateds.parsexml_()   A
last analyzed

Complexity

Conditions 5

Size

Total Lines 16
Code Lines 13

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 13
dl 0
loc 16
rs 9.2833
c 0
b 0
f 0
cc 5
nop 3
1
#!/usr/bin/env python
2
# -*- coding: utf-8 -*-
3
4
#
5
# Generated Mon Feb 17 10:32:54 2025 by generateDS.py version 2.44.1.
6
# Python 3.8.17+ (heads/3.8-dirty:1663f8ba84, Aug 15 2023, 18:13:01)  [GCC 8.3.0]
7
#
8
# Command line options:
9
#   ('-f', '')
10
#   ('--root-element', 'PcGts')
11
#   ('-o', 'src/ocrd_models/ocrd_page_generateds.py')
12
#   ('--silence', '')
13
#   ('--export', 'write etree')
14
#   ('--disable-generatedssuper-lookup', '')
15
#   ('--user-methods', 'src/ocrd_page_user_methods.py')
16
#
17
# Command line arguments:
18
#   src/ocrd_validators/page.xsd
19
#
20
# Command line:
21
#   /data/ocr-d/ocrd_all/venv38/bin/generateDS -f --root-element="PcGts" -o "src/ocrd_models/ocrd_page_generateds.py" --silence --export="write etree" --disable-generatedssuper-lookup --user-methods="src/ocrd_page_user_methods.py" src/ocrd_validators/page.xsd
22
#
23
# Current working directory (os.getcwd()):
24
#   core
25
#
26
27
import sys
28
try:
29
    ModulenotfoundExp_ = ModuleNotFoundError
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable ModuleNotFoundError does not seem to be defined.
Loading history...
30
except NameError:
31
    ModulenotfoundExp_ = ImportError
32
from itertools import zip_longest
33
import os
34
import re as re_
35
import base64
36
import datetime as datetime_
37
import decimal as decimal_
38
from lxml import etree as etree_
39
40
41
Validate_simpletypes_ = True
42
SaveElementTreeNode = True
43
TagNamePrefix = ""
44
if sys.version_info.major == 2:
45
    BaseStrType_ = basestring
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable basestring does not seem to be defined.
Loading history...
46
else:
47
    BaseStrType_ = str
48
49
50
def parsexml_(infile, parser=None, **kwargs):
51
    if parser is None:
52
        # Use the lxml ElementTree compatible parser so that, e.g.,
53
        #   we ignore comments.
54
        try:
55
            parser = etree_.ETCompatXMLParser()
56
        except AttributeError:
57
            # fallback to xml.etree
58
            parser = etree_.XMLParser()
59
    try:
60
        if isinstance(infile, os.PathLike):
61
            infile = os.path.join(infile)
62
    except AttributeError:
63
        pass
64
    doc = etree_.parse(infile, parser=parser, **kwargs)
65
    return doc
66
67
def parsexmlstring_(instring, parser=None, **kwargs):
68
    if parser is None:
69
        # Use the lxml ElementTree compatible parser so that, e.g.,
70
        #   we ignore comments.
71
        try:
72
            parser = etree_.ETCompatXMLParser()
73
        except AttributeError:
74
            # fallback to xml.etree
75
            parser = etree_.XMLParser()
76
    element = etree_.fromstring(instring, parser=parser, **kwargs)
77
    return element
78
79
#
80
# Namespace prefix definition table (and other attributes, too)
81
#
82
# The module generatedsnamespaces, if it is importable, must contain
83
# a dictionary named GeneratedsNamespaceDefs.  This Python dictionary
84
# should map element type names (strings) to XML schema namespace prefix
85
# definitions.  The export method for any class for which there is
86
# a namespace prefix definition, will export that definition in the
87
# XML representation of that element.  See the export method of
88
# any generated element type class for an example of the use of this
89
# table.
90
# A sample table is:
91
#
92
#     # File: generatedsnamespaces.py
93
#
94
#     GenerateDSNamespaceDefs = {
95
#         "ElementtypeA": "http://www.xxx.com/namespaceA",
96
#         "ElementtypeB": "http://www.xxx.com/namespaceB",
97
#     }
98
#
99
# Additionally, the generatedsnamespaces module can contain a python
100
# dictionary named GenerateDSNamespaceTypePrefixes that associates element
101
# types with the namespace prefixes that are to be added to the
102
# "xsi:type" attribute value.  See the _exportAttributes method of
103
# any generated element type and the generation of "xsi:type" for an
104
# example of the use of this table.
105
# An example table:
106
#
107
#     # File: generatedsnamespaces.py
108
#
109
#     GenerateDSNamespaceTypePrefixes = {
110
#         "ElementtypeC": "aaa:",
111
#         "ElementtypeD": "bbb:",
112
#     }
113
#
114
115
try:
116
    from generatedsnamespaces import GenerateDSNamespaceDefs as GenerateDSNamespaceDefs_
117
except ModulenotfoundExp_ :
118
    GenerateDSNamespaceDefs_ = {}
119
try:
120
    from generatedsnamespaces import GenerateDSNamespaceTypePrefixes as GenerateDSNamespaceTypePrefixes_
121
except ModulenotfoundExp_ :
122
    GenerateDSNamespaceTypePrefixes_ = {}
123
124
#
125
# You can replace the following class definition by defining an
126
# importable module named "generatedscollector" containing a class
127
# named "GdsCollector".  See the default class definition below for
128
# clues about the possible content of that class.
129
#
130
try:
131
    from generatedscollector import GdsCollector as GdsCollector_
132
except ModulenotfoundExp_ :
133
134
    class GdsCollector_(object):
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable object does not seem to be defined.
Loading history...
135
136
        def __init__(self, messages=None):
137
            if messages is None:
138
                self.messages = []
139
            else:
140
                self.messages = messages
141
142
        def add_message(self, msg):
143
            self.messages.append(msg)
144
145
        def get_messages(self):
146
            return self.messages
147
148
        def clear_messages(self):
149
            self.messages = []
150
151
        def print_messages(self):
152
            for msg in self.messages:
153
                print("Warning: {}".format(msg))
154
155
        def write_messages(self, outstream):
156
            for msg in self.messages:
157
                outstream.write("Warning: {}\n".format(msg))
158
159
160
#
161
# The super-class for enum types
162
#
163
164
try:
165
    from enum import Enum
166
except ModulenotfoundExp_ :
167
    Enum = object
168
169
#
170
# The root super-class for element type classes
171
#
172
# Calls to the methods in these classes are generated by generateDS.py.
173
# You can replace these methods by re-implementing the following class
174
#   in a module named generatedssuper.py.
175
176
177
class GeneratedsSuper(object):
178
    __hash__ = object.__hash__
179
    tzoff_pattern = re_.compile('(\\+|-)((0[0-9]|1[0-3]):[0-5][0-9]|14:00)$')
180
    class _FixedOffsetTZ(datetime_.tzinfo):
181
        def __init__(self, offset, name):
182
            self.__offset = datetime_.timedelta(minutes=offset)
183
            self.__name = name
184
        def utcoffset(self, dt):
185
            return self.__offset
186
        def tzname(self, dt):
187
            return self.__name
188
        def dst(self, dt):
189
            return None
190
    def __str__(self):
191
        settings = {
192
            'str_pretty_print': True,
193
            'str_indent_level': 0,
194
            'str_namespaceprefix': '',
195
            'str_name': self.__class__.__name__,
196
            'str_namespacedefs': '',
197
        }
198
        for n in settings:
199
            if hasattr(self, n):
200
                settings[n] = getattr(self, n)
201
        if sys.version_info.major == 2:
202
            from StringIO import StringIO
203
        else:
204
            from io import StringIO
205
        output = StringIO()
206
        self.export(
207
            output,
208
            settings['str_indent_level'],
209
            pretty_print=settings['str_pretty_print'],
210
            namespaceprefix_=settings['str_namespaceprefix'],
211
            name_=settings['str_name'],
212
            namespacedef_=settings['str_namespacedefs']
213
        )
214
        strval = output.getvalue()
215
        output.close()
216
        return strval
217
    def gds_format_string(self, input_data, input_name=''):
218
        return input_data
219
    def gds_parse_string(self, input_data, node=None, input_name=''):
220
        return input_data
221
    def gds_validate_string(self, input_data, node=None, input_name=''):
222
        if not input_data:
223
            return ''
224
        else:
225
            return input_data
226
    def gds_format_base64(self, input_data, input_name=''):
227
        return base64.b64encode(input_data).decode('ascii')
228
    def gds_validate_base64(self, input_data, node=None, input_name=''):
229
        return input_data
230
    def gds_format_integer(self, input_data, input_name=''):
231
        return '%d' % int(input_data)
232
    def gds_parse_integer(self, input_data, node=None, input_name=''):
233
        try:
234
            ival = int(input_data)
235
        except (TypeError, ValueError) as exp:
236
            raise_parse_error(node, 'Requires integer value: %s' % exp)
237
        return ival
238
    def gds_validate_integer(self, input_data, node=None, input_name=''):
239
        try:
240
            value = int(input_data)
241
        except (TypeError, ValueError):
242
            raise_parse_error(node, 'Requires integer value')
243
        return value
244
    def gds_format_integer_list(self, input_data, input_name=''):
245
        if len(input_data) > 0 and not isinstance(input_data[0], BaseStrType_):
246
            input_data = [str(s) for s in input_data]
247
        return '%s' % ' '.join(input_data)
248
    def gds_validate_integer_list(
249
            self, input_data, node=None, input_name=''):
250
        values = input_data.split()
251
        for value in values:
252
            try:
253
                int(value)
254
            except (TypeError, ValueError):
255
                raise_parse_error(node, 'Requires sequence of integer values')
256
        return values
257
    def gds_format_float(self, input_data, input_name=''):
258
        value = ('%.15f' % float(input_data)).rstrip('0')
259
        if value.endswith('.'):
260
            value += '0'
261
        return value
262
263
    def gds_parse_float(self, input_data, node=None, input_name=''):
264
        try:
265
            fval_ = float(input_data)
266
        except (TypeError, ValueError) as exp:
267
            raise_parse_error(node, 'Requires float or double value: %s' % exp)
268
        return fval_
269
    def gds_validate_float(self, input_data, node=None, input_name=''):
270
        try:
271
            value = float(input_data)
272
        except (TypeError, ValueError):
273
            raise_parse_error(node, 'Requires float value')
274
        return value
275
    def gds_format_float_list(self, input_data, input_name=''):
276
        if len(input_data) > 0 and not isinstance(input_data[0], BaseStrType_):
277
            input_data = [str(s) for s in input_data]
278
        return '%s' % ' '.join(input_data)
279
    def gds_validate_float_list(
280
            self, input_data, node=None, input_name=''):
281
        values = input_data.split()
282
        for value in values:
283
            try:
284
                float(value)
285
            except (TypeError, ValueError):
286
                raise_parse_error(node, 'Requires sequence of float values')
287
        return values
288
    def gds_format_decimal(self, input_data, input_name=''):
289
        return_value = '%s' % input_data
290
        if '.' in return_value:
291
            return_value = return_value.rstrip('0')
292
            if return_value.endswith('.'):
293
                return_value = return_value.rstrip('.')
294
        return return_value
295
    def gds_parse_decimal(self, input_data, node=None, input_name=''):
296
        try:
297
            decimal_value = decimal_.Decimal(input_data)
298
        except (TypeError, ValueError):
299
            raise_parse_error(node, 'Requires decimal value')
300
        return decimal_value
301
    def gds_validate_decimal(self, input_data, node=None, input_name=''):
302
        try:
303
            value = decimal_.Decimal(input_data)
304
        except (TypeError, ValueError):
305
            raise_parse_error(node, 'Requires decimal value')
306
        return value
307
    def gds_format_decimal_list(self, input_data, input_name=''):
308
        if len(input_data) > 0 and not isinstance(input_data[0], BaseStrType_):
309
            input_data = [str(s) for s in input_data]
310
        return ' '.join([self.gds_format_decimal(item) for item in input_data])
311
    def gds_validate_decimal_list(
312
            self, input_data, node=None, input_name=''):
313
        values = input_data.split()
314
        for value in values:
315
            try:
316
                decimal_.Decimal(value)
317
            except (TypeError, ValueError):
318
                raise_parse_error(node, 'Requires sequence of decimal values')
319
        return values
320
    def gds_format_double(self, input_data, input_name=''):
321
        return '%s' % input_data
322
    def gds_parse_double(self, input_data, node=None, input_name=''):
323
        try:
324
            fval_ = float(input_data)
325
        except (TypeError, ValueError) as exp:
326
            raise_parse_error(node, 'Requires double or float value: %s' % exp)
327
        return fval_
328
    def gds_validate_double(self, input_data, node=None, input_name=''):
329
        try:
330
            value = float(input_data)
331
        except (TypeError, ValueError):
332
            raise_parse_error(node, 'Requires double or float value')
333
        return value
334
    def gds_format_double_list(self, input_data, input_name=''):
335
        if len(input_data) > 0 and not isinstance(input_data[0], BaseStrType_):
336
            input_data = [str(s) for s in input_data]
337
        return '%s' % ' '.join(input_data)
338
    def gds_validate_double_list(
339
            self, input_data, node=None, input_name=''):
340
        values = input_data.split()
341
        for value in values:
342
            try:
343
                float(value)
344
            except (TypeError, ValueError):
345
                raise_parse_error(
346
                    node, 'Requires sequence of double or float values')
347
        return values
348
    def gds_format_boolean(self, input_data, input_name=''):
349
        return ('%s' % input_data).lower()
350
    def gds_parse_boolean(self, input_data, node=None, input_name=''):
351
        input_data = input_data.strip()
352
        if input_data in ('true', '1'):
353
            bval = True
354
        elif input_data in ('false', '0'):
355
            bval = False
356
        else:
357
            raise_parse_error(node, 'Requires boolean value')
358
        return bval
0 ignored issues
show
introduced by
The variable bval does not seem to be defined for all execution paths.
Loading history...
359
    def gds_validate_boolean(self, input_data, node=None, input_name=''):
360
        if input_data not in (True, 1, False, 0, ):
361
            raise_parse_error(
362
                node,
363
                'Requires boolean value '
364
                '(one of True, 1, False, 0)')
365
        return input_data
366
    def gds_format_boolean_list(self, input_data, input_name=''):
367
        if len(input_data) > 0 and not isinstance(input_data[0], BaseStrType_):
368
            input_data = [str(s) for s in input_data]
369
        return '%s' % ' '.join(input_data)
370
    def gds_validate_boolean_list(
371
            self, input_data, node=None, input_name=''):
372
        values = input_data.split()
373
        for value in values:
374
            value = self.gds_parse_boolean(value, node, input_name)
375
            if value not in (True, 1, False, 0, ):
376
                raise_parse_error(
377
                    node,
378
                    'Requires sequence of boolean values '
379
                    '(one of True, 1, False, 0)')
380
        return values
381
    def gds_validate_datetime(self, input_data, node=None, input_name=''):
382
        return input_data
383 View Code Duplication
    def gds_format_datetime(self, input_data, input_name=''):
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
384
        if input_data.microsecond == 0:
385
            _svalue = '%04d-%02d-%02dT%02d:%02d:%02d' % (
386
                input_data.year,
387
                input_data.month,
388
                input_data.day,
389
                input_data.hour,
390
                input_data.minute,
391
                input_data.second,
392
            )
393
        else:
394
            _svalue = '%04d-%02d-%02dT%02d:%02d:%02d.%s' % (
395
                input_data.year,
396
                input_data.month,
397
                input_data.day,
398
                input_data.hour,
399
                input_data.minute,
400
                input_data.second,
401
                ('%f' % (float(input_data.microsecond) / 1000000))[2:],
402
            )
403
        if input_data.tzinfo is not None:
404
            tzoff = input_data.tzinfo.utcoffset(input_data)
405
            if tzoff is not None:
406
                total_seconds = tzoff.seconds + (86400 * tzoff.days)
407
                if total_seconds == 0:
408
                    _svalue += 'Z'
409
                else:
410
                    if total_seconds < 0:
411
                        _svalue += '-'
412
                        total_seconds *= -1
413
                    else:
414
                        _svalue += '+'
415
                    hours = total_seconds // 3600
416
                    minutes = (total_seconds - (hours * 3600)) // 60
417
                    _svalue += '{0:02d}:{1:02d}'.format(hours, minutes)
418
        return _svalue
419
    @classmethod
420
    def gds_parse_datetime(cls, input_data):
421
        tz = None
422 View Code Duplication
        if input_data[-1] == 'Z':
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
423
            tz = GeneratedsSuper._FixedOffsetTZ(0, 'UTC')
424
            input_data = input_data[:-1]
425
        else:
426
            results = GeneratedsSuper.tzoff_pattern.search(input_data)
427
            if results is not None:
428
                tzoff_parts = results.group(2).split(':')
429
                tzoff = int(tzoff_parts[0]) * 60 + int(tzoff_parts[1])
430
                if results.group(1) == '-':
431
                    tzoff *= -1
432
                tz = GeneratedsSuper._FixedOffsetTZ(
433
                    tzoff, results.group(0))
434
                input_data = input_data[:-6]
435
        time_parts = input_data.split('.')
436
        if len(time_parts) > 1:
437
            micro_seconds = int(float('0.' + time_parts[1]) * 1000000)
438
            input_data = '%s.%s' % (
439
                time_parts[0], "{}".format(micro_seconds).rjust(6, "0"), )
440
            dt = datetime_.datetime.strptime(
441
                input_data, '%Y-%m-%dT%H:%M:%S.%f')
442
        else:
443
            dt = datetime_.datetime.strptime(
444
                input_data, '%Y-%m-%dT%H:%M:%S')
445
        dt = dt.replace(tzinfo=tz)
446
        return dt
447
    def gds_validate_date(self, input_data, node=None, input_name=''):
448
        return input_data
449
    def gds_format_date(self, input_data, input_name=''):
450
        _svalue = '%04d-%02d-%02d' % (
451
            input_data.year,
452
            input_data.month,
453
            input_data.day,
454
        )
455
        try:
456
            if input_data.tzinfo is not None:
457
                tzoff = input_data.tzinfo.utcoffset(input_data)
458
                if tzoff is not None:
459
                    total_seconds = tzoff.seconds + (86400 * tzoff.days)
460
                    if total_seconds == 0:
461
                        _svalue += 'Z'
462
                    else:
463
                        if total_seconds < 0:
464
                            _svalue += '-'
465
                            total_seconds *= -1
466
                        else:
467
                            _svalue += '+'
468
                        hours = total_seconds // 3600
469
                        minutes = (total_seconds - (hours * 3600)) // 60
470
                        _svalue += '{0:02d}:{1:02d}'.format(
471
                            hours, minutes)
472
        except AttributeError:
473
            pass
474
        return _svalue
475
    @classmethod
476
    def gds_parse_date(cls, input_data):
477
        tz = None
478 View Code Duplication
        if input_data[-1] == 'Z':
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
479
            tz = GeneratedsSuper._FixedOffsetTZ(0, 'UTC')
480
            input_data = input_data[:-1]
481
        else:
482
            results = GeneratedsSuper.tzoff_pattern.search(input_data)
483
            if results is not None:
484
                tzoff_parts = results.group(2).split(':')
485
                tzoff = int(tzoff_parts[0]) * 60 + int(tzoff_parts[1])
486
                if results.group(1) == '-':
487
                    tzoff *= -1
488
                tz = GeneratedsSuper._FixedOffsetTZ(
489
                    tzoff, results.group(0))
490
                input_data = input_data[:-6]
491
        dt = datetime_.datetime.strptime(input_data, '%Y-%m-%d')
492
        dt = dt.replace(tzinfo=tz)
493
        return dt.date()
494
    def gds_validate_time(self, input_data, node=None, input_name=''):
495
        return input_data
496 View Code Duplication
    def gds_format_time(self, input_data, input_name=''):
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
497
        if input_data.microsecond == 0:
498
            _svalue = '%02d:%02d:%02d' % (
499
                input_data.hour,
500
                input_data.minute,
501
                input_data.second,
502
            )
503
        else:
504
            _svalue = '%02d:%02d:%02d.%s' % (
505
                input_data.hour,
506
                input_data.minute,
507
                input_data.second,
508
                ('%f' % (float(input_data.microsecond) / 1000000))[2:],
509
            )
510
        if input_data.tzinfo is not None:
511
            tzoff = input_data.tzinfo.utcoffset(input_data)
512
            if tzoff is not None:
513
                total_seconds = tzoff.seconds + (86400 * tzoff.days)
514
                if total_seconds == 0:
515
                    _svalue += 'Z'
516
                else:
517
                    if total_seconds < 0:
518
                        _svalue += '-'
519
                        total_seconds *= -1
520
                    else:
521
                        _svalue += '+'
522
                    hours = total_seconds // 3600
523
                    minutes = (total_seconds - (hours * 3600)) // 60
524
                    _svalue += '{0:02d}:{1:02d}'.format(hours, minutes)
525
        return _svalue
526
    def gds_validate_simple_patterns(self, patterns, target):
527
        # pat is a list of lists of strings/patterns.
528
        # The target value must match at least one of the patterns
529
        # in order for the test to succeed.
530
        found1 = True
531
        target = str(target)
532
        for patterns1 in patterns:
533
            found2 = False
534
            for patterns2 in patterns1:
535
                mo = re_.search(patterns2, target)
536
                if mo is not None and len(mo.group(0)) == len(target):
537
                    found2 = True
538
                    break
539
            if not found2:
540
                found1 = False
541
                break
542
        return found1
543
    @classmethod
544
    def gds_parse_time(cls, input_data):
545
        tz = None
546 View Code Duplication
        if input_data[-1] == 'Z':
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
547
            tz = GeneratedsSuper._FixedOffsetTZ(0, 'UTC')
548
            input_data = input_data[:-1]
549
        else:
550
            results = GeneratedsSuper.tzoff_pattern.search(input_data)
551
            if results is not None:
552
                tzoff_parts = results.group(2).split(':')
553
                tzoff = int(tzoff_parts[0]) * 60 + int(tzoff_parts[1])
554
                if results.group(1) == '-':
555
                    tzoff *= -1
556
                tz = GeneratedsSuper._FixedOffsetTZ(
557
                    tzoff, results.group(0))
558
                input_data = input_data[:-6]
559
        if len(input_data.split('.')) > 1:
560
            dt = datetime_.datetime.strptime(input_data, '%H:%M:%S.%f')
561
        else:
562
            dt = datetime_.datetime.strptime(input_data, '%H:%M:%S')
563
        dt = dt.replace(tzinfo=tz)
564
        return dt.time()
565
    def gds_check_cardinality_(
566
            self, value, input_name,
567
            min_occurs=0, max_occurs=1, required=None):
568
        if value is None:
569
            length = 0
570
        elif isinstance(value, list):
571
            length = len(value)
572
        else:
573
            length = 1
574
        if required is not None :
575
            if required and length < 1:
576
                self.gds_collector_.add_message(
577
                    "Required value {}{} is missing".format(
578
                        input_name, self.gds_get_node_lineno_()))
579
        if length < min_occurs:
580
            self.gds_collector_.add_message(
581
                "Number of values for {}{} is below "
582
                "the minimum allowed, "
583
                "expected at least {}, found {}".format(
584
                    input_name, self.gds_get_node_lineno_(),
585
                    min_occurs, length))
586
        elif length > max_occurs:
587
            self.gds_collector_.add_message(
588
                "Number of values for {}{} is above "
589
                "the maximum allowed, "
590
                "expected at most {}, found {}".format(
591
                    input_name, self.gds_get_node_lineno_(),
592
                    max_occurs, length))
593
    def gds_validate_builtin_ST_(
594
            self, validator, value, input_name,
595
            min_occurs=None, max_occurs=None, required=None):
596
        if value is not None:
597
            try:
598
                validator(value, input_name=input_name)
599
            except GDSParseError as parse_error:
600
                self.gds_collector_.add_message(str(parse_error))
601
    def gds_validate_defined_ST_(
602
            self, validator, value, input_name,
603
            min_occurs=None, max_occurs=None, required=None):
604
        if value is not None:
605
            try:
606
                validator(value)
607
            except GDSParseError as parse_error:
608
                self.gds_collector_.add_message(str(parse_error))
609
    def gds_str_lower(self, instring):
610
        return instring.lower()
611
    def get_path_(self, node):
612
        path_list = []
613
        self.get_path_list_(node, path_list)
614
        path_list.reverse()
615
        path = '/'.join(path_list)
616
        return path
617
    Tag_strip_pattern_ = re_.compile(r'{.*}')
618
    def get_path_list_(self, node, path_list):
619
        if node is None:
620
            return
621
        tag = GeneratedsSuper.Tag_strip_pattern_.sub('', node.tag)
622
        if tag:
623
            path_list.append(tag)
624
        self.get_path_list_(node.getparent(), path_list)
625
    def get_class_obj_(self, node, default_class=None):
626
        class_obj1 = default_class
627
        if 'xsi' in node.nsmap:
628
            classname = node.get('{%s}type' % node.nsmap['xsi'])
629
            if classname is not None:
630
                names = classname.split(':')
631
                if len(names) == 2:
632
                    classname = names[1]
633
                class_obj2 = globals().get(classname)
634
                if class_obj2 is not None:
635
                    class_obj1 = class_obj2
636
        return class_obj1
637
    def gds_build_any(self, node, type_name=None):
638
        # provide default value in case option --disable-xml is used.
639
        content = ""
640
        content = etree_.tostring(node, encoding="unicode")
641
        return content
642
    @classmethod
643
    def gds_reverse_node_mapping(cls, mapping):
644
        return dict(((v, k) for k, v in mapping.items()))
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable k does not seem to be defined.
Loading history...
Comprehensibility Best Practice introduced by
The variable v does not seem to be defined.
Loading history...
645
    @staticmethod
646
    def gds_encode(instring):
647
        if sys.version_info.major == 2:
648
            if ExternalEncoding:
649
                encoding = ExternalEncoding
650
            else:
651
                encoding = 'utf-8'
652
            return instring.encode(encoding)
653
        else:
654
            return instring
655
    @staticmethod
656
    def convert_unicode(instring):
657
        if isinstance(instring, str):
658
            result = quote_xml(instring)
659
        elif sys.version_info.major == 2 and isinstance(instring, unicode):
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable unicode does not seem to be defined.
Loading history...
660
            result = quote_xml(instring).encode('utf8')
661
        else:
662
            result = GeneratedsSuper.gds_encode(str(instring))
663
        return result
664
    def __eq__(self, other):
665
        def excl_select_objs_(obj):
666
            return (obj[0] != 'parent_object_' and
667
                    obj[0] != 'gds_collector_')
668
        if type(self) != type(other):
669
            return False
670
        return all(x == y for x, y in zip_longest(
671
            filter(excl_select_objs_, self.__dict__.items()),
672
            filter(excl_select_objs_, other.__dict__.items())))
673
    def __ne__(self, other):
674
        return not self.__eq__(other)
675
    # Django ETL transform hooks.
676
    def gds_djo_etl_transform(self):
677
        pass
678
    def gds_djo_etl_transform_db_obj(self, dbobj):
679
        pass
680
    # SQLAlchemy ETL transform hooks.
681
    def gds_sqa_etl_transform(self):
682
        return 0, None
683
    def gds_sqa_etl_transform_db_obj(self, dbobj):
684
        pass
685
    def gds_get_node_lineno_(self):
686
        if (hasattr(self, "gds_elementtree_node_") and
687
                self.gds_elementtree_node_ is not None):
688
            return ' near line {}'.format(
689
                self.gds_elementtree_node_.sourceline)
690
        else:
691
            return ""
692
693
694
def getSubclassFromModule_(module, class_):
695
    '''Get the subclass of a class from a specific module.'''
696
    name = class_.__name__ + 'Sub'
697
    if hasattr(module, name):
698
        return getattr(module, name)
699
    else:
700
        return None
701
702
703
#
704
# If you have installed IPython you can uncomment and use the following.
705
# IPython is available from http://ipython.scipy.org/.
706
#
707
708
## from IPython.Shell import IPShellEmbed
709
## args = ''
710
## ipshell = IPShellEmbed(args,
711
##     banner = 'Dropping into IPython',
712
##     exit_msg = 'Leaving Interpreter, back to program.')
713
714
# Then use the following line where and when you want to drop into the
715
# IPython shell:
716
#    ipshell('<some message> -- Entering ipshell.\nHit Ctrl-D to exit')
717
718
#
719
# Globals
720
#
721
722
ExternalEncoding = ''
723
# Set this to false in order to deactivate during export, the use of
724
# name space prefixes captured from the input document.
725
UseCapturedNS_ = True
726
CapturedNsmap_ = {}
727
Tag_pattern_ = re_.compile(r'({.*})?(.*)')
728
String_cleanup_pat_ = re_.compile(r"[\n\r\s]+")
729
Namespace_extract_pat_ = re_.compile(r'{(.*)}(.*)')
730
CDATA_pattern_ = re_.compile(r"<!\[CDATA\[.*?\]\]>", re_.DOTALL)
731
732
# Change this to redirect the generated superclass module to use a
733
# specific subclass module.
734
CurrentSubclassModule_ = None
735
736
#
737
# Support/utility functions.
738
#
739
740
741
def showIndent(outfile, level, pretty_print=True):
742
    if pretty_print:
743
        for idx in range(level):
744
            outfile.write('    ')
745
746
747
def quote_xml(inStr):
748
    "Escape markup chars, but do not modify CDATA sections."
749
    if not inStr:
750
        return ''
751
    s1 = (isinstance(inStr, BaseStrType_) and inStr or '%s' % inStr)
752
    s2 = ''
753
    pos = 0
754
    matchobjects = CDATA_pattern_.finditer(s1)
755
    for mo in matchobjects:
756
        s3 = s1[pos:mo.start()]
757
        s2 += quote_xml_aux(s3)
758
        s2 += s1[mo.start():mo.end()]
759
        pos = mo.end()
760
    s3 = s1[pos:]
761
    s2 += quote_xml_aux(s3)
762
    return s2
763
764
765
def quote_xml_aux(inStr):
766
    s1 = inStr.replace('&', '&amp;')
767
    s1 = s1.replace('<', '&lt;')
768
    s1 = s1.replace('>', '&gt;')
769
    return s1
770
771
772
def quote_attrib(inStr):
773
    s1 = (isinstance(inStr, BaseStrType_) and inStr or '%s' % inStr)
774
    s1 = s1.replace('&', '&amp;')
775
    s1 = s1.replace('<', '&lt;')
776
    s1 = s1.replace('>', '&gt;')
777
    s1 = s1.replace('\n', '&#10;')
778
    if '"' in s1:
779
        if "'" in s1:
780
            s1 = '"%s"' % s1.replace('"', "&quot;")
781
        else:
782
            s1 = "'%s'" % s1
783
    else:
784
        s1 = '"%s"' % s1
785
    return s1
786
787
788
def quote_python(inStr):
789
    s1 = inStr
790
    if s1.find("'") == -1:
791
        if s1.find('\n') == -1:
792
            return "'%s'" % s1
793
        else:
794
            return "'''%s'''" % s1
795
    else:
796
        if s1.find('"') != -1:
797
            s1 = s1.replace('"', '\\"')
798
        if s1.find('\n') == -1:
799
            return '"%s"' % s1
800
        else:
801
            return '"""%s"""' % s1
802
803
804
def get_all_text_(node):
805
    if node.text is not None:
806
        text = node.text
807
    else:
808
        text = ''
809
    for child in node:
810
        if child.tail is not None:
811
            text += child.tail
812
    return text
813
814
815
def find_attr_value_(attr_name, node):
816
    attrs = node.attrib
817
    attr_parts = attr_name.split(':')
818
    value = None
819
    if len(attr_parts) == 1:
820
        value = attrs.get(attr_name)
821
    elif len(attr_parts) == 2:
822
        prefix, name = attr_parts
823
        if prefix == 'xml':
824
            namespace = 'http://www.w3.org/XML/1998/namespace'
825
        else:
826
            namespace = node.nsmap.get(prefix)
827
        if namespace is not None:
828
            value = attrs.get('{%s}%s' % (namespace, name, ))
829
    return value
830
831
832
def encode_str_2_3(instr):
833
    return instr
834
835
836
class GDSParseError(Exception):
837
    pass
838
839
840
def raise_parse_error(node, msg):
841
    if node is not None:
842
        msg = '%s (element %s/line %d)' % (msg, node.tag, node.sourceline, )
843
    raise GDSParseError(msg)
844
845
846
class MixedContainer:
847
    # Constants for category:
848
    CategoryNone = 0
849
    CategoryText = 1
850
    CategorySimple = 2
851
    CategoryComplex = 3
852
    # Constants for content_type:
853
    TypeNone = 0
854
    TypeText = 1
855
    TypeString = 2
856
    TypeInteger = 3
857
    TypeFloat = 4
858
    TypeDecimal = 5
859
    TypeDouble = 6
860
    TypeBoolean = 7
861
    TypeBase64 = 8
862
    def __init__(self, category, content_type, name, value):
863
        self.category = category
864
        self.content_type = content_type
865
        self.name = name
866
        self.value = value
867
    def getCategory(self):
868
        return self.category
869
    def getContenttype(self, content_type):
870
        return self.content_type
871
    def getValue(self):
872
        return self.value
873
    def getName(self):
874
        return self.name
875
    def export(self, outfile, level, name, namespace,
876
               pretty_print=True):
877
        if self.category == MixedContainer.CategoryText:
878
            # Prevent exporting empty content as empty lines.
879
            if self.value.strip():
880
                outfile.write(self.value)
881
        elif self.category == MixedContainer.CategorySimple:
882
            self.exportSimple(outfile, level, name)
883
        else:    # category == MixedContainer.CategoryComplex
884
            self.value.export(
885
                outfile, level, namespace, name_=name,
886
                pretty_print=pretty_print)
887
    def exportSimple(self, outfile, level, name):
888
        if self.content_type == MixedContainer.TypeString:
889
            outfile.write('<%s>%s</%s>' % (
890
                self.name, self.value, self.name))
891
        elif self.content_type == MixedContainer.TypeInteger or \
892
                self.content_type == MixedContainer.TypeBoolean:
893
            outfile.write('<%s>%d</%s>' % (
894
                self.name, self.value, self.name))
895
        elif self.content_type == MixedContainer.TypeFloat or \
896
                self.content_type == MixedContainer.TypeDecimal:
897
            outfile.write('<%s>%f</%s>' % (
898
                self.name, self.value, self.name))
899
        elif self.content_type == MixedContainer.TypeDouble:
900
            outfile.write('<%s>%g</%s>' % (
901
                self.name, self.value, self.name))
902
        elif self.content_type == MixedContainer.TypeBase64:
903
            outfile.write('<%s>%s</%s>' % (
904
                self.name,
905
                base64.b64encode(self.value),
906
                self.name))
907
    def to_etree(self, element, mapping_=None, reverse_mapping_=None, nsmap_=None):
908
        if self.category == MixedContainer.CategoryText:
909
            # Prevent exporting empty content as empty lines.
910
            if self.value.strip():
911
                if len(element) > 0:
912
                    if element[-1].tail is None:
913
                        element[-1].tail = self.value
914
                    else:
915
                        element[-1].tail += self.value
916
                else:
917
                    if element.text is None:
918
                        element.text = self.value
919
                    else:
920
                        element.text += self.value
921
        elif self.category == MixedContainer.CategorySimple:
922
            subelement = etree_.SubElement(
923
                element, '%s' % self.name)
924
            subelement.text = self.to_etree_simple()
925
        else:    # category == MixedContainer.CategoryComplex
926
            self.value.to_etree(element)
927
    def to_etree_simple(self, mapping_=None, reverse_mapping_=None, nsmap_=None):
928
        if self.content_type == MixedContainer.TypeString:
929
            text = self.value
930
        elif (self.content_type == MixedContainer.TypeInteger or
931
                self.content_type == MixedContainer.TypeBoolean):
932
            text = '%d' % self.value
933
        elif (self.content_type == MixedContainer.TypeFloat or
934
                self.content_type == MixedContainer.TypeDecimal):
935
            text = '%f' % self.value
936
        elif self.content_type == MixedContainer.TypeDouble:
937
            text = '%g' % self.value
938
        elif self.content_type == MixedContainer.TypeBase64:
939
            text = '%s' % base64.b64encode(self.value)
940
        return text
0 ignored issues
show
introduced by
The variable text does not seem to be defined for all execution paths.
Loading history...
941
    def exportLiteral(self, outfile, level, name):
942
        if self.category == MixedContainer.CategoryText:
943
            showIndent(outfile, level)
944
            outfile.write(
945
                'model_.MixedContainer(%d, %d, "%s", "%s"),\n' % (
946
                    self.category, self.content_type,
947
                    self.name, self.value))
948
        elif self.category == MixedContainer.CategorySimple:
949
            showIndent(outfile, level)
950
            outfile.write(
951
                'model_.MixedContainer(%d, %d, "%s", "%s"),\n' % (
952
                    self.category, self.content_type,
953
                    self.name, self.value))
954
        else:    # category == MixedContainer.CategoryComplex
955
            showIndent(outfile, level)
956
            outfile.write(
957
                'model_.MixedContainer(%d, %d, "%s",\n' % (
958
                    self.category, self.content_type, self.name,))
959
            self.value.exportLiteral(outfile, level + 1)
960
            showIndent(outfile, level)
961
            outfile.write(')\n')
962
963
964
class MemberSpec_(object):
965
    def __init__(self, name='', data_type='', container=0,
966
            optional=0, child_attrs=None, choice=None):
967
        self.name = name
968
        self.data_type = data_type
969
        self.container = container
970
        self.child_attrs = child_attrs
971
        self.choice = choice
972
        self.optional = optional
973
    def set_name(self, name): self.name = name
974
    def get_name(self): return self.name
975
    def set_data_type(self, data_type): self.data_type = data_type
976
    def get_data_type_chain(self): return self.data_type
977
    def get_data_type(self):
978
        if isinstance(self.data_type, list):
979
            if len(self.data_type) > 0:
980
                return self.data_type[-1]
981
            else:
982
                return 'xs:string'
983
        else:
984
            return self.data_type
985
    def set_container(self, container): self.container = container
986
    def get_container(self): return self.container
987
    def set_child_attrs(self, child_attrs): self.child_attrs = child_attrs
988
    def get_child_attrs(self): return self.child_attrs
989
    def set_choice(self, choice): self.choice = choice
990
    def get_choice(self): return self.choice
991
    def set_optional(self, optional): self.optional = optional
992
    def get_optional(self): return self.optional
993
994
995
def _cast(typ, value):
996
    if typ is None or value is None:
997
        return value
998
    return typ(value)
999
1000
1001
#
1002
# Start enum classes
1003
#
1004
class AlignSimpleType(str, Enum):
1005
    LEFT='left'
1006
    CENTRE='centre'
1007
    RIGHT='right'
1008
    JUSTIFY='justify'
1009
1010
1011
class ChartTypeSimpleType(str, Enum):
1012
    BAR='bar'
1013
    LINE='line'
1014
    PIE='pie'
1015
    SCATTER='scatter'
1016
    SURFACE='surface'
1017
    OTHER='other'
1018
1019
1020
class ColourDepthSimpleType(str, Enum):
1021
    BILEVEL='bilevel'
1022
    GREYSCALE='greyscale'
1023
    COLOUR='colour'
1024
    OTHER='other'
1025
1026
1027
class ColourSimpleType(str, Enum):
1028
    BLACK='black'
1029
    BLUE='blue'
1030
    BROWN='brown'
1031
    CYAN='cyan'
1032
    GREEN='green'
1033
    GREY='grey'
1034
    INDIGO='indigo'
1035
    MAGENTA='magenta'
1036
    ORANGE='orange'
1037
    PINK='pink'
1038
    RED='red'
1039
    TURQUOISE='turquoise'
1040
    VIOLET='violet'
1041
    WHITE='white'
1042
    YELLOW='yellow'
1043
    OTHER='other'
1044
1045
1046
class GraphicsTypeSimpleType(str, Enum):
1047
    LOGO='logo'
1048
    LETTERHEAD='letterhead'
1049
    DECORATION='decoration'
1050
    FRAME='frame'
1051
    HANDWRITTENANNOTATION='handwritten-annotation'
1052
    STAMP='stamp'
1053
    SIGNATURE='signature'
1054
    BARCODE='barcode'
1055
    PAPERGROW='paper-grow'
1056
    PUNCHHOLE='punch-hole'
1057
    OTHER='other'
1058
1059
1060
class GroupTypeSimpleType(str, Enum):
1061
    PARAGRAPH='paragraph'
1062
    LIST='list'
1063
    LISTITEM='list-item'
1064
    FIGURE='figure'
1065
    ARTICLE='article'
1066
    DIV='div'
1067
    OTHER='other'
1068
1069
1070
class LanguageSimpleType(str, Enum):
1071
    """LanguageSimpleType -- ISO 639.x 2016-07-14
1072
    
1073
    """
1074
    ABKHAZ='Abkhaz'
1075
    AFAR='Afar'
1076
    AFRIKAANS='Afrikaans'
1077
    AKAN='Akan'
1078
    ALBANIAN='Albanian'
1079
    AMHARIC='Amharic'
1080
    ARABIC='Arabic'
1081
    ARAGONESE='Aragonese'
1082
    ARMENIAN='Armenian'
1083
    ASSAMESE='Assamese'
1084
    AVARIC='Avaric'
1085
    AVESTAN='Avestan'
1086
    AYMARA='Aymara'
1087
    AZERBAIJANI='Azerbaijani'
1088
    BAMBARA='Bambara'
1089
    BASHKIR='Bashkir'
1090
    BASQUE='Basque'
1091
    BELARUSIAN='Belarusian'
1092
    BENGALI='Bengali'
1093
    BIHARI='Bihari'
1094
    BISLAMA='Bislama'
1095
    BOSNIAN='Bosnian'
1096
    BRETON='Breton'
1097
    BULGARIAN='Bulgarian'
1098
    BURMESE='Burmese'
1099
    CAMBODIAN='Cambodian'
1100
    CANTONESE='Cantonese'
1101
    CATALAN='Catalan'
1102
    CHAMORRO='Chamorro'
1103
    CHECHEN='Chechen'
1104
    CHICHEWA='Chichewa'
1105
    CHINESE='Chinese'
1106
    CHUVASH='Chuvash'
1107
    CORNISH='Cornish'
1108
    CORSICAN='Corsican'
1109
    CREE='Cree'
1110
    CROATIAN='Croatian'
1111
    CZECH='Czech'
1112
    DANISH='Danish'
1113
    DIVEHI='Divehi'
1114
    DUTCH='Dutch'
1115
    DZONGKHA='Dzongkha'
1116
    ENGLISH='English'
1117
    ESPERANTO='Esperanto'
1118
    ESTONIAN='Estonian'
1119
    EWE='Ewe'
1120
    FAROESE='Faroese'
1121
    FIJIAN='Fijian'
1122
    FINNISH='Finnish'
1123
    FRENCH='French'
1124
    FULA='Fula'
1125
    GAELIC='Gaelic'
1126
    GALICIAN='Galician'
1127
    GANDA='Ganda'
1128
    GEORGIAN='Georgian'
1129
    GERMAN='German'
1130
    GREEK='Greek'
1131
    GUARANÍ='Guaraní'
1132
    GUJARATI='Gujarati'
1133
    HAITIAN='Haitian'
1134
    HAUSA='Hausa'
1135
    HEBREW='Hebrew'
1136
    HERERO='Herero'
1137
    HINDI='Hindi'
1138
    HIRI_MOTU='Hiri Motu'
1139
    HUNGARIAN='Hungarian'
1140
    ICELANDIC='Icelandic'
1141
    IDO='Ido'
1142
    IGBO='Igbo'
1143
    INDONESIAN='Indonesian'
1144
    INTERLINGUA='Interlingua'
1145
    INTERLINGUE='Interlingue'
1146
    INUKTITUT='Inuktitut'
1147
    INUPIAQ='Inupiaq'
1148
    IRISH='Irish'
1149
    ITALIAN='Italian'
1150
    JAPANESE='Japanese'
1151
    JAVANESE='Javanese'
1152
    KALAALLISUT='Kalaallisut'
1153
    KANNADA='Kannada'
1154
    KANURI='Kanuri'
1155
    KASHMIRI='Kashmiri'
1156
    KAZAKH='Kazakh'
1157
    KHMER='Khmer'
1158
    KIKUYU='Kikuyu'
1159
    KINYARWANDA='Kinyarwanda'
1160
    KIRUNDI='Kirundi'
1161
    KOMI='Komi'
1162
    KONGO='Kongo'
1163
    KOREAN='Korean'
1164
    KURDISH='Kurdish'
1165
    KWANYAMA='Kwanyama'
1166
    KYRGYZ='Kyrgyz'
1167
    LAO='Lao'
1168
    LATIN='Latin'
1169
    LATVIAN='Latvian'
1170
    LIMBURGISH='Limburgish'
1171
    LINGALA='Lingala'
1172
    LITHUANIAN='Lithuanian'
1173
    LUBA_KATANGA='Luba-Katanga'
1174
    LUXEMBOURGISH='Luxembourgish'
1175
    MACEDONIAN='Macedonian'
1176
    MALAGASY='Malagasy'
1177
    MALAY='Malay'
1178
    MALAYALAM='Malayalam'
1179
    MALTESE='Maltese'
1180
    MANX='Manx'
1181
    MĀORI='Māori'
1182
    MARATHI='Marathi'
1183
    MARSHALLESE='Marshallese'
1184
    MONGOLIAN='Mongolian'
1185
    NAURU='Nauru'
1186
    NAVAJO='Navajo'
1187
    NDONGA='Ndonga'
1188
    NEPALI='Nepali'
1189
    NORTH_NDEBELE='North Ndebele'
1190
    NORTHERN_SAMI='Northern Sami'
1191
    NORWEGIAN='Norwegian'
1192
    NORWEGIAN_BOKMÅL='Norwegian Bokmål'
1193
    NORWEGIAN_NYNORSK='Norwegian Nynorsk'
1194
    NUOSU='Nuosu'
1195
    OCCITAN='Occitan'
1196
    OJIBWE='Ojibwe'
1197
    OLD_CHURCH_SLAVONIC='Old Church Slavonic'
1198
    ORIYA='Oriya'
1199
    OROMO='Oromo'
1200
    OSSETIAN='Ossetian'
1201
    PĀLI='Pāli'
1202
    PANJABI='Panjabi'
1203
    PASHTO='Pashto'
1204
    PERSIAN='Persian'
1205
    POLISH='Polish'
1206
    PORTUGUESE='Portuguese'
1207
    PUNJABI='Punjabi'
1208
    QUECHUA='Quechua'
1209
    ROMANIAN='Romanian'
1210
    ROMANSH='Romansh'
1211
    RUSSIAN='Russian'
1212
    SAMOAN='Samoan'
1213
    SANGO='Sango'
1214
    SANSKRIT='Sanskrit'
1215
    SARDINIAN='Sardinian'
1216
    SERBIAN='Serbian'
1217
    SHONA='Shona'
1218
    SINDHI='Sindhi'
1219
    SINHALA='Sinhala'
1220
    SLOVAK='Slovak'
1221
    SLOVENE='Slovene'
1222
    SOMALI='Somali'
1223
    SOUTH_NDEBELE='South Ndebele'
1224
    SOUTHERN_SOTHO='Southern Sotho'
1225
    SPANISH='Spanish'
1226
    SUNDANESE='Sundanese'
1227
    SWAHILI='Swahili'
1228
    SWATI='Swati'
1229
    SWEDISH='Swedish'
1230
    TAGALOG='Tagalog'
1231
    TAHITIAN='Tahitian'
1232
    TAJIK='Tajik'
1233
    TAMIL='Tamil'
1234
    TATAR='Tatar'
1235
    TELUGU='Telugu'
1236
    THAI='Thai'
1237
    TIBETAN='Tibetan'
1238
    TIGRINYA='Tigrinya'
1239
    TONGA='Tonga'
1240
    TSONGA='Tsonga'
1241
    TSWANA='Tswana'
1242
    TURKISH='Turkish'
1243
    TURKMEN='Turkmen'
1244
    TWI='Twi'
1245
    UIGHUR='Uighur'
1246
    UKRAINIAN='Ukrainian'
1247
    URDU='Urdu'
1248
    UZBEK='Uzbek'
1249
    VENDA='Venda'
1250
    VIETNAMESE='Vietnamese'
1251
    VOLAPÜK='Volapük'
1252
    WALLOON='Walloon'
1253
    WELSH='Welsh'
1254
    WESTERN_FRISIAN='Western Frisian'
1255
    WOLOF='Wolof'
1256
    XHOSA='Xhosa'
1257
    YIDDISH='Yiddish'
1258
    YORUBA='Yoruba'
1259
    ZHUANG='Zhuang'
1260
    ZULU='Zulu'
1261
    OTHER='other'
1262
1263
1264
class PageTypeSimpleType(str, Enum):
1265
    FRONTCOVER='front-cover'
1266
    BACKCOVER='back-cover'
1267
    TITLE='title'
1268
    TABLEOFCONTENTS='table-of-contents'
1269
    INDEX='index'
1270
    CONTENT='content'
1271
    BLANK='blank'
1272
    OTHER='other'
1273
1274
1275
class ProductionSimpleType(str, Enum):
1276
    """ProductionSimpleType -- Text production type
1277
    
1278
    """
1279
    PRINTED='printed'
1280
    TYPEWRITTEN='typewritten'
1281
    HANDWRITTENCURSIVE='handwritten-cursive'
1282
    HANDWRITTENPRINTSCRIPT='handwritten-printscript'
1283
    MEDIEVALMANUSCRIPT='medieval-manuscript'
1284
    OTHER='other'
1285
1286
1287
class ReadingDirectionSimpleType(str, Enum):
1288
    LEFTTORIGHT='left-to-right'
1289
    RIGHTTOLEFT='right-to-left'
1290
    TOPTOBOTTOM='top-to-bottom'
1291
    BOTTOMTOTOP='bottom-to-top'
1292
1293
1294
class ScriptSimpleType(str, Enum):
1295
    """ScriptSimpleType -- iso15924 2016-07-14
1296
    
1297
    """
1298
    ADLM_ADLAM='Adlm - Adlam'
1299
    AFAK_AFAKA='Afak - Afaka'
1300
    AGHB_CAUCASIAN_ALBANIAN='Aghb - Caucasian Albanian'
1301
    AHOM_AHOM_TAI_AHOM='Ahom - Ahom, Tai Ahom'
1302
    ARAB_ARABIC='Arab - Arabic'
1303
    ARAN_ARABIC_NASTALIQVARIANT='Aran - Arabic (Nastaliq variant)'
1304
    ARMI_IMPERIAL_ARAMAIC='Armi - Imperial Aramaic'
1305
    ARMN_ARMENIAN='Armn - Armenian'
1306
    AVST_AVESTAN='Avst - Avestan'
1307
    BALI_BALINESE='Bali - Balinese'
1308
    BAMU_BAMUM='Bamu - Bamum'
1309
    BASS_BASSA_VAH='Bass - Bassa Vah'
1310
    BATK_BATAK='Batk - Batak'
1311
    BENG_BENGALI='Beng - Bengali'
1312
    BHKS_BHAIKSUKI='Bhks - Bhaiksuki'
1313
    BLIS_BLISSYMBOLS='Blis - Blissymbols'
1314
    BOPO_BOPOMOFO='Bopo - Bopomofo'
1315
    BRAH_BRAHMI='Brah - Brahmi'
1316
    BRAI_BRAILLE='Brai - Braille'
1317
    BUGI_BUGINESE='Bugi - Buginese'
1318
    BUHD_BUHID='Buhd - Buhid'
1319
    CAKM_CHAKMA='Cakm - Chakma'
1320
    CANS_UNIFIED_CANADIAN_ABORIGINAL_SYLLABICS='Cans - Unified Canadian Aboriginal Syllabics'
1321
    CARI_CARIAN='Cari - Carian'
1322
    CHAM_CHAM='Cham - Cham'
1323
    CHER_CHEROKEE='Cher - Cherokee'
1324
    CIRT_CIRTH='Cirt - Cirth'
1325
    COPT_COPTIC='Copt - Coptic'
1326
    CPRT_CYPRIOT='Cprt - Cypriot'
1327
    CYRL_CYRILLIC='Cyrl - Cyrillic'
1328
    CYRS_CYRILLIC_OLD_CHURCH_SLAVONICVARIANT='Cyrs - Cyrillic (Old Church Slavonic variant)'
1329
    DEVA_DEVANAGARI_NAGARI='Deva - Devanagari (Nagari)'
1330
    DSRT_DESERET_MORMON='Dsrt - Deseret (Mormon)'
1331
    DUPL_DUPLOYANSHORTHAND_DUPLOYANSTENOGRAPHY='Dupl - Duployan shorthand, Duployan stenography'
1332
    EGYD_EGYPTIANDEMOTIC='Egyd - Egyptian demotic'
1333
    EGYH_EGYPTIANHIERATIC='Egyh - Egyptian hieratic'
1334
    EGYP_EGYPTIANHIEROGLYPHS='Egyp - Egyptian hieroglyphs'
1335
    ELBA_ELBASAN='Elba - Elbasan'
1336
    ETHI_ETHIOPIC='Ethi - Ethiopic'
1337
    GEOK_KHUTSURI_ASOMTAVRULIAND_NUSKHURI='Geok - Khutsuri (Asomtavruli and Nuskhuri)'
1338
    GEOR_GEORGIAN_MKHEDRULI='Geor - Georgian (Mkhedruli)'
1339
    GLAG_GLAGOLITIC='Glag - Glagolitic'
1340
    GOTH_GOTHIC='Goth - Gothic'
1341
    GRAN_GRANTHA='Gran - Grantha'
1342
    GREK_GREEK='Grek - Greek'
1343
    GUJR_GUJARATI='Gujr - Gujarati'
1344
    GURU_GURMUKHI='Guru - Gurmukhi'
1345
    HANB_HANWITH_BOPOMOFO='Hanb - Han with Bopomofo'
1346
    HANG_HANGUL='Hang - Hangul'
1347
    HANI_HAN_HANZI_KANJI_HANJA='Hani - Han (Hanzi, Kanji, Hanja)'
1348
    HANO_HANUNOO_HANUNÓO='Hano - Hanunoo (Hanunóo)'
1349
    HANS_HAN_SIMPLIFIEDVARIANT='Hans - Han (Simplified variant)'
1350
    HANT_HAN_TRADITIONALVARIANT='Hant - Han (Traditional variant)'
1351
    HATR_HATRAN='Hatr - Hatran'
1352
    HEBR_HEBREW='Hebr - Hebrew'
1353
    HIRA_HIRAGANA='Hira - Hiragana'
1354
    HLUW_ANATOLIAN_HIEROGLYPHS='Hluw - Anatolian Hieroglyphs'
1355
    HMNG_PAHAWH_HMONG='Hmng - Pahawh Hmong'
1356
    HRKT_JAPANESESYLLABARIES='Hrkt - Japanese syllabaries'
1357
    HUNG_OLD_HUNGARIAN_HUNGARIAN_RUNIC='Hung - Old Hungarian (Hungarian Runic)'
1358
    INDS_INDUS_HARAPPAN='Inds - Indus (Harappan)'
1359
    ITAL_OLD_ITALIC_ETRUSCAN_OSCANETC='Ital - Old Italic (Etruscan, Oscan etc.)'
1360
    JAMO_JAMO='Jamo - Jamo'
1361
    JAVA_JAVANESE='Java - Javanese'
1362
    JPAN_JAPANESE='Jpan - Japanese'
1363
    JURC_JURCHEN='Jurc - Jurchen'
1364
    KALI_KAYAH_LI='Kali - Kayah Li'
1365
    KANA_KATAKANA='Kana - Katakana'
1366
    KHAR_KHAROSHTHI='Khar - Kharoshthi'
1367
    KHMR_KHMER='Khmr - Khmer'
1368
    KHOJ_KHOJKI='Khoj - Khojki'
1369
    KITL_KHITANLARGESCRIPT='Kitl - Khitan large script'
1370
    KITS_KHITANSMALLSCRIPT='Kits - Khitan small script'
1371
    KNDA_KANNADA='Knda - Kannada'
1372
    KORE_KOREANALIASFOR_HANGUL_HAN='Kore - Korean (alias for Hangul + Han)'
1373
    KPEL_KPELLE='Kpel - Kpelle'
1374
    KTHI_KAITHI='Kthi - Kaithi'
1375
    LANA_TAI_THAM_LANNA='Lana - Tai Tham (Lanna)'
1376
    LAOO_LAO='Laoo - Lao'
1377
    LATF_LATIN_FRAKTURVARIANT='Latf - Latin (Fraktur variant)'
1378
    LATG_LATIN_GAELICVARIANT='Latg - Latin (Gaelic variant)'
1379
    LATN_LATIN='Latn - Latin'
1380
    LEKE_LEKE='Leke - Leke'
1381
    LEPC_LEPCHARÓNG='Lepc - Lepcha (Róng)'
1382
    LIMB_LIMBU='Limb - Limbu'
1383
    LINA_LINEARA='Lina - Linear A'
1384
    LINB_LINEARB='Linb - Linear B'
1385
    LISU_LISU_FRASER='Lisu - Lisu (Fraser)'
1386
    LOMA_LOMA='Loma - Loma'
1387
    LYCI_LYCIAN='Lyci - Lycian'
1388
    LYDI_LYDIAN='Lydi - Lydian'
1389
    MAHJ_MAHAJANI='Mahj - Mahajani'
1390
    MAND_MANDAIC_MANDAEAN='Mand - Mandaic, Mandaean'
1391
    MANI_MANICHAEAN='Mani - Manichaean'
1392
    MARC_MARCHEN='Marc - Marchen'
1393
    MAYA_MAYANHIEROGLYPHS='Maya - Mayan hieroglyphs'
1394
    MEND_MENDE_KIKAKUI='Mend - Mende Kikakui'
1395
    MERC_MEROITIC_CURSIVE='Merc - Meroitic Cursive'
1396
    MERO_MEROITIC_HIEROGLYPHS='Mero - Meroitic Hieroglyphs'
1397
    MLYM_MALAYALAM='Mlym - Malayalam'
1398
    MODI_MODI_MOḌĪ='Modi - Modi, Moḍī'
1399
    MONG_MONGOLIAN='Mong - Mongolian'
1400
    MOON_MOON_MOONCODE_MOONSCRIPT_MOONTYPE='Moon - Moon (Moon code, Moon script, Moon type)'
1401
    MROO_MRO_MRU='Mroo - Mro, Mru'
1402
    MTEI_MEITEI_MAYEK_MEITHEI_MEETEI='Mtei - Meitei Mayek (Meithei, Meetei)'
1403
    MULT_MULTANI='Mult - Multani'
1404
    MYMR_MYANMAR_BURMESE='Mymr - Myanmar (Burmese)'
1405
    NARB_OLD_NORTH_ARABIAN_ANCIENT_NORTH_ARABIAN='Narb - Old North Arabian (Ancient North Arabian)'
1406
    NBAT_NABATAEAN='Nbat - Nabataean'
1407
    NEWA_NEWA_NEWAR_NEWARI='Newa - Newa, Newar, Newari'
1408
    NKGB_NAKHI_GEBA='Nkgb - Nakhi Geba'
1409
    NKOON_KO='Nkoo - N’Ko'
1410
    NSHUNÜSHU='Nshu - Nüshu'
1411
    OGAM_OGHAM='Ogam - Ogham'
1412
    OLCK_OL_CHIKI_OL_CEMET_OL_SANTALI='Olck - Ol Chiki (Ol Cemet’, Ol, Santali)'
1413
    ORKH_OLD_TURKIC_ORKHON_RUNIC='Orkh - Old Turkic, Orkhon Runic'
1414
    ORYA_ORIYA='Orya - Oriya'
1415
    OSGE_OSAGE='Osge - Osage'
1416
    OSMA_OSMANYA='Osma - Osmanya'
1417
    PALM_PALMYRENE='Palm - Palmyrene'
1418
    PAUC_PAU_CIN_HAU='Pauc - Pau Cin Hau'
1419
    PERM_OLD_PERMIC='Perm - Old Permic'
1420
    PHAG_PHAGSPA='Phag - Phags-pa'
1421
    PHLI_INSCRIPTIONAL_PAHLAVI='Phli - Inscriptional Pahlavi'
1422
    PHLP_PSALTER_PAHLAVI='Phlp - Psalter Pahlavi'
1423
    PHLV_BOOK_PAHLAVI='Phlv - Book Pahlavi'
1424
    PHNX_PHOENICIAN='Phnx - Phoenician'
1425
    PIQD_KLINGONKLIP_IQA_D='Piqd - Klingon (KLI pIqaD)'
1426
    PLRD_MIAO_POLLARD='Plrd - Miao (Pollard)'
1427
    PRTI_INSCRIPTIONAL_PARTHIAN='Prti - Inscriptional Parthian'
1428
    RJNG_REJANG_REDJANG_KAGANGA='Rjng - Rejang (Redjang, Kaganga)'
1429
    RORO_RONGORONGO='Roro - Rongorongo'
1430
    RUNR_RUNIC='Runr - Runic'
1431
    SAMR_SAMARITAN='Samr - Samaritan'
1432
    SARA_SARATI='Sara - Sarati'
1433
    SARB_OLD_SOUTH_ARABIAN='Sarb - Old South Arabian'
1434
    SAUR_SAURASHTRA='Saur - Saurashtra'
1435
    SGNW_SIGN_WRITING='Sgnw - SignWriting'
1436
    SHAW_SHAVIAN_SHAW='Shaw - Shavian (Shaw)'
1437
    SHRD_SHARADAŚĀRADĀ='Shrd - Sharada, Śāradā'
1438
    SIDD_SIDDHAM='Sidd - Siddham'
1439
    SIND_KHUDAWADI_SINDHI='Sind - Khudawadi, Sindhi'
1440
    SINH_SINHALA='Sinh - Sinhala'
1441
    SORA_SORA_SOMPENG='Sora - Sora Sompeng'
1442
    SUND_SUNDANESE='Sund - Sundanese'
1443
    SYLO_SYLOTI_NAGRI='Sylo - Syloti Nagri'
1444
    SYRC_SYRIAC='Syrc - Syriac'
1445
    SYRE_SYRIAC_ESTRANGELOVARIANT='Syre - Syriac (Estrangelo variant)'
1446
    SYRJ_SYRIAC_WESTERNVARIANT='Syrj - Syriac (Western variant)'
1447
    SYRN_SYRIAC_EASTERNVARIANT='Syrn - Syriac (Eastern variant)'
1448
    TAGB_TAGBANWA='Tagb - Tagbanwa'
1449
    TAKR_TAKRI='Takr - Takri'
1450
    TALE_TAI_LE='Tale - Tai Le'
1451
    TALU_NEW_TAI_LUE='Talu - New Tai Lue'
1452
    TAML_TAMIL='Taml - Tamil'
1453
    TANG_TANGUT='Tang - Tangut'
1454
    TAVT_TAI_VIET='Tavt - Tai Viet'
1455
    TELU_TELUGU='Telu - Telugu'
1456
    TENG_TENGWAR='Teng - Tengwar'
1457
    TFNG_TIFINAGH_BERBER='Tfng - Tifinagh (Berber)'
1458
    TGLG_TAGALOG_BAYBAYIN_ALIBATA='Tglg - Tagalog (Baybayin, Alibata)'
1459
    THAA_THAANA='Thaa - Thaana'
1460
    THAI_THAI='Thai - Thai'
1461
    TIBT_TIBETAN='Tibt - Tibetan'
1462
    TIRH_TIRHUTA='Tirh - Tirhuta'
1463
    UGAR_UGARITIC='Ugar - Ugaritic'
1464
    VAII_VAI='Vaii - Vai'
1465
    VISP_VISIBLE_SPEECH='Visp - Visible Speech'
1466
    WARA_WARANG_CITI_VARANG_KSHITI='Wara - Warang Citi (Varang Kshiti)'
1467
    WOLE_WOLEAI='Wole - Woleai'
1468
    XPEO_OLD_PERSIAN='Xpeo - Old Persian'
1469
    XSUX_CUNEIFORM_SUMERO_AKKADIAN='Xsux - Cuneiform, Sumero-Akkadian'
1470
    YIII_YI='Yiii - Yi'
1471
    ZINH_CODEFORINHERITEDSCRIPT='Zinh - Code for inherited script'
1472
    ZMTH_MATHEMATICALNOTATION='Zmth - Mathematical notation'
1473
    ZSYE_SYMBOLS_EMOJIVARIANT='Zsye - Symbols (Emoji variant)'
1474
    ZSYM_SYMBOLS='Zsym - Symbols'
1475
    ZXXX_CODEFORUNWRITTENDOCUMENTS='Zxxx - Code for unwritten documents'
1476
    ZYYY_CODEFORUNDETERMINEDSCRIPT='Zyyy - Code for undetermined script'
1477
    ZZZZ_CODEFORUNCODEDSCRIPT='Zzzz - Code for uncoded script'
1478
    OTHER='other'
1479
1480
1481
class TextDataTypeSimpleType(str, Enum):
1482
    XSDDECIMAL='xsd:decimal' # Examples: "123.456", "+1234.456", "-1234.456", "-.456", "-456"
1483
    XSDFLOAT='xsd:float' # Examples: "123.456", "+1234.456", "-1.2344e56", "-.45E-6", "INF", "-INF", "NaN"
1484
    XSDINTEGER='xsd:integer' # Examples: "123456", "+00000012", "-1", "-456"
1485
    XSDBOOLEAN='xsd:boolean' # Examples: "true", "false", "1", "0"
1486
    XSDDATE='xsd:date' # Examples: "2001-10-26", "2001-10-26+02:00", "2001-10-26Z", "2001-10-26+00:00", "-2001-10-26", "-20000-04-01"
1487
    XSDTIME='xsd:time' # Examples: "21:32:52", "21:32:52+02:00", "19:32:52Z", "19:32:52+00:00", "21:32:52.12679"
1488
    XSDDATE_TIME='xsd:dateTime' # Examples: "2001-10-26T21:32:52", "2001-10-26T21:32:52+02:00", "2001-10-26T19:32:52Z", "2001-10-26T19:32:52+00:00", "-2001-10-26T21:32:52", "2001-10-26T21:32:52.12679"
1489
    XSDSTRING='xsd:string' # Generic text string
1490
    OTHER='other' # An XSD type that is not listed or a custom type (use dataTypeDetails attribute).
1491
1492
1493
class TextLineOrderSimpleType(str, Enum):
1494
    TOPTOBOTTOM='top-to-bottom'
1495
    BOTTOMTOTOP='bottom-to-top'
1496
    LEFTTORIGHT='left-to-right'
1497
    RIGHTTOLEFT='right-to-left'
1498
1499
1500
class TextTypeSimpleType(str, Enum):
1501
    PARAGRAPH='paragraph'
1502
    HEADING='heading'
1503
    CAPTION='caption'
1504
    HEADER='header'
1505
    FOOTER='footer'
1506
    PAGENUMBER='page-number'
1507
    DROPCAPITAL='drop-capital'
1508
    CREDIT='credit'
1509
    FLOATING='floating'
1510
    SIGNATUREMARK='signature-mark'
1511
    CATCHWORD='catch-word'
1512
    MARGINALIA='marginalia'
1513
    FOOTNOTE='footnote'
1514
    FOOTNOTECONTINUED='footnote-continued'
1515
    ENDNOTE='endnote'
1516
    TOCENTRY='TOC-entry'
1517
    LISTLABEL='list-label'
1518
    OTHER='other'
1519
1520
1521
class UnderlineStyleSimpleType(str, Enum):
1522
    SINGLE_LINE='singleLine'
1523
    DOUBLE_LINE='doubleLine'
1524
    OTHER='other'
1525
1526
1527
class charTypeType(str, Enum):
1528
    """charTypeType --
1529
    Type of character represented by the
1530
    grapheme, group, or non-printing character element.
1531
    
1532
    """
1533
    BASE='base'
1534
    COMBINING='combining'
1535
1536
1537
class imageResolutionUnitType(str, Enum):
1538
    """imageResolutionUnitType --
1539
    Specifies the unit of the resolution information
1540
    referring to a standardised unit of measurement
1541
    (pixels per inch, pixels per centimeter or other).
1542
    
1543
    """
1544
    PPI='PPI'
1545
    PPCM='PPCM'
1546
    OTHER='other'
1547
1548
1549
class typeType(str, Enum):
1550
    """typeType --
1551
    Type of metadata (e.g. author)
1552
    
1553
    """
1554
    AUTHOR='author'
1555
    IMAGE_PROPERTIES='imageProperties'
1556
    PROCESSING_STEP='processingStep'
1557
    OTHER='other'
1558
1559
1560
class typeType1(str, Enum):
1561
    LINK='link'
1562
    JOIN='join'
1563
1564
1565
class typeType3(str, Enum):
1566
    XSDSTRING='xsd:string'
1567
    XSDINTEGER='xsd:integer'
1568
    XSDBOOLEAN='xsd:boolean'
1569
    XSDFLOAT='xsd:float'
1570
1571
1572
#
1573
# Start data representation classes
1574
#
1575
class PcGtsType(GeneratedsSuper):
1576
    __hash__ = GeneratedsSuper.__hash__
1577
    member_data_items_ = [
1578
        MemberSpec_('pcGtsId', 'string', 0, 1, {'use': 'optional', 'name': 'pcGtsId'}),
1579
        MemberSpec_('Metadata', 'MetadataType', 0, 0, {'name': 'Metadata', 'type': 'MetadataType'}, None),
1580
        MemberSpec_('Page', 'PageType', 0, 0, {'name': 'Page', 'type': 'PageType'}, None),
1581
    ]
1582
    subclass = None
1583
    superclass = None
1584
    def __init__(self, pcGtsId=None, Metadata=None, Page=None, gds_collector_=None, **kwargs_):
1585
        self.gds_collector_ = gds_collector_
1586
        self.gds_elementtree_node_ = None
1587
        self.original_tagname_ = None
1588
        self.parent_object_ = kwargs_.get('parent_object_')
1589
        self.ns_prefix_ = "pc"
1590
        self.pcGtsId = _cast(None, pcGtsId)
1591
        self.pcGtsId_nsprefix_ = "pc"
1592
        self.Metadata = Metadata
1593
        self.Metadata_nsprefix_ = "pc"
1594
        self.Page = Page
1595
        self.Page_nsprefix_ = "pc"
1596
    def factory(*args_, **kwargs_):
1597
        if CurrentSubclassModule_ is not None:
1598
            subclass = getSubclassFromModule_(
1599
                CurrentSubclassModule_, PcGtsType)
1600
            if subclass is not None:
1601
                return subclass(*args_, **kwargs_)
1602
        if PcGtsType.subclass:
1603
            return PcGtsType.subclass(*args_, **kwargs_)
1604
        else:
1605
            return PcGtsType(*args_, **kwargs_)
1606
    factory = staticmethod(factory)
1607
    def get_ns_prefix_(self):
1608
        return self.ns_prefix_
1609
    def set_ns_prefix_(self, ns_prefix):
1610
        self.ns_prefix_ = ns_prefix
1611
    def get_Metadata(self):
1612
        return self.Metadata
1613
    def set_Metadata(self, Metadata):
1614
        self.Metadata = Metadata
1615
    def get_Page(self):
1616
        return self.Page
1617
    def set_Page(self, Page):
1618
        self.Page = Page
1619
    def get_pcGtsId(self):
1620
        return self.pcGtsId
1621
    def set_pcGtsId(self, pcGtsId):
1622
        self.pcGtsId = pcGtsId
1623
    def has__content(self):
1624
        if (
1625
            self.Metadata is not None or
1626
            self.Page is not None
1627
        ):
1628
            return True
1629
        else:
1630
            return False
1631
    def export(self, outfile, level, namespaceprefix_='', namespacedef_='xmlns:pc="http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15"', name_='PcGtsType', pretty_print=True):
1632
        imported_ns_def_ = GenerateDSNamespaceDefs_.get('PcGtsType')
1633
        if imported_ns_def_ is not None:
1634
            namespacedef_ = imported_ns_def_
1635
        if pretty_print:
1636
            eol_ = '\n'
1637
        else:
1638
            eol_ = ''
1639
        if self.original_tagname_ is not None and name_ == 'PcGtsType':
1640
            name_ = self.original_tagname_
1641
        if UseCapturedNS_ and self.ns_prefix_:
1642
            namespaceprefix_ = self.ns_prefix_ + ':'
1643
        showIndent(outfile, level, pretty_print)
1644
        outfile.write('<%s%s%s' % (namespaceprefix_, name_, namespacedef_ and ' ' + namespacedef_ or '', ))
1645
        already_processed = set()
1646
        self._exportAttributes(outfile, level, already_processed, namespaceprefix_, name_='PcGtsType')
1647
        if self.has__content():
1648
            outfile.write('>%s' % (eol_, ))
1649
            self._exportChildren(outfile, level + 1, namespaceprefix_, namespacedef_, name_='PcGtsType', pretty_print=pretty_print)
1650
            showIndent(outfile, level, pretty_print)
1651
            outfile.write('</%s%s>%s' % (namespaceprefix_, name_, eol_))
1652
        else:
1653
            outfile.write('/>%s' % (eol_, ))
1654
    def _exportAttributes(self, outfile, level, already_processed, namespaceprefix_='', name_='PcGtsType'):
1655
        if self.pcGtsId is not None and 'pcGtsId' not in already_processed:
1656
            already_processed.add('pcGtsId')
1657
            outfile.write(' pcGtsId=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.pcGtsId), input_name='pcGtsId')), ))
1658
    def _exportChildren(self, outfile, level, namespaceprefix_='', namespacedef_='xmlns:pc="http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15"', name_='PcGtsType', fromsubclass_=False, pretty_print=True):
1659
        if pretty_print:
1660
            eol_ = '\n'
1661
        else:
1662
            eol_ = ''
1663
        if self.Metadata is not None:
1664
            namespaceprefix_ = self.Metadata_nsprefix_ + ':' if (UseCapturedNS_ and self.Metadata_nsprefix_) else ''
1665
            self.Metadata.export(outfile, level, namespaceprefix_, namespacedef_='', name_='Metadata', pretty_print=pretty_print)
1666
        if self.Page is not None:
1667
            namespaceprefix_ = self.Page_nsprefix_ + ':' if (UseCapturedNS_ and self.Page_nsprefix_) else ''
1668
            self.Page.export(outfile, level, namespaceprefix_, namespacedef_='', name_='Page', pretty_print=pretty_print)
1669
    def to_etree(self, parent_element=None, name_='PcGtsType', mapping_=None, reverse_mapping_=None, nsmap_=None):
1670
        if parent_element is None:
1671
            element = etree_.Element('{http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15}' + name_, nsmap=nsmap_)
1672
        else:
1673
            element = etree_.SubElement(parent_element, '{http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15}' + name_, nsmap=nsmap_)
1674
        if self.pcGtsId is not None:
1675
            element.set('pcGtsId', self.gds_format_string(self.pcGtsId))
1676
        if self.Metadata is not None:
1677
            Metadata_ = self.Metadata
1678
            Metadata_.to_etree(element, name_='Metadata', mapping_=mapping_, reverse_mapping_=reverse_mapping_, nsmap_=nsmap_)
1679
        if self.Page is not None:
1680
            Page_ = self.Page
1681
            Page_.to_etree(element, name_='Page', mapping_=mapping_, reverse_mapping_=reverse_mapping_, nsmap_=nsmap_)
1682
        if mapping_ is not None:
1683
            mapping_[id(self)] = element
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable id does not seem to be defined.
Loading history...
1684
        if reverse_mapping_ is not None:
1685
            reverse_mapping_[element] = self
1686
        return element
1687
    def build(self, node, gds_collector_=None):
1688
        self.gds_collector_ = gds_collector_
1689
        if SaveElementTreeNode:
1690
            self.gds_elementtree_node_ = node
1691
        already_processed = set()
1692
        self.ns_prefix_ = node.prefix
1693
        self._buildAttributes(node, node.attrib, already_processed)
1694
        for child in node:
1695
            nodeName_ = Tag_pattern_.match(child.tag).groups()[-1]
1696
            self._buildChildren(child, node, nodeName_, gds_collector_=gds_collector_)
1697
        return self
1698
    def _buildAttributes(self, node, attrs, already_processed):
1699
        value = find_attr_value_('pcGtsId', node)
1700
        if value is not None and 'pcGtsId' not in already_processed:
1701
            already_processed.add('pcGtsId')
1702
            self.pcGtsId = value
1703
    def _buildChildren(self, child_, node, nodeName_, fromsubclass_=False, gds_collector_=None):
1704
        if nodeName_ == 'Metadata':
1705
            obj_ = MetadataType.factory(parent_object_=self)
1706
            obj_.build(child_, gds_collector_=gds_collector_)
1707
            self.Metadata = obj_
1708
            obj_.original_tagname_ = 'Metadata'
1709
        elif nodeName_ == 'Page':
1710
            obj_ = PageType.factory(parent_object_=self)
1711
            obj_.build(child_, gds_collector_=gds_collector_)
1712
            self.Page = obj_
1713
            obj_.original_tagname_ = 'Page'
1714
    def __hash__(self):
1715
        return hash(self.id)
1716
    @property
1717
    def id(self):
1718
        from ocrd_utils import make_xml_id
1719
        if hasattr(self, 'pcGtsId'):
1720
            return self.pcGtsId or ''
1721
        return make_xml_id(self.imageFilename)
1722 View Code Duplication
    def get_AllAlternativeImagePaths(self, page=True, region=True, line=True, word=True, glyph=True):
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
1723
        """
1724
        Get all the ``pc:AlternativeImage/@filename`` paths referenced in the PAGE-XML document.
1725
    
1726
        Arguments:
1727
            page (boolean): Get images on ``pc:Page`` level
1728
            region (boolean): Get images on ``pc:*Region`` level
1729
            line (boolean): Get images on ``pc:TextLine`` level
1730
            word (boolean): Get images on ``pc:Word`` level
1731
            glyph (boolean): Get images on ``pc:Glyph`` level
1732
    
1733
        Returns:
1734
            a list of image filename strings
1735
        """
1736
        from .constants import NAMESPACES, PAGE_REGION_TYPES # pylint: disable=relative-beyond-top-level,import-outside-toplevel
1737
        from io import StringIO  # pylint: disable=import-outside-toplevel
1738
        ret = []
1739
        # XXX Since we're only interested in the **paths** of the images,
1740
        # export, parse and xpath are less convoluted than traversing
1741
        # the generateDS API. Quite possibly not as efficient as could be.
1742
        sio = StringIO()
1743
        self.export(
1744
                outfile=sio,
1745
                level=0,
1746
                name_='PcGts',
1747
                namespaceprefix_='pc:',
1748
                namespacedef_='xmlns:pc="%s" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="%s %s/pagecontent.xsd"' % (
1749
                    NAMESPACES['page'],
1750
                    NAMESPACES['page'],
1751
                    NAMESPACES['page']
1752
                ))
1753
        doc = parsexmlstring_(sio.getvalue())  # pylint: disable=undefined-variable
1754
        # shortcut
1755
        if page and region and line and word and glyph:
1756
            ret += doc.xpath('//page:AlternativeImage/@filename', namespaces=NAMESPACES)
1757
        else:
1758
            if page:
1759
                ret += doc.xpath('/page:PcGts/page:Page/page:AlternativeImage/@filename', namespaces=NAMESPACES)
1760
            if region:
1761
                for class_ in PAGE_REGION_TYPES:
1762
                    ret += doc.xpath('//page:%sRegion/page:AlternativeImage/@filename' % class_, namespaces=NAMESPACES)
1763
            if line:
1764
                ret += doc.xpath('//page:TextLine/page:AlternativeImage/@filename', namespaces=NAMESPACES)
1765
            if word:
1766
                ret += doc.xpath('//page:Word/page:AlternativeImage/@filename', namespaces=NAMESPACES)
1767
            if glyph:
1768
                ret += doc.xpath('//page:Glyph/page:AlternativeImage/@filename', namespaces=NAMESPACES)
1769
    
1770
        return ret
1771 View Code Duplication
    def prune_ReadingOrder(self):
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
1772
        """
1773
        Remove any empty ReadingOrder elements
1774
        """
1775
        ro = self.get_Page().get_ReadingOrder()
1776
        if ro:
1777
            og = ro.get_OrderedGroup()
1778
            if og and (not og.get_RegionRefIndexed() and
1779
                       not og.get_OrderedGroupIndexed() and
1780
                       not og.get_UnorderedGroupIndexed()):
1781
                og = None
1782
            ug = ro.get_UnorderedGroup()
1783
            if ug and (not ug.get_RegionRef() and
1784
                       not ug.get_OrderedGroup() and
1785
                       not ug.get_UnorderedGroup()):
1786
                ug = None
1787
            if not og and not ug:
1788
                self.get_Page().set_ReadingOrder(None)
1789
# end class PcGtsType
1790
1791
1792
class MetadataType(GeneratedsSuper):
1793
    """externalRef -- External reference of any kind
1794
    Created --
1795
    The timestamp has to be in UTC (Coordinated
1796
    Universal Time) and not local time.
1797
      
1798
    * LastChange --
1799
      The timestamp has to be in UTC
1800
      (Coordinated Universal Time)
1801
      and not local time.
1802
    
1803
    """
1804
    __hash__ = GeneratedsSuper.__hash__
1805
    member_data_items_ = [
1806
        MemberSpec_('externalRef', 'string', 0, 1, {'use': 'optional', 'name': 'externalRef'}),
1807
        MemberSpec_('Creator', 'string', 0, 0, {'name': 'Creator', 'type': 'string'}, None),
1808
        MemberSpec_('Created', 'dateTime', 0, 0, {'name': 'Created', 'type': 'dateTime'}, None),
1809
        MemberSpec_('LastChange', 'dateTime', 0, 0, {'name': 'LastChange', 'type': 'dateTime'}, None),
1810
        MemberSpec_('Comments', 'string', 0, 1, {'maxOccurs': '1', 'minOccurs': '0', 'name': 'Comments', 'type': 'string'}, None),
1811
        MemberSpec_('UserDefined', 'UserDefinedType', 0, 1, {'maxOccurs': '1', 'minOccurs': '0', 'name': 'UserDefined', 'type': 'UserDefinedType'}, None),
1812
        MemberSpec_('MetadataItem', 'MetadataItemType', 1, 1, {'maxOccurs': 'unbounded', 'minOccurs': '0', 'name': 'MetadataItem', 'type': 'MetadataItemType'}, None),
1813
    ]
1814
    subclass = None
1815
    superclass = None
1816
    def __init__(self, externalRef=None, Creator=None, Created=None, LastChange=None, Comments=None, UserDefined=None, MetadataItem=None, gds_collector_=None, **kwargs_):
1817
        self.gds_collector_ = gds_collector_
1818
        self.gds_elementtree_node_ = None
1819
        self.original_tagname_ = None
1820
        self.parent_object_ = kwargs_.get('parent_object_')
1821
        self.ns_prefix_ = None
1822
        self.externalRef = _cast(None, externalRef)
1823
        self.externalRef_nsprefix_ = "pc"
1824
        self.Creator = Creator
1825
        self.Creator_nsprefix_ = "pc"
1826
        if isinstance(Created, BaseStrType_):
1827
            initvalue_ = datetime_.datetime.strptime(Created, '%Y-%m-%dT%H:%M:%S')
1828
        else:
1829
            initvalue_ = Created
1830
        self.Created = initvalue_
1831
        self.Created_nsprefix_ = "pc"
1832
        if isinstance(LastChange, BaseStrType_):
1833
            initvalue_ = datetime_.datetime.strptime(LastChange, '%Y-%m-%dT%H:%M:%S')
1834
        else:
1835
            initvalue_ = LastChange
1836
        self.LastChange = initvalue_
1837
        self.LastChange_nsprefix_ = "pc"
1838
        self.Comments = Comments
1839
        self.Comments_nsprefix_ = "pc"
1840
        self.UserDefined = UserDefined
1841
        self.UserDefined_nsprefix_ = "pc"
1842
        if MetadataItem is None:
1843
            self.MetadataItem = []
1844
        else:
1845
            self.MetadataItem = MetadataItem
1846
        self.MetadataItem_nsprefix_ = "pc"
1847
    def factory(*args_, **kwargs_):
1848
        if CurrentSubclassModule_ is not None:
1849
            subclass = getSubclassFromModule_(
1850
                CurrentSubclassModule_, MetadataType)
1851
            if subclass is not None:
1852
                return subclass(*args_, **kwargs_)
1853
        if MetadataType.subclass:
1854
            return MetadataType.subclass(*args_, **kwargs_)
1855
        else:
1856
            return MetadataType(*args_, **kwargs_)
1857
    factory = staticmethod(factory)
1858
    def get_ns_prefix_(self):
1859
        return self.ns_prefix_
1860
    def set_ns_prefix_(self, ns_prefix):
1861
        self.ns_prefix_ = ns_prefix
1862
    def get_Creator(self):
1863
        return self.Creator
1864
    def set_Creator(self, Creator):
1865
        self.Creator = Creator
1866
    def get_Created(self):
1867
        return self.Created
1868
    def set_Created(self, Created):
1869
        self.Created = Created
1870
    def get_LastChange(self):
1871
        return self.LastChange
1872
    def set_LastChange(self, LastChange):
1873
        self.LastChange = LastChange
1874
    def get_Comments(self):
1875
        return self.Comments
1876
    def set_Comments(self, Comments):
1877
        self.Comments = Comments
1878
    def get_UserDefined(self):
1879
        return self.UserDefined
1880
    def set_UserDefined(self, UserDefined):
1881
        self.UserDefined = UserDefined
1882
    def get_MetadataItem(self):
1883
        return self.MetadataItem
1884
    def set_MetadataItem(self, MetadataItem):
1885
        self.MetadataItem = MetadataItem
1886
    def add_MetadataItem(self, value):
1887
        self.MetadataItem.append(value)
1888
    def insert_MetadataItem_at(self, index, value):
1889
        self.MetadataItem.insert(index, value)
1890
    def replace_MetadataItem_at(self, index, value):
1891
        self.MetadataItem[index] = value
1892
    def get_externalRef(self):
1893
        return self.externalRef
1894
    def set_externalRef(self, externalRef):
1895
        self.externalRef = externalRef
1896
    def has__content(self):
1897
        if (
1898
            self.Creator is not None or
1899
            self.Created is not None or
1900
            self.LastChange is not None or
1901
            self.Comments is not None or
1902
            self.UserDefined is not None or
1903
            self.MetadataItem
1904
        ):
1905
            return True
1906
        else:
1907
            return False
1908
    def export(self, outfile, level, namespaceprefix_='', namespacedef_='xmlns:pc="http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15" xmlns:None="http://www.w3.org/2001/XMLSchema" ', name_='MetadataType', pretty_print=True):
1909
        imported_ns_def_ = GenerateDSNamespaceDefs_.get('MetadataType')
1910
        if imported_ns_def_ is not None:
1911
            namespacedef_ = imported_ns_def_
1912
        if pretty_print:
1913
            eol_ = '\n'
1914
        else:
1915
            eol_ = ''
1916
        if self.original_tagname_ is not None and name_ == 'MetadataType':
1917
            name_ = self.original_tagname_
1918
        if UseCapturedNS_ and self.ns_prefix_:
1919
            namespaceprefix_ = self.ns_prefix_ + ':'
1920
        showIndent(outfile, level, pretty_print)
1921
        outfile.write('<%s%s%s' % (namespaceprefix_, name_, namespacedef_ and ' ' + namespacedef_ or '', ))
1922
        already_processed = set()
1923
        self._exportAttributes(outfile, level, already_processed, namespaceprefix_, name_='MetadataType')
1924
        if self.has__content():
1925
            outfile.write('>%s' % (eol_, ))
1926
            self._exportChildren(outfile, level + 1, namespaceprefix_, namespacedef_, name_='MetadataType', pretty_print=pretty_print)
1927
            showIndent(outfile, level, pretty_print)
1928
            outfile.write('</%s%s>%s' % (namespaceprefix_, name_, eol_))
1929
        else:
1930
            outfile.write('/>%s' % (eol_, ))
1931
    def _exportAttributes(self, outfile, level, already_processed, namespaceprefix_='', name_='MetadataType'):
1932
        if self.externalRef is not None and 'externalRef' not in already_processed:
1933
            already_processed.add('externalRef')
1934
            outfile.write(' externalRef=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.externalRef), input_name='externalRef')), ))
1935
    def _exportChildren(self, outfile, level, namespaceprefix_='', namespacedef_='xmlns:pc="http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15" xmlns:None="http://www.w3.org/2001/XMLSchema" ', name_='MetadataType', fromsubclass_=False, pretty_print=True):
1936
        if pretty_print:
1937
            eol_ = '\n'
1938
        else:
1939
            eol_ = ''
1940
        if self.Creator is not None:
1941
            namespaceprefix_ = self.Creator_nsprefix_ + ':' if (UseCapturedNS_ and self.Creator_nsprefix_) else ''
1942
            showIndent(outfile, level, pretty_print)
1943
            outfile.write('<%sCreator>%s</%sCreator>%s' % (namespaceprefix_ , self.gds_encode(self.gds_format_string(quote_xml(self.Creator), input_name='Creator')), namespaceprefix_ , eol_))
1944
        if self.Created is not None:
1945
            namespaceprefix_ = self.Created_nsprefix_ + ':' if (UseCapturedNS_ and self.Created_nsprefix_) else ''
1946
            showIndent(outfile, level, pretty_print)
1947
            outfile.write('<%sCreated>%s</%sCreated>%s' % (namespaceprefix_ , self.gds_format_datetime(self.Created, input_name='Created'), namespaceprefix_ , eol_))
1948
        if self.LastChange is not None:
1949
            namespaceprefix_ = self.LastChange_nsprefix_ + ':' if (UseCapturedNS_ and self.LastChange_nsprefix_) else ''
1950
            showIndent(outfile, level, pretty_print)
1951
            outfile.write('<%sLastChange>%s</%sLastChange>%s' % (namespaceprefix_ , self.gds_format_datetime(self.LastChange, input_name='LastChange'), namespaceprefix_ , eol_))
1952
        if self.Comments is not None:
1953
            namespaceprefix_ = self.Comments_nsprefix_ + ':' if (UseCapturedNS_ and self.Comments_nsprefix_) else ''
1954
            showIndent(outfile, level, pretty_print)
1955
            outfile.write('<%sComments>%s</%sComments>%s' % (namespaceprefix_ , self.gds_encode(self.gds_format_string(quote_xml(self.Comments), input_name='Comments')), namespaceprefix_ , eol_))
1956
        if self.UserDefined is not None:
1957
            namespaceprefix_ = self.UserDefined_nsprefix_ + ':' if (UseCapturedNS_ and self.UserDefined_nsprefix_) else ''
1958
            self.UserDefined.export(outfile, level, namespaceprefix_, namespacedef_='', name_='UserDefined', pretty_print=pretty_print)
1959
        for MetadataItem_ in self.MetadataItem:
1960
            namespaceprefix_ = self.MetadataItem_nsprefix_ + ':' if (UseCapturedNS_ and self.MetadataItem_nsprefix_) else ''
1961
            MetadataItem_.export(outfile, level, namespaceprefix_, namespacedef_='', name_='MetadataItem', pretty_print=pretty_print)
1962
    def to_etree(self, parent_element=None, name_='MetadataType', mapping_=None, reverse_mapping_=None, nsmap_=None):
1963
        if parent_element is None:
1964
            element = etree_.Element('{http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15}' + name_, nsmap=nsmap_)
1965
        else:
1966
            element = etree_.SubElement(parent_element, '{http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15}' + name_, nsmap=nsmap_)
1967
        if self.externalRef is not None:
1968
            element.set('externalRef', self.gds_format_string(self.externalRef))
1969
        if self.Creator is not None:
1970
            Creator_ = self.Creator
1971
            etree_.SubElement(element, '{http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15}Creator').text = self.gds_format_string(Creator_)
1972
        if self.Created is not None:
1973
            Created_ = self.Created
1974
            etree_.SubElement(element, '{http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15}Created').text = self.gds_format_datetime(Created_)
1975
        if self.LastChange is not None:
1976
            LastChange_ = self.LastChange
1977
            etree_.SubElement(element, '{http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15}LastChange').text = self.gds_format_datetime(LastChange_)
1978
        if self.Comments is not None:
1979
            Comments_ = self.Comments
1980
            etree_.SubElement(element, '{http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15}Comments').text = self.gds_format_string(Comments_)
1981
        if self.UserDefined is not None:
1982
            UserDefined_ = self.UserDefined
1983
            UserDefined_.to_etree(element, name_='UserDefined', mapping_=mapping_, reverse_mapping_=reverse_mapping_, nsmap_=nsmap_)
1984
        for MetadataItem_ in self.MetadataItem:
1985
            MetadataItem_.to_etree(element, name_='MetadataItem', mapping_=mapping_, reverse_mapping_=reverse_mapping_, nsmap_=nsmap_)
1986
        if mapping_ is not None:
1987
            mapping_[id(self)] = element
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable id does not seem to be defined.
Loading history...
1988
        if reverse_mapping_ is not None:
1989
            reverse_mapping_[element] = self
1990
        return element
1991
    def build(self, node, gds_collector_=None):
1992
        self.gds_collector_ = gds_collector_
1993
        if SaveElementTreeNode:
1994
            self.gds_elementtree_node_ = node
1995
        already_processed = set()
1996
        self.ns_prefix_ = node.prefix
1997
        self._buildAttributes(node, node.attrib, already_processed)
1998
        for child in node:
1999
            nodeName_ = Tag_pattern_.match(child.tag).groups()[-1]
2000
            self._buildChildren(child, node, nodeName_, gds_collector_=gds_collector_)
2001
        return self
2002
    def _buildAttributes(self, node, attrs, already_processed):
2003
        value = find_attr_value_('externalRef', node)
2004
        if value is not None and 'externalRef' not in already_processed:
2005
            already_processed.add('externalRef')
2006
            self.externalRef = value
2007
    def _buildChildren(self, child_, node, nodeName_, fromsubclass_=False, gds_collector_=None):
2008
        if nodeName_ == 'Creator':
2009
            value_ = child_.text
2010
            value_ = self.gds_parse_string(value_, node, 'Creator')
2011
            value_ = self.gds_validate_string(value_, node, 'Creator')
2012
            self.Creator = value_
2013
2014
        elif nodeName_ == 'Created':
2015
            sval_ = child_.text
2016
            dval_ = self.gds_parse_datetime(sval_)
2017
            self.Created = dval_
2018
2019
        elif nodeName_ == 'LastChange':
2020
            sval_ = child_.text
2021
            dval_ = self.gds_parse_datetime(sval_)
2022
            self.LastChange = dval_
2023
2024
        elif nodeName_ == 'Comments':
2025
            value_ = child_.text
2026
            value_ = self.gds_parse_string(value_, node, 'Comments')
2027
            value_ = self.gds_validate_string(value_, node, 'Comments')
2028
            self.Comments = value_
2029
2030
        elif nodeName_ == 'UserDefined':
2031
            obj_ = UserDefinedType.factory(parent_object_=self)
2032
            obj_.build(child_, gds_collector_=gds_collector_)
2033
            self.UserDefined = obj_
2034
            obj_.original_tagname_ = 'UserDefined'
2035
        elif nodeName_ == 'MetadataItem':
2036
            obj_ = MetadataItemType.factory(parent_object_=self)
2037
            obj_.build(child_, gds_collector_=gds_collector_)
2038
            self.MetadataItem.append(obj_)
2039
            obj_.original_tagname_ = 'MetadataItem'
2040
    def __hash__(self):
2041
        return hash(self.id)
2042
# end class MetadataType
2043
2044
2045
class MetadataItemType(GeneratedsSuper):
2046
    """type --
2047
    Type of metadata (e.g. author)
2048
      
2049
    * name --
2050
      E.g. imagePhotometricInterpretation
2051
      
2052
    * value -- E.g. RGB
2053
    * Labels -- Semantic labels / tags
2054
    
2055
    """
2056
    __hash__ = GeneratedsSuper.__hash__
2057
    member_data_items_ = [
2058
        MemberSpec_('type_', 'typeType', 0, 1, {'use': 'optional', 'name': 'type_'}),
2059
        MemberSpec_('name', 'string', 0, 1, {'use': 'optional', 'name': 'name'}),
2060
        MemberSpec_('value', 'string', 0, 0, {'use': 'required', 'name': 'value'}),
2061
        MemberSpec_('date', 'dateTime', 0, 1, {'use': 'optional', 'name': 'date'}),
2062
        MemberSpec_('Labels', 'LabelsType', 1, 1, {'maxOccurs': 'unbounded', 'minOccurs': '0', 'name': 'Labels', 'type': 'LabelsType'}, None),
2063
    ]
2064
    subclass = None
2065
    superclass = None
2066
    def __init__(self, type_=None, name=None, value=None, date=None, Labels=None, gds_collector_=None, **kwargs_):
2067
        self.gds_collector_ = gds_collector_
2068
        self.gds_elementtree_node_ = None
2069
        self.original_tagname_ = None
2070
        self.parent_object_ = kwargs_.get('parent_object_')
2071
        self.ns_prefix_ = "pc"
2072
        self.type_ = _cast(None, type_)
2073
        self.type__nsprefix_ = "pc"
2074
        self.name = _cast(None, name)
2075
        self.name_nsprefix_ = "pc"
2076
        self.value = _cast(None, value)
2077
        self.value_nsprefix_ = "pc"
2078
        if isinstance(date, BaseStrType_):
2079
            initvalue_ = datetime_.datetime.strptime(date, '%Y-%m-%dT%H:%M:%S')
2080
        else:
2081
            initvalue_ = date
2082
        self.date = initvalue_
2083
        if Labels is None:
2084
            self.Labels = []
2085
        else:
2086
            self.Labels = Labels
2087
        self.Labels_nsprefix_ = "pc"
2088
    def factory(*args_, **kwargs_):
2089
        if CurrentSubclassModule_ is not None:
2090
            subclass = getSubclassFromModule_(
2091
                CurrentSubclassModule_, MetadataItemType)
2092
            if subclass is not None:
2093
                return subclass(*args_, **kwargs_)
2094
        if MetadataItemType.subclass:
2095
            return MetadataItemType.subclass(*args_, **kwargs_)
2096
        else:
2097
            return MetadataItemType(*args_, **kwargs_)
2098
    factory = staticmethod(factory)
2099
    def get_ns_prefix_(self):
2100
        return self.ns_prefix_
2101
    def set_ns_prefix_(self, ns_prefix):
2102
        self.ns_prefix_ = ns_prefix
2103
    def get_Labels(self):
2104
        return self.Labels
2105
    def set_Labels(self, Labels):
2106
        self.Labels = Labels
2107
    def add_Labels(self, value):
2108
        self.Labels.append(value)
2109
    def insert_Labels_at(self, index, value):
2110
        self.Labels.insert(index, value)
2111
    def replace_Labels_at(self, index, value):
2112
        self.Labels[index] = value
2113
    def get_type(self):
2114
        return self.type_
2115
    def set_type(self, type_):
2116
        self.type_ = type_
2117
    def get_name(self):
2118
        return self.name
2119
    def set_name(self, name):
2120
        self.name = name
2121
    def get_value(self):
2122
        return self.value
2123
    def set_value(self, value):
2124
        self.value = value
2125
    def get_date(self):
2126
        return self.date
2127
    def set_date(self, date):
2128
        self.date = date
2129
    def validate_typeType(self, value):
2130
        # Validate type typeType, a restriction on string.
2131
        if value is not None and Validate_simpletypes_ and self.gds_collector_ is not None:
2132
            if not isinstance(value, str):
2133
                lineno = self.gds_get_node_lineno_()
2134
                self.gds_collector_.add_message('Value "%(value)s"%(lineno)s is not of the correct base simple type (str)' % {"value": value, "lineno": lineno, })
2135
                return False
2136
            value = value
2137
            enumerations = ['author', 'imageProperties', 'processingStep', 'other']
2138
            if value not in enumerations:
2139
                lineno = self.gds_get_node_lineno_()
2140
                self.gds_collector_.add_message('Value "%(value)s"%(lineno)s does not match xsd enumeration restriction on typeType' % {"value" : encode_str_2_3(value), "lineno": lineno} )
2141
                result = False
2142
    def has__content(self):
2143
        if (
2144
            self.Labels
2145
        ):
2146
            return True
2147
        else:
2148
            return False
2149
    def export(self, outfile, level, namespaceprefix_='', namespacedef_='xmlns:pc="http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15"', name_='MetadataItemType', pretty_print=True):
2150
        imported_ns_def_ = GenerateDSNamespaceDefs_.get('MetadataItemType')
2151
        if imported_ns_def_ is not None:
2152
            namespacedef_ = imported_ns_def_
2153
        if pretty_print:
2154
            eol_ = '\n'
2155
        else:
2156
            eol_ = ''
2157
        if self.original_tagname_ is not None and name_ == 'MetadataItemType':
2158
            name_ = self.original_tagname_
2159
        if UseCapturedNS_ and self.ns_prefix_:
2160
            namespaceprefix_ = self.ns_prefix_ + ':'
2161
        showIndent(outfile, level, pretty_print)
2162
        outfile.write('<%s%s%s' % (namespaceprefix_, name_, namespacedef_ and ' ' + namespacedef_ or '', ))
2163
        already_processed = set()
2164
        self._exportAttributes(outfile, level, already_processed, namespaceprefix_, name_='MetadataItemType')
2165
        if self.has__content():
2166
            outfile.write('>%s' % (eol_, ))
2167
            self._exportChildren(outfile, level + 1, namespaceprefix_, namespacedef_, name_='MetadataItemType', pretty_print=pretty_print)
2168
            showIndent(outfile, level, pretty_print)
2169
            outfile.write('</%s%s>%s' % (namespaceprefix_, name_, eol_))
2170
        else:
2171
            outfile.write('/>%s' % (eol_, ))
2172
    def _exportAttributes(self, outfile, level, already_processed, namespaceprefix_='', name_='MetadataItemType'):
2173
        if self.type_ is not None and 'type_' not in already_processed:
2174
            already_processed.add('type_')
2175
            outfile.write(' type=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.type_), input_name='type')), ))
2176
        if self.name is not None and 'name' not in already_processed:
2177
            already_processed.add('name')
2178
            outfile.write(' name=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.name), input_name='name')), ))
2179
        if self.value is not None and 'value' not in already_processed:
2180
            already_processed.add('value')
2181
            outfile.write(' value=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.value), input_name='value')), ))
2182
        if self.date is not None and 'date' not in already_processed:
2183
            already_processed.add('date')
2184
            outfile.write(' date="%s"' % self.gds_format_datetime(self.date, input_name='date'))
2185
    def _exportChildren(self, outfile, level, namespaceprefix_='', namespacedef_='xmlns:pc="http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15"', name_='MetadataItemType', fromsubclass_=False, pretty_print=True):
2186
        if pretty_print:
2187
            eol_ = '\n'
2188
        else:
2189
            eol_ = ''
2190
        for Labels_ in self.Labels:
2191
            namespaceprefix_ = self.Labels_nsprefix_ + ':' if (UseCapturedNS_ and self.Labels_nsprefix_) else ''
2192
            Labels_.export(outfile, level, namespaceprefix_, namespacedef_='', name_='Labels', pretty_print=pretty_print)
2193
    def to_etree(self, parent_element=None, name_='MetadataItemType', mapping_=None, reverse_mapping_=None, nsmap_=None):
2194
        if parent_element is None:
2195
            element = etree_.Element('{http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15}' + name_, nsmap=nsmap_)
2196
        else:
2197
            element = etree_.SubElement(parent_element, '{http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15}' + name_, nsmap=nsmap_)
2198
        if self.type_ is not None:
2199
            element.set('type', self.gds_format_string(self.type_))
2200
        if self.name is not None:
2201
            element.set('name', self.gds_format_string(self.name))
2202
        if self.value is not None:
2203
            element.set('value', self.gds_format_string(self.value))
2204
        if self.date is not None:
2205
            element.set('date', self.gds_format_datetime(self.date))
2206
        for Labels_ in self.Labels:
2207
            Labels_.to_etree(element, name_='Labels', mapping_=mapping_, reverse_mapping_=reverse_mapping_, nsmap_=nsmap_)
2208
        if mapping_ is not None:
2209
            mapping_[id(self)] = element
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable id does not seem to be defined.
Loading history...
2210
        if reverse_mapping_ is not None:
2211
            reverse_mapping_[element] = self
2212
        return element
2213
    def build(self, node, gds_collector_=None):
2214
        self.gds_collector_ = gds_collector_
2215
        if SaveElementTreeNode:
2216
            self.gds_elementtree_node_ = node
2217
        already_processed = set()
2218
        self.ns_prefix_ = node.prefix
2219
        self._buildAttributes(node, node.attrib, already_processed)
2220
        for child in node:
2221
            nodeName_ = Tag_pattern_.match(child.tag).groups()[-1]
2222
            self._buildChildren(child, node, nodeName_, gds_collector_=gds_collector_)
2223
        return self
2224
    def _buildAttributes(self, node, attrs, already_processed):
2225
        value = find_attr_value_('type', node)
2226
        if value is not None and 'type' not in already_processed:
2227
            already_processed.add('type')
2228
            self.type_ = value
2229
            self.validate_typeType(self.type_)    # validate type typeType
2230
        value = find_attr_value_('name', node)
2231
        if value is not None and 'name' not in already_processed:
2232
            already_processed.add('name')
2233
            self.name = value
2234
        value = find_attr_value_('value', node)
2235
        if value is not None and 'value' not in already_processed:
2236
            already_processed.add('value')
2237
            self.value = value
2238
        value = find_attr_value_('date', node)
2239
        if value is not None and 'date' not in already_processed:
2240
            already_processed.add('date')
2241
            try:
2242
                self.date = self.gds_parse_datetime(value)
2243
            except ValueError as exp:
2244
                raise ValueError('Bad date-time attribute (date): %s' % exp)
2245
    def _buildChildren(self, child_, node, nodeName_, fromsubclass_=False, gds_collector_=None):
2246
        if nodeName_ == 'Labels':
2247
            obj_ = LabelsType.factory(parent_object_=self)
2248
            obj_.build(child_, gds_collector_=gds_collector_)
2249
            self.Labels.append(obj_)
2250
            obj_.original_tagname_ = 'Labels'
2251
    def __hash__(self):
2252
        return hash(self.id)
2253
# end class MetadataItemType
2254
2255
2256
class LabelsType(GeneratedsSuper):
2257
    """externalModel --
2258
    Reference to external model / ontology / schema
2259
      
2260
    * externalId --
2261
      E.g. an RDF resource identifier
2262
      (to be used as subject or object of an RDF triple)
2263
      
2264
    * prefix --
2265
      Prefix for all labels (e.g. first part of an URI)
2266
      
2267
    * Label --
2268
      A semantic label / tag
2269
    
2270
    """
2271
    __hash__ = GeneratedsSuper.__hash__
2272
    member_data_items_ = [
2273
        MemberSpec_('externalModel', 'string', 0, 1, {'use': 'optional', 'name': 'externalModel'}),
2274
        MemberSpec_('externalId', 'string', 0, 1, {'use': 'optional', 'name': 'externalId'}),
2275
        MemberSpec_('prefix', 'string', 0, 1, {'use': 'optional', 'name': 'prefix'}),
2276
        MemberSpec_('comments', 'string', 0, 1, {'use': 'optional', 'name': 'comments'}),
2277
        MemberSpec_('Label', 'LabelType', 1, 1, {'maxOccurs': 'unbounded', 'minOccurs': '0', 'name': 'Label', 'type': 'LabelType'}, None),
2278
    ]
2279
    subclass = None
2280
    superclass = None
2281
    def __init__(self, externalModel=None, externalId=None, prefix=None, comments=None, Label=None, gds_collector_=None, **kwargs_):
2282
        self.gds_collector_ = gds_collector_
2283
        self.gds_elementtree_node_ = None
2284
        self.original_tagname_ = None
2285
        self.parent_object_ = kwargs_.get('parent_object_')
2286
        self.ns_prefix_ = "pc"
2287
        self.externalModel = _cast(None, externalModel)
2288
        self.externalModel_nsprefix_ = "pc"
2289
        self.externalId = _cast(None, externalId)
2290
        self.externalId_nsprefix_ = "pc"
2291
        self.prefix = _cast(None, prefix)
2292
        self.prefix_nsprefix_ = "pc"
2293
        self.comments = _cast(None, comments)
2294
        self.comments_nsprefix_ = "pc"
2295
        if Label is None:
2296
            self.Label = []
2297
        else:
2298
            self.Label = Label
2299
        self.Label_nsprefix_ = "pc"
2300
    def factory(*args_, **kwargs_):
2301
        if CurrentSubclassModule_ is not None:
2302
            subclass = getSubclassFromModule_(
2303
                CurrentSubclassModule_, LabelsType)
2304
            if subclass is not None:
2305
                return subclass(*args_, **kwargs_)
2306
        if LabelsType.subclass:
2307
            return LabelsType.subclass(*args_, **kwargs_)
2308
        else:
2309
            return LabelsType(*args_, **kwargs_)
2310
    factory = staticmethod(factory)
2311
    def get_ns_prefix_(self):
2312
        return self.ns_prefix_
2313
    def set_ns_prefix_(self, ns_prefix):
2314
        self.ns_prefix_ = ns_prefix
2315
    def get_Label(self):
2316
        return self.Label
2317
    def set_Label(self, Label):
2318
        self.Label = Label
2319
    def add_Label(self, value):
2320
        self.Label.append(value)
2321
    def insert_Label_at(self, index, value):
2322
        self.Label.insert(index, value)
2323
    def replace_Label_at(self, index, value):
2324
        self.Label[index] = value
2325
    def get_externalModel(self):
2326
        return self.externalModel
2327
    def set_externalModel(self, externalModel):
2328
        self.externalModel = externalModel
2329
    def get_externalId(self):
2330
        return self.externalId
2331
    def set_externalId(self, externalId):
2332
        self.externalId = externalId
2333
    def get_prefix(self):
2334
        return self.prefix
2335
    def set_prefix(self, prefix):
2336
        self.prefix = prefix
2337
    def get_comments(self):
2338
        return self.comments
2339
    def set_comments(self, comments):
2340
        self.comments = comments
2341
    def has__content(self):
2342
        if (
2343
            self.Label
2344
        ):
2345
            return True
2346
        else:
2347
            return False
2348
    def export(self, outfile, level, namespaceprefix_='', namespacedef_='xmlns:pc="http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15"', name_='LabelsType', pretty_print=True):
2349
        imported_ns_def_ = GenerateDSNamespaceDefs_.get('LabelsType')
2350
        if imported_ns_def_ is not None:
2351
            namespacedef_ = imported_ns_def_
2352
        if pretty_print:
2353
            eol_ = '\n'
2354
        else:
2355
            eol_ = ''
2356
        if self.original_tagname_ is not None and name_ == 'LabelsType':
2357
            name_ = self.original_tagname_
2358
        if UseCapturedNS_ and self.ns_prefix_:
2359
            namespaceprefix_ = self.ns_prefix_ + ':'
2360
        showIndent(outfile, level, pretty_print)
2361
        outfile.write('<%s%s%s' % (namespaceprefix_, name_, namespacedef_ and ' ' + namespacedef_ or '', ))
2362
        already_processed = set()
2363
        self._exportAttributes(outfile, level, already_processed, namespaceprefix_, name_='LabelsType')
2364
        if self.has__content():
2365
            outfile.write('>%s' % (eol_, ))
2366
            self._exportChildren(outfile, level + 1, namespaceprefix_, namespacedef_, name_='LabelsType', pretty_print=pretty_print)
2367
            showIndent(outfile, level, pretty_print)
2368
            outfile.write('</%s%s>%s' % (namespaceprefix_, name_, eol_))
2369
        else:
2370
            outfile.write('/>%s' % (eol_, ))
2371 View Code Duplication
    def _exportAttributes(self, outfile, level, already_processed, namespaceprefix_='', name_='LabelsType'):
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
2372
        if self.externalModel is not None and 'externalModel' not in already_processed:
2373
            already_processed.add('externalModel')
2374
            outfile.write(' externalModel=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.externalModel), input_name='externalModel')), ))
2375
        if self.externalId is not None and 'externalId' not in already_processed:
2376
            already_processed.add('externalId')
2377
            outfile.write(' externalId=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.externalId), input_name='externalId')), ))
2378
        if self.prefix is not None and 'prefix' not in already_processed:
2379
            already_processed.add('prefix')
2380
            outfile.write(' prefix=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.prefix), input_name='prefix')), ))
2381
        if self.comments is not None and 'comments' not in already_processed:
2382
            already_processed.add('comments')
2383
            outfile.write(' comments=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.comments), input_name='comments')), ))
2384
    def _exportChildren(self, outfile, level, namespaceprefix_='', namespacedef_='xmlns:pc="http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15"', name_='LabelsType', fromsubclass_=False, pretty_print=True):
2385
        if pretty_print:
2386
            eol_ = '\n'
2387
        else:
2388
            eol_ = ''
2389
        for Label_ in self.Label:
2390
            namespaceprefix_ = self.Label_nsprefix_ + ':' if (UseCapturedNS_ and self.Label_nsprefix_) else ''
2391
            Label_.export(outfile, level, namespaceprefix_, namespacedef_='', name_='Label', pretty_print=pretty_print)
2392
    def to_etree(self, parent_element=None, name_='LabelsType', mapping_=None, reverse_mapping_=None, nsmap_=None):
2393
        if parent_element is None:
2394
            element = etree_.Element('{http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15}' + name_, nsmap=nsmap_)
2395
        else:
2396
            element = etree_.SubElement(parent_element, '{http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15}' + name_, nsmap=nsmap_)
2397
        if self.externalModel is not None:
2398
            element.set('externalModel', self.gds_format_string(self.externalModel))
2399
        if self.externalId is not None:
2400
            element.set('externalId', self.gds_format_string(self.externalId))
2401
        if self.prefix is not None:
2402
            element.set('prefix', self.gds_format_string(self.prefix))
2403
        if self.comments is not None:
2404
            element.set('comments', self.gds_format_string(self.comments))
2405
        for Label_ in self.Label:
2406
            Label_.to_etree(element, name_='Label', mapping_=mapping_, reverse_mapping_=reverse_mapping_, nsmap_=nsmap_)
2407
        if mapping_ is not None:
2408
            mapping_[id(self)] = element
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable id does not seem to be defined.
Loading history...
2409
        if reverse_mapping_ is not None:
2410
            reverse_mapping_[element] = self
2411
        return element
2412
    def build(self, node, gds_collector_=None):
2413
        self.gds_collector_ = gds_collector_
2414
        if SaveElementTreeNode:
2415
            self.gds_elementtree_node_ = node
2416
        already_processed = set()
2417
        self.ns_prefix_ = node.prefix
2418
        self._buildAttributes(node, node.attrib, already_processed)
2419
        for child in node:
2420
            nodeName_ = Tag_pattern_.match(child.tag).groups()[-1]
2421
            self._buildChildren(child, node, nodeName_, gds_collector_=gds_collector_)
2422
        return self
2423
    def _buildAttributes(self, node, attrs, already_processed):
2424
        value = find_attr_value_('externalModel', node)
2425
        if value is not None and 'externalModel' not in already_processed:
2426
            already_processed.add('externalModel')
2427
            self.externalModel = value
2428
        value = find_attr_value_('externalId', node)
2429
        if value is not None and 'externalId' not in already_processed:
2430
            already_processed.add('externalId')
2431
            self.externalId = value
2432
        value = find_attr_value_('prefix', node)
2433
        if value is not None and 'prefix' not in already_processed:
2434
            already_processed.add('prefix')
2435
            self.prefix = value
2436
        value = find_attr_value_('comments', node)
2437
        if value is not None and 'comments' not in already_processed:
2438
            already_processed.add('comments')
2439
            self.comments = value
2440
    def _buildChildren(self, child_, node, nodeName_, fromsubclass_=False, gds_collector_=None):
2441
        if nodeName_ == 'Label':
2442
            obj_ = LabelType.factory(parent_object_=self)
2443
            obj_.build(child_, gds_collector_=gds_collector_)
2444
            self.Label.append(obj_)
2445
            obj_.original_tagname_ = 'Label'
2446
    def __hash__(self):
2447
        return hash(self.id)
2448
# end class LabelsType
2449
2450
2451
class LabelType(GeneratedsSuper):
2452
    """LabelType -- Semantic label
2453
    value --
2454
    The label / tag (e.g. 'person').
2455
    Can be an RDF resource identifier
2456
    (e.g. object of an RDF triple).
2457
      
2458
    * type --
2459
      Additional information on the label
2460
      (e.g. 'YYYY-mm-dd' for a date label).
2461
      Can be used as predicate of an RDF triple.
2462
    
2463
    """
2464
    __hash__ = GeneratedsSuper.__hash__
2465
    member_data_items_ = [
2466
        MemberSpec_('value', 'string', 0, 0, {'use': 'required', 'name': 'value'}),
2467
        MemberSpec_('type_', 'string', 0, 1, {'use': 'optional', 'name': 'type_'}),
2468
        MemberSpec_('comments', 'string', 0, 1, {'use': 'optional', 'name': 'comments'}),
2469
    ]
2470
    subclass = None
2471
    superclass = None
2472
    def __init__(self, value=None, type_=None, comments=None, gds_collector_=None, **kwargs_):
2473
        self.gds_collector_ = gds_collector_
2474
        self.gds_elementtree_node_ = None
2475
        self.original_tagname_ = None
2476
        self.parent_object_ = kwargs_.get('parent_object_')
2477
        self.ns_prefix_ = "pc"
2478
        self.value = _cast(None, value)
2479
        self.value_nsprefix_ = "pc"
2480
        self.type_ = _cast(None, type_)
2481
        self.type__nsprefix_ = "pc"
2482
        self.comments = _cast(None, comments)
2483
        self.comments_nsprefix_ = "pc"
2484
    def factory(*args_, **kwargs_):
2485
        if CurrentSubclassModule_ is not None:
2486
            subclass = getSubclassFromModule_(
2487
                CurrentSubclassModule_, LabelType)
2488
            if subclass is not None:
2489
                return subclass(*args_, **kwargs_)
2490
        if LabelType.subclass:
2491
            return LabelType.subclass(*args_, **kwargs_)
2492
        else:
2493
            return LabelType(*args_, **kwargs_)
2494
    factory = staticmethod(factory)
2495
    def get_ns_prefix_(self):
2496
        return self.ns_prefix_
2497
    def set_ns_prefix_(self, ns_prefix):
2498
        self.ns_prefix_ = ns_prefix
2499
    def get_value(self):
2500
        return self.value
2501
    def set_value(self, value):
2502
        self.value = value
2503
    def get_type(self):
2504
        return self.type_
2505
    def set_type(self, type_):
2506
        self.type_ = type_
2507
    def get_comments(self):
2508
        return self.comments
2509
    def set_comments(self, comments):
2510
        self.comments = comments
2511
    def has__content(self):
2512
        if (
2513
2514
        ):
2515
            return True
2516
        else:
2517
            return False
2518
    def export(self, outfile, level, namespaceprefix_='', namespacedef_='xmlns:pc="http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15"', name_='LabelType', pretty_print=True):
2519
        imported_ns_def_ = GenerateDSNamespaceDefs_.get('LabelType')
2520
        if imported_ns_def_ is not None:
2521
            namespacedef_ = imported_ns_def_
2522
        if pretty_print:
2523
            eol_ = '\n'
2524
        else:
2525
            eol_ = ''
2526
        if self.original_tagname_ is not None and name_ == 'LabelType':
2527
            name_ = self.original_tagname_
2528
        if UseCapturedNS_ and self.ns_prefix_:
2529
            namespaceprefix_ = self.ns_prefix_ + ':'
2530
        showIndent(outfile, level, pretty_print)
2531
        outfile.write('<%s%s%s' % (namespaceprefix_, name_, namespacedef_ and ' ' + namespacedef_ or '', ))
2532
        already_processed = set()
2533
        self._exportAttributes(outfile, level, already_processed, namespaceprefix_, name_='LabelType')
2534
        if self.has__content():
2535
            outfile.write('>%s' % (eol_, ))
2536
            self._exportChildren(outfile, level + 1, namespaceprefix_, namespacedef_, name_='LabelType', pretty_print=pretty_print)
2537
            outfile.write('</%s%s>%s' % (namespaceprefix_, name_, eol_))
2538
        else:
2539
            outfile.write('/>%s' % (eol_, ))
2540 View Code Duplication
    def _exportAttributes(self, outfile, level, already_processed, namespaceprefix_='', name_='LabelType'):
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
2541
        if self.value is not None and 'value' not in already_processed:
2542
            already_processed.add('value')
2543
            outfile.write(' value=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.value), input_name='value')), ))
2544
        if self.type_ is not None and 'type_' not in already_processed:
2545
            already_processed.add('type_')
2546
            outfile.write(' type=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.type_), input_name='type')), ))
2547
        if self.comments is not None and 'comments' not in already_processed:
2548
            already_processed.add('comments')
2549
            outfile.write(' comments=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.comments), input_name='comments')), ))
2550
    def _exportChildren(self, outfile, level, namespaceprefix_='', namespacedef_='xmlns:pc="http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15"', name_='LabelType', fromsubclass_=False, pretty_print=True):
2551
        pass
2552 View Code Duplication
    def to_etree(self, parent_element=None, name_='LabelType', mapping_=None, reverse_mapping_=None, nsmap_=None):
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
2553
        if parent_element is None:
2554
            element = etree_.Element('{http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15}' + name_, nsmap=nsmap_)
2555
        else:
2556
            element = etree_.SubElement(parent_element, '{http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15}' + name_, nsmap=nsmap_)
2557
        if self.value is not None:
2558
            element.set('value', self.gds_format_string(self.value))
2559
        if self.type_ is not None:
2560
            element.set('type', self.gds_format_string(self.type_))
2561
        if self.comments is not None:
2562
            element.set('comments', self.gds_format_string(self.comments))
2563
        if mapping_ is not None:
2564
            mapping_[id(self)] = element
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable id does not seem to be defined.
Loading history...
2565
        if reverse_mapping_ is not None:
2566
            reverse_mapping_[element] = self
2567
        return element
2568
    def build(self, node, gds_collector_=None):
2569
        self.gds_collector_ = gds_collector_
2570
        if SaveElementTreeNode:
2571
            self.gds_elementtree_node_ = node
2572
        already_processed = set()
2573
        self.ns_prefix_ = node.prefix
2574
        self._buildAttributes(node, node.attrib, already_processed)
2575
        for child in node:
2576
            nodeName_ = Tag_pattern_.match(child.tag).groups()[-1]
2577
            self._buildChildren(child, node, nodeName_, gds_collector_=gds_collector_)
2578
        return self
2579
    def _buildAttributes(self, node, attrs, already_processed):
2580
        value = find_attr_value_('value', node)
2581
        if value is not None and 'value' not in already_processed:
2582
            already_processed.add('value')
2583
            self.value = value
2584
        value = find_attr_value_('type', node)
2585
        if value is not None and 'type' not in already_processed:
2586
            already_processed.add('type')
2587
            self.type_ = value
2588
        value = find_attr_value_('comments', node)
2589
        if value is not None and 'comments' not in already_processed:
2590
            already_processed.add('comments')
2591
            self.comments = value
2592
    def _buildChildren(self, child_, node, nodeName_, fromsubclass_=False, gds_collector_=None):
2593
        pass
2594
    def __hash__(self):
2595
        return hash(self.id)
2596
# end class LabelType
2597
2598
2599
class PageType(GeneratedsSuper):
2600
    """imageFilename --
2601
    Contains the image file name including the file extension.
2602
      
2603
    * imageWidth -- Specifies the width of the image.
2604
    * imageHeight -- Specifies the height of the image.
2605
    * imageXResolution -- Specifies the image resolution in width.
2606
    * imageYResolution -- Specifies the image resolution in height.
2607
    * imageResolutionUnit --
2608
      Specifies the unit of the resolution information
2609
      referring to a standardised unit of measurement
2610
      (pixels per inch, pixels per centimeter or other).
2611
      
2612
    * custom -- For generic use
2613
    * orientation --
2614
      The angle the rectangle encapsulating the page
2615
      (or its Border)	has to be rotated in clockwise direction
2616
      in order to correct the present skew
2617
      (negative values indicate anti-clockwise rotation).
2618
      (The rotated image can be further referenced
2619
      via
2620
2621
      AlternativeImage
2622
2623
      .)
2624
      Range: -179.999,180
2625
      
2626
    * type --
2627
      The type of the page within the document
2628
      (e.g. cover page).
2629
      
2630
    * primaryLanguage --
2631
      The primary language used in the page
2632
      (lower-level definitions override the page-level definition).
2633
      
2634
    * secondaryLanguage --
2635
      The secondary language used in the page
2636
      (lower-level definitions override the page-level definition).
2637
      
2638
    * primaryScript --
2639
      The primary script used in the page
2640
      (lower-level definitions override the page-level definition).
2641
      
2642
    * secondaryScript --
2643
      The secondary script used in the page
2644
      (lower-level definitions override the page-level definition).
2645
      
2646
    * readingDirection --
2647
      The direction in which text within lines
2648
      should be read (order of words and characters),
2649
      in addition to
2650
2651
      textLineOrder
2652
2653
      (lower-level definitions override the page-level definition).
2654
      
2655
    * textLineOrder --
2656
      The order of text lines within a block,
2657
      in addition to
2658
2659
      readingDirection
2660
2661
      (lower-level definitions override the page-level definition).
2662
      
2663
    * conf -- Confidence value for whole page (between 0 and 1)
2664
    * AlternativeImage --
2665
      Alternative document page images
2666
      (e.g. black-and-white).
2667
      
2668
    * ReadingOrder -- Order of blocks within the page.
2669
    * Layers --
2670
      Unassigned regions are considered to be in the
2671
      (virtual) default layer which is to be treated
2672
      as below any other layers.
2673
      
2674
    * TextStyle -- Default text style
2675
    * Labels -- Semantic labels / tags
2676
    
2677
    """
2678
    __hash__ = GeneratedsSuper.__hash__
2679
    member_data_items_ = [
2680
        MemberSpec_('imageFilename', 'string', 0, 0, {'use': 'required', 'name': 'imageFilename'}),
2681
        MemberSpec_('imageWidth', 'int', 0, 0, {'use': 'required', 'name': 'imageWidth'}),
2682
        MemberSpec_('imageHeight', 'int', 0, 0, {'use': 'required', 'name': 'imageHeight'}),
2683
        MemberSpec_('imageXResolution', 'float', 0, 1, {'use': 'optional', 'name': 'imageXResolution'}),
2684
        MemberSpec_('imageYResolution', 'float', 0, 1, {'use': 'optional', 'name': 'imageYResolution'}),
2685
        MemberSpec_('imageResolutionUnit', 'imageResolutionUnitType', 0, 1, {'use': 'optional', 'name': 'imageResolutionUnit'}),
2686
        MemberSpec_('custom', 'string', 0, 1, {'use': 'optional', 'name': 'custom'}),
2687
        MemberSpec_('orientation', 'float', 0, 1, {'use': 'optional', 'name': 'orientation'}),
2688
        MemberSpec_('type_', 'pc:PageTypeSimpleType', 0, 1, {'use': 'optional', 'name': 'type_'}),
2689
        MemberSpec_('primaryLanguage', 'pc:LanguageSimpleType', 0, 1, {'use': 'optional', 'name': 'primaryLanguage'}),
2690
        MemberSpec_('secondaryLanguage', 'pc:LanguageSimpleType', 0, 1, {'use': 'optional', 'name': 'secondaryLanguage'}),
2691
        MemberSpec_('primaryScript', 'pc:ScriptSimpleType', 0, 1, {'use': 'optional', 'name': 'primaryScript'}),
2692
        MemberSpec_('secondaryScript', 'pc:ScriptSimpleType', 0, 1, {'use': 'optional', 'name': 'secondaryScript'}),
2693
        MemberSpec_('readingDirection', 'pc:ReadingDirectionSimpleType', 0, 1, {'use': 'optional', 'name': 'readingDirection'}),
2694
        MemberSpec_('textLineOrder', 'pc:TextLineOrderSimpleType', 0, 1, {'use': 'optional', 'name': 'textLineOrder'}),
2695
        MemberSpec_('conf', 'pc:ConfSimpleType', 0, 1, {'use': 'optional', 'name': 'conf'}),
2696
        MemberSpec_('AlternativeImage', 'AlternativeImageType', 1, 1, {'maxOccurs': 'unbounded', 'minOccurs': '0', 'name': 'AlternativeImage', 'type': 'AlternativeImageType'}, None),
2697
        MemberSpec_('Border', 'BorderType', 0, 1, {'maxOccurs': '1', 'minOccurs': '0', 'name': 'Border', 'type': 'BorderType'}, None),
2698
        MemberSpec_('PrintSpace', 'PrintSpaceType', 0, 1, {'maxOccurs': '1', 'minOccurs': '0', 'name': 'PrintSpace', 'type': 'PrintSpaceType'}, None),
2699
        MemberSpec_('ReadingOrder', 'ReadingOrderType', 0, 1, {'maxOccurs': '1', 'minOccurs': '0', 'name': 'ReadingOrder', 'type': 'ReadingOrderType'}, None),
2700
        MemberSpec_('Layers', 'LayersType', 0, 1, {'maxOccurs': '1', 'minOccurs': '0', 'name': 'Layers', 'type': 'LayersType'}, None),
2701
        MemberSpec_('Relations', 'RelationsType', 0, 1, {'minOccurs': '0', 'name': 'Relations', 'type': 'RelationsType'}, None),
2702
        MemberSpec_('TextStyle', 'TextStyleType', 0, 1, {'maxOccurs': '1', 'minOccurs': '0', 'name': 'TextStyle', 'type': 'TextStyleType'}, None),
2703
        MemberSpec_('UserDefined', 'UserDefinedType', 0, 1, {'maxOccurs': '1', 'minOccurs': '0', 'name': 'UserDefined', 'type': 'UserDefinedType'}, None),
2704
        MemberSpec_('Labels', 'LabelsType', 1, 1, {'maxOccurs': 'unbounded', 'minOccurs': '0', 'name': 'Labels', 'type': 'LabelsType'}, None),
2705
        MemberSpec_('TextRegion', 'TextRegionType', 1, 1, {'name': 'TextRegion', 'type': 'TextRegionType'}, 1),
2706
        MemberSpec_('ImageRegion', 'ImageRegionType', 1, 1, {'name': 'ImageRegion', 'type': 'ImageRegionType'}, 1),
2707
        MemberSpec_('LineDrawingRegion', 'LineDrawingRegionType', 1, 1, {'name': 'LineDrawingRegion', 'type': 'LineDrawingRegionType'}, 1),
2708
        MemberSpec_('GraphicRegion', 'GraphicRegionType', 1, 1, {'name': 'GraphicRegion', 'type': 'GraphicRegionType'}, 1),
2709
        MemberSpec_('TableRegion', 'TableRegionType', 1, 1, {'name': 'TableRegion', 'type': 'TableRegionType'}, 1),
2710
        MemberSpec_('ChartRegion', 'ChartRegionType', 1, 1, {'name': 'ChartRegion', 'type': 'ChartRegionType'}, 1),
2711
        MemberSpec_('MapRegion', 'MapRegionType', 1, 1, {'name': 'MapRegion', 'type': 'MapRegionType'}, 1),
2712
        MemberSpec_('SeparatorRegion', 'SeparatorRegionType', 1, 1, {'name': 'SeparatorRegion', 'type': 'SeparatorRegionType'}, 1),
2713
        MemberSpec_('MathsRegion', 'MathsRegionType', 1, 1, {'name': 'MathsRegion', 'type': 'MathsRegionType'}, 1),
2714
        MemberSpec_('ChemRegion', 'ChemRegionType', 1, 1, {'name': 'ChemRegion', 'type': 'ChemRegionType'}, 1),
2715
        MemberSpec_('MusicRegion', 'MusicRegionType', 1, 1, {'name': 'MusicRegion', 'type': 'MusicRegionType'}, 1),
2716
        MemberSpec_('AdvertRegion', 'AdvertRegionType', 1, 1, {'name': 'AdvertRegion', 'type': 'AdvertRegionType'}, 1),
2717
        MemberSpec_('NoiseRegion', 'NoiseRegionType', 1, 1, {'name': 'NoiseRegion', 'type': 'NoiseRegionType'}, 1),
2718
        MemberSpec_('UnknownRegion', 'UnknownRegionType', 1, 1, {'name': 'UnknownRegion', 'type': 'UnknownRegionType'}, 1),
2719
        MemberSpec_('CustomRegion', 'CustomRegionType', 1, 1, {'name': 'CustomRegion', 'type': 'CustomRegionType'}, 1),
2720
    ]
2721
    subclass = None
2722
    superclass = None
2723
    def __init__(self, imageFilename=None, imageWidth=None, imageHeight=None, imageXResolution=None, imageYResolution=None, imageResolutionUnit=None, custom=None, orientation=None, type_=None, primaryLanguage=None, secondaryLanguage=None, primaryScript=None, secondaryScript=None, readingDirection=None, textLineOrder=None, conf=None, AlternativeImage=None, Border=None, PrintSpace=None, ReadingOrder=None, Layers=None, Relations=None, TextStyle=None, UserDefined=None, Labels=None, TextRegion=None, ImageRegion=None, LineDrawingRegion=None, GraphicRegion=None, TableRegion=None, ChartRegion=None, MapRegion=None, SeparatorRegion=None, MathsRegion=None, ChemRegion=None, MusicRegion=None, AdvertRegion=None, NoiseRegion=None, UnknownRegion=None, CustomRegion=None, gds_collector_=None, **kwargs_):
2724
        self.gds_collector_ = gds_collector_
2725
        self.gds_elementtree_node_ = None
2726
        self.original_tagname_ = None
2727
        self.parent_object_ = kwargs_.get('parent_object_')
2728
        self.ns_prefix_ = "pc"
2729
        self.imageFilename = _cast(None, imageFilename)
2730
        self.imageFilename_nsprefix_ = "pc"
2731
        self.imageWidth = _cast(int, imageWidth)
2732
        self.imageWidth_nsprefix_ = "pc"
2733
        self.imageHeight = _cast(int, imageHeight)
2734
        self.imageHeight_nsprefix_ = "pc"
2735
        self.imageXResolution = _cast(float, imageXResolution)
2736
        self.imageXResolution_nsprefix_ = "pc"
2737
        self.imageYResolution = _cast(float, imageYResolution)
2738
        self.imageYResolution_nsprefix_ = "pc"
2739
        self.imageResolutionUnit = _cast(None, imageResolutionUnit)
2740
        self.imageResolutionUnit_nsprefix_ = "pc"
2741
        self.custom = _cast(None, custom)
2742
        self.custom_nsprefix_ = "pc"
2743
        self.orientation = _cast(float, orientation)
2744
        self.orientation_nsprefix_ = "pc"
2745
        self.type_ = _cast(None, type_)
2746
        self.type__nsprefix_ = "pc"
2747
        self.primaryLanguage = _cast(None, primaryLanguage)
2748
        self.primaryLanguage_nsprefix_ = "pc"
2749
        self.secondaryLanguage = _cast(None, secondaryLanguage)
2750
        self.secondaryLanguage_nsprefix_ = "pc"
2751
        self.primaryScript = _cast(None, primaryScript)
2752
        self.primaryScript_nsprefix_ = "pc"
2753
        self.secondaryScript = _cast(None, secondaryScript)
2754
        self.secondaryScript_nsprefix_ = "pc"
2755
        self.readingDirection = _cast(None, readingDirection)
2756
        self.readingDirection_nsprefix_ = "pc"
2757
        self.textLineOrder = _cast(None, textLineOrder)
2758
        self.textLineOrder_nsprefix_ = "pc"
2759
        self.conf = _cast(float, conf)
2760
        self.conf_nsprefix_ = "pc"
2761
        if AlternativeImage is None:
2762
            self.AlternativeImage = []
2763
        else:
2764
            self.AlternativeImage = AlternativeImage
2765
        self.AlternativeImage_nsprefix_ = "pc"
2766
        self.Border = Border
2767
        self.Border_nsprefix_ = "pc"
2768
        self.PrintSpace = PrintSpace
2769
        self.PrintSpace_nsprefix_ = "pc"
2770
        self.ReadingOrder = ReadingOrder
2771
        self.ReadingOrder_nsprefix_ = "pc"
2772
        self.Layers = Layers
2773
        self.Layers_nsprefix_ = "pc"
2774
        self.Relations = Relations
2775
        self.Relations_nsprefix_ = "pc"
2776
        self.TextStyle = TextStyle
2777
        self.TextStyle_nsprefix_ = "pc"
2778
        self.UserDefined = UserDefined
2779
        self.UserDefined_nsprefix_ = "pc"
2780
        if Labels is None:
2781
            self.Labels = []
2782
        else:
2783
            self.Labels = Labels
2784
        self.Labels_nsprefix_ = "pc"
2785
        if TextRegion is None:
2786
            self.TextRegion = []
2787
        else:
2788
            self.TextRegion = TextRegion
2789
        self.TextRegion_nsprefix_ = "pc"
2790
        if ImageRegion is None:
2791
            self.ImageRegion = []
2792
        else:
2793
            self.ImageRegion = ImageRegion
2794
        self.ImageRegion_nsprefix_ = "pc"
2795
        if LineDrawingRegion is None:
2796
            self.LineDrawingRegion = []
2797
        else:
2798
            self.LineDrawingRegion = LineDrawingRegion
2799
        self.LineDrawingRegion_nsprefix_ = "pc"
2800
        if GraphicRegion is None:
2801
            self.GraphicRegion = []
2802
        else:
2803
            self.GraphicRegion = GraphicRegion
2804
        self.GraphicRegion_nsprefix_ = "pc"
2805
        if TableRegion is None:
2806
            self.TableRegion = []
2807
        else:
2808
            self.TableRegion = TableRegion
2809
        self.TableRegion_nsprefix_ = "pc"
2810
        if ChartRegion is None:
2811
            self.ChartRegion = []
2812
        else:
2813
            self.ChartRegion = ChartRegion
2814
        self.ChartRegion_nsprefix_ = "pc"
2815
        if MapRegion is None:
2816
            self.MapRegion = []
2817
        else:
2818
            self.MapRegion = MapRegion
2819
        self.MapRegion_nsprefix_ = "pc"
2820
        if SeparatorRegion is None:
2821
            self.SeparatorRegion = []
2822
        else:
2823
            self.SeparatorRegion = SeparatorRegion
2824
        self.SeparatorRegion_nsprefix_ = "pc"
2825
        if MathsRegion is None:
2826
            self.MathsRegion = []
2827
        else:
2828
            self.MathsRegion = MathsRegion
2829
        self.MathsRegion_nsprefix_ = "pc"
2830
        if ChemRegion is None:
2831
            self.ChemRegion = []
2832
        else:
2833
            self.ChemRegion = ChemRegion
2834
        self.ChemRegion_nsprefix_ = "pc"
2835
        if MusicRegion is None:
2836
            self.MusicRegion = []
2837
        else:
2838
            self.MusicRegion = MusicRegion
2839
        self.MusicRegion_nsprefix_ = "pc"
2840
        if AdvertRegion is None:
2841
            self.AdvertRegion = []
2842
        else:
2843
            self.AdvertRegion = AdvertRegion
2844
        self.AdvertRegion_nsprefix_ = "pc"
2845
        if NoiseRegion is None:
2846
            self.NoiseRegion = []
2847
        else:
2848
            self.NoiseRegion = NoiseRegion
2849
        self.NoiseRegion_nsprefix_ = "pc"
2850
        if UnknownRegion is None:
2851
            self.UnknownRegion = []
2852
        else:
2853
            self.UnknownRegion = UnknownRegion
2854
        self.UnknownRegion_nsprefix_ = "pc"
2855
        if CustomRegion is None:
2856
            self.CustomRegion = []
2857
        else:
2858
            self.CustomRegion = CustomRegion
2859
        self.CustomRegion_nsprefix_ = "pc"
2860
    def factory(*args_, **kwargs_):
2861
        if CurrentSubclassModule_ is not None:
2862
            subclass = getSubclassFromModule_(
2863
                CurrentSubclassModule_, PageType)
2864
            if subclass is not None:
2865
                return subclass(*args_, **kwargs_)
2866
        if PageType.subclass:
2867
            return PageType.subclass(*args_, **kwargs_)
2868
        else:
2869
            return PageType(*args_, **kwargs_)
2870
    factory = staticmethod(factory)
2871
    def get_ns_prefix_(self):
2872
        return self.ns_prefix_
2873
    def set_ns_prefix_(self, ns_prefix):
2874
        self.ns_prefix_ = ns_prefix
2875
    def get_AlternativeImage(self):
2876
        return self.AlternativeImage
2877
    def set_AlternativeImage(self, AlternativeImage):
2878
        self.AlternativeImage = AlternativeImage
2879
    def add_AlternativeImage(self, value):
2880
        self.AlternativeImage.append(value)
2881
    def insert_AlternativeImage_at(self, index, value):
2882
        self.AlternativeImage.insert(index, value)
2883
    def replace_AlternativeImage_at(self, index, value):
2884
        self.AlternativeImage[index] = value
2885
    def get_Border(self):
2886
        return self.Border
2887
    def set_Border(self, Border):
2888
        self.Border = Border
2889
    def get_PrintSpace(self):
2890
        return self.PrintSpace
2891
    def set_PrintSpace(self, PrintSpace):
2892
        self.PrintSpace = PrintSpace
2893
    def get_ReadingOrder(self):
2894
        return self.ReadingOrder
2895
    def set_ReadingOrder(self, ReadingOrder):
2896
        self.ReadingOrder = ReadingOrder
2897
    def get_Layers(self):
2898
        return self.Layers
2899
    def set_Layers(self, Layers):
2900
        self.Layers = Layers
2901
    def get_Relations(self):
2902
        return self.Relations
2903
    def set_Relations(self, Relations):
2904
        self.Relations = Relations
2905
    def get_TextStyle(self):
2906
        return self.TextStyle
2907
    def set_TextStyle(self, TextStyle):
2908
        self.TextStyle = TextStyle
2909
    def get_UserDefined(self):
2910
        return self.UserDefined
2911
    def set_UserDefined(self, UserDefined):
2912
        self.UserDefined = UserDefined
2913
    def get_Labels(self):
2914
        return self.Labels
2915
    def set_Labels(self, Labels):
2916
        self.Labels = Labels
2917
    def add_Labels(self, value):
2918
        self.Labels.append(value)
2919
    def insert_Labels_at(self, index, value):
2920
        self.Labels.insert(index, value)
2921
    def replace_Labels_at(self, index, value):
2922
        self.Labels[index] = value
2923
    def get_TextRegion(self):
2924
        return self.TextRegion
2925
    def set_TextRegion(self, TextRegion):
2926
        self.TextRegion = TextRegion
2927
    def add_TextRegion(self, value):
2928
        self.TextRegion.append(value)
2929
    def insert_TextRegion_at(self, index, value):
2930
        self.TextRegion.insert(index, value)
2931
    def replace_TextRegion_at(self, index, value):
2932
        self.TextRegion[index] = value
2933
    def get_ImageRegion(self):
2934
        return self.ImageRegion
2935
    def set_ImageRegion(self, ImageRegion):
2936
        self.ImageRegion = ImageRegion
2937
    def add_ImageRegion(self, value):
2938
        self.ImageRegion.append(value)
2939
    def insert_ImageRegion_at(self, index, value):
2940
        self.ImageRegion.insert(index, value)
2941
    def replace_ImageRegion_at(self, index, value):
2942
        self.ImageRegion[index] = value
2943
    def get_LineDrawingRegion(self):
2944
        return self.LineDrawingRegion
2945
    def set_LineDrawingRegion(self, LineDrawingRegion):
2946
        self.LineDrawingRegion = LineDrawingRegion
2947
    def add_LineDrawingRegion(self, value):
2948
        self.LineDrawingRegion.append(value)
2949
    def insert_LineDrawingRegion_at(self, index, value):
2950
        self.LineDrawingRegion.insert(index, value)
2951
    def replace_LineDrawingRegion_at(self, index, value):
2952
        self.LineDrawingRegion[index] = value
2953
    def get_GraphicRegion(self):
2954
        return self.GraphicRegion
2955
    def set_GraphicRegion(self, GraphicRegion):
2956
        self.GraphicRegion = GraphicRegion
2957
    def add_GraphicRegion(self, value):
2958
        self.GraphicRegion.append(value)
2959
    def insert_GraphicRegion_at(self, index, value):
2960
        self.GraphicRegion.insert(index, value)
2961
    def replace_GraphicRegion_at(self, index, value):
2962
        self.GraphicRegion[index] = value
2963
    def get_TableRegion(self):
2964
        return self.TableRegion
2965
    def set_TableRegion(self, TableRegion):
2966
        self.TableRegion = TableRegion
2967
    def add_TableRegion(self, value):
2968
        self.TableRegion.append(value)
2969
    def insert_TableRegion_at(self, index, value):
2970
        self.TableRegion.insert(index, value)
2971
    def replace_TableRegion_at(self, index, value):
2972
        self.TableRegion[index] = value
2973
    def get_ChartRegion(self):
2974
        return self.ChartRegion
2975
    def set_ChartRegion(self, ChartRegion):
2976
        self.ChartRegion = ChartRegion
2977
    def add_ChartRegion(self, value):
2978
        self.ChartRegion.append(value)
2979
    def insert_ChartRegion_at(self, index, value):
2980
        self.ChartRegion.insert(index, value)
2981
    def replace_ChartRegion_at(self, index, value):
2982
        self.ChartRegion[index] = value
2983
    def get_MapRegion(self):
2984
        return self.MapRegion
2985
    def set_MapRegion(self, MapRegion):
2986
        self.MapRegion = MapRegion
2987
    def add_MapRegion(self, value):
2988
        self.MapRegion.append(value)
2989
    def insert_MapRegion_at(self, index, value):
2990
        self.MapRegion.insert(index, value)
2991
    def replace_MapRegion_at(self, index, value):
2992
        self.MapRegion[index] = value
2993
    def get_SeparatorRegion(self):
2994
        return self.SeparatorRegion
2995
    def set_SeparatorRegion(self, SeparatorRegion):
2996
        self.SeparatorRegion = SeparatorRegion
2997
    def add_SeparatorRegion(self, value):
2998
        self.SeparatorRegion.append(value)
2999
    def insert_SeparatorRegion_at(self, index, value):
3000
        self.SeparatorRegion.insert(index, value)
3001
    def replace_SeparatorRegion_at(self, index, value):
3002
        self.SeparatorRegion[index] = value
3003
    def get_MathsRegion(self):
3004
        return self.MathsRegion
3005
    def set_MathsRegion(self, MathsRegion):
3006
        self.MathsRegion = MathsRegion
3007
    def add_MathsRegion(self, value):
3008
        self.MathsRegion.append(value)
3009
    def insert_MathsRegion_at(self, index, value):
3010
        self.MathsRegion.insert(index, value)
3011
    def replace_MathsRegion_at(self, index, value):
3012
        self.MathsRegion[index] = value
3013
    def get_ChemRegion(self):
3014
        return self.ChemRegion
3015
    def set_ChemRegion(self, ChemRegion):
3016
        self.ChemRegion = ChemRegion
3017
    def add_ChemRegion(self, value):
3018
        self.ChemRegion.append(value)
3019
    def insert_ChemRegion_at(self, index, value):
3020
        self.ChemRegion.insert(index, value)
3021
    def replace_ChemRegion_at(self, index, value):
3022
        self.ChemRegion[index] = value
3023
    def get_MusicRegion(self):
3024
        return self.MusicRegion
3025
    def set_MusicRegion(self, MusicRegion):
3026
        self.MusicRegion = MusicRegion
3027
    def add_MusicRegion(self, value):
3028
        self.MusicRegion.append(value)
3029
    def insert_MusicRegion_at(self, index, value):
3030
        self.MusicRegion.insert(index, value)
3031
    def replace_MusicRegion_at(self, index, value):
3032
        self.MusicRegion[index] = value
3033
    def get_AdvertRegion(self):
3034
        return self.AdvertRegion
3035
    def set_AdvertRegion(self, AdvertRegion):
3036
        self.AdvertRegion = AdvertRegion
3037
    def add_AdvertRegion(self, value):
3038
        self.AdvertRegion.append(value)
3039
    def insert_AdvertRegion_at(self, index, value):
3040
        self.AdvertRegion.insert(index, value)
3041
    def replace_AdvertRegion_at(self, index, value):
3042
        self.AdvertRegion[index] = value
3043
    def get_NoiseRegion(self):
3044
        return self.NoiseRegion
3045
    def set_NoiseRegion(self, NoiseRegion):
3046
        self.NoiseRegion = NoiseRegion
3047
    def add_NoiseRegion(self, value):
3048
        self.NoiseRegion.append(value)
3049
    def insert_NoiseRegion_at(self, index, value):
3050
        self.NoiseRegion.insert(index, value)
3051
    def replace_NoiseRegion_at(self, index, value):
3052
        self.NoiseRegion[index] = value
3053
    def get_UnknownRegion(self):
3054
        return self.UnknownRegion
3055
    def set_UnknownRegion(self, UnknownRegion):
3056
        self.UnknownRegion = UnknownRegion
3057
    def add_UnknownRegion(self, value):
3058
        self.UnknownRegion.append(value)
3059
    def insert_UnknownRegion_at(self, index, value):
3060
        self.UnknownRegion.insert(index, value)
3061
    def replace_UnknownRegion_at(self, index, value):
3062
        self.UnknownRegion[index] = value
3063
    def get_CustomRegion(self):
3064
        return self.CustomRegion
3065
    def set_CustomRegion(self, CustomRegion):
3066
        self.CustomRegion = CustomRegion
3067
    def add_CustomRegion(self, value):
3068
        self.CustomRegion.append(value)
3069
    def insert_CustomRegion_at(self, index, value):
3070
        self.CustomRegion.insert(index, value)
3071
    def replace_CustomRegion_at(self, index, value):
3072
        self.CustomRegion[index] = value
3073
    def get_imageFilename(self):
3074
        return self.imageFilename
3075
    def set_imageFilename(self, imageFilename):
3076
        self.imageFilename = imageFilename
3077
    def get_imageWidth(self):
3078
        return self.imageWidth
3079
    def set_imageWidth(self, imageWidth):
3080
        self.imageWidth = imageWidth
3081
    def get_imageHeight(self):
3082
        return self.imageHeight
3083
    def set_imageHeight(self, imageHeight):
3084
        self.imageHeight = imageHeight
3085
    def get_imageXResolution(self):
3086
        return self.imageXResolution
3087
    def set_imageXResolution(self, imageXResolution):
3088
        self.imageXResolution = imageXResolution
3089
    def get_imageYResolution(self):
3090
        return self.imageYResolution
3091
    def set_imageYResolution(self, imageYResolution):
3092
        self.imageYResolution = imageYResolution
3093
    def get_imageResolutionUnit(self):
3094
        return self.imageResolutionUnit
3095
    def set_imageResolutionUnit(self, imageResolutionUnit):
3096
        self.imageResolutionUnit = imageResolutionUnit
3097
    def get_custom(self):
3098
        return self.custom
3099
    def set_custom(self, custom):
3100
        self.custom = custom
3101
    def get_orientation(self):
3102
        return self.orientation
3103
    def set_orientation(self, orientation):
3104
        self.orientation = orientation
3105
    def get_type(self):
3106
        return self.type_
3107
    def set_type(self, type_):
3108
        self.type_ = type_
3109
    def get_primaryLanguage(self):
3110
        return self.primaryLanguage
3111
    def set_primaryLanguage(self, primaryLanguage):
3112
        self.primaryLanguage = primaryLanguage
3113
    def get_secondaryLanguage(self):
3114
        return self.secondaryLanguage
3115
    def set_secondaryLanguage(self, secondaryLanguage):
3116
        self.secondaryLanguage = secondaryLanguage
3117
    def get_primaryScript(self):
3118
        return self.primaryScript
3119
    def set_primaryScript(self, primaryScript):
3120
        self.primaryScript = primaryScript
3121
    def get_secondaryScript(self):
3122
        return self.secondaryScript
3123
    def set_secondaryScript(self, secondaryScript):
3124
        self.secondaryScript = secondaryScript
3125
    def get_readingDirection(self):
3126
        return self.readingDirection
3127
    def set_readingDirection(self, readingDirection):
3128
        self.readingDirection = readingDirection
3129
    def get_textLineOrder(self):
3130
        return self.textLineOrder
3131
    def set_textLineOrder(self, textLineOrder):
3132
        self.textLineOrder = textLineOrder
3133
    def get_conf(self):
3134
        return self.conf
3135
    def set_conf(self, conf):
3136
        self.conf = conf
3137
    def validate_imageResolutionUnitType(self, value):
3138
        # Validate type imageResolutionUnitType, a restriction on string.
3139
        if value is not None and Validate_simpletypes_ and self.gds_collector_ is not None:
3140
            if not isinstance(value, str):
3141
                lineno = self.gds_get_node_lineno_()
3142
                self.gds_collector_.add_message('Value "%(value)s"%(lineno)s is not of the correct base simple type (str)' % {"value": value, "lineno": lineno, })
3143
                return False
3144
            value = value
3145
            enumerations = ['PPI', 'PPCM', 'other']
3146
            if value not in enumerations:
3147
                lineno = self.gds_get_node_lineno_()
3148
                self.gds_collector_.add_message('Value "%(value)s"%(lineno)s does not match xsd enumeration restriction on imageResolutionUnitType' % {"value" : encode_str_2_3(value), "lineno": lineno} )
3149
                result = False
3150
    def validate_PageTypeSimpleType(self, value):
3151
        # Validate type pc:PageTypeSimpleType, a restriction on string.
3152
        if value is not None and Validate_simpletypes_ and self.gds_collector_ is not None:
3153
            if not isinstance(value, str):
3154
                lineno = self.gds_get_node_lineno_()
3155
                self.gds_collector_.add_message('Value "%(value)s"%(lineno)s is not of the correct base simple type (str)' % {"value": value, "lineno": lineno, })
3156
                return False
3157
            value = value
3158
            enumerations = ['front-cover', 'back-cover', 'title', 'table-of-contents', 'index', 'content', 'blank', 'other']
3159
            if value not in enumerations:
3160
                lineno = self.gds_get_node_lineno_()
3161
                self.gds_collector_.add_message('Value "%(value)s"%(lineno)s does not match xsd enumeration restriction on PageTypeSimpleType' % {"value" : encode_str_2_3(value), "lineno": lineno} )
3162
                result = False
3163
    def validate_LanguageSimpleType(self, value):
3164
        # Validate type pc:LanguageSimpleType, a restriction on string.
3165
        if value is not None and Validate_simpletypes_ and self.gds_collector_ is not None:
3166
            if not isinstance(value, str):
3167
                lineno = self.gds_get_node_lineno_()
3168
                self.gds_collector_.add_message('Value "%(value)s"%(lineno)s is not of the correct base simple type (str)' % {"value": value, "lineno": lineno, })
3169
                return False
3170
            value = value
3171
            enumerations = ['Abkhaz', 'Afar', 'Afrikaans', 'Akan', 'Albanian', 'Amharic', 'Arabic', 'Aragonese', 'Armenian', 'Assamese', 'Avaric', 'Avestan', 'Aymara', 'Azerbaijani', 'Bambara', 'Bashkir', 'Basque', 'Belarusian', 'Bengali', 'Bihari', 'Bislama', 'Bosnian', 'Breton', 'Bulgarian', 'Burmese', 'Cambodian', 'Cantonese', 'Catalan', 'Chamorro', 'Chechen', 'Chichewa', 'Chinese', 'Chuvash', 'Cornish', 'Corsican', 'Cree', 'Croatian', 'Czech', 'Danish', 'Divehi', 'Dutch', 'Dzongkha', 'English', 'Esperanto', 'Estonian', 'Ewe', 'Faroese', 'Fijian', 'Finnish', 'French', 'Fula', 'Gaelic', 'Galician', 'Ganda', 'Georgian', 'German', 'Greek', 'Guaraní', 'Gujarati', 'Haitian', 'Hausa', 'Hebrew', 'Herero', 'Hindi', 'Hiri Motu', 'Hungarian', 'Icelandic', 'Ido', 'Igbo', 'Indonesian', 'Interlingua', 'Interlingue', 'Inuktitut', 'Inupiaq', 'Irish', 'Italian', 'Japanese', 'Javanese', 'Kalaallisut', 'Kannada', 'Kanuri', 'Kashmiri', 'Kazakh', 'Khmer', 'Kikuyu', 'Kinyarwanda', 'Kirundi', 'Komi', 'Kongo', 'Korean', 'Kurdish', 'Kwanyama', 'Kyrgyz', 'Lao', 'Latin', 'Latvian', 'Limburgish', 'Lingala', 'Lithuanian', 'Luba-Katanga', 'Luxembourgish', 'Macedonian', 'Malagasy', 'Malay', 'Malayalam', 'Maltese', 'Manx', 'Māori', 'Marathi', 'Marshallese', 'Mongolian', 'Nauru', 'Navajo', 'Ndonga', 'Nepali', 'North Ndebele', 'Northern Sami', 'Norwegian', 'Norwegian Bokmål', 'Norwegian Nynorsk', 'Nuosu', 'Occitan', 'Ojibwe', 'Old Church Slavonic', 'Oriya', 'Oromo', 'Ossetian', 'Pāli', 'Panjabi', 'Pashto', 'Persian', 'Polish', 'Portuguese', 'Punjabi', 'Quechua', 'Romanian', 'Romansh', 'Russian', 'Samoan', 'Sango', 'Sanskrit', 'Sardinian', 'Serbian', 'Shona', 'Sindhi', 'Sinhala', 'Slovak', 'Slovene', 'Somali', 'South Ndebele', 'Southern Sotho', 'Spanish', 'Sundanese', 'Swahili', 'Swati', 'Swedish', 'Tagalog', 'Tahitian', 'Tajik', 'Tamil', 'Tatar', 'Telugu', 'Thai', 'Tibetan', 'Tigrinya', 'Tonga', 'Tsonga', 'Tswana', 'Turkish', 'Turkmen', 'Twi', 'Uighur', 'Ukrainian', 'Urdu', 'Uzbek', 'Venda', 'Vietnamese', 'Volapük', 'Walloon', 'Welsh', 'Western Frisian', 'Wolof', 'Xhosa', 'Yiddish', 'Yoruba', 'Zhuang', 'Zulu', 'other']
3172
            if value not in enumerations:
3173
                lineno = self.gds_get_node_lineno_()
3174
                self.gds_collector_.add_message('Value "%(value)s"%(lineno)s does not match xsd enumeration restriction on LanguageSimpleType' % {"value" : encode_str_2_3(value), "lineno": lineno} )
3175
                result = False
3176
    def validate_ScriptSimpleType(self, value):
3177
        # Validate type pc:ScriptSimpleType, a restriction on string.
3178
        if value is not None and Validate_simpletypes_ and self.gds_collector_ is not None:
3179
            if not isinstance(value, str):
3180
                lineno = self.gds_get_node_lineno_()
3181
                self.gds_collector_.add_message('Value "%(value)s"%(lineno)s is not of the correct base simple type (str)' % {"value": value, "lineno": lineno, })
3182
                return False
3183
            value = value
3184
            enumerations = ['Adlm - Adlam', 'Afak - Afaka', 'Aghb - Caucasian Albanian', 'Ahom - Ahom, Tai Ahom', 'Arab - Arabic', 'Aran - Arabic (Nastaliq variant)', 'Armi - Imperial Aramaic', 'Armn - Armenian', 'Avst - Avestan', 'Bali - Balinese', 'Bamu - Bamum', 'Bass - Bassa Vah', 'Batk - Batak', 'Beng - Bengali', 'Bhks - Bhaiksuki', 'Blis - Blissymbols', 'Bopo - Bopomofo', 'Brah - Brahmi', 'Brai - Braille', 'Bugi - Buginese', 'Buhd - Buhid', 'Cakm - Chakma', 'Cans - Unified Canadian Aboriginal Syllabics', 'Cari - Carian', 'Cham - Cham', 'Cher - Cherokee', 'Cirt - Cirth', 'Copt - Coptic', 'Cprt - Cypriot', 'Cyrl - Cyrillic', 'Cyrs - Cyrillic (Old Church Slavonic variant)', 'Deva - Devanagari (Nagari)', 'Dsrt - Deseret (Mormon)', 'Dupl - Duployan shorthand, Duployan stenography', 'Egyd - Egyptian demotic', 'Egyh - Egyptian hieratic', 'Egyp - Egyptian hieroglyphs', 'Elba - Elbasan', 'Ethi - Ethiopic', 'Geok - Khutsuri (Asomtavruli and Nuskhuri)', 'Geor - Georgian (Mkhedruli)', 'Glag - Glagolitic', 'Goth - Gothic', 'Gran - Grantha', 'Grek - Greek', 'Gujr - Gujarati', 'Guru - Gurmukhi', 'Hanb - Han with Bopomofo', 'Hang - Hangul', 'Hani - Han (Hanzi, Kanji, Hanja)', 'Hano - Hanunoo (Hanunóo)', 'Hans - Han (Simplified variant)', 'Hant - Han (Traditional variant)', 'Hatr - Hatran', 'Hebr - Hebrew', 'Hira - Hiragana', 'Hluw - Anatolian Hieroglyphs', 'Hmng - Pahawh Hmong', 'Hrkt - Japanese syllabaries', 'Hung - Old Hungarian (Hungarian Runic)', 'Inds - Indus (Harappan)', 'Ital - Old Italic (Etruscan, Oscan etc.)', 'Jamo - Jamo', 'Java - Javanese', 'Jpan - Japanese', 'Jurc - Jurchen', 'Kali - Kayah Li', 'Kana - Katakana', 'Khar - Kharoshthi', 'Khmr - Khmer', 'Khoj - Khojki', 'Kitl - Khitan large script', 'Kits - Khitan small script', 'Knda - Kannada', 'Kore - Korean (alias for Hangul + Han)', 'Kpel - Kpelle', 'Kthi - Kaithi', 'Lana - Tai Tham (Lanna)', 'Laoo - Lao', 'Latf - Latin (Fraktur variant)', 'Latg - Latin (Gaelic variant)', 'Latn - Latin', 'Leke - Leke', 'Lepc - Lepcha (Róng)', 'Limb - Limbu', 'Lina - Linear A', 'Linb - Linear B', 'Lisu - Lisu (Fraser)', 'Loma - Loma', 'Lyci - Lycian', 'Lydi - Lydian', 'Mahj - Mahajani', 'Mand - Mandaic, Mandaean', 'Mani - Manichaean', 'Marc - Marchen', 'Maya - Mayan hieroglyphs', 'Mend - Mende Kikakui', 'Merc - Meroitic Cursive', 'Mero - Meroitic Hieroglyphs', 'Mlym - Malayalam', 'Modi - Modi, Moḍī', 'Mong - Mongolian', 'Moon - Moon (Moon code, Moon script, Moon type)', 'Mroo - Mro, Mru', 'Mtei - Meitei Mayek (Meithei, Meetei)', 'Mult - Multani', 'Mymr - Myanmar (Burmese)', 'Narb - Old North Arabian (Ancient North Arabian)', 'Nbat - Nabataean', 'Newa - Newa, Newar, Newari', 'Nkgb - Nakhi Geba', 'Nkoo - N’Ko', 'Nshu - Nüshu', 'Ogam - Ogham', 'Olck - Ol Chiki (Ol Cemet’, Ol, Santali)', 'Orkh - Old Turkic, Orkhon Runic', 'Orya - Oriya', 'Osge - Osage', 'Osma - Osmanya', 'Palm - Palmyrene', 'Pauc - Pau Cin Hau', 'Perm - Old Permic', 'Phag - Phags-pa', 'Phli - Inscriptional Pahlavi', 'Phlp - Psalter Pahlavi', 'Phlv - Book Pahlavi', 'Phnx - Phoenician', 'Piqd - Klingon (KLI pIqaD)', 'Plrd - Miao (Pollard)', 'Prti - Inscriptional Parthian', 'Rjng - Rejang (Redjang, Kaganga)', 'Roro - Rongorongo', 'Runr - Runic', 'Samr - Samaritan', 'Sara - Sarati', 'Sarb - Old South Arabian', 'Saur - Saurashtra', 'Sgnw - SignWriting', 'Shaw - Shavian (Shaw)', 'Shrd - Sharada, Śāradā', 'Sidd - Siddham', 'Sind - Khudawadi, Sindhi', 'Sinh - Sinhala', 'Sora - Sora Sompeng', 'Sund - Sundanese', 'Sylo - Syloti Nagri', 'Syrc - Syriac', 'Syre - Syriac (Estrangelo variant)', 'Syrj - Syriac (Western variant)', 'Syrn - Syriac (Eastern variant)', 'Tagb - Tagbanwa', 'Takr - Takri', 'Tale - Tai Le', 'Talu - New Tai Lue', 'Taml - Tamil', 'Tang - Tangut', 'Tavt - Tai Viet', 'Telu - Telugu', 'Teng - Tengwar', 'Tfng - Tifinagh (Berber)', 'Tglg - Tagalog (Baybayin, Alibata)', 'Thaa - Thaana', 'Thai - Thai', 'Tibt - Tibetan', 'Tirh - Tirhuta', 'Ugar - Ugaritic', 'Vaii - Vai', 'Visp - Visible Speech', 'Wara - Warang Citi (Varang Kshiti)', 'Wole - Woleai', 'Xpeo - Old Persian', 'Xsux - Cuneiform, Sumero-Akkadian', 'Yiii - Yi', 'Zinh - Code for inherited script', 'Zmth - Mathematical notation', 'Zsye - Symbols (Emoji variant)', 'Zsym - Symbols', 'Zxxx - Code for unwritten documents', 'Zyyy - Code for undetermined script', 'Zzzz - Code for uncoded script', 'other']
3185
            if value not in enumerations:
3186
                lineno = self.gds_get_node_lineno_()
3187
                self.gds_collector_.add_message('Value "%(value)s"%(lineno)s does not match xsd enumeration restriction on ScriptSimpleType' % {"value" : encode_str_2_3(value), "lineno": lineno} )
3188
                result = False
3189
    def validate_ReadingDirectionSimpleType(self, value):
3190
        # Validate type pc:ReadingDirectionSimpleType, a restriction on string.
3191
        if value is not None and Validate_simpletypes_ and self.gds_collector_ is not None:
3192
            if not isinstance(value, str):
3193
                lineno = self.gds_get_node_lineno_()
3194
                self.gds_collector_.add_message('Value "%(value)s"%(lineno)s is not of the correct base simple type (str)' % {"value": value, "lineno": lineno, })
3195
                return False
3196
            value = value
3197
            enumerations = ['left-to-right', 'right-to-left', 'top-to-bottom', 'bottom-to-top']
3198
            if value not in enumerations:
3199
                lineno = self.gds_get_node_lineno_()
3200
                self.gds_collector_.add_message('Value "%(value)s"%(lineno)s does not match xsd enumeration restriction on ReadingDirectionSimpleType' % {"value" : encode_str_2_3(value), "lineno": lineno} )
3201
                result = False
3202
    def validate_TextLineOrderSimpleType(self, value):
3203
        # Validate type pc:TextLineOrderSimpleType, a restriction on string.
3204
        if value is not None and Validate_simpletypes_ and self.gds_collector_ is not None:
3205
            if not isinstance(value, str):
3206
                lineno = self.gds_get_node_lineno_()
3207
                self.gds_collector_.add_message('Value "%(value)s"%(lineno)s is not of the correct base simple type (str)' % {"value": value, "lineno": lineno, })
3208
                return False
3209
            value = value
3210
            enumerations = ['top-to-bottom', 'bottom-to-top', 'left-to-right', 'right-to-left']
3211
            if value not in enumerations:
3212
                lineno = self.gds_get_node_lineno_()
3213
                self.gds_collector_.add_message('Value "%(value)s"%(lineno)s does not match xsd enumeration restriction on TextLineOrderSimpleType' % {"value" : encode_str_2_3(value), "lineno": lineno} )
3214
                result = False
3215 View Code Duplication
    def validate_ConfSimpleType(self, value):
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
3216
        # Validate type pc:ConfSimpleType, a restriction on float.
3217
        if value is not None and Validate_simpletypes_ and self.gds_collector_ is not None:
3218
            if not isinstance(value, float):
3219
                lineno = self.gds_get_node_lineno_()
3220
                self.gds_collector_.add_message('Value "%(value)s"%(lineno)s is not of the correct base simple type (float)' % {"value": value, "lineno": lineno, })
3221
                return False
3222
            if value < 0:
3223
                lineno = self.gds_get_node_lineno_()
3224
                self.gds_collector_.add_message('Value "%(value)s"%(lineno)s does not match xsd minInclusive restriction on ConfSimpleType' % {"value": value, "lineno": lineno} )
3225
                result = False
3226
            if value > 1:
3227
                lineno = self.gds_get_node_lineno_()
3228
                self.gds_collector_.add_message('Value "%(value)s"%(lineno)s does not match xsd maxInclusive restriction on ConfSimpleType' % {"value": value, "lineno": lineno} )
3229
                result = False
3230
    def has__content(self):
3231
        if (
3232
            self.AlternativeImage or
3233
            self.Border is not None or
3234
            self.PrintSpace is not None or
3235
            self.ReadingOrder is not None or
3236
            self.Layers is not None or
3237
            self.Relations is not None or
3238
            self.TextStyle is not None or
3239
            self.UserDefined is not None or
3240
            self.Labels or
3241
            self.TextRegion or
3242
            self.ImageRegion or
3243
            self.LineDrawingRegion or
3244
            self.GraphicRegion or
3245
            self.TableRegion or
3246
            self.ChartRegion or
3247
            self.MapRegion or
3248
            self.SeparatorRegion or
3249
            self.MathsRegion or
3250
            self.ChemRegion or
3251
            self.MusicRegion or
3252
            self.AdvertRegion or
3253
            self.NoiseRegion or
3254
            self.UnknownRegion or
3255
            self.CustomRegion
3256
        ):
3257
            return True
3258
        else:
3259
            return False
3260
    def export(self, outfile, level, namespaceprefix_='', namespacedef_='xmlns:pc="http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15"', name_='PageType', pretty_print=True):
3261
        imported_ns_def_ = GenerateDSNamespaceDefs_.get('PageType')
3262
        if imported_ns_def_ is not None:
3263
            namespacedef_ = imported_ns_def_
3264
        if pretty_print:
3265
            eol_ = '\n'
3266
        else:
3267
            eol_ = ''
3268
        if self.original_tagname_ is not None and name_ == 'PageType':
3269
            name_ = self.original_tagname_
3270
        if UseCapturedNS_ and self.ns_prefix_:
3271
            namespaceprefix_ = self.ns_prefix_ + ':'
3272
        showIndent(outfile, level, pretty_print)
3273
        outfile.write('<%s%s%s' % (namespaceprefix_, name_, namespacedef_ and ' ' + namespacedef_ or '', ))
3274
        already_processed = set()
3275
        self._exportAttributes(outfile, level, already_processed, namespaceprefix_, name_='PageType')
3276
        if self.has__content():
3277
            outfile.write('>%s' % (eol_, ))
3278
            self._exportChildren(outfile, level + 1, namespaceprefix_, namespacedef_, name_='PageType', pretty_print=pretty_print)
3279
            showIndent(outfile, level, pretty_print)
3280
            outfile.write('</%s%s>%s' % (namespaceprefix_, name_, eol_))
3281
        else:
3282
            outfile.write('/>%s' % (eol_, ))
3283
    def _exportAttributes(self, outfile, level, already_processed, namespaceprefix_='', name_='PageType'):
3284
        if self.imageFilename is not None and 'imageFilename' not in already_processed:
3285
            already_processed.add('imageFilename')
3286
            outfile.write(' imageFilename=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.imageFilename), input_name='imageFilename')), ))
3287
        if self.imageWidth is not None and 'imageWidth' not in already_processed:
3288
            already_processed.add('imageWidth')
3289
            outfile.write(' imageWidth="%s"' % self.gds_format_integer(self.imageWidth, input_name='imageWidth'))
3290
        if self.imageHeight is not None and 'imageHeight' not in already_processed:
3291
            already_processed.add('imageHeight')
3292
            outfile.write(' imageHeight="%s"' % self.gds_format_integer(self.imageHeight, input_name='imageHeight'))
3293
        if self.imageXResolution is not None and 'imageXResolution' not in already_processed:
3294
            already_processed.add('imageXResolution')
3295
            outfile.write(' imageXResolution="%s"' % self.gds_format_float(self.imageXResolution, input_name='imageXResolution'))
3296
        if self.imageYResolution is not None and 'imageYResolution' not in already_processed:
3297
            already_processed.add('imageYResolution')
3298
            outfile.write(' imageYResolution="%s"' % self.gds_format_float(self.imageYResolution, input_name='imageYResolution'))
3299
        if self.imageResolutionUnit is not None and 'imageResolutionUnit' not in already_processed:
3300
            already_processed.add('imageResolutionUnit')
3301
            outfile.write(' imageResolutionUnit=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.imageResolutionUnit), input_name='imageResolutionUnit')), ))
3302
        if self.custom is not None and 'custom' not in already_processed:
3303
            already_processed.add('custom')
3304
            outfile.write(' custom=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.custom), input_name='custom')), ))
3305
        if self.orientation is not None and 'orientation' not in already_processed:
3306
            already_processed.add('orientation')
3307
            outfile.write(' orientation="%s"' % self.gds_format_float(self.orientation, input_name='orientation'))
3308
        if self.type_ is not None and 'type_' not in already_processed:
3309
            already_processed.add('type_')
3310
            outfile.write(' type=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.type_), input_name='type')), ))
3311
        if self.primaryLanguage is not None and 'primaryLanguage' not in already_processed:
3312
            already_processed.add('primaryLanguage')
3313
            outfile.write(' primaryLanguage=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.primaryLanguage), input_name='primaryLanguage')), ))
3314
        if self.secondaryLanguage is not None and 'secondaryLanguage' not in already_processed:
3315
            already_processed.add('secondaryLanguage')
3316
            outfile.write(' secondaryLanguage=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.secondaryLanguage), input_name='secondaryLanguage')), ))
3317
        if self.primaryScript is not None and 'primaryScript' not in already_processed:
3318
            already_processed.add('primaryScript')
3319
            outfile.write(' primaryScript=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.primaryScript), input_name='primaryScript')), ))
3320
        if self.secondaryScript is not None and 'secondaryScript' not in already_processed:
3321
            already_processed.add('secondaryScript')
3322
            outfile.write(' secondaryScript=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.secondaryScript), input_name='secondaryScript')), ))
3323
        if self.readingDirection is not None and 'readingDirection' not in already_processed:
3324
            already_processed.add('readingDirection')
3325
            outfile.write(' readingDirection=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.readingDirection), input_name='readingDirection')), ))
3326
        if self.textLineOrder is not None and 'textLineOrder' not in already_processed:
3327
            already_processed.add('textLineOrder')
3328
            outfile.write(' textLineOrder=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.textLineOrder), input_name='textLineOrder')), ))
3329
        if self.conf is not None and 'conf' not in already_processed:
3330
            already_processed.add('conf')
3331
            outfile.write(' conf="%s"' % self.gds_format_float(self.conf, input_name='conf'))
3332
    def _exportChildren(self, outfile, level, namespaceprefix_='', namespacedef_='xmlns:pc="http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15"', name_='PageType', fromsubclass_=False, pretty_print=True):
3333
        if pretty_print:
3334
            eol_ = '\n'
3335
        else:
3336
            eol_ = ''
3337
        for AlternativeImage_ in self.AlternativeImage:
3338
            namespaceprefix_ = self.AlternativeImage_nsprefix_ + ':' if (UseCapturedNS_ and self.AlternativeImage_nsprefix_) else ''
3339
            AlternativeImage_.export(outfile, level, namespaceprefix_, namespacedef_='', name_='AlternativeImage', pretty_print=pretty_print)
3340
        if self.Border is not None:
3341
            namespaceprefix_ = self.Border_nsprefix_ + ':' if (UseCapturedNS_ and self.Border_nsprefix_) else ''
3342
            self.Border.export(outfile, level, namespaceprefix_, namespacedef_='', name_='Border', pretty_print=pretty_print)
3343
        if self.PrintSpace is not None:
3344
            namespaceprefix_ = self.PrintSpace_nsprefix_ + ':' if (UseCapturedNS_ and self.PrintSpace_nsprefix_) else ''
3345
            self.PrintSpace.export(outfile, level, namespaceprefix_, namespacedef_='', name_='PrintSpace', pretty_print=pretty_print)
3346
        if self.ReadingOrder is not None:
3347
            namespaceprefix_ = self.ReadingOrder_nsprefix_ + ':' if (UseCapturedNS_ and self.ReadingOrder_nsprefix_) else ''
3348
            self.ReadingOrder.export(outfile, level, namespaceprefix_, namespacedef_='', name_='ReadingOrder', pretty_print=pretty_print)
3349
        if self.Layers is not None:
3350
            namespaceprefix_ = self.Layers_nsprefix_ + ':' if (UseCapturedNS_ and self.Layers_nsprefix_) else ''
3351
            self.Layers.export(outfile, level, namespaceprefix_, namespacedef_='', name_='Layers', pretty_print=pretty_print)
3352
        if self.Relations is not None:
3353
            namespaceprefix_ = self.Relations_nsprefix_ + ':' if (UseCapturedNS_ and self.Relations_nsprefix_) else ''
3354
            self.Relations.export(outfile, level, namespaceprefix_, namespacedef_='', name_='Relations', pretty_print=pretty_print)
3355
        if self.TextStyle is not None:
3356
            namespaceprefix_ = self.TextStyle_nsprefix_ + ':' if (UseCapturedNS_ and self.TextStyle_nsprefix_) else ''
3357
            self.TextStyle.export(outfile, level, namespaceprefix_, namespacedef_='', name_='TextStyle', pretty_print=pretty_print)
3358
        if self.UserDefined is not None:
3359
            namespaceprefix_ = self.UserDefined_nsprefix_ + ':' if (UseCapturedNS_ and self.UserDefined_nsprefix_) else ''
3360
            self.UserDefined.export(outfile, level, namespaceprefix_, namespacedef_='', name_='UserDefined', pretty_print=pretty_print)
3361
        for Labels_ in self.Labels:
3362
            namespaceprefix_ = self.Labels_nsprefix_ + ':' if (UseCapturedNS_ and self.Labels_nsprefix_) else ''
3363
            Labels_.export(outfile, level, namespaceprefix_, namespacedef_='', name_='Labels', pretty_print=pretty_print)
3364
        for TextRegion_ in self.TextRegion:
3365
            namespaceprefix_ = self.TextRegion_nsprefix_ + ':' if (UseCapturedNS_ and self.TextRegion_nsprefix_) else ''
3366
            TextRegion_.export(outfile, level, namespaceprefix_, namespacedef_='', name_='TextRegion', pretty_print=pretty_print)
3367
        for ImageRegion_ in self.ImageRegion:
3368
            namespaceprefix_ = self.ImageRegion_nsprefix_ + ':' if (UseCapturedNS_ and self.ImageRegion_nsprefix_) else ''
3369
            ImageRegion_.export(outfile, level, namespaceprefix_, namespacedef_='', name_='ImageRegion', pretty_print=pretty_print)
3370
        for LineDrawingRegion_ in self.LineDrawingRegion:
3371
            namespaceprefix_ = self.LineDrawingRegion_nsprefix_ + ':' if (UseCapturedNS_ and self.LineDrawingRegion_nsprefix_) else ''
3372
            LineDrawingRegion_.export(outfile, level, namespaceprefix_, namespacedef_='', name_='LineDrawingRegion', pretty_print=pretty_print)
3373
        for GraphicRegion_ in self.GraphicRegion:
3374
            namespaceprefix_ = self.GraphicRegion_nsprefix_ + ':' if (UseCapturedNS_ and self.GraphicRegion_nsprefix_) else ''
3375
            GraphicRegion_.export(outfile, level, namespaceprefix_, namespacedef_='', name_='GraphicRegion', pretty_print=pretty_print)
3376
        for TableRegion_ in self.TableRegion:
3377
            namespaceprefix_ = self.TableRegion_nsprefix_ + ':' if (UseCapturedNS_ and self.TableRegion_nsprefix_) else ''
3378
            TableRegion_.export(outfile, level, namespaceprefix_, namespacedef_='', name_='TableRegion', pretty_print=pretty_print)
3379
        for ChartRegion_ in self.ChartRegion:
3380
            namespaceprefix_ = self.ChartRegion_nsprefix_ + ':' if (UseCapturedNS_ and self.ChartRegion_nsprefix_) else ''
3381
            ChartRegion_.export(outfile, level, namespaceprefix_, namespacedef_='', name_='ChartRegion', pretty_print=pretty_print)
3382
        for MapRegion_ in self.MapRegion:
3383
            namespaceprefix_ = self.MapRegion_nsprefix_ + ':' if (UseCapturedNS_ and self.MapRegion_nsprefix_) else ''
3384
            MapRegion_.export(outfile, level, namespaceprefix_, namespacedef_='', name_='MapRegion', pretty_print=pretty_print)
3385
        for SeparatorRegion_ in self.SeparatorRegion:
3386
            namespaceprefix_ = self.SeparatorRegion_nsprefix_ + ':' if (UseCapturedNS_ and self.SeparatorRegion_nsprefix_) else ''
3387
            SeparatorRegion_.export(outfile, level, namespaceprefix_, namespacedef_='', name_='SeparatorRegion', pretty_print=pretty_print)
3388
        for MathsRegion_ in self.MathsRegion:
3389
            namespaceprefix_ = self.MathsRegion_nsprefix_ + ':' if (UseCapturedNS_ and self.MathsRegion_nsprefix_) else ''
3390
            MathsRegion_.export(outfile, level, namespaceprefix_, namespacedef_='', name_='MathsRegion', pretty_print=pretty_print)
3391
        for ChemRegion_ in self.ChemRegion:
3392
            namespaceprefix_ = self.ChemRegion_nsprefix_ + ':' if (UseCapturedNS_ and self.ChemRegion_nsprefix_) else ''
3393
            ChemRegion_.export(outfile, level, namespaceprefix_, namespacedef_='', name_='ChemRegion', pretty_print=pretty_print)
3394
        for MusicRegion_ in self.MusicRegion:
3395
            namespaceprefix_ = self.MusicRegion_nsprefix_ + ':' if (UseCapturedNS_ and self.MusicRegion_nsprefix_) else ''
3396
            MusicRegion_.export(outfile, level, namespaceprefix_, namespacedef_='', name_='MusicRegion', pretty_print=pretty_print)
3397
        for AdvertRegion_ in self.AdvertRegion:
3398
            namespaceprefix_ = self.AdvertRegion_nsprefix_ + ':' if (UseCapturedNS_ and self.AdvertRegion_nsprefix_) else ''
3399
            AdvertRegion_.export(outfile, level, namespaceprefix_, namespacedef_='', name_='AdvertRegion', pretty_print=pretty_print)
3400
        for NoiseRegion_ in self.NoiseRegion:
3401
            namespaceprefix_ = self.NoiseRegion_nsprefix_ + ':' if (UseCapturedNS_ and self.NoiseRegion_nsprefix_) else ''
3402
            NoiseRegion_.export(outfile, level, namespaceprefix_, namespacedef_='', name_='NoiseRegion', pretty_print=pretty_print)
3403
        for UnknownRegion_ in self.UnknownRegion:
3404
            namespaceprefix_ = self.UnknownRegion_nsprefix_ + ':' if (UseCapturedNS_ and self.UnknownRegion_nsprefix_) else ''
3405
            UnknownRegion_.export(outfile, level, namespaceprefix_, namespacedef_='', name_='UnknownRegion', pretty_print=pretty_print)
3406
        for CustomRegion_ in self.CustomRegion:
3407
            namespaceprefix_ = self.CustomRegion_nsprefix_ + ':' if (UseCapturedNS_ and self.CustomRegion_nsprefix_) else ''
3408
            CustomRegion_.export(outfile, level, namespaceprefix_, namespacedef_='', name_='CustomRegion', pretty_print=pretty_print)
3409
    def to_etree(self, parent_element=None, name_='PageType', mapping_=None, reverse_mapping_=None, nsmap_=None):
3410
        if parent_element is None:
3411
            element = etree_.Element('{http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15}' + name_, nsmap=nsmap_)
3412
        else:
3413
            element = etree_.SubElement(parent_element, '{http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15}' + name_, nsmap=nsmap_)
3414
        if self.imageFilename is not None:
3415
            element.set('imageFilename', self.gds_format_string(self.imageFilename))
3416
        if self.imageWidth is not None:
3417
            element.set('imageWidth', self.gds_format_integer(self.imageWidth))
3418
        if self.imageHeight is not None:
3419
            element.set('imageHeight', self.gds_format_integer(self.imageHeight))
3420
        if self.imageXResolution is not None:
3421
            element.set('imageXResolution', self.gds_format_float(self.imageXResolution))
3422
        if self.imageYResolution is not None:
3423
            element.set('imageYResolution', self.gds_format_float(self.imageYResolution))
3424
        if self.imageResolutionUnit is not None:
3425
            element.set('imageResolutionUnit', self.gds_format_string(self.imageResolutionUnit))
3426
        if self.custom is not None:
3427
            element.set('custom', self.gds_format_string(self.custom))
3428
        if self.orientation is not None:
3429
            element.set('orientation', self.gds_format_float(self.orientation))
3430
        if self.type_ is not None:
3431
            element.set('type', self.gds_format_string(self.type_))
3432
        if self.primaryLanguage is not None:
3433
            element.set('primaryLanguage', self.gds_format_string(self.primaryLanguage))
3434
        if self.secondaryLanguage is not None:
3435
            element.set('secondaryLanguage', self.gds_format_string(self.secondaryLanguage))
3436
        if self.primaryScript is not None:
3437
            element.set('primaryScript', self.gds_format_string(self.primaryScript))
3438
        if self.secondaryScript is not None:
3439
            element.set('secondaryScript', self.gds_format_string(self.secondaryScript))
3440
        if self.readingDirection is not None:
3441
            element.set('readingDirection', self.gds_format_string(self.readingDirection))
3442
        if self.textLineOrder is not None:
3443
            element.set('textLineOrder', self.gds_format_string(self.textLineOrder))
3444
        if self.conf is not None:
3445
            element.set('conf', self.gds_format_float(self.conf))
3446
        for AlternativeImage_ in self.AlternativeImage:
3447
            AlternativeImage_.to_etree(element, name_='AlternativeImage', mapping_=mapping_, reverse_mapping_=reverse_mapping_, nsmap_=nsmap_)
3448
        if self.Border is not None:
3449
            Border_ = self.Border
3450
            Border_.to_etree(element, name_='Border', mapping_=mapping_, reverse_mapping_=reverse_mapping_, nsmap_=nsmap_)
3451
        if self.PrintSpace is not None:
3452
            PrintSpace_ = self.PrintSpace
3453
            PrintSpace_.to_etree(element, name_='PrintSpace', mapping_=mapping_, reverse_mapping_=reverse_mapping_, nsmap_=nsmap_)
3454
        if self.ReadingOrder is not None:
3455
            ReadingOrder_ = self.ReadingOrder
3456
            ReadingOrder_.to_etree(element, name_='ReadingOrder', mapping_=mapping_, reverse_mapping_=reverse_mapping_, nsmap_=nsmap_)
3457
        if self.Layers is not None:
3458
            Layers_ = self.Layers
3459
            Layers_.to_etree(element, name_='Layers', mapping_=mapping_, reverse_mapping_=reverse_mapping_, nsmap_=nsmap_)
3460
        if self.Relations is not None:
3461
            Relations_ = self.Relations
3462
            Relations_.to_etree(element, name_='Relations', mapping_=mapping_, reverse_mapping_=reverse_mapping_, nsmap_=nsmap_)
3463
        if self.TextStyle is not None:
3464
            TextStyle_ = self.TextStyle
3465
            TextStyle_.to_etree(element, name_='TextStyle', mapping_=mapping_, reverse_mapping_=reverse_mapping_, nsmap_=nsmap_)
3466
        if self.UserDefined is not None:
3467
            UserDefined_ = self.UserDefined
3468
            UserDefined_.to_etree(element, name_='UserDefined', mapping_=mapping_, reverse_mapping_=reverse_mapping_, nsmap_=nsmap_)
3469
        for Labels_ in self.Labels:
3470
            Labels_.to_etree(element, name_='Labels', mapping_=mapping_, reverse_mapping_=reverse_mapping_, nsmap_=nsmap_)
3471
        for TextRegion_ in self.TextRegion:
3472
            TextRegion_.to_etree(element, name_='TextRegion', mapping_=mapping_, reverse_mapping_=reverse_mapping_, nsmap_=nsmap_)
3473
        for ImageRegion_ in self.ImageRegion:
3474
            ImageRegion_.to_etree(element, name_='ImageRegion', mapping_=mapping_, reverse_mapping_=reverse_mapping_, nsmap_=nsmap_)
3475
        for LineDrawingRegion_ in self.LineDrawingRegion:
3476
            LineDrawingRegion_.to_etree(element, name_='LineDrawingRegion', mapping_=mapping_, reverse_mapping_=reverse_mapping_, nsmap_=nsmap_)
3477
        for GraphicRegion_ in self.GraphicRegion:
3478
            GraphicRegion_.to_etree(element, name_='GraphicRegion', mapping_=mapping_, reverse_mapping_=reverse_mapping_, nsmap_=nsmap_)
3479
        for TableRegion_ in self.TableRegion:
3480
            TableRegion_.to_etree(element, name_='TableRegion', mapping_=mapping_, reverse_mapping_=reverse_mapping_, nsmap_=nsmap_)
3481
        for ChartRegion_ in self.ChartRegion:
3482
            ChartRegion_.to_etree(element, name_='ChartRegion', mapping_=mapping_, reverse_mapping_=reverse_mapping_, nsmap_=nsmap_)
3483
        for MapRegion_ in self.MapRegion:
3484
            MapRegion_.to_etree(element, name_='MapRegion', mapping_=mapping_, reverse_mapping_=reverse_mapping_, nsmap_=nsmap_)
3485
        for SeparatorRegion_ in self.SeparatorRegion:
3486
            SeparatorRegion_.to_etree(element, name_='SeparatorRegion', mapping_=mapping_, reverse_mapping_=reverse_mapping_, nsmap_=nsmap_)
3487
        for MathsRegion_ in self.MathsRegion:
3488
            MathsRegion_.to_etree(element, name_='MathsRegion', mapping_=mapping_, reverse_mapping_=reverse_mapping_, nsmap_=nsmap_)
3489
        for ChemRegion_ in self.ChemRegion:
3490
            ChemRegion_.to_etree(element, name_='ChemRegion', mapping_=mapping_, reverse_mapping_=reverse_mapping_, nsmap_=nsmap_)
3491
        for MusicRegion_ in self.MusicRegion:
3492
            MusicRegion_.to_etree(element, name_='MusicRegion', mapping_=mapping_, reverse_mapping_=reverse_mapping_, nsmap_=nsmap_)
3493
        for AdvertRegion_ in self.AdvertRegion:
3494
            AdvertRegion_.to_etree(element, name_='AdvertRegion', mapping_=mapping_, reverse_mapping_=reverse_mapping_, nsmap_=nsmap_)
3495
        for NoiseRegion_ in self.NoiseRegion:
3496
            NoiseRegion_.to_etree(element, name_='NoiseRegion', mapping_=mapping_, reverse_mapping_=reverse_mapping_, nsmap_=nsmap_)
3497
        for UnknownRegion_ in self.UnknownRegion:
3498
            UnknownRegion_.to_etree(element, name_='UnknownRegion', mapping_=mapping_, reverse_mapping_=reverse_mapping_, nsmap_=nsmap_)
3499
        for CustomRegion_ in self.CustomRegion:
3500
            CustomRegion_.to_etree(element, name_='CustomRegion', mapping_=mapping_, reverse_mapping_=reverse_mapping_, nsmap_=nsmap_)
3501
        if mapping_ is not None:
3502
            mapping_[id(self)] = element
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable id does not seem to be defined.
Loading history...
3503
        if reverse_mapping_ is not None:
3504
            reverse_mapping_[element] = self
3505
        return element
3506
    def build(self, node, gds_collector_=None):
3507
        self.gds_collector_ = gds_collector_
3508
        if SaveElementTreeNode:
3509
            self.gds_elementtree_node_ = node
3510
        already_processed = set()
3511
        self.ns_prefix_ = node.prefix
3512
        self._buildAttributes(node, node.attrib, already_processed)
3513
        for child in node:
3514
            nodeName_ = Tag_pattern_.match(child.tag).groups()[-1]
3515
            self._buildChildren(child, node, nodeName_, gds_collector_=gds_collector_)
3516
        return self
3517
    def _buildAttributes(self, node, attrs, already_processed):
3518
        value = find_attr_value_('imageFilename', node)
3519
        if value is not None and 'imageFilename' not in already_processed:
3520
            already_processed.add('imageFilename')
3521
            self.imageFilename = value
3522
        value = find_attr_value_('imageWidth', node)
3523
        if value is not None and 'imageWidth' not in already_processed:
3524
            already_processed.add('imageWidth')
3525
            self.imageWidth = self.gds_parse_integer(value, node, 'imageWidth')
3526
        value = find_attr_value_('imageHeight', node)
3527
        if value is not None and 'imageHeight' not in already_processed:
3528
            already_processed.add('imageHeight')
3529
            self.imageHeight = self.gds_parse_integer(value, node, 'imageHeight')
3530
        value = find_attr_value_('imageXResolution', node)
3531
        if value is not None and 'imageXResolution' not in already_processed:
3532
            already_processed.add('imageXResolution')
3533
            value = self.gds_parse_float(value, node, 'imageXResolution')
3534
            self.imageXResolution = value
3535
        value = find_attr_value_('imageYResolution', node)
3536
        if value is not None and 'imageYResolution' not in already_processed:
3537
            already_processed.add('imageYResolution')
3538
            value = self.gds_parse_float(value, node, 'imageYResolution')
3539
            self.imageYResolution = value
3540
        value = find_attr_value_('imageResolutionUnit', node)
3541
        if value is not None and 'imageResolutionUnit' not in already_processed:
3542
            already_processed.add('imageResolutionUnit')
3543
            self.imageResolutionUnit = value
3544
            self.validate_imageResolutionUnitType(self.imageResolutionUnit)    # validate type imageResolutionUnitType
3545
        value = find_attr_value_('custom', node)
3546
        if value is not None and 'custom' not in already_processed:
3547
            already_processed.add('custom')
3548
            self.custom = value
3549
        value = find_attr_value_('orientation', node)
3550
        if value is not None and 'orientation' not in already_processed:
3551
            already_processed.add('orientation')
3552
            value = self.gds_parse_float(value, node, 'orientation')
3553
            self.orientation = value
3554
        value = find_attr_value_('type', node)
3555
        if value is not None and 'type' not in already_processed:
3556
            already_processed.add('type')
3557
            self.type_ = value
3558
            self.validate_PageTypeSimpleType(self.type_)    # validate type PageTypeSimpleType
3559
        value = find_attr_value_('primaryLanguage', node)
3560
        if value is not None and 'primaryLanguage' not in already_processed:
3561
            already_processed.add('primaryLanguage')
3562
            self.primaryLanguage = value
3563
            self.validate_LanguageSimpleType(self.primaryLanguage)    # validate type LanguageSimpleType
3564
        value = find_attr_value_('secondaryLanguage', node)
3565
        if value is not None and 'secondaryLanguage' not in already_processed:
3566
            already_processed.add('secondaryLanguage')
3567
            self.secondaryLanguage = value
3568
            self.validate_LanguageSimpleType(self.secondaryLanguage)    # validate type LanguageSimpleType
3569
        value = find_attr_value_('primaryScript', node)
3570
        if value is not None and 'primaryScript' not in already_processed:
3571
            already_processed.add('primaryScript')
3572
            self.primaryScript = value
3573
            self.validate_ScriptSimpleType(self.primaryScript)    # validate type ScriptSimpleType
3574
        value = find_attr_value_('secondaryScript', node)
3575
        if value is not None and 'secondaryScript' not in already_processed:
3576
            already_processed.add('secondaryScript')
3577
            self.secondaryScript = value
3578
            self.validate_ScriptSimpleType(self.secondaryScript)    # validate type ScriptSimpleType
3579
        value = find_attr_value_('readingDirection', node)
3580
        if value is not None and 'readingDirection' not in already_processed:
3581
            already_processed.add('readingDirection')
3582
            self.readingDirection = value
3583
            self.validate_ReadingDirectionSimpleType(self.readingDirection)    # validate type ReadingDirectionSimpleType
3584
        value = find_attr_value_('textLineOrder', node)
3585
        if value is not None and 'textLineOrder' not in already_processed:
3586
            already_processed.add('textLineOrder')
3587
            self.textLineOrder = value
3588
            self.validate_TextLineOrderSimpleType(self.textLineOrder)    # validate type TextLineOrderSimpleType
3589
        value = find_attr_value_('conf', node)
3590
        if value is not None and 'conf' not in already_processed:
3591
            already_processed.add('conf')
3592
            value = self.gds_parse_float(value, node, 'conf')
3593
            self.conf = value
3594
            self.validate_ConfSimpleType(self.conf)    # validate type ConfSimpleType
3595
    def _buildChildren(self, child_, node, nodeName_, fromsubclass_=False, gds_collector_=None):
3596
        if nodeName_ == 'AlternativeImage':
3597
            obj_ = AlternativeImageType.factory(parent_object_=self)
3598
            obj_.build(child_, gds_collector_=gds_collector_)
3599
            self.AlternativeImage.append(obj_)
3600
            obj_.original_tagname_ = 'AlternativeImage'
3601
        elif nodeName_ == 'Border':
3602
            obj_ = BorderType.factory(parent_object_=self)
3603
            obj_.build(child_, gds_collector_=gds_collector_)
3604
            self.Border = obj_
3605
            obj_.original_tagname_ = 'Border'
3606
        elif nodeName_ == 'PrintSpace':
3607
            obj_ = PrintSpaceType.factory(parent_object_=self)
3608
            obj_.build(child_, gds_collector_=gds_collector_)
3609
            self.PrintSpace = obj_
3610
            obj_.original_tagname_ = 'PrintSpace'
3611
        elif nodeName_ == 'ReadingOrder':
3612
            obj_ = ReadingOrderType.factory(parent_object_=self)
3613
            obj_.build(child_, gds_collector_=gds_collector_)
3614
            self.ReadingOrder = obj_
3615
            obj_.original_tagname_ = 'ReadingOrder'
3616
        elif nodeName_ == 'Layers':
3617
            obj_ = LayersType.factory(parent_object_=self)
3618
            obj_.build(child_, gds_collector_=gds_collector_)
3619
            self.Layers = obj_
3620
            obj_.original_tagname_ = 'Layers'
3621
        elif nodeName_ == 'Relations':
3622
            obj_ = RelationsType.factory(parent_object_=self)
3623
            obj_.build(child_, gds_collector_=gds_collector_)
3624
            self.Relations = obj_
3625
            obj_.original_tagname_ = 'Relations'
3626
        elif nodeName_ == 'TextStyle':
3627
            obj_ = TextStyleType.factory(parent_object_=self)
3628
            obj_.build(child_, gds_collector_=gds_collector_)
3629
            self.TextStyle = obj_
3630
            obj_.original_tagname_ = 'TextStyle'
3631
        elif nodeName_ == 'UserDefined':
3632
            obj_ = UserDefinedType.factory(parent_object_=self)
3633
            obj_.build(child_, gds_collector_=gds_collector_)
3634
            self.UserDefined = obj_
3635
            obj_.original_tagname_ = 'UserDefined'
3636
        elif nodeName_ == 'Labels':
3637
            obj_ = LabelsType.factory(parent_object_=self)
3638
            obj_.build(child_, gds_collector_=gds_collector_)
3639
            self.Labels.append(obj_)
3640
            obj_.original_tagname_ = 'Labels'
3641
        elif nodeName_ == 'TextRegion':
3642
            obj_ = TextRegionType.factory(parent_object_=self)
3643
            obj_.build(child_, gds_collector_=gds_collector_)
3644
            self.TextRegion.append(obj_)
3645
            obj_.original_tagname_ = 'TextRegion'
3646
        elif nodeName_ == 'ImageRegion':
3647
            obj_ = ImageRegionType.factory(parent_object_=self)
3648
            obj_.build(child_, gds_collector_=gds_collector_)
3649
            self.ImageRegion.append(obj_)
3650
            obj_.original_tagname_ = 'ImageRegion'
3651
        elif nodeName_ == 'LineDrawingRegion':
3652
            obj_ = LineDrawingRegionType.factory(parent_object_=self)
3653
            obj_.build(child_, gds_collector_=gds_collector_)
3654
            self.LineDrawingRegion.append(obj_)
3655
            obj_.original_tagname_ = 'LineDrawingRegion'
3656
        elif nodeName_ == 'GraphicRegion':
3657
            obj_ = GraphicRegionType.factory(parent_object_=self)
3658
            obj_.build(child_, gds_collector_=gds_collector_)
3659
            self.GraphicRegion.append(obj_)
3660
            obj_.original_tagname_ = 'GraphicRegion'
3661
        elif nodeName_ == 'TableRegion':
3662
            obj_ = TableRegionType.factory(parent_object_=self)
3663
            obj_.build(child_, gds_collector_=gds_collector_)
3664
            self.TableRegion.append(obj_)
3665
            obj_.original_tagname_ = 'TableRegion'
3666
        elif nodeName_ == 'ChartRegion':
3667
            obj_ = ChartRegionType.factory(parent_object_=self)
3668
            obj_.build(child_, gds_collector_=gds_collector_)
3669
            self.ChartRegion.append(obj_)
3670
            obj_.original_tagname_ = 'ChartRegion'
3671
        elif nodeName_ == 'MapRegion':
3672
            obj_ = MapRegionType.factory(parent_object_=self)
3673
            obj_.build(child_, gds_collector_=gds_collector_)
3674
            self.MapRegion.append(obj_)
3675
            obj_.original_tagname_ = 'MapRegion'
3676
        elif nodeName_ == 'SeparatorRegion':
3677
            obj_ = SeparatorRegionType.factory(parent_object_=self)
3678
            obj_.build(child_, gds_collector_=gds_collector_)
3679
            self.SeparatorRegion.append(obj_)
3680
            obj_.original_tagname_ = 'SeparatorRegion'
3681
        elif nodeName_ == 'MathsRegion':
3682
            obj_ = MathsRegionType.factory(parent_object_=self)
3683
            obj_.build(child_, gds_collector_=gds_collector_)
3684
            self.MathsRegion.append(obj_)
3685
            obj_.original_tagname_ = 'MathsRegion'
3686
        elif nodeName_ == 'ChemRegion':
3687
            obj_ = ChemRegionType.factory(parent_object_=self)
3688
            obj_.build(child_, gds_collector_=gds_collector_)
3689
            self.ChemRegion.append(obj_)
3690
            obj_.original_tagname_ = 'ChemRegion'
3691
        elif nodeName_ == 'MusicRegion':
3692
            obj_ = MusicRegionType.factory(parent_object_=self)
3693
            obj_.build(child_, gds_collector_=gds_collector_)
3694
            self.MusicRegion.append(obj_)
3695
            obj_.original_tagname_ = 'MusicRegion'
3696
        elif nodeName_ == 'AdvertRegion':
3697
            obj_ = AdvertRegionType.factory(parent_object_=self)
3698
            obj_.build(child_, gds_collector_=gds_collector_)
3699
            self.AdvertRegion.append(obj_)
3700
            obj_.original_tagname_ = 'AdvertRegion'
3701
        elif nodeName_ == 'NoiseRegion':
3702
            obj_ = NoiseRegionType.factory(parent_object_=self)
3703
            obj_.build(child_, gds_collector_=gds_collector_)
3704
            self.NoiseRegion.append(obj_)
3705
            obj_.original_tagname_ = 'NoiseRegion'
3706
        elif nodeName_ == 'UnknownRegion':
3707
            obj_ = UnknownRegionType.factory(parent_object_=self)
3708
            obj_.build(child_, gds_collector_=gds_collector_)
3709
            self.UnknownRegion.append(obj_)
3710
            obj_.original_tagname_ = 'UnknownRegion'
3711
        elif nodeName_ == 'CustomRegion':
3712
            obj_ = CustomRegionType.factory(parent_object_=self)
3713
            obj_.build(child_, gds_collector_=gds_collector_)
3714
            self.CustomRegion.append(obj_)
3715
            obj_.original_tagname_ = 'CustomRegion'
3716
    def __hash__(self):
3717
        return hash(self.id)
3718
    @property
3719
    def id(self):
3720
        from ocrd_utils import make_xml_id
3721
        if hasattr(self, 'pcGtsId'):
3722
            return self.pcGtsId or ''
3723
        return make_xml_id(self.imageFilename)
3724
    # pylint: disable=line-too-long,invalid-name,protected-access,missing-module-docstring
3725
    def _region_class(self, x): # pylint: disable=unused-argument
3726
        return x.__class__.__name__.replace('RegionType', '')
3727
    
3728 View Code Duplication
    def _get_recursive_regions(self, regions, level, classes=None):
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
3729
        from .constants import PAGE_REGION_TYPES  # pylint: disable=relative-beyond-top-level,import-outside-toplevel
3730
        if level == 1:
3731
            # stop recursion, filter classes
3732
            if classes:
3733
                return [r for r in regions if self._region_class(r) in classes]
3734
            if regions and regions[0].__class__.__name__ == 'PageType':
3735
                regions = regions[1:]
3736
            return regions
3737
        # find more regions recursively
3738
        more_regions = []
3739
        for region in regions:
3740
            more_regions.append([])
3741
            for class_ in PAGE_REGION_TYPES:
3742
                if class_ == 'Map' and not isinstance(region, PageType): # pylint: disable=undefined-variable
3743
                    # 'Map' is not recursive in 2019 schema
3744
                    continue
3745
                more_regions[-1] += getattr(region, 'get_{}Region'.format(class_))()
3746
        if not any(more_regions):
3747
            return self._get_recursive_regions(regions, 1, classes)
3748
        ret = []
3749
        for r, more in zip(regions, more_regions):
3750
            ret.append(r)
3751
            ret += self._get_recursive_regions(more, level - 1 if level else 0, classes)
3752
        return self._get_recursive_regions(ret, 1, classes)
3753
    
3754 View Code Duplication
    def _get_recursive_reading_order(self, rogroup):
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
3755
        if isinstance(rogroup, (OrderedGroupType, OrderedGroupIndexedType)): # pylint: disable=undefined-variable
3756
            elements = rogroup.get_AllIndexed()
3757
        if isinstance(rogroup, (UnorderedGroupType, UnorderedGroupIndexedType)): # pylint: disable=undefined-variable
3758
            elements = (rogroup.get_RegionRef() + rogroup.get_OrderedGroup() + rogroup.get_UnorderedGroup())
3759
        regionrefs = list()
3760
        for elem in elements:
0 ignored issues
show
introduced by
The variable elements does not seem to be defined in case isinstance(rogroup, TupleNode) on line 3755 is False. Are you sure this can never be the case?
Loading history...
3761
            regionrefs.append(elem.get_regionRef())
3762
            if not isinstance(elem, (RegionRefType, RegionRefIndexedType)): # pylint: disable=undefined-variable
3763
                regionrefs.extend(self._get_recursive_reading_order(elem))
3764
        return regionrefs
3765
    
3766 View Code Duplication
    def get_AllRegions(self, classes=None, order='document', depth=0):
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
3767
        """
3768
        Get all the ``*Region`` elements, or only those provided by `classes`.
3769
        Return in document order, unless `order` is ``reading-order``.
3770
    
3771
        Arguments:
3772
            classes (list): Classes of regions that shall be returned, \
3773
                e.g. ``['Text', 'Image']``
3774
            order ("document"|"reading-order"|"reading-order-only"): Whether to \
3775
                return regions sorted by document order (``document``, default) or by
3776
                reading order with regions not in the reading order at the end of the
3777
                returned list (``reading-order``) or regions not in the reading order
3778
                omitted (``reading-order-only``)
3779
            depth (int): Recursive depth to look for regions at, set to `0` for \
3780
                all regions at any depth. Default: 0
3781
    
3782
        Returns:
3783
            a list of :py:class:`TextRegionType`, :py:class:`ImageRegionType`, \
3784
                :py:class:`LineDrawingRegionType`, :py:class:`GraphicRegionType`, \
3785
                :py:class:`TableRegionType`, :py:class:`ChartRegionType`, \
3786
                :py:class:`MapRegionType`, :py:class:`SeparatorRegionType`, \
3787
                :py:class:`MathsRegionType`, :py:class:`ChemRegionType`, \
3788
                :py:class:`MusicRegionType`, :py:class:`AdvertRegionType`, \
3789
                :py:class:`NoiseRegionType`, :py:class:`UnknownRegionType`, \
3790
                and/or :py:class:`CustomRegionType`
3791
    
3792
        For example, to get all text anywhere on the page in reading order, use:
3793
        ::
3794
            '\\n'.join(line.get_TextEquiv()[0].Unicode
3795
                      for region in page.get_AllRegions(classes=['Text'], depth=0, order='reading-order')
3796
                      for line in region.get_TextLine())
3797
        """
3798
        if order not in ['document', 'reading-order', 'reading-order-only']:
3799
            raise Exception("Argument 'order' must be either 'document', 'reading-order' or 'reading-order-only', not '{}'".format(order))
3800
        if depth < 0:
3801
            raise Exception("Argument 'depth' must be an integer greater-or-equal 0, not '{}'".format(depth))
3802
        ret = self._get_recursive_regions([self], depth + 1 if depth else 0, classes)
3803
        if order.startswith('reading-order'):
3804
            reading_order = self.get_ReadingOrder()
3805
            if reading_order:
3806
                reading_order = reading_order.get_OrderedGroup() or reading_order.get_UnorderedGroup()
3807
            if reading_order:
3808
                reading_order = self._get_recursive_reading_order(reading_order)
3809
            if reading_order:
3810
                id2region = {region.id: region for region in ret}
3811
                in_reading_order = [id2region[region_id] for region_id in reading_order if region_id in id2region]
3812
                #  print("ret: {} / in_ro: {} / not-in-ro: {}".format(
3813
                #      len(ret),
3814
                #      len([id2region[region_id] for region_id in reading_order if region_id in id2region]),
3815
                #      len([r for r in ret if r not in in_reading_order])
3816
                #      ))
3817
                if order == 'reading-order-only':
3818
                    ret = in_reading_order
3819
                else:
3820
                    ret = in_reading_order + [r for r in ret if r not in in_reading_order]
3821
        return ret
3822 View Code Duplication
    def get_AllAlternativeImages(self, page=True, region=True, line=True, word=True, glyph=True):
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
3823
        """
3824
        Get all the ``pc:AlternativeImage`` in a document
3825
    
3826
        Arguments:
3827
            page (boolean): Get images on ``pc:Page`` level
3828
            region (boolean): Get images on ``pc:*Region`` level
3829
            line (boolean): Get images on ``pc:TextLine`` level
3830
            word (boolean): Get images on ``pc:Word`` level
3831
            glyph (boolean): Get images on ``pc:Glyph`` level
3832
    
3833
        Returns:
3834
            a list of :py:class:`AlternativeImageType`
3835
        """
3836
        ret = []
3837
        if page:
3838
            ret += self.get_AlternativeImage()
3839
        for this_region in self.get_AllRegions(['Text']):
3840
            if region:
3841
                ret += this_region.get_AlternativeImage()
3842
            for this_line in this_region.get_TextLine():
3843
                if line:
3844
                    ret += this_line.get_AlternativeImage()
3845
                for this_word in this_line.get_Word():
3846
                    if word:
3847
                        ret += this_word.get_AlternativeImage()
3848
                    for this_glyph in this_word.get_Glyph():
3849
                        if glyph:
3850
                            ret += this_glyph.get_AlternativeImage()
3851
        return ret
3852
    
3853 View Code Duplication
    def invalidate_AlternativeImage(self, feature_selector=None):
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
3854
        """
3855
        Remove derived images from this segment (due to changed coordinates).
3856
    
3857
        If `feature_selector` is not none, remove only images with
3858
        matching ``@comments``, e.g. ``feature_selector=cropped,deskewed``.
3859
        """
3860
        existing_images = self.AlternativeImage or []
3861
        removed_images = []
3862
        if feature_selector:
3863
            new_images = []
3864
            for image in existing_images:
3865
                features = image.get_comments() or ''
3866
                if any(feature in features.split(',')
3867
                       for feature in feature_selector.split(',') if feature):
3868
                    removed_images.append(image)
3869
                else:
3870
                    new_images.append(image)
3871
            self.AlternativeImage = new_images
3872
        else:
3873
            removed_images = existing_images
3874
            self.AlternativeImage = []
3875
        if hasattr(self, 'id'):
3876
            name = self.id
3877
        elif hasattr(self, 'parent_object_') and hasattr(self.parent_object_, 'pcGtsId'):
3878
            name = self.parent_object_.pcGtsId
3879
        else:
3880
            name = ''
3881
        for image in removed_images:
3882
            self.gds_collector_.add_message('Removing AlternativeImage %s from "%s"' % (
3883
                image.get_comments() or '', name))
3884
    def set_Border(self, Border):
3885
        """
3886
        Set coordinate polygon by given :py:class:`BorderType` object.
3887
        Moreover, invalidate self's ``pc:AlternativeImage``s
3888
        (because they will have been cropped with a bbox
3889
        of the previous polygon).
3890
        """
3891
        self.invalidate_AlternativeImage(feature_selector='cropped')
3892
        self.Border = Border
3893 View Code Duplication
    def get_AllTextLines(self, region_order='document', respect_textline_order=True):
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
3894
        """
3895
        Return all the TextLine in the document
3896
    
3897
        Arguments:
3898
            region_order ("document"|"reading-order"|"reading-order-only"): Whether to \
3899
                return regions sorted by document order (``document``, default) or by \
3900
                reading order with regions not in the reading order at the end of the \
3901
                returned list (``reading-order``) or regions not in the reading order \
3902
                omitted (``reading-order-only``)
3903
            respect_textline_order (boolean): Whether to respect `@textLineOrder` attribute
3904
    
3905
        Returns:
3906
            a list of :py:class:`TextLineType`
3907
        """
3908
        # TODO handle textLineOrder according to https://github.com/PRImA-Research-Lab/PAGE-XML/issues/26
3909
        ret = []
3910
        for reg in self.get_AllRegions(['Text'], order=region_order):
3911
            lines = reg.get_TextLine()
3912
            if not respect_textline_order:
3913
                ret += lines
3914
            else:
3915
                lo = reg.get_textLineOrder() or self.get_textLineOrder() or 'top-to-bottom'
3916
                ret += lines if lo in ['top-to-bottom', 'left-to-right'] else list(reversed(lines))
3917
        return ret
3918
    
3919 View Code Duplication
    def get_ReadingOrderGroups(self) -> dict:
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
3920
        """
3921
        Aggregate recursive ReadingOrder into a dictionary, mapping each regionRef
3922
        (i.e. segment `@id`) to its referring group object (i.e one of
3923
    
3924
        \b
3925
        - :py:class:`.RegionRefType`
3926
        - :py:class:`.RegionRefIndexedType`
3927
        - :py:class:`.OrderedGroupType`
3928
        - :py:class:`.OrderedGroupIndexedType`
3929
        - :py:class:`.UnoderedGroupType`
3930
        - :py:class:`.UnoderedGroupIndexedType`
3931
        """
3932
        def get_groupdict(group):
3933
            regionrefs = list()
3934
            if isinstance(group, (OrderedGroupType, OrderedGroupIndexedType)):
3935
                regionrefs = (group.get_RegionRefIndexed() +
3936
                              group.get_OrderedGroupIndexed() +
3937
                              group.get_UnorderedGroupIndexed())
3938
            if isinstance(group, (UnorderedGroupType, UnorderedGroupIndexedType)):
3939
                regionrefs = (group.get_RegionRef() +
3940
                              group.get_OrderedGroup() +
3941
                              group.get_UnorderedGroup())
3942
            refdict = {}
3943
            for elem in regionrefs:
3944
                refdict[elem.get_regionRef()] = elem
3945
                if not isinstance(elem, (RegionRefType, RegionRefIndexedType)):
3946
                    refdict = {**refdict, **get_groupdict(elem)}
3947
            return refdict
3948
        ro = self.get_ReadingOrder()
3949
        if ro is None:
3950
            return {}
3951
        return get_groupdict(ro.get_OrderedGroup() or ro.get_UnorderedGroup())
3952
    def set_orientation(self, orientation):
3953
        """
3954
        Set deskewing angle to given `orientation` number.
3955
        Moreover, invalidate self's ``pc:AlternativeImage``s
3956
        (because they will have been rotated and enlarged
3957
        with the angle of the previous value).
3958
        """
3959
        if hasattr(self, 'invalidate_AlternativeImage'):
3960
            # PageType, RegionType:
3961
            self.invalidate_AlternativeImage(feature_selector='deskewed')
3962
        self.orientation = orientation
3963
# end class PageType
3964
3965
3966
class CoordsType(GeneratedsSuper):
3967
    """points --
3968
    Polygon outline of the element as a path of points.
3969
    No points may lie outside the outline of its parent,
3970
    which in the case of Border is the bounding rectangle
3971
    of the root image. Paths are closed by convention,
3972
    i.e. the last point logically connects with the first
3973
    (and at least 3 points are required to span an area).
3974
    Paths must be planar (i.e. must not self-intersect).
3975
      
3976
    * conf -- Confidence value (between 0 and 1)
3977
    
3978
    """
3979
    __hash__ = GeneratedsSuper.__hash__
3980
    member_data_items_ = [
3981
        MemberSpec_('points', 'pc:PointsType', 0, 0, {'use': 'required', 'name': 'points'}),
3982
        MemberSpec_('conf', 'pc:ConfSimpleType', 0, 1, {'use': 'optional', 'name': 'conf'}),
3983
    ]
3984
    subclass = None
3985
    superclass = None
3986 View Code Duplication
    def __init__(self, points=None, conf=None, gds_collector_=None, **kwargs_):
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
3987
        self.gds_collector_ = gds_collector_
3988
        self.gds_elementtree_node_ = None
3989
        self.original_tagname_ = None
3990
        self.parent_object_ = kwargs_.get('parent_object_')
3991
        self.ns_prefix_ = "pc"
3992
        self.points = _cast(None, points)
3993
        self.points_nsprefix_ = "pc"
3994
        self.conf = _cast(float, conf)
3995
        self.conf_nsprefix_ = "pc"
3996
    def factory(*args_, **kwargs_):
3997
        if CurrentSubclassModule_ is not None:
3998
            subclass = getSubclassFromModule_(
3999
                CurrentSubclassModule_, CoordsType)
4000
            if subclass is not None:
4001
                return subclass(*args_, **kwargs_)
4002
        if CoordsType.subclass:
4003
            return CoordsType.subclass(*args_, **kwargs_)
4004
        else:
4005
            return CoordsType(*args_, **kwargs_)
4006
    factory = staticmethod(factory)
4007
    def get_ns_prefix_(self):
4008
        return self.ns_prefix_
4009
    def set_ns_prefix_(self, ns_prefix):
4010
        self.ns_prefix_ = ns_prefix
4011
    def get_points(self):
4012
        return self.points
4013
    def set_points(self, points):
4014
        self.points = points
4015
    def get_conf(self):
4016
        return self.conf
4017
    def set_conf(self, conf):
4018
        self.conf = conf
4019 View Code Duplication
    def validate_PointsType(self, value):
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
4020
        # Validate type pc:PointsType, a restriction on string.
4021
        if value is not None and Validate_simpletypes_ and self.gds_collector_ is not None:
4022
            if not isinstance(value, str):
4023
                lineno = self.gds_get_node_lineno_()
4024
                self.gds_collector_.add_message('Value "%(value)s"%(lineno)s is not of the correct base simple type (str)' % {"value": value, "lineno": lineno, })
4025
                return False
4026
            if not self.gds_validate_simple_patterns(
4027
                    self.validate_PointsType_patterns_, value):
4028
                self.gds_collector_.add_message('Value "%s" does not match xsd pattern restrictions: %s' % (encode_str_2_3(value), self.validate_PointsType_patterns_, ))
4029
    validate_PointsType_patterns_ = [['^(([0-9]+,[0-9]+ )+([0-9]+,[0-9]+))$']]
4030 View Code Duplication
    def validate_ConfSimpleType(self, value):
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
4031
        # Validate type pc:ConfSimpleType, a restriction on float.
4032
        if value is not None and Validate_simpletypes_ and self.gds_collector_ is not None:
4033
            if not isinstance(value, float):
4034
                lineno = self.gds_get_node_lineno_()
4035
                self.gds_collector_.add_message('Value "%(value)s"%(lineno)s is not of the correct base simple type (float)' % {"value": value, "lineno": lineno, })
4036
                return False
4037
            if value < 0:
4038
                lineno = self.gds_get_node_lineno_()
4039
                self.gds_collector_.add_message('Value "%(value)s"%(lineno)s does not match xsd minInclusive restriction on ConfSimpleType' % {"value": value, "lineno": lineno} )
4040
                result = False
4041
            if value > 1:
4042
                lineno = self.gds_get_node_lineno_()
4043
                self.gds_collector_.add_message('Value "%(value)s"%(lineno)s does not match xsd maxInclusive restriction on ConfSimpleType' % {"value": value, "lineno": lineno} )
4044
                result = False
4045
    def has__content(self):
4046
        if (
4047
4048
        ):
4049
            return True
4050
        else:
4051
            return False
4052
    def export(self, outfile, level, namespaceprefix_='', namespacedef_='xmlns:pc="http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15"', name_='CoordsType', pretty_print=True):
4053
        imported_ns_def_ = GenerateDSNamespaceDefs_.get('CoordsType')
4054
        if imported_ns_def_ is not None:
4055
            namespacedef_ = imported_ns_def_
4056
        if pretty_print:
4057
            eol_ = '\n'
4058
        else:
4059
            eol_ = ''
4060
        if self.original_tagname_ is not None and name_ == 'CoordsType':
4061
            name_ = self.original_tagname_
4062
        if UseCapturedNS_ and self.ns_prefix_:
4063
            namespaceprefix_ = self.ns_prefix_ + ':'
4064
        showIndent(outfile, level, pretty_print)
4065
        outfile.write('<%s%s%s' % (namespaceprefix_, name_, namespacedef_ and ' ' + namespacedef_ or '', ))
4066
        already_processed = set()
4067
        self._exportAttributes(outfile, level, already_processed, namespaceprefix_, name_='CoordsType')
4068
        if self.has__content():
4069
            outfile.write('>%s' % (eol_, ))
4070
            self._exportChildren(outfile, level + 1, namespaceprefix_, namespacedef_, name_='CoordsType', pretty_print=pretty_print)
4071
            outfile.write('</%s%s>%s' % (namespaceprefix_, name_, eol_))
4072
        else:
4073
            outfile.write('/>%s' % (eol_, ))
4074
    def _exportAttributes(self, outfile, level, already_processed, namespaceprefix_='', name_='CoordsType'):
4075
        if self.points is not None and 'points' not in already_processed:
4076
            already_processed.add('points')
4077
            outfile.write(' points=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.points), input_name='points')), ))
4078
        if self.conf is not None and 'conf' not in already_processed:
4079
            already_processed.add('conf')
4080
            outfile.write(' conf="%s"' % self.gds_format_float(self.conf, input_name='conf'))
4081
    def _exportChildren(self, outfile, level, namespaceprefix_='', namespacedef_='xmlns:pc="http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15"', name_='CoordsType', fromsubclass_=False, pretty_print=True):
4082
        pass
4083 View Code Duplication
    def to_etree(self, parent_element=None, name_='CoordsType', mapping_=None, reverse_mapping_=None, nsmap_=None):
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
4084
        if parent_element is None:
4085
            element = etree_.Element('{http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15}' + name_, nsmap=nsmap_)
4086
        else:
4087
            element = etree_.SubElement(parent_element, '{http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15}' + name_, nsmap=nsmap_)
4088
        if self.points is not None:
4089
            element.set('points', self.gds_format_string(self.points))
4090
        if self.conf is not None:
4091
            element.set('conf', self.gds_format_float(self.conf))
4092
        if mapping_ is not None:
4093
            mapping_[id(self)] = element
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable id does not seem to be defined.
Loading history...
4094
        if reverse_mapping_ is not None:
4095
            reverse_mapping_[element] = self
4096
        return element
4097
    def build(self, node, gds_collector_=None):
4098
        self.gds_collector_ = gds_collector_
4099
        if SaveElementTreeNode:
4100
            self.gds_elementtree_node_ = node
4101
        already_processed = set()
4102
        self.ns_prefix_ = node.prefix
4103
        self._buildAttributes(node, node.attrib, already_processed)
4104
        for child in node:
4105
            nodeName_ = Tag_pattern_.match(child.tag).groups()[-1]
4106
            self._buildChildren(child, node, nodeName_, gds_collector_=gds_collector_)
4107
        return self
4108 View Code Duplication
    def _buildAttributes(self, node, attrs, already_processed):
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
4109
        value = find_attr_value_('points', node)
4110
        if value is not None and 'points' not in already_processed:
4111
            already_processed.add('points')
4112
            self.points = value
4113
            self.validate_PointsType(self.points)    # validate type PointsType
4114
        value = find_attr_value_('conf', node)
4115
        if value is not None and 'conf' not in already_processed:
4116
            already_processed.add('conf')
4117
            value = self.gds_parse_float(value, node, 'conf')
4118
            self.conf = value
4119
            self.validate_ConfSimpleType(self.conf)    # validate type ConfSimpleType
4120
    def _buildChildren(self, child_, node, nodeName_, fromsubclass_=False, gds_collector_=None):
4121
        pass
4122
    def __hash__(self):
4123
        return hash(self.id)
4124 View Code Duplication
    def set_points(self, points):
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
4125
        """
4126
        Set coordinate polygon by given string.
4127
        Moreover, invalidate the parent's ``pc:AlternativeImage``s
4128
        (because they will have been cropped with a bbox
4129
        of the previous polygon).
4130
        """
4131
        if hasattr(self, 'parent_object_'):
4132
            parent = self.parent_object_
4133
            if hasattr(parent, 'invalidate_AlternativeImage'):
4134
                # RegionType, TextLineType, WordType, GlyphType:
4135
                parent.invalidate_AlternativeImage()
4136
            elif hasattr(parent, 'parent_object_') and hasattr(parent.parent_object_, 'invalidate_AlternativeImage'):
4137
                # BorderType:
4138
                parent.parent_object_.invalidate_AlternativeImage(feature_selector='cropped')
4139
        self.points = points
4140
# end class CoordsType
4141
4142
4143
class TextLineType(GeneratedsSuper):
4144
    """primaryLanguage --
4145
    Overrides primaryLanguage attribute of parent text
4146
    region
4147
      
4148
    * primaryScript --
4149
      The primary script used in the text line
4150
      
4151
    * secondaryScript --
4152
      The secondary script used in the text line
4153
      
4154
    * readingDirection --
4155
      The direction in which text within the line
4156
      should be read (order of words and characters).
4157
      
4158
    * production --
4159
      Overrides the production attribute of the parent
4160
      text region
4161
      
4162
    * custom -- For generic use
4163
    * index --
4164
      Position (order number) of this text line within the
4165
      parent text region.
4166
      
4167
    * AlternativeImage --
4168
      Alternative text line images (e.g.
4169
      black-and-white)
4170
      
4171
    * Baseline --
4172
      Multiple connected points that mark the baseline
4173
      of the glyphs
4174
      
4175
    * Labels -- Semantic labels / tags
4176
    
4177
    """
4178
    __hash__ = GeneratedsSuper.__hash__
4179
    member_data_items_ = [
4180
        MemberSpec_('id', 'string', 0, 0, {'use': 'required', 'name': 'id'}),
4181
        MemberSpec_('primaryLanguage', 'pc:LanguageSimpleType', 0, 1, {'use': 'optional', 'name': 'primaryLanguage'}),
4182
        MemberSpec_('primaryScript', 'pc:ScriptSimpleType', 0, 1, {'use': 'optional', 'name': 'primaryScript'}),
4183
        MemberSpec_('secondaryScript', 'pc:ScriptSimpleType', 0, 1, {'use': 'optional', 'name': 'secondaryScript'}),
4184
        MemberSpec_('readingDirection', 'pc:ReadingDirectionSimpleType', 0, 1, {'use': 'optional', 'name': 'readingDirection'}),
4185
        MemberSpec_('production', 'pc:ProductionSimpleType', 0, 1, {'use': 'optional', 'name': 'production'}),
4186
        MemberSpec_('custom', 'string', 0, 1, {'use': 'optional', 'name': 'custom'}),
4187
        MemberSpec_('comments', 'string', 0, 1, {'use': 'optional', 'name': 'comments'}),
4188
        MemberSpec_('index', 'int', 0, 1, {'use': 'optional', 'name': 'index'}),
4189
        MemberSpec_('AlternativeImage', 'AlternativeImageType', 1, 1, {'maxOccurs': 'unbounded', 'minOccurs': '0', 'name': 'AlternativeImage', 'type': 'AlternativeImageType'}, None),
4190
        MemberSpec_('Coords', 'CoordsType', 0, 0, {'name': 'Coords', 'type': 'CoordsType'}, None),
4191
        MemberSpec_('Baseline', 'BaselineType', 0, 1, {'minOccurs': '0', 'name': 'Baseline', 'type': 'BaselineType'}, None),
4192
        MemberSpec_('Word', 'WordType', 1, 1, {'maxOccurs': 'unbounded', 'minOccurs': '0', 'name': 'Word', 'type': 'WordType'}, None),
4193
        MemberSpec_('TextEquiv', 'TextEquivType', 1, 1, {'maxOccurs': 'unbounded', 'minOccurs': '0', 'name': 'TextEquiv', 'type': 'TextEquivType'}, None),
4194
        MemberSpec_('TextStyle', 'TextStyleType', 0, 1, {'minOccurs': '0', 'name': 'TextStyle', 'type': 'TextStyleType'}, None),
4195
        MemberSpec_('UserDefined', 'UserDefinedType', 0, 1, {'maxOccurs': '1', 'minOccurs': '0', 'name': 'UserDefined', 'type': 'UserDefinedType'}, None),
4196
        MemberSpec_('Labels', 'LabelsType', 1, 1, {'maxOccurs': 'unbounded', 'minOccurs': '0', 'name': 'Labels', 'type': 'LabelsType'}, None),
4197
    ]
4198
    subclass = None
4199
    superclass = None
4200
    def __init__(self, id=None, primaryLanguage=None, primaryScript=None, secondaryScript=None, readingDirection=None, production=None, custom=None, comments=None, index=None, AlternativeImage=None, Coords=None, Baseline=None, Word=None, TextEquiv=None, TextStyle=None, UserDefined=None, Labels=None, gds_collector_=None, **kwargs_):
4201
        self.gds_collector_ = gds_collector_
4202
        self.gds_elementtree_node_ = None
4203
        self.original_tagname_ = None
4204
        self.parent_object_ = kwargs_.get('parent_object_')
4205
        self.ns_prefix_ = "pc"
4206
        self.id = _cast(None, id)
4207
        self.id_nsprefix_ = "pc"
4208
        self.primaryLanguage = _cast(None, primaryLanguage)
4209
        self.primaryLanguage_nsprefix_ = "pc"
4210
        self.primaryScript = _cast(None, primaryScript)
4211
        self.primaryScript_nsprefix_ = "pc"
4212
        self.secondaryScript = _cast(None, secondaryScript)
4213
        self.secondaryScript_nsprefix_ = "pc"
4214
        self.readingDirection = _cast(None, readingDirection)
4215
        self.readingDirection_nsprefix_ = "pc"
4216
        self.production = _cast(None, production)
4217
        self.production_nsprefix_ = "pc"
4218
        self.custom = _cast(None, custom)
4219
        self.custom_nsprefix_ = "pc"
4220
        self.comments = _cast(None, comments)
4221
        self.comments_nsprefix_ = "pc"
4222
        self.index = _cast(int, index)
4223
        self.index_nsprefix_ = "pc"
4224
        if AlternativeImage is None:
4225
            self.AlternativeImage = []
4226
        else:
4227
            self.AlternativeImage = AlternativeImage
4228
        self.AlternativeImage_nsprefix_ = "pc"
4229
        self.Coords = Coords
4230
        self.Coords_nsprefix_ = "pc"
4231
        self.Baseline = Baseline
4232
        self.Baseline_nsprefix_ = "pc"
4233
        if Word is None:
4234
            self.Word = []
4235
        else:
4236
            self.Word = Word
4237
        self.Word_nsprefix_ = "pc"
4238
        if TextEquiv is None:
4239
            self.TextEquiv = []
4240
        else:
4241
            self.TextEquiv = TextEquiv
4242
        self.TextEquiv_nsprefix_ = "pc"
4243
        self.TextStyle = TextStyle
4244
        self.TextStyle_nsprefix_ = "pc"
4245
        self.UserDefined = UserDefined
4246
        self.UserDefined_nsprefix_ = "pc"
4247
        if Labels is None:
4248
            self.Labels = []
4249
        else:
4250
            self.Labels = Labels
4251
        self.Labels_nsprefix_ = "pc"
4252
    def factory(*args_, **kwargs_):
4253
        if CurrentSubclassModule_ is not None:
4254
            subclass = getSubclassFromModule_(
4255
                CurrentSubclassModule_, TextLineType)
4256
            if subclass is not None:
4257
                return subclass(*args_, **kwargs_)
4258
        if TextLineType.subclass:
4259
            return TextLineType.subclass(*args_, **kwargs_)
4260
        else:
4261
            return TextLineType(*args_, **kwargs_)
4262
    factory = staticmethod(factory)
4263
    def get_ns_prefix_(self):
4264
        return self.ns_prefix_
4265
    def set_ns_prefix_(self, ns_prefix):
4266
        self.ns_prefix_ = ns_prefix
4267
    def get_AlternativeImage(self):
4268
        return self.AlternativeImage
4269
    def set_AlternativeImage(self, AlternativeImage):
4270
        self.AlternativeImage = AlternativeImage
4271
    def add_AlternativeImage(self, value):
4272
        self.AlternativeImage.append(value)
4273
    def insert_AlternativeImage_at(self, index, value):
4274
        self.AlternativeImage.insert(index, value)
4275
    def replace_AlternativeImage_at(self, index, value):
4276
        self.AlternativeImage[index] = value
4277
    def get_Coords(self):
4278
        return self.Coords
4279
    def set_Coords(self, Coords):
4280
        self.Coords = Coords
4281
    def get_Baseline(self):
4282
        return self.Baseline
4283
    def set_Baseline(self, Baseline):
4284
        self.Baseline = Baseline
4285
    def get_Word(self):
4286
        return self.Word
4287
    def set_Word(self, Word):
4288
        self.Word = Word
4289
    def add_Word(self, value):
4290
        self.Word.append(value)
4291
    def insert_Word_at(self, index, value):
4292
        self.Word.insert(index, value)
4293
    def replace_Word_at(self, index, value):
4294
        self.Word[index] = value
4295
    def get_TextEquiv(self):
4296
        return self.TextEquiv
4297
    def set_TextEquiv(self, TextEquiv):
4298
        self.TextEquiv = TextEquiv
4299
    def add_TextEquiv(self, value):
4300
        self.TextEquiv.append(value)
4301
    def insert_TextEquiv_at(self, index, value):
4302
        self.TextEquiv.insert(index, value)
4303
    def replace_TextEquiv_at(self, index, value):
4304
        self.TextEquiv[index] = value
4305
    def get_TextStyle(self):
4306
        return self.TextStyle
4307
    def set_TextStyle(self, TextStyle):
4308
        self.TextStyle = TextStyle
4309
    def get_UserDefined(self):
4310
        return self.UserDefined
4311
    def set_UserDefined(self, UserDefined):
4312
        self.UserDefined = UserDefined
4313
    def get_Labels(self):
4314
        return self.Labels
4315
    def set_Labels(self, Labels):
4316
        self.Labels = Labels
4317
    def add_Labels(self, value):
4318
        self.Labels.append(value)
4319
    def insert_Labels_at(self, index, value):
4320
        self.Labels.insert(index, value)
4321
    def replace_Labels_at(self, index, value):
4322
        self.Labels[index] = value
4323
    def get_id(self):
4324
        return self.id
4325
    def set_id(self, id):
4326
        self.id = id
4327
    def get_primaryLanguage(self):
4328
        return self.primaryLanguage
4329
    def set_primaryLanguage(self, primaryLanguage):
4330
        self.primaryLanguage = primaryLanguage
4331
    def get_primaryScript(self):
4332
        return self.primaryScript
4333
    def set_primaryScript(self, primaryScript):
4334
        self.primaryScript = primaryScript
4335
    def get_secondaryScript(self):
4336
        return self.secondaryScript
4337
    def set_secondaryScript(self, secondaryScript):
4338
        self.secondaryScript = secondaryScript
4339
    def get_readingDirection(self):
4340
        return self.readingDirection
4341
    def set_readingDirection(self, readingDirection):
4342
        self.readingDirection = readingDirection
4343
    def get_production(self):
4344
        return self.production
4345
    def set_production(self, production):
4346
        self.production = production
4347
    def get_custom(self):
4348
        return self.custom
4349
    def set_custom(self, custom):
4350
        self.custom = custom
4351
    def get_comments(self):
4352
        return self.comments
4353
    def set_comments(self, comments):
4354
        self.comments = comments
4355
    def get_index(self):
4356
        return self.index
4357
    def set_index(self, index):
4358
        self.index = index
4359
    def validate_LanguageSimpleType(self, value):
4360
        # Validate type pc:LanguageSimpleType, a restriction on string.
4361
        if value is not None and Validate_simpletypes_ and self.gds_collector_ is not None:
4362
            if not isinstance(value, str):
4363
                lineno = self.gds_get_node_lineno_()
4364
                self.gds_collector_.add_message('Value "%(value)s"%(lineno)s is not of the correct base simple type (str)' % {"value": value, "lineno": lineno, })
4365
                return False
4366
            value = value
4367
            enumerations = ['Abkhaz', 'Afar', 'Afrikaans', 'Akan', 'Albanian', 'Amharic', 'Arabic', 'Aragonese', 'Armenian', 'Assamese', 'Avaric', 'Avestan', 'Aymara', 'Azerbaijani', 'Bambara', 'Bashkir', 'Basque', 'Belarusian', 'Bengali', 'Bihari', 'Bislama', 'Bosnian', 'Breton', 'Bulgarian', 'Burmese', 'Cambodian', 'Cantonese', 'Catalan', 'Chamorro', 'Chechen', 'Chichewa', 'Chinese', 'Chuvash', 'Cornish', 'Corsican', 'Cree', 'Croatian', 'Czech', 'Danish', 'Divehi', 'Dutch', 'Dzongkha', 'English', 'Esperanto', 'Estonian', 'Ewe', 'Faroese', 'Fijian', 'Finnish', 'French', 'Fula', 'Gaelic', 'Galician', 'Ganda', 'Georgian', 'German', 'Greek', 'Guaraní', 'Gujarati', 'Haitian', 'Hausa', 'Hebrew', 'Herero', 'Hindi', 'Hiri Motu', 'Hungarian', 'Icelandic', 'Ido', 'Igbo', 'Indonesian', 'Interlingua', 'Interlingue', 'Inuktitut', 'Inupiaq', 'Irish', 'Italian', 'Japanese', 'Javanese', 'Kalaallisut', 'Kannada', 'Kanuri', 'Kashmiri', 'Kazakh', 'Khmer', 'Kikuyu', 'Kinyarwanda', 'Kirundi', 'Komi', 'Kongo', 'Korean', 'Kurdish', 'Kwanyama', 'Kyrgyz', 'Lao', 'Latin', 'Latvian', 'Limburgish', 'Lingala', 'Lithuanian', 'Luba-Katanga', 'Luxembourgish', 'Macedonian', 'Malagasy', 'Malay', 'Malayalam', 'Maltese', 'Manx', 'Māori', 'Marathi', 'Marshallese', 'Mongolian', 'Nauru', 'Navajo', 'Ndonga', 'Nepali', 'North Ndebele', 'Northern Sami', 'Norwegian', 'Norwegian Bokmål', 'Norwegian Nynorsk', 'Nuosu', 'Occitan', 'Ojibwe', 'Old Church Slavonic', 'Oriya', 'Oromo', 'Ossetian', 'Pāli', 'Panjabi', 'Pashto', 'Persian', 'Polish', 'Portuguese', 'Punjabi', 'Quechua', 'Romanian', 'Romansh', 'Russian', 'Samoan', 'Sango', 'Sanskrit', 'Sardinian', 'Serbian', 'Shona', 'Sindhi', 'Sinhala', 'Slovak', 'Slovene', 'Somali', 'South Ndebele', 'Southern Sotho', 'Spanish', 'Sundanese', 'Swahili', 'Swati', 'Swedish', 'Tagalog', 'Tahitian', 'Tajik', 'Tamil', 'Tatar', 'Telugu', 'Thai', 'Tibetan', 'Tigrinya', 'Tonga', 'Tsonga', 'Tswana', 'Turkish', 'Turkmen', 'Twi', 'Uighur', 'Ukrainian', 'Urdu', 'Uzbek', 'Venda', 'Vietnamese', 'Volapük', 'Walloon', 'Welsh', 'Western Frisian', 'Wolof', 'Xhosa', 'Yiddish', 'Yoruba', 'Zhuang', 'Zulu', 'other']
4368
            if value not in enumerations:
4369
                lineno = self.gds_get_node_lineno_()
4370
                self.gds_collector_.add_message('Value "%(value)s"%(lineno)s does not match xsd enumeration restriction on LanguageSimpleType' % {"value" : encode_str_2_3(value), "lineno": lineno} )
4371
                result = False
4372
    def validate_ScriptSimpleType(self, value):
4373
        # Validate type pc:ScriptSimpleType, a restriction on string.
4374
        if value is not None and Validate_simpletypes_ and self.gds_collector_ is not None:
4375
            if not isinstance(value, str):
4376
                lineno = self.gds_get_node_lineno_()
4377
                self.gds_collector_.add_message('Value "%(value)s"%(lineno)s is not of the correct base simple type (str)' % {"value": value, "lineno": lineno, })
4378
                return False
4379
            value = value
4380
            enumerations = ['Adlm - Adlam', 'Afak - Afaka', 'Aghb - Caucasian Albanian', 'Ahom - Ahom, Tai Ahom', 'Arab - Arabic', 'Aran - Arabic (Nastaliq variant)', 'Armi - Imperial Aramaic', 'Armn - Armenian', 'Avst - Avestan', 'Bali - Balinese', 'Bamu - Bamum', 'Bass - Bassa Vah', 'Batk - Batak', 'Beng - Bengali', 'Bhks - Bhaiksuki', 'Blis - Blissymbols', 'Bopo - Bopomofo', 'Brah - Brahmi', 'Brai - Braille', 'Bugi - Buginese', 'Buhd - Buhid', 'Cakm - Chakma', 'Cans - Unified Canadian Aboriginal Syllabics', 'Cari - Carian', 'Cham - Cham', 'Cher - Cherokee', 'Cirt - Cirth', 'Copt - Coptic', 'Cprt - Cypriot', 'Cyrl - Cyrillic', 'Cyrs - Cyrillic (Old Church Slavonic variant)', 'Deva - Devanagari (Nagari)', 'Dsrt - Deseret (Mormon)', 'Dupl - Duployan shorthand, Duployan stenography', 'Egyd - Egyptian demotic', 'Egyh - Egyptian hieratic', 'Egyp - Egyptian hieroglyphs', 'Elba - Elbasan', 'Ethi - Ethiopic', 'Geok - Khutsuri (Asomtavruli and Nuskhuri)', 'Geor - Georgian (Mkhedruli)', 'Glag - Glagolitic', 'Goth - Gothic', 'Gran - Grantha', 'Grek - Greek', 'Gujr - Gujarati', 'Guru - Gurmukhi', 'Hanb - Han with Bopomofo', 'Hang - Hangul', 'Hani - Han (Hanzi, Kanji, Hanja)', 'Hano - Hanunoo (Hanunóo)', 'Hans - Han (Simplified variant)', 'Hant - Han (Traditional variant)', 'Hatr - Hatran', 'Hebr - Hebrew', 'Hira - Hiragana', 'Hluw - Anatolian Hieroglyphs', 'Hmng - Pahawh Hmong', 'Hrkt - Japanese syllabaries', 'Hung - Old Hungarian (Hungarian Runic)', 'Inds - Indus (Harappan)', 'Ital - Old Italic (Etruscan, Oscan etc.)', 'Jamo - Jamo', 'Java - Javanese', 'Jpan - Japanese', 'Jurc - Jurchen', 'Kali - Kayah Li', 'Kana - Katakana', 'Khar - Kharoshthi', 'Khmr - Khmer', 'Khoj - Khojki', 'Kitl - Khitan large script', 'Kits - Khitan small script', 'Knda - Kannada', 'Kore - Korean (alias for Hangul + Han)', 'Kpel - Kpelle', 'Kthi - Kaithi', 'Lana - Tai Tham (Lanna)', 'Laoo - Lao', 'Latf - Latin (Fraktur variant)', 'Latg - Latin (Gaelic variant)', 'Latn - Latin', 'Leke - Leke', 'Lepc - Lepcha (Róng)', 'Limb - Limbu', 'Lina - Linear A', 'Linb - Linear B', 'Lisu - Lisu (Fraser)', 'Loma - Loma', 'Lyci - Lycian', 'Lydi - Lydian', 'Mahj - Mahajani', 'Mand - Mandaic, Mandaean', 'Mani - Manichaean', 'Marc - Marchen', 'Maya - Mayan hieroglyphs', 'Mend - Mende Kikakui', 'Merc - Meroitic Cursive', 'Mero - Meroitic Hieroglyphs', 'Mlym - Malayalam', 'Modi - Modi, Moḍī', 'Mong - Mongolian', 'Moon - Moon (Moon code, Moon script, Moon type)', 'Mroo - Mro, Mru', 'Mtei - Meitei Mayek (Meithei, Meetei)', 'Mult - Multani', 'Mymr - Myanmar (Burmese)', 'Narb - Old North Arabian (Ancient North Arabian)', 'Nbat - Nabataean', 'Newa - Newa, Newar, Newari', 'Nkgb - Nakhi Geba', 'Nkoo - N’Ko', 'Nshu - Nüshu', 'Ogam - Ogham', 'Olck - Ol Chiki (Ol Cemet’, Ol, Santali)', 'Orkh - Old Turkic, Orkhon Runic', 'Orya - Oriya', 'Osge - Osage', 'Osma - Osmanya', 'Palm - Palmyrene', 'Pauc - Pau Cin Hau', 'Perm - Old Permic', 'Phag - Phags-pa', 'Phli - Inscriptional Pahlavi', 'Phlp - Psalter Pahlavi', 'Phlv - Book Pahlavi', 'Phnx - Phoenician', 'Piqd - Klingon (KLI pIqaD)', 'Plrd - Miao (Pollard)', 'Prti - Inscriptional Parthian', 'Rjng - Rejang (Redjang, Kaganga)', 'Roro - Rongorongo', 'Runr - Runic', 'Samr - Samaritan', 'Sara - Sarati', 'Sarb - Old South Arabian', 'Saur - Saurashtra', 'Sgnw - SignWriting', 'Shaw - Shavian (Shaw)', 'Shrd - Sharada, Śāradā', 'Sidd - Siddham', 'Sind - Khudawadi, Sindhi', 'Sinh - Sinhala', 'Sora - Sora Sompeng', 'Sund - Sundanese', 'Sylo - Syloti Nagri', 'Syrc - Syriac', 'Syre - Syriac (Estrangelo variant)', 'Syrj - Syriac (Western variant)', 'Syrn - Syriac (Eastern variant)', 'Tagb - Tagbanwa', 'Takr - Takri', 'Tale - Tai Le', 'Talu - New Tai Lue', 'Taml - Tamil', 'Tang - Tangut', 'Tavt - Tai Viet', 'Telu - Telugu', 'Teng - Tengwar', 'Tfng - Tifinagh (Berber)', 'Tglg - Tagalog (Baybayin, Alibata)', 'Thaa - Thaana', 'Thai - Thai', 'Tibt - Tibetan', 'Tirh - Tirhuta', 'Ugar - Ugaritic', 'Vaii - Vai', 'Visp - Visible Speech', 'Wara - Warang Citi (Varang Kshiti)', 'Wole - Woleai', 'Xpeo - Old Persian', 'Xsux - Cuneiform, Sumero-Akkadian', 'Yiii - Yi', 'Zinh - Code for inherited script', 'Zmth - Mathematical notation', 'Zsye - Symbols (Emoji variant)', 'Zsym - Symbols', 'Zxxx - Code for unwritten documents', 'Zyyy - Code for undetermined script', 'Zzzz - Code for uncoded script', 'other']
4381
            if value not in enumerations:
4382
                lineno = self.gds_get_node_lineno_()
4383
                self.gds_collector_.add_message('Value "%(value)s"%(lineno)s does not match xsd enumeration restriction on ScriptSimpleType' % {"value" : encode_str_2_3(value), "lineno": lineno} )
4384
                result = False
4385
    def validate_ReadingDirectionSimpleType(self, value):
4386
        # Validate type pc:ReadingDirectionSimpleType, a restriction on string.
4387
        if value is not None and Validate_simpletypes_ and self.gds_collector_ is not None:
4388
            if not isinstance(value, str):
4389
                lineno = self.gds_get_node_lineno_()
4390
                self.gds_collector_.add_message('Value "%(value)s"%(lineno)s is not of the correct base simple type (str)' % {"value": value, "lineno": lineno, })
4391
                return False
4392
            value = value
4393
            enumerations = ['left-to-right', 'right-to-left', 'top-to-bottom', 'bottom-to-top']
4394
            if value not in enumerations:
4395
                lineno = self.gds_get_node_lineno_()
4396
                self.gds_collector_.add_message('Value "%(value)s"%(lineno)s does not match xsd enumeration restriction on ReadingDirectionSimpleType' % {"value" : encode_str_2_3(value), "lineno": lineno} )
4397
                result = False
4398
    def validate_ProductionSimpleType(self, value):
4399
        # Validate type pc:ProductionSimpleType, a restriction on string.
4400
        if value is not None and Validate_simpletypes_ and self.gds_collector_ is not None:
4401
            if not isinstance(value, str):
4402
                lineno = self.gds_get_node_lineno_()
4403
                self.gds_collector_.add_message('Value "%(value)s"%(lineno)s is not of the correct base simple type (str)' % {"value": value, "lineno": lineno, })
4404
                return False
4405
            value = value
4406
            enumerations = ['printed', 'typewritten', 'handwritten-cursive', 'handwritten-printscript', 'medieval-manuscript', 'other']
4407
            if value not in enumerations:
4408
                lineno = self.gds_get_node_lineno_()
4409
                self.gds_collector_.add_message('Value "%(value)s"%(lineno)s does not match xsd enumeration restriction on ProductionSimpleType' % {"value" : encode_str_2_3(value), "lineno": lineno} )
4410
                result = False
4411
    def has__content(self):
4412
        if (
4413
            self.AlternativeImage or
4414
            self.Coords is not None or
4415
            self.Baseline is not None or
4416
            self.Word or
4417
            self.TextEquiv or
4418
            self.TextStyle is not None or
4419
            self.UserDefined is not None or
4420
            self.Labels
4421
        ):
4422
            return True
4423
        else:
4424
            return False
4425
    def export(self, outfile, level, namespaceprefix_='', namespacedef_='xmlns:pc="http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15"', name_='TextLineType', pretty_print=True):
4426
        imported_ns_def_ = GenerateDSNamespaceDefs_.get('TextLineType')
4427
        if imported_ns_def_ is not None:
4428
            namespacedef_ = imported_ns_def_
4429
        if pretty_print:
4430
            eol_ = '\n'
4431
        else:
4432
            eol_ = ''
4433
        if self.original_tagname_ is not None and name_ == 'TextLineType':
4434
            name_ = self.original_tagname_
4435
        if UseCapturedNS_ and self.ns_prefix_:
4436
            namespaceprefix_ = self.ns_prefix_ + ':'
4437
        showIndent(outfile, level, pretty_print)
4438
        outfile.write('<%s%s%s' % (namespaceprefix_, name_, namespacedef_ and ' ' + namespacedef_ or '', ))
4439
        already_processed = set()
4440
        self._exportAttributes(outfile, level, already_processed, namespaceprefix_, name_='TextLineType')
4441
        if self.has__content():
4442
            outfile.write('>%s' % (eol_, ))
4443
            self._exportChildren(outfile, level + 1, namespaceprefix_, namespacedef_, name_='TextLineType', pretty_print=pretty_print)
4444
            showIndent(outfile, level, pretty_print)
4445
            outfile.write('</%s%s>%s' % (namespaceprefix_, name_, eol_))
4446
        else:
4447
            outfile.write('/>%s' % (eol_, ))
4448
    def _exportAttributes(self, outfile, level, already_processed, namespaceprefix_='', name_='TextLineType'):
4449
        if self.id is not None and 'id' not in already_processed:
4450
            already_processed.add('id')
4451
            outfile.write(' id=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.id), input_name='id')), ))
4452
        if self.primaryLanguage is not None and 'primaryLanguage' not in already_processed:
4453
            already_processed.add('primaryLanguage')
4454
            outfile.write(' primaryLanguage=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.primaryLanguage), input_name='primaryLanguage')), ))
4455
        if self.primaryScript is not None and 'primaryScript' not in already_processed:
4456
            already_processed.add('primaryScript')
4457
            outfile.write(' primaryScript=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.primaryScript), input_name='primaryScript')), ))
4458
        if self.secondaryScript is not None and 'secondaryScript' not in already_processed:
4459
            already_processed.add('secondaryScript')
4460
            outfile.write(' secondaryScript=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.secondaryScript), input_name='secondaryScript')), ))
4461
        if self.readingDirection is not None and 'readingDirection' not in already_processed:
4462
            already_processed.add('readingDirection')
4463
            outfile.write(' readingDirection=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.readingDirection), input_name='readingDirection')), ))
4464
        if self.production is not None and 'production' not in already_processed:
4465
            already_processed.add('production')
4466
            outfile.write(' production=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.production), input_name='production')), ))
4467
        if self.custom is not None and 'custom' not in already_processed:
4468
            already_processed.add('custom')
4469
            outfile.write(' custom=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.custom), input_name='custom')), ))
4470
        if self.comments is not None and 'comments' not in already_processed:
4471
            already_processed.add('comments')
4472
            outfile.write(' comments=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.comments), input_name='comments')), ))
4473
        if self.index is not None and 'index' not in already_processed:
4474
            already_processed.add('index')
4475
            outfile.write(' index="%s"' % self.gds_format_integer(self.index, input_name='index'))
4476
    def _exportChildren(self, outfile, level, namespaceprefix_='', namespacedef_='xmlns:pc="http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15"', name_='TextLineType', fromsubclass_=False, pretty_print=True):
4477
        if pretty_print:
4478
            eol_ = '\n'
4479
        else:
4480
            eol_ = ''
4481
        for AlternativeImage_ in self.AlternativeImage:
4482
            namespaceprefix_ = self.AlternativeImage_nsprefix_ + ':' if (UseCapturedNS_ and self.AlternativeImage_nsprefix_) else ''
4483
            AlternativeImage_.export(outfile, level, namespaceprefix_, namespacedef_='', name_='AlternativeImage', pretty_print=pretty_print)
4484
        if self.Coords is not None:
4485
            namespaceprefix_ = self.Coords_nsprefix_ + ':' if (UseCapturedNS_ and self.Coords_nsprefix_) else ''
4486
            self.Coords.export(outfile, level, namespaceprefix_, namespacedef_='', name_='Coords', pretty_print=pretty_print)
4487
        if self.Baseline is not None:
4488
            namespaceprefix_ = self.Baseline_nsprefix_ + ':' if (UseCapturedNS_ and self.Baseline_nsprefix_) else ''
4489
            self.Baseline.export(outfile, level, namespaceprefix_, namespacedef_='', name_='Baseline', pretty_print=pretty_print)
4490
        for Word_ in self.Word:
4491
            namespaceprefix_ = self.Word_nsprefix_ + ':' if (UseCapturedNS_ and self.Word_nsprefix_) else ''
4492
            Word_.export(outfile, level, namespaceprefix_, namespacedef_='', name_='Word', pretty_print=pretty_print)
4493
        for TextEquiv_ in self.TextEquiv:
4494
            namespaceprefix_ = self.TextEquiv_nsprefix_ + ':' if (UseCapturedNS_ and self.TextEquiv_nsprefix_) else ''
4495
            TextEquiv_.export(outfile, level, namespaceprefix_, namespacedef_='', name_='TextEquiv', pretty_print=pretty_print)
4496
        if self.TextStyle is not None:
4497
            namespaceprefix_ = self.TextStyle_nsprefix_ + ':' if (UseCapturedNS_ and self.TextStyle_nsprefix_) else ''
4498
            self.TextStyle.export(outfile, level, namespaceprefix_, namespacedef_='', name_='TextStyle', pretty_print=pretty_print)
4499
        if self.UserDefined is not None:
4500
            namespaceprefix_ = self.UserDefined_nsprefix_ + ':' if (UseCapturedNS_ and self.UserDefined_nsprefix_) else ''
4501
            self.UserDefined.export(outfile, level, namespaceprefix_, namespacedef_='', name_='UserDefined', pretty_print=pretty_print)
4502
        for Labels_ in self.Labels:
4503
            namespaceprefix_ = self.Labels_nsprefix_ + ':' if (UseCapturedNS_ and self.Labels_nsprefix_) else ''
4504
            Labels_.export(outfile, level, namespaceprefix_, namespacedef_='', name_='Labels', pretty_print=pretty_print)
4505
    def to_etree(self, parent_element=None, name_='TextLineType', mapping_=None, reverse_mapping_=None, nsmap_=None):
4506
        if parent_element is None:
4507
            element = etree_.Element('{http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15}' + name_, nsmap=nsmap_)
4508
        else:
4509
            element = etree_.SubElement(parent_element, '{http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15}' + name_, nsmap=nsmap_)
4510
        if self.id is not None:
4511
            element.set('id', self.gds_format_string(self.id))
4512
        if self.primaryLanguage is not None:
4513
            element.set('primaryLanguage', self.gds_format_string(self.primaryLanguage))
4514
        if self.primaryScript is not None:
4515
            element.set('primaryScript', self.gds_format_string(self.primaryScript))
4516
        if self.secondaryScript is not None:
4517
            element.set('secondaryScript', self.gds_format_string(self.secondaryScript))
4518
        if self.readingDirection is not None:
4519
            element.set('readingDirection', self.gds_format_string(self.readingDirection))
4520
        if self.production is not None:
4521
            element.set('production', self.gds_format_string(self.production))
4522
        if self.custom is not None:
4523
            element.set('custom', self.gds_format_string(self.custom))
4524
        if self.comments is not None:
4525
            element.set('comments', self.gds_format_string(self.comments))
4526
        if self.index is not None:
4527
            element.set('index', self.gds_format_integer(self.index))
4528
        for AlternativeImage_ in self.AlternativeImage:
4529
            AlternativeImage_.to_etree(element, name_='AlternativeImage', mapping_=mapping_, reverse_mapping_=reverse_mapping_, nsmap_=nsmap_)
4530
        if self.Coords is not None:
4531
            Coords_ = self.Coords
4532
            Coords_.to_etree(element, name_='Coords', mapping_=mapping_, reverse_mapping_=reverse_mapping_, nsmap_=nsmap_)
4533
        if self.Baseline is not None:
4534
            Baseline_ = self.Baseline
4535
            Baseline_.to_etree(element, name_='Baseline', mapping_=mapping_, reverse_mapping_=reverse_mapping_, nsmap_=nsmap_)
4536
        for Word_ in self.Word:
4537
            Word_.to_etree(element, name_='Word', mapping_=mapping_, reverse_mapping_=reverse_mapping_, nsmap_=nsmap_)
4538
        for TextEquiv_ in self.TextEquiv:
4539
            TextEquiv_.to_etree(element, name_='TextEquiv', mapping_=mapping_, reverse_mapping_=reverse_mapping_, nsmap_=nsmap_)
4540
        if self.TextStyle is not None:
4541
            TextStyle_ = self.TextStyle
4542
            TextStyle_.to_etree(element, name_='TextStyle', mapping_=mapping_, reverse_mapping_=reverse_mapping_, nsmap_=nsmap_)
4543
        if self.UserDefined is not None:
4544
            UserDefined_ = self.UserDefined
4545
            UserDefined_.to_etree(element, name_='UserDefined', mapping_=mapping_, reverse_mapping_=reverse_mapping_, nsmap_=nsmap_)
4546
        for Labels_ in self.Labels:
4547
            Labels_.to_etree(element, name_='Labels', mapping_=mapping_, reverse_mapping_=reverse_mapping_, nsmap_=nsmap_)
4548
        if mapping_ is not None:
4549
            mapping_[id(self)] = element
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable id does not seem to be defined.
Loading history...
4550
        if reverse_mapping_ is not None:
4551
            reverse_mapping_[element] = self
4552
        return element
4553
    def build(self, node, gds_collector_=None):
4554
        self.gds_collector_ = gds_collector_
4555
        if SaveElementTreeNode:
4556
            self.gds_elementtree_node_ = node
4557
        already_processed = set()
4558
        self.ns_prefix_ = node.prefix
4559
        self._buildAttributes(node, node.attrib, already_processed)
4560
        for child in node:
4561
            nodeName_ = Tag_pattern_.match(child.tag).groups()[-1]
4562
            self._buildChildren(child, node, nodeName_, gds_collector_=gds_collector_)
4563
        return self
4564
    def _buildAttributes(self, node, attrs, already_processed):
4565
        value = find_attr_value_('id', node)
4566
        if value is not None and 'id' not in already_processed:
4567
            already_processed.add('id')
4568
            self.id = value
4569
        value = find_attr_value_('primaryLanguage', node)
4570
        if value is not None and 'primaryLanguage' not in already_processed:
4571
            already_processed.add('primaryLanguage')
4572
            self.primaryLanguage = value
4573
            self.validate_LanguageSimpleType(self.primaryLanguage)    # validate type LanguageSimpleType
4574
        value = find_attr_value_('primaryScript', node)
4575
        if value is not None and 'primaryScript' not in already_processed:
4576
            already_processed.add('primaryScript')
4577
            self.primaryScript = value
4578
            self.validate_ScriptSimpleType(self.primaryScript)    # validate type ScriptSimpleType
4579
        value = find_attr_value_('secondaryScript', node)
4580
        if value is not None and 'secondaryScript' not in already_processed:
4581
            already_processed.add('secondaryScript')
4582
            self.secondaryScript = value
4583
            self.validate_ScriptSimpleType(self.secondaryScript)    # validate type ScriptSimpleType
4584
        value = find_attr_value_('readingDirection', node)
4585
        if value is not None and 'readingDirection' not in already_processed:
4586
            already_processed.add('readingDirection')
4587
            self.readingDirection = value
4588
            self.validate_ReadingDirectionSimpleType(self.readingDirection)    # validate type ReadingDirectionSimpleType
4589
        value = find_attr_value_('production', node)
4590
        if value is not None and 'production' not in already_processed:
4591
            already_processed.add('production')
4592
            self.production = value
4593
            self.validate_ProductionSimpleType(self.production)    # validate type ProductionSimpleType
4594
        value = find_attr_value_('custom', node)
4595
        if value is not None and 'custom' not in already_processed:
4596
            already_processed.add('custom')
4597
            self.custom = value
4598
        value = find_attr_value_('comments', node)
4599
        if value is not None and 'comments' not in already_processed:
4600
            already_processed.add('comments')
4601
            self.comments = value
4602
        value = find_attr_value_('index', node)
4603
        if value is not None and 'index' not in already_processed:
4604
            already_processed.add('index')
4605
            self.index = self.gds_parse_integer(value, node, 'index')
4606
    def _buildChildren(self, child_, node, nodeName_, fromsubclass_=False, gds_collector_=None):
4607
        if nodeName_ == 'AlternativeImage':
4608
            obj_ = AlternativeImageType.factory(parent_object_=self)
4609
            obj_.build(child_, gds_collector_=gds_collector_)
4610
            self.AlternativeImage.append(obj_)
4611
            obj_.original_tagname_ = 'AlternativeImage'
4612
        elif nodeName_ == 'Coords':
4613
            obj_ = CoordsType.factory(parent_object_=self)
4614
            obj_.build(child_, gds_collector_=gds_collector_)
4615
            self.Coords = obj_
4616
            obj_.original_tagname_ = 'Coords'
4617
        elif nodeName_ == 'Baseline':
4618
            obj_ = BaselineType.factory(parent_object_=self)
4619
            obj_.build(child_, gds_collector_=gds_collector_)
4620
            self.Baseline = obj_
4621
            obj_.original_tagname_ = 'Baseline'
4622
        elif nodeName_ == 'Word':
4623
            obj_ = WordType.factory(parent_object_=self)
4624
            obj_.build(child_, gds_collector_=gds_collector_)
4625
            self.Word.append(obj_)
4626
            obj_.original_tagname_ = 'Word'
4627
        elif nodeName_ == 'TextEquiv':
4628
            obj_ = TextEquivType.factory(parent_object_=self)
4629
            obj_.build(child_, gds_collector_=gds_collector_)
4630
            self.TextEquiv.append(obj_)
4631
            obj_.original_tagname_ = 'TextEquiv'
4632
        elif nodeName_ == 'TextStyle':
4633
            obj_ = TextStyleType.factory(parent_object_=self)
4634
            obj_.build(child_, gds_collector_=gds_collector_)
4635
            self.TextStyle = obj_
4636
            obj_.original_tagname_ = 'TextStyle'
4637
        elif nodeName_ == 'UserDefined':
4638
            obj_ = UserDefinedType.factory(parent_object_=self)
4639
            obj_.build(child_, gds_collector_=gds_collector_)
4640
            self.UserDefined = obj_
4641
            obj_.original_tagname_ = 'UserDefined'
4642
        elif nodeName_ == 'Labels':
4643
            obj_ = LabelsType.factory(parent_object_=self)
4644
            obj_.build(child_, gds_collector_=gds_collector_)
4645
            self.Labels.append(obj_)
4646
            obj_.original_tagname_ = 'Labels'
4647
    def __hash__(self):
4648
        return hash(self.id)
4649 View Code Duplication
    def invalidate_AlternativeImage(self, feature_selector=None):
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
4650
        """
4651
        Remove derived images from this segment (due to changed coordinates).
4652
    
4653
        If `feature_selector` is not none, remove only images with
4654
        matching ``@comments``, e.g. ``feature_selector=cropped,deskewed``.
4655
        """
4656
        existing_images = self.AlternativeImage or []
4657
        removed_images = []
4658
        if feature_selector:
4659
            new_images = []
4660
            for image in existing_images:
4661
                features = image.get_comments() or ''
4662
                if any(feature in features.split(',')
4663
                       for feature in feature_selector.split(',') if feature):
4664
                    removed_images.append(image)
4665
                else:
4666
                    new_images.append(image)
4667
            self.AlternativeImage = new_images
4668
        else:
4669
            removed_images = existing_images
4670
            self.AlternativeImage = []
4671
        if hasattr(self, 'id'):
4672
            name = self.id
4673
        elif hasattr(self, 'parent_object_') and hasattr(self.parent_object_, 'pcGtsId'):
4674
            name = self.parent_object_.pcGtsId
4675
        else:
4676
            name = ''
4677
        for image in removed_images:
4678
            self.gds_collector_.add_message('Removing AlternativeImage %s from "%s"' % (
4679
                image.get_comments() or '', name))
4680
    def set_Coords(self, Coords):
4681
        """
4682
        Set coordinate polygon by given :py:class:`CoordsType` object.
4683
        Moreover, invalidate self's ``pc:AlternativeImage``s
4684
        (because they will have been cropped with a bbox
4685
        of the previous polygon).
4686
        """
4687
        if hasattr(self, 'invalidate_AlternativeImage'):
4688
            # RegionType, TextLineType, WordType, GlyphType:
4689
            self.invalidate_AlternativeImage()
4690
        elif hasattr(self, 'parent_object_') and hasattr(self.parent_object_, 'invalidate_AlternativeImage'):
4691
            # BorderType:
4692
            self.parent_object_.invalidate_AlternativeImage(feature_selector='cropped')
4693
        self.Coords = Coords
4694
# end class TextLineType
4695
4696
4697
class WordType(GeneratedsSuper):
4698
    """language --
4699
    Overrides primaryLanguage attribute of parent line
4700
    and/or text region
4701
      
4702
    * primaryScript --
4703
      The primary script used in the word
4704
      
4705
    * secondaryScript --
4706
      The secondary script used in the word
4707
      
4708
    * readingDirection --
4709
      The direction in which text within the word
4710
      should be read (order of characters).
4711
      
4712
    * production --
4713
      Overrides the production attribute of the parent
4714
      text line and/or text region.
4715
      
4716
    * custom -- For generic use
4717
    * AlternativeImage --
4718
      Alternative word images (e.g.
4719
      black-and-white)
4720
      
4721
    * Labels -- Semantic labels / tags
4722
    
4723
    """
4724
    __hash__ = GeneratedsSuper.__hash__
4725
    member_data_items_ = [
4726
        MemberSpec_('id', 'string', 0, 0, {'use': 'required', 'name': 'id'}),
4727
        MemberSpec_('language', 'pc:LanguageSimpleType', 0, 1, {'use': 'optional', 'name': 'language'}),
4728
        MemberSpec_('primaryScript', 'pc:ScriptSimpleType', 0, 1, {'use': 'optional', 'name': 'primaryScript'}),
4729
        MemberSpec_('secondaryScript', 'pc:ScriptSimpleType', 0, 1, {'use': 'optional', 'name': 'secondaryScript'}),
4730
        MemberSpec_('readingDirection', 'pc:ReadingDirectionSimpleType', 0, 1, {'use': 'optional', 'name': 'readingDirection'}),
4731
        MemberSpec_('production', 'pc:ProductionSimpleType', 0, 1, {'use': 'optional', 'name': 'production'}),
4732
        MemberSpec_('custom', 'string', 0, 1, {'use': 'optional', 'name': 'custom'}),
4733
        MemberSpec_('comments', 'string', 0, 1, {'use': 'optional', 'name': 'comments'}),
4734
        MemberSpec_('AlternativeImage', 'AlternativeImageType', 1, 1, {'maxOccurs': 'unbounded', 'minOccurs': '0', 'name': 'AlternativeImage', 'type': 'AlternativeImageType'}, None),
4735
        MemberSpec_('Coords', 'CoordsType', 0, 0, {'name': 'Coords', 'type': 'CoordsType'}, None),
4736
        MemberSpec_('Glyph', 'GlyphType', 1, 1, {'maxOccurs': 'unbounded', 'minOccurs': '0', 'name': 'Glyph', 'type': 'GlyphType'}, None),
4737
        MemberSpec_('TextEquiv', 'TextEquivType', 1, 1, {'maxOccurs': 'unbounded', 'minOccurs': '0', 'name': 'TextEquiv', 'type': 'TextEquivType'}, None),
4738
        MemberSpec_('TextStyle', 'TextStyleType', 0, 1, {'minOccurs': '0', 'name': 'TextStyle', 'type': 'TextStyleType'}, None),
4739
        MemberSpec_('UserDefined', 'UserDefinedType', 0, 1, {'maxOccurs': '1', 'minOccurs': '0', 'name': 'UserDefined', 'type': 'UserDefinedType'}, None),
4740
        MemberSpec_('Labels', 'LabelsType', 1, 1, {'maxOccurs': 'unbounded', 'minOccurs': '0', 'name': 'Labels', 'type': 'LabelsType'}, None),
4741
    ]
4742
    subclass = None
4743
    superclass = None
4744
    def __init__(self, id=None, language=None, primaryScript=None, secondaryScript=None, readingDirection=None, production=None, custom=None, comments=None, AlternativeImage=None, Coords=None, Glyph=None, TextEquiv=None, TextStyle=None, UserDefined=None, Labels=None, gds_collector_=None, **kwargs_):
4745
        self.gds_collector_ = gds_collector_
4746
        self.gds_elementtree_node_ = None
4747
        self.original_tagname_ = None
4748
        self.parent_object_ = kwargs_.get('parent_object_')
4749
        self.ns_prefix_ = "pc"
4750
        self.id = _cast(None, id)
4751
        self.id_nsprefix_ = "pc"
4752
        self.language = _cast(None, language)
4753
        self.language_nsprefix_ = "pc"
4754
        self.primaryScript = _cast(None, primaryScript)
4755
        self.primaryScript_nsprefix_ = "pc"
4756
        self.secondaryScript = _cast(None, secondaryScript)
4757
        self.secondaryScript_nsprefix_ = "pc"
4758
        self.readingDirection = _cast(None, readingDirection)
4759
        self.readingDirection_nsprefix_ = "pc"
4760
        self.production = _cast(None, production)
4761
        self.production_nsprefix_ = "pc"
4762
        self.custom = _cast(None, custom)
4763
        self.custom_nsprefix_ = "pc"
4764
        self.comments = _cast(None, comments)
4765
        self.comments_nsprefix_ = "pc"
4766
        if AlternativeImage is None:
4767
            self.AlternativeImage = []
4768
        else:
4769
            self.AlternativeImage = AlternativeImage
4770
        self.AlternativeImage_nsprefix_ = "pc"
4771
        self.Coords = Coords
4772
        self.Coords_nsprefix_ = "pc"
4773
        if Glyph is None:
4774
            self.Glyph = []
4775
        else:
4776
            self.Glyph = Glyph
4777
        self.Glyph_nsprefix_ = "pc"
4778
        if TextEquiv is None:
4779
            self.TextEquiv = []
4780
        else:
4781
            self.TextEquiv = TextEquiv
4782
        self.TextEquiv_nsprefix_ = "pc"
4783
        self.TextStyle = TextStyle
4784
        self.TextStyle_nsprefix_ = "pc"
4785
        self.UserDefined = UserDefined
4786
        self.UserDefined_nsprefix_ = "pc"
4787
        if Labels is None:
4788
            self.Labels = []
4789
        else:
4790
            self.Labels = Labels
4791
        self.Labels_nsprefix_ = "pc"
4792
    def factory(*args_, **kwargs_):
4793
        if CurrentSubclassModule_ is not None:
4794
            subclass = getSubclassFromModule_(
4795
                CurrentSubclassModule_, WordType)
4796
            if subclass is not None:
4797
                return subclass(*args_, **kwargs_)
4798
        if WordType.subclass:
4799
            return WordType.subclass(*args_, **kwargs_)
4800
        else:
4801
            return WordType(*args_, **kwargs_)
4802
    factory = staticmethod(factory)
4803
    def get_ns_prefix_(self):
4804
        return self.ns_prefix_
4805
    def set_ns_prefix_(self, ns_prefix):
4806
        self.ns_prefix_ = ns_prefix
4807
    def get_AlternativeImage(self):
4808
        return self.AlternativeImage
4809
    def set_AlternativeImage(self, AlternativeImage):
4810
        self.AlternativeImage = AlternativeImage
4811
    def add_AlternativeImage(self, value):
4812
        self.AlternativeImage.append(value)
4813
    def insert_AlternativeImage_at(self, index, value):
4814
        self.AlternativeImage.insert(index, value)
4815
    def replace_AlternativeImage_at(self, index, value):
4816
        self.AlternativeImage[index] = value
4817
    def get_Coords(self):
4818
        return self.Coords
4819
    def set_Coords(self, Coords):
4820
        self.Coords = Coords
4821
    def get_Glyph(self):
4822
        return self.Glyph
4823
    def set_Glyph(self, Glyph):
4824
        self.Glyph = Glyph
4825
    def add_Glyph(self, value):
4826
        self.Glyph.append(value)
4827
    def insert_Glyph_at(self, index, value):
4828
        self.Glyph.insert(index, value)
4829
    def replace_Glyph_at(self, index, value):
4830
        self.Glyph[index] = value
4831
    def get_TextEquiv(self):
4832
        return self.TextEquiv
4833
    def set_TextEquiv(self, TextEquiv):
4834
        self.TextEquiv = TextEquiv
4835
    def add_TextEquiv(self, value):
4836
        self.TextEquiv.append(value)
4837
    def insert_TextEquiv_at(self, index, value):
4838
        self.TextEquiv.insert(index, value)
4839
    def replace_TextEquiv_at(self, index, value):
4840
        self.TextEquiv[index] = value
4841
    def get_TextStyle(self):
4842
        return self.TextStyle
4843
    def set_TextStyle(self, TextStyle):
4844
        self.TextStyle = TextStyle
4845
    def get_UserDefined(self):
4846
        return self.UserDefined
4847
    def set_UserDefined(self, UserDefined):
4848
        self.UserDefined = UserDefined
4849
    def get_Labels(self):
4850
        return self.Labels
4851
    def set_Labels(self, Labels):
4852
        self.Labels = Labels
4853
    def add_Labels(self, value):
4854
        self.Labels.append(value)
4855
    def insert_Labels_at(self, index, value):
4856
        self.Labels.insert(index, value)
4857
    def replace_Labels_at(self, index, value):
4858
        self.Labels[index] = value
4859
    def get_id(self):
4860
        return self.id
4861
    def set_id(self, id):
4862
        self.id = id
4863
    def get_language(self):
4864
        return self.language
4865
    def set_language(self, language):
4866
        self.language = language
4867
    def get_primaryScript(self):
4868
        return self.primaryScript
4869
    def set_primaryScript(self, primaryScript):
4870
        self.primaryScript = primaryScript
4871
    def get_secondaryScript(self):
4872
        return self.secondaryScript
4873
    def set_secondaryScript(self, secondaryScript):
4874
        self.secondaryScript = secondaryScript
4875
    def get_readingDirection(self):
4876
        return self.readingDirection
4877
    def set_readingDirection(self, readingDirection):
4878
        self.readingDirection = readingDirection
4879
    def get_production(self):
4880
        return self.production
4881
    def set_production(self, production):
4882
        self.production = production
4883
    def get_custom(self):
4884
        return self.custom
4885
    def set_custom(self, custom):
4886
        self.custom = custom
4887
    def get_comments(self):
4888
        return self.comments
4889
    def set_comments(self, comments):
4890
        self.comments = comments
4891
    def validate_LanguageSimpleType(self, value):
4892
        # Validate type pc:LanguageSimpleType, a restriction on string.
4893
        if value is not None and Validate_simpletypes_ and self.gds_collector_ is not None:
4894
            if not isinstance(value, str):
4895
                lineno = self.gds_get_node_lineno_()
4896
                self.gds_collector_.add_message('Value "%(value)s"%(lineno)s is not of the correct base simple type (str)' % {"value": value, "lineno": lineno, })
4897
                return False
4898
            value = value
4899
            enumerations = ['Abkhaz', 'Afar', 'Afrikaans', 'Akan', 'Albanian', 'Amharic', 'Arabic', 'Aragonese', 'Armenian', 'Assamese', 'Avaric', 'Avestan', 'Aymara', 'Azerbaijani', 'Bambara', 'Bashkir', 'Basque', 'Belarusian', 'Bengali', 'Bihari', 'Bislama', 'Bosnian', 'Breton', 'Bulgarian', 'Burmese', 'Cambodian', 'Cantonese', 'Catalan', 'Chamorro', 'Chechen', 'Chichewa', 'Chinese', 'Chuvash', 'Cornish', 'Corsican', 'Cree', 'Croatian', 'Czech', 'Danish', 'Divehi', 'Dutch', 'Dzongkha', 'English', 'Esperanto', 'Estonian', 'Ewe', 'Faroese', 'Fijian', 'Finnish', 'French', 'Fula', 'Gaelic', 'Galician', 'Ganda', 'Georgian', 'German', 'Greek', 'Guaraní', 'Gujarati', 'Haitian', 'Hausa', 'Hebrew', 'Herero', 'Hindi', 'Hiri Motu', 'Hungarian', 'Icelandic', 'Ido', 'Igbo', 'Indonesian', 'Interlingua', 'Interlingue', 'Inuktitut', 'Inupiaq', 'Irish', 'Italian', 'Japanese', 'Javanese', 'Kalaallisut', 'Kannada', 'Kanuri', 'Kashmiri', 'Kazakh', 'Khmer', 'Kikuyu', 'Kinyarwanda', 'Kirundi', 'Komi', 'Kongo', 'Korean', 'Kurdish', 'Kwanyama', 'Kyrgyz', 'Lao', 'Latin', 'Latvian', 'Limburgish', 'Lingala', 'Lithuanian', 'Luba-Katanga', 'Luxembourgish', 'Macedonian', 'Malagasy', 'Malay', 'Malayalam', 'Maltese', 'Manx', 'Māori', 'Marathi', 'Marshallese', 'Mongolian', 'Nauru', 'Navajo', 'Ndonga', 'Nepali', 'North Ndebele', 'Northern Sami', 'Norwegian', 'Norwegian Bokmål', 'Norwegian Nynorsk', 'Nuosu', 'Occitan', 'Ojibwe', 'Old Church Slavonic', 'Oriya', 'Oromo', 'Ossetian', 'Pāli', 'Panjabi', 'Pashto', 'Persian', 'Polish', 'Portuguese', 'Punjabi', 'Quechua', 'Romanian', 'Romansh', 'Russian', 'Samoan', 'Sango', 'Sanskrit', 'Sardinian', 'Serbian', 'Shona', 'Sindhi', 'Sinhala', 'Slovak', 'Slovene', 'Somali', 'South Ndebele', 'Southern Sotho', 'Spanish', 'Sundanese', 'Swahili', 'Swati', 'Swedish', 'Tagalog', 'Tahitian', 'Tajik', 'Tamil', 'Tatar', 'Telugu', 'Thai', 'Tibetan', 'Tigrinya', 'Tonga', 'Tsonga', 'Tswana', 'Turkish', 'Turkmen', 'Twi', 'Uighur', 'Ukrainian', 'Urdu', 'Uzbek', 'Venda', 'Vietnamese', 'Volapük', 'Walloon', 'Welsh', 'Western Frisian', 'Wolof', 'Xhosa', 'Yiddish', 'Yoruba', 'Zhuang', 'Zulu', 'other']
4900
            if value not in enumerations:
4901
                lineno = self.gds_get_node_lineno_()
4902
                self.gds_collector_.add_message('Value "%(value)s"%(lineno)s does not match xsd enumeration restriction on LanguageSimpleType' % {"value" : encode_str_2_3(value), "lineno": lineno} )
4903
                result = False
4904
    def validate_ScriptSimpleType(self, value):
4905
        # Validate type pc:ScriptSimpleType, a restriction on string.
4906
        if value is not None and Validate_simpletypes_ and self.gds_collector_ is not None:
4907
            if not isinstance(value, str):
4908
                lineno = self.gds_get_node_lineno_()
4909
                self.gds_collector_.add_message('Value "%(value)s"%(lineno)s is not of the correct base simple type (str)' % {"value": value, "lineno": lineno, })
4910
                return False
4911
            value = value
4912
            enumerations = ['Adlm - Adlam', 'Afak - Afaka', 'Aghb - Caucasian Albanian', 'Ahom - Ahom, Tai Ahom', 'Arab - Arabic', 'Aran - Arabic (Nastaliq variant)', 'Armi - Imperial Aramaic', 'Armn - Armenian', 'Avst - Avestan', 'Bali - Balinese', 'Bamu - Bamum', 'Bass - Bassa Vah', 'Batk - Batak', 'Beng - Bengali', 'Bhks - Bhaiksuki', 'Blis - Blissymbols', 'Bopo - Bopomofo', 'Brah - Brahmi', 'Brai - Braille', 'Bugi - Buginese', 'Buhd - Buhid', 'Cakm - Chakma', 'Cans - Unified Canadian Aboriginal Syllabics', 'Cari - Carian', 'Cham - Cham', 'Cher - Cherokee', 'Cirt - Cirth', 'Copt - Coptic', 'Cprt - Cypriot', 'Cyrl - Cyrillic', 'Cyrs - Cyrillic (Old Church Slavonic variant)', 'Deva - Devanagari (Nagari)', 'Dsrt - Deseret (Mormon)', 'Dupl - Duployan shorthand, Duployan stenography', 'Egyd - Egyptian demotic', 'Egyh - Egyptian hieratic', 'Egyp - Egyptian hieroglyphs', 'Elba - Elbasan', 'Ethi - Ethiopic', 'Geok - Khutsuri (Asomtavruli and Nuskhuri)', 'Geor - Georgian (Mkhedruli)', 'Glag - Glagolitic', 'Goth - Gothic', 'Gran - Grantha', 'Grek - Greek', 'Gujr - Gujarati', 'Guru - Gurmukhi', 'Hanb - Han with Bopomofo', 'Hang - Hangul', 'Hani - Han (Hanzi, Kanji, Hanja)', 'Hano - Hanunoo (Hanunóo)', 'Hans - Han (Simplified variant)', 'Hant - Han (Traditional variant)', 'Hatr - Hatran', 'Hebr - Hebrew', 'Hira - Hiragana', 'Hluw - Anatolian Hieroglyphs', 'Hmng - Pahawh Hmong', 'Hrkt - Japanese syllabaries', 'Hung - Old Hungarian (Hungarian Runic)', 'Inds - Indus (Harappan)', 'Ital - Old Italic (Etruscan, Oscan etc.)', 'Jamo - Jamo', 'Java - Javanese', 'Jpan - Japanese', 'Jurc - Jurchen', 'Kali - Kayah Li', 'Kana - Katakana', 'Khar - Kharoshthi', 'Khmr - Khmer', 'Khoj - Khojki', 'Kitl - Khitan large script', 'Kits - Khitan small script', 'Knda - Kannada', 'Kore - Korean (alias for Hangul + Han)', 'Kpel - Kpelle', 'Kthi - Kaithi', 'Lana - Tai Tham (Lanna)', 'Laoo - Lao', 'Latf - Latin (Fraktur variant)', 'Latg - Latin (Gaelic variant)', 'Latn - Latin', 'Leke - Leke', 'Lepc - Lepcha (Róng)', 'Limb - Limbu', 'Lina - Linear A', 'Linb - Linear B', 'Lisu - Lisu (Fraser)', 'Loma - Loma', 'Lyci - Lycian', 'Lydi - Lydian', 'Mahj - Mahajani', 'Mand - Mandaic, Mandaean', 'Mani - Manichaean', 'Marc - Marchen', 'Maya - Mayan hieroglyphs', 'Mend - Mende Kikakui', 'Merc - Meroitic Cursive', 'Mero - Meroitic Hieroglyphs', 'Mlym - Malayalam', 'Modi - Modi, Moḍī', 'Mong - Mongolian', 'Moon - Moon (Moon code, Moon script, Moon type)', 'Mroo - Mro, Mru', 'Mtei - Meitei Mayek (Meithei, Meetei)', 'Mult - Multani', 'Mymr - Myanmar (Burmese)', 'Narb - Old North Arabian (Ancient North Arabian)', 'Nbat - Nabataean', 'Newa - Newa, Newar, Newari', 'Nkgb - Nakhi Geba', 'Nkoo - N’Ko', 'Nshu - Nüshu', 'Ogam - Ogham', 'Olck - Ol Chiki (Ol Cemet’, Ol, Santali)', 'Orkh - Old Turkic, Orkhon Runic', 'Orya - Oriya', 'Osge - Osage', 'Osma - Osmanya', 'Palm - Palmyrene', 'Pauc - Pau Cin Hau', 'Perm - Old Permic', 'Phag - Phags-pa', 'Phli - Inscriptional Pahlavi', 'Phlp - Psalter Pahlavi', 'Phlv - Book Pahlavi', 'Phnx - Phoenician', 'Piqd - Klingon (KLI pIqaD)', 'Plrd - Miao (Pollard)', 'Prti - Inscriptional Parthian', 'Rjng - Rejang (Redjang, Kaganga)', 'Roro - Rongorongo', 'Runr - Runic', 'Samr - Samaritan', 'Sara - Sarati', 'Sarb - Old South Arabian', 'Saur - Saurashtra', 'Sgnw - SignWriting', 'Shaw - Shavian (Shaw)', 'Shrd - Sharada, Śāradā', 'Sidd - Siddham', 'Sind - Khudawadi, Sindhi', 'Sinh - Sinhala', 'Sora - Sora Sompeng', 'Sund - Sundanese', 'Sylo - Syloti Nagri', 'Syrc - Syriac', 'Syre - Syriac (Estrangelo variant)', 'Syrj - Syriac (Western variant)', 'Syrn - Syriac (Eastern variant)', 'Tagb - Tagbanwa', 'Takr - Takri', 'Tale - Tai Le', 'Talu - New Tai Lue', 'Taml - Tamil', 'Tang - Tangut', 'Tavt - Tai Viet', 'Telu - Telugu', 'Teng - Tengwar', 'Tfng - Tifinagh (Berber)', 'Tglg - Tagalog (Baybayin, Alibata)', 'Thaa - Thaana', 'Thai - Thai', 'Tibt - Tibetan', 'Tirh - Tirhuta', 'Ugar - Ugaritic', 'Vaii - Vai', 'Visp - Visible Speech', 'Wara - Warang Citi (Varang Kshiti)', 'Wole - Woleai', 'Xpeo - Old Persian', 'Xsux - Cuneiform, Sumero-Akkadian', 'Yiii - Yi', 'Zinh - Code for inherited script', 'Zmth - Mathematical notation', 'Zsye - Symbols (Emoji variant)', 'Zsym - Symbols', 'Zxxx - Code for unwritten documents', 'Zyyy - Code for undetermined script', 'Zzzz - Code for uncoded script', 'other']
4913
            if value not in enumerations:
4914
                lineno = self.gds_get_node_lineno_()
4915
                self.gds_collector_.add_message('Value "%(value)s"%(lineno)s does not match xsd enumeration restriction on ScriptSimpleType' % {"value" : encode_str_2_3(value), "lineno": lineno} )
4916
                result = False
4917
    def validate_ReadingDirectionSimpleType(self, value):
4918
        # Validate type pc:ReadingDirectionSimpleType, a restriction on string.
4919
        if value is not None and Validate_simpletypes_ and self.gds_collector_ is not None:
4920
            if not isinstance(value, str):
4921
                lineno = self.gds_get_node_lineno_()
4922
                self.gds_collector_.add_message('Value "%(value)s"%(lineno)s is not of the correct base simple type (str)' % {"value": value, "lineno": lineno, })
4923
                return False
4924
            value = value
4925
            enumerations = ['left-to-right', 'right-to-left', 'top-to-bottom', 'bottom-to-top']
4926
            if value not in enumerations:
4927
                lineno = self.gds_get_node_lineno_()
4928
                self.gds_collector_.add_message('Value "%(value)s"%(lineno)s does not match xsd enumeration restriction on ReadingDirectionSimpleType' % {"value" : encode_str_2_3(value), "lineno": lineno} )
4929
                result = False
4930
    def validate_ProductionSimpleType(self, value):
4931
        # Validate type pc:ProductionSimpleType, a restriction on string.
4932
        if value is not None and Validate_simpletypes_ and self.gds_collector_ is not None:
4933
            if not isinstance(value, str):
4934
                lineno = self.gds_get_node_lineno_()
4935
                self.gds_collector_.add_message('Value "%(value)s"%(lineno)s is not of the correct base simple type (str)' % {"value": value, "lineno": lineno, })
4936
                return False
4937
            value = value
4938
            enumerations = ['printed', 'typewritten', 'handwritten-cursive', 'handwritten-printscript', 'medieval-manuscript', 'other']
4939
            if value not in enumerations:
4940
                lineno = self.gds_get_node_lineno_()
4941
                self.gds_collector_.add_message('Value "%(value)s"%(lineno)s does not match xsd enumeration restriction on ProductionSimpleType' % {"value" : encode_str_2_3(value), "lineno": lineno} )
4942
                result = False
4943
    def has__content(self):
4944
        if (
4945
            self.AlternativeImage or
4946
            self.Coords is not None or
4947
            self.Glyph or
4948
            self.TextEquiv or
4949
            self.TextStyle is not None or
4950
            self.UserDefined is not None or
4951
            self.Labels
4952
        ):
4953
            return True
4954
        else:
4955
            return False
4956
    def export(self, outfile, level, namespaceprefix_='', namespacedef_='xmlns:pc="http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15"', name_='WordType', pretty_print=True):
4957
        imported_ns_def_ = GenerateDSNamespaceDefs_.get('WordType')
4958
        if imported_ns_def_ is not None:
4959
            namespacedef_ = imported_ns_def_
4960
        if pretty_print:
4961
            eol_ = '\n'
4962
        else:
4963
            eol_ = ''
4964
        if self.original_tagname_ is not None and name_ == 'WordType':
4965
            name_ = self.original_tagname_
4966
        if UseCapturedNS_ and self.ns_prefix_:
4967
            namespaceprefix_ = self.ns_prefix_ + ':'
4968
        showIndent(outfile, level, pretty_print)
4969
        outfile.write('<%s%s%s' % (namespaceprefix_, name_, namespacedef_ and ' ' + namespacedef_ or '', ))
4970
        already_processed = set()
4971
        self._exportAttributes(outfile, level, already_processed, namespaceprefix_, name_='WordType')
4972
        if self.has__content():
4973
            outfile.write('>%s' % (eol_, ))
4974
            self._exportChildren(outfile, level + 1, namespaceprefix_, namespacedef_, name_='WordType', pretty_print=pretty_print)
4975
            showIndent(outfile, level, pretty_print)
4976
            outfile.write('</%s%s>%s' % (namespaceprefix_, name_, eol_))
4977
        else:
4978
            outfile.write('/>%s' % (eol_, ))
4979
    def _exportAttributes(self, outfile, level, already_processed, namespaceprefix_='', name_='WordType'):
4980
        if self.id is not None and 'id' not in already_processed:
4981
            already_processed.add('id')
4982
            outfile.write(' id=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.id), input_name='id')), ))
4983
        if self.language is not None and 'language' not in already_processed:
4984
            already_processed.add('language')
4985
            outfile.write(' language=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.language), input_name='language')), ))
4986
        if self.primaryScript is not None and 'primaryScript' not in already_processed:
4987
            already_processed.add('primaryScript')
4988
            outfile.write(' primaryScript=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.primaryScript), input_name='primaryScript')), ))
4989
        if self.secondaryScript is not None and 'secondaryScript' not in already_processed:
4990
            already_processed.add('secondaryScript')
4991
            outfile.write(' secondaryScript=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.secondaryScript), input_name='secondaryScript')), ))
4992
        if self.readingDirection is not None and 'readingDirection' not in already_processed:
4993
            already_processed.add('readingDirection')
4994
            outfile.write(' readingDirection=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.readingDirection), input_name='readingDirection')), ))
4995
        if self.production is not None and 'production' not in already_processed:
4996
            already_processed.add('production')
4997
            outfile.write(' production=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.production), input_name='production')), ))
4998
        if self.custom is not None and 'custom' not in already_processed:
4999
            already_processed.add('custom')
5000
            outfile.write(' custom=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.custom), input_name='custom')), ))
5001
        if self.comments is not None and 'comments' not in already_processed:
5002
            already_processed.add('comments')
5003
            outfile.write(' comments=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.comments), input_name='comments')), ))
5004 View Code Duplication
    def _exportChildren(self, outfile, level, namespaceprefix_='', namespacedef_='xmlns:pc="http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15"', name_='WordType', fromsubclass_=False, pretty_print=True):
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
5005
        if pretty_print:
5006
            eol_ = '\n'
5007
        else:
5008
            eol_ = ''
5009
        for AlternativeImage_ in self.AlternativeImage:
5010
            namespaceprefix_ = self.AlternativeImage_nsprefix_ + ':' if (UseCapturedNS_ and self.AlternativeImage_nsprefix_) else ''
5011
            AlternativeImage_.export(outfile, level, namespaceprefix_, namespacedef_='', name_='AlternativeImage', pretty_print=pretty_print)
5012
        if self.Coords is not None:
5013
            namespaceprefix_ = self.Coords_nsprefix_ + ':' if (UseCapturedNS_ and self.Coords_nsprefix_) else ''
5014
            self.Coords.export(outfile, level, namespaceprefix_, namespacedef_='', name_='Coords', pretty_print=pretty_print)
5015
        for Glyph_ in self.Glyph:
5016
            namespaceprefix_ = self.Glyph_nsprefix_ + ':' if (UseCapturedNS_ and self.Glyph_nsprefix_) else ''
5017
            Glyph_.export(outfile, level, namespaceprefix_, namespacedef_='', name_='Glyph', pretty_print=pretty_print)
5018
        for TextEquiv_ in self.TextEquiv:
5019
            namespaceprefix_ = self.TextEquiv_nsprefix_ + ':' if (UseCapturedNS_ and self.TextEquiv_nsprefix_) else ''
5020
            TextEquiv_.export(outfile, level, namespaceprefix_, namespacedef_='', name_='TextEquiv', pretty_print=pretty_print)
5021
        if self.TextStyle is not None:
5022
            namespaceprefix_ = self.TextStyle_nsprefix_ + ':' if (UseCapturedNS_ and self.TextStyle_nsprefix_) else ''
5023
            self.TextStyle.export(outfile, level, namespaceprefix_, namespacedef_='', name_='TextStyle', pretty_print=pretty_print)
5024
        if self.UserDefined is not None:
5025
            namespaceprefix_ = self.UserDefined_nsprefix_ + ':' if (UseCapturedNS_ and self.UserDefined_nsprefix_) else ''
5026
            self.UserDefined.export(outfile, level, namespaceprefix_, namespacedef_='', name_='UserDefined', pretty_print=pretty_print)
5027
        for Labels_ in self.Labels:
5028
            namespaceprefix_ = self.Labels_nsprefix_ + ':' if (UseCapturedNS_ and self.Labels_nsprefix_) else ''
5029
            Labels_.export(outfile, level, namespaceprefix_, namespacedef_='', name_='Labels', pretty_print=pretty_print)
5030
    def to_etree(self, parent_element=None, name_='WordType', mapping_=None, reverse_mapping_=None, nsmap_=None):
5031
        if parent_element is None:
5032
            element = etree_.Element('{http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15}' + name_, nsmap=nsmap_)
5033
        else:
5034
            element = etree_.SubElement(parent_element, '{http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15}' + name_, nsmap=nsmap_)
5035
        if self.id is not None:
5036
            element.set('id', self.gds_format_string(self.id))
5037
        if self.language is not None:
5038
            element.set('language', self.gds_format_string(self.language))
5039
        if self.primaryScript is not None:
5040
            element.set('primaryScript', self.gds_format_string(self.primaryScript))
5041
        if self.secondaryScript is not None:
5042
            element.set('secondaryScript', self.gds_format_string(self.secondaryScript))
5043
        if self.readingDirection is not None:
5044
            element.set('readingDirection', self.gds_format_string(self.readingDirection))
5045
        if self.production is not None:
5046
            element.set('production', self.gds_format_string(self.production))
5047
        if self.custom is not None:
5048
            element.set('custom', self.gds_format_string(self.custom))
5049
        if self.comments is not None:
5050
            element.set('comments', self.gds_format_string(self.comments))
5051
        for AlternativeImage_ in self.AlternativeImage:
5052
            AlternativeImage_.to_etree(element, name_='AlternativeImage', mapping_=mapping_, reverse_mapping_=reverse_mapping_, nsmap_=nsmap_)
5053
        if self.Coords is not None:
5054
            Coords_ = self.Coords
5055
            Coords_.to_etree(element, name_='Coords', mapping_=mapping_, reverse_mapping_=reverse_mapping_, nsmap_=nsmap_)
5056
        for Glyph_ in self.Glyph:
5057
            Glyph_.to_etree(element, name_='Glyph', mapping_=mapping_, reverse_mapping_=reverse_mapping_, nsmap_=nsmap_)
5058
        for TextEquiv_ in self.TextEquiv:
5059
            TextEquiv_.to_etree(element, name_='TextEquiv', mapping_=mapping_, reverse_mapping_=reverse_mapping_, nsmap_=nsmap_)
5060
        if self.TextStyle is not None:
5061
            TextStyle_ = self.TextStyle
5062
            TextStyle_.to_etree(element, name_='TextStyle', mapping_=mapping_, reverse_mapping_=reverse_mapping_, nsmap_=nsmap_)
5063
        if self.UserDefined is not None:
5064
            UserDefined_ = self.UserDefined
5065
            UserDefined_.to_etree(element, name_='UserDefined', mapping_=mapping_, reverse_mapping_=reverse_mapping_, nsmap_=nsmap_)
5066
        for Labels_ in self.Labels:
5067
            Labels_.to_etree(element, name_='Labels', mapping_=mapping_, reverse_mapping_=reverse_mapping_, nsmap_=nsmap_)
5068
        if mapping_ is not None:
5069
            mapping_[id(self)] = element
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable id does not seem to be defined.
Loading history...
5070
        if reverse_mapping_ is not None:
5071
            reverse_mapping_[element] = self
5072
        return element
5073
    def build(self, node, gds_collector_=None):
5074
        self.gds_collector_ = gds_collector_
5075
        if SaveElementTreeNode:
5076
            self.gds_elementtree_node_ = node
5077
        already_processed = set()
5078
        self.ns_prefix_ = node.prefix
5079
        self._buildAttributes(node, node.attrib, already_processed)
5080
        for child in node:
5081
            nodeName_ = Tag_pattern_.match(child.tag).groups()[-1]
5082
            self._buildChildren(child, node, nodeName_, gds_collector_=gds_collector_)
5083
        return self
5084
    def _buildAttributes(self, node, attrs, already_processed):
5085
        value = find_attr_value_('id', node)
5086
        if value is not None and 'id' not in already_processed:
5087
            already_processed.add('id')
5088
            self.id = value
5089
        value = find_attr_value_('language', node)
5090
        if value is not None and 'language' not in already_processed:
5091
            already_processed.add('language')
5092
            self.language = value
5093
            self.validate_LanguageSimpleType(self.language)    # validate type LanguageSimpleType
5094
        value = find_attr_value_('primaryScript', node)
5095
        if value is not None and 'primaryScript' not in already_processed:
5096
            already_processed.add('primaryScript')
5097
            self.primaryScript = value
5098
            self.validate_ScriptSimpleType(self.primaryScript)    # validate type ScriptSimpleType
5099
        value = find_attr_value_('secondaryScript', node)
5100
        if value is not None and 'secondaryScript' not in already_processed:
5101
            already_processed.add('secondaryScript')
5102
            self.secondaryScript = value
5103
            self.validate_ScriptSimpleType(self.secondaryScript)    # validate type ScriptSimpleType
5104
        value = find_attr_value_('readingDirection', node)
5105
        if value is not None and 'readingDirection' not in already_processed:
5106
            already_processed.add('readingDirection')
5107
            self.readingDirection = value
5108
            self.validate_ReadingDirectionSimpleType(self.readingDirection)    # validate type ReadingDirectionSimpleType
5109
        value = find_attr_value_('production', node)
5110
        if value is not None and 'production' not in already_processed:
5111
            already_processed.add('production')
5112
            self.production = value
5113
            self.validate_ProductionSimpleType(self.production)    # validate type ProductionSimpleType
5114
        value = find_attr_value_('custom', node)
5115
        if value is not None and 'custom' not in already_processed:
5116
            already_processed.add('custom')
5117
            self.custom = value
5118
        value = find_attr_value_('comments', node)
5119
        if value is not None and 'comments' not in already_processed:
5120
            already_processed.add('comments')
5121
            self.comments = value
5122 View Code Duplication
    def _buildChildren(self, child_, node, nodeName_, fromsubclass_=False, gds_collector_=None):
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
5123
        if nodeName_ == 'AlternativeImage':
5124
            obj_ = AlternativeImageType.factory(parent_object_=self)
5125
            obj_.build(child_, gds_collector_=gds_collector_)
5126
            self.AlternativeImage.append(obj_)
5127
            obj_.original_tagname_ = 'AlternativeImage'
5128
        elif nodeName_ == 'Coords':
5129
            obj_ = CoordsType.factory(parent_object_=self)
5130
            obj_.build(child_, gds_collector_=gds_collector_)
5131
            self.Coords = obj_
5132
            obj_.original_tagname_ = 'Coords'
5133
        elif nodeName_ == 'Glyph':
5134
            obj_ = GlyphType.factory(parent_object_=self)
5135
            obj_.build(child_, gds_collector_=gds_collector_)
5136
            self.Glyph.append(obj_)
5137
            obj_.original_tagname_ = 'Glyph'
5138
        elif nodeName_ == 'TextEquiv':
5139
            obj_ = TextEquivType.factory(parent_object_=self)
5140
            obj_.build(child_, gds_collector_=gds_collector_)
5141
            self.TextEquiv.append(obj_)
5142
            obj_.original_tagname_ = 'TextEquiv'
5143
        elif nodeName_ == 'TextStyle':
5144
            obj_ = TextStyleType.factory(parent_object_=self)
5145
            obj_.build(child_, gds_collector_=gds_collector_)
5146
            self.TextStyle = obj_
5147
            obj_.original_tagname_ = 'TextStyle'
5148
        elif nodeName_ == 'UserDefined':
5149
            obj_ = UserDefinedType.factory(parent_object_=self)
5150
            obj_.build(child_, gds_collector_=gds_collector_)
5151
            self.UserDefined = obj_
5152
            obj_.original_tagname_ = 'UserDefined'
5153
        elif nodeName_ == 'Labels':
5154
            obj_ = LabelsType.factory(parent_object_=self)
5155
            obj_.build(child_, gds_collector_=gds_collector_)
5156
            self.Labels.append(obj_)
5157
            obj_.original_tagname_ = 'Labels'
5158
    def __hash__(self):
5159
        return hash(self.id)
5160 View Code Duplication
    def invalidate_AlternativeImage(self, feature_selector=None):
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
5161
        """
5162
        Remove derived images from this segment (due to changed coordinates).
5163
    
5164
        If `feature_selector` is not none, remove only images with
5165
        matching ``@comments``, e.g. ``feature_selector=cropped,deskewed``.
5166
        """
5167
        existing_images = self.AlternativeImage or []
5168
        removed_images = []
5169
        if feature_selector:
5170
            new_images = []
5171
            for image in existing_images:
5172
                features = image.get_comments() or ''
5173
                if any(feature in features.split(',')
5174
                       for feature in feature_selector.split(',') if feature):
5175
                    removed_images.append(image)
5176
                else:
5177
                    new_images.append(image)
5178
            self.AlternativeImage = new_images
5179
        else:
5180
            removed_images = existing_images
5181
            self.AlternativeImage = []
5182
        if hasattr(self, 'id'):
5183
            name = self.id
5184
        elif hasattr(self, 'parent_object_') and hasattr(self.parent_object_, 'pcGtsId'):
5185
            name = self.parent_object_.pcGtsId
5186
        else:
5187
            name = ''
5188
        for image in removed_images:
5189
            self.gds_collector_.add_message('Removing AlternativeImage %s from "%s"' % (
5190
                image.get_comments() or '', name))
5191
    def set_Coords(self, Coords):
5192
        """
5193
        Set coordinate polygon by given :py:class:`CoordsType` object.
5194
        Moreover, invalidate self's ``pc:AlternativeImage``s
5195
        (because they will have been cropped with a bbox
5196
        of the previous polygon).
5197
        """
5198
        if hasattr(self, 'invalidate_AlternativeImage'):
5199
            # RegionType, TextLineType, WordType, GlyphType:
5200
            self.invalidate_AlternativeImage()
5201
        elif hasattr(self, 'parent_object_') and hasattr(self.parent_object_, 'invalidate_AlternativeImage'):
5202
            # BorderType:
5203
            self.parent_object_.invalidate_AlternativeImage(feature_selector='cropped')
5204
        self.Coords = Coords
5205
# end class WordType
5206
5207
5208
class GlyphType(GeneratedsSuper):
5209
    """script --
5210
    The script used for the glyph
5211
      
5212
    * production --
5213
      Overrides the production attribute of the parent
5214
      word / text line / text region.
5215
      
5216
    * custom -- For generic use
5217
    * AlternativeImage --
5218
      Alternative glyph images (e.g.
5219
      black-and-white)
5220
      
5221
    * Graphemes --
5222
      Container for graphemes, grapheme groups and
5223
      non-printing characters
5224
      
5225
    * Labels -- Semantic labels / tags
5226
    
5227
    """
5228
    __hash__ = GeneratedsSuper.__hash__
5229
    member_data_items_ = [
5230
        MemberSpec_('id', 'string', 0, 0, {'use': 'required', 'name': 'id'}),
5231
        MemberSpec_('ligature', 'boolean', 0, 1, {'use': 'optional', 'name': 'ligature'}),
5232
        MemberSpec_('symbol', 'boolean', 0, 1, {'use': 'optional', 'name': 'symbol'}),
5233
        MemberSpec_('script', 'pc:ScriptSimpleType', 0, 1, {'use': 'optional', 'name': 'script'}),
5234
        MemberSpec_('production', 'pc:ProductionSimpleType', 0, 1, {'use': 'optional', 'name': 'production'}),
5235
        MemberSpec_('custom', 'string', 0, 1, {'use': 'optional', 'name': 'custom'}),
5236
        MemberSpec_('comments', 'string', 0, 1, {'use': 'optional', 'name': 'comments'}),
5237
        MemberSpec_('AlternativeImage', 'AlternativeImageType', 1, 1, {'maxOccurs': 'unbounded', 'minOccurs': '0', 'name': 'AlternativeImage', 'type': 'AlternativeImageType'}, None),
5238
        MemberSpec_('Coords', 'CoordsType', 0, 0, {'name': 'Coords', 'type': 'CoordsType'}, None),
5239
        MemberSpec_('Graphemes', 'GraphemesType', 0, 1, {'maxOccurs': '1', 'minOccurs': '0', 'name': 'Graphemes', 'type': 'GraphemesType'}, None),
5240
        MemberSpec_('TextEquiv', 'TextEquivType', 1, 1, {'maxOccurs': 'unbounded', 'minOccurs': '0', 'name': 'TextEquiv', 'type': 'TextEquivType'}, None),
5241
        MemberSpec_('TextStyle', 'TextStyleType', 0, 1, {'minOccurs': '0', 'name': 'TextStyle', 'type': 'TextStyleType'}, None),
5242
        MemberSpec_('UserDefined', 'UserDefinedType', 0, 1, {'maxOccurs': '1', 'minOccurs': '0', 'name': 'UserDefined', 'type': 'UserDefinedType'}, None),
5243
        MemberSpec_('Labels', 'LabelsType', 1, 1, {'maxOccurs': 'unbounded', 'minOccurs': '0', 'name': 'Labels', 'type': 'LabelsType'}, None),
5244
    ]
5245
    subclass = None
5246
    superclass = None
5247
    def __init__(self, id=None, ligature=None, symbol=None, script=None, production=None, custom=None, comments=None, AlternativeImage=None, Coords=None, Graphemes=None, TextEquiv=None, TextStyle=None, UserDefined=None, Labels=None, gds_collector_=None, **kwargs_):
5248
        self.gds_collector_ = gds_collector_
5249
        self.gds_elementtree_node_ = None
5250
        self.original_tagname_ = None
5251
        self.parent_object_ = kwargs_.get('parent_object_')
5252
        self.ns_prefix_ = "pc"
5253
        self.id = _cast(None, id)
5254
        self.id_nsprefix_ = "pc"
5255
        self.ligature = _cast(bool, ligature)
5256
        self.ligature_nsprefix_ = "pc"
5257
        self.symbol = _cast(bool, symbol)
5258
        self.symbol_nsprefix_ = "pc"
5259
        self.script = _cast(None, script)
5260
        self.script_nsprefix_ = "pc"
5261
        self.production = _cast(None, production)
5262
        self.production_nsprefix_ = "pc"
5263
        self.custom = _cast(None, custom)
5264
        self.custom_nsprefix_ = "pc"
5265
        self.comments = _cast(None, comments)
5266
        self.comments_nsprefix_ = "pc"
5267
        if AlternativeImage is None:
5268
            self.AlternativeImage = []
5269
        else:
5270
            self.AlternativeImage = AlternativeImage
5271
        self.AlternativeImage_nsprefix_ = "pc"
5272
        self.Coords = Coords
5273
        self.Coords_nsprefix_ = "pc"
5274
        self.Graphemes = Graphemes
5275
        self.Graphemes_nsprefix_ = "pc"
5276
        if TextEquiv is None:
5277
            self.TextEquiv = []
5278
        else:
5279
            self.TextEquiv = TextEquiv
5280
        self.TextEquiv_nsprefix_ = "pc"
5281
        self.TextStyle = TextStyle
5282
        self.TextStyle_nsprefix_ = "pc"
5283
        self.UserDefined = UserDefined
5284
        self.UserDefined_nsprefix_ = "pc"
5285
        if Labels is None:
5286
            self.Labels = []
5287
        else:
5288
            self.Labels = Labels
5289
        self.Labels_nsprefix_ = "pc"
5290
    def factory(*args_, **kwargs_):
5291
        if CurrentSubclassModule_ is not None:
5292
            subclass = getSubclassFromModule_(
5293
                CurrentSubclassModule_, GlyphType)
5294
            if subclass is not None:
5295
                return subclass(*args_, **kwargs_)
5296
        if GlyphType.subclass:
5297
            return GlyphType.subclass(*args_, **kwargs_)
5298
        else:
5299
            return GlyphType(*args_, **kwargs_)
5300
    factory = staticmethod(factory)
5301
    def get_ns_prefix_(self):
5302
        return self.ns_prefix_
5303
    def set_ns_prefix_(self, ns_prefix):
5304
        self.ns_prefix_ = ns_prefix
5305
    def get_AlternativeImage(self):
5306
        return self.AlternativeImage
5307
    def set_AlternativeImage(self, AlternativeImage):
5308
        self.AlternativeImage = AlternativeImage
5309
    def add_AlternativeImage(self, value):
5310
        self.AlternativeImage.append(value)
5311
    def insert_AlternativeImage_at(self, index, value):
5312
        self.AlternativeImage.insert(index, value)
5313
    def replace_AlternativeImage_at(self, index, value):
5314
        self.AlternativeImage[index] = value
5315
    def get_Coords(self):
5316
        return self.Coords
5317
    def set_Coords(self, Coords):
5318
        self.Coords = Coords
5319
    def get_Graphemes(self):
5320
        return self.Graphemes
5321
    def set_Graphemes(self, Graphemes):
5322
        self.Graphemes = Graphemes
5323
    def get_TextEquiv(self):
5324
        return self.TextEquiv
5325
    def set_TextEquiv(self, TextEquiv):
5326
        self.TextEquiv = TextEquiv
5327
    def add_TextEquiv(self, value):
5328
        self.TextEquiv.append(value)
5329
    def insert_TextEquiv_at(self, index, value):
5330
        self.TextEquiv.insert(index, value)
5331
    def replace_TextEquiv_at(self, index, value):
5332
        self.TextEquiv[index] = value
5333
    def get_TextStyle(self):
5334
        return self.TextStyle
5335
    def set_TextStyle(self, TextStyle):
5336
        self.TextStyle = TextStyle
5337
    def get_UserDefined(self):
5338
        return self.UserDefined
5339
    def set_UserDefined(self, UserDefined):
5340
        self.UserDefined = UserDefined
5341
    def get_Labels(self):
5342
        return self.Labels
5343
    def set_Labels(self, Labels):
5344
        self.Labels = Labels
5345
    def add_Labels(self, value):
5346
        self.Labels.append(value)
5347
    def insert_Labels_at(self, index, value):
5348
        self.Labels.insert(index, value)
5349
    def replace_Labels_at(self, index, value):
5350
        self.Labels[index] = value
5351
    def get_id(self):
5352
        return self.id
5353
    def set_id(self, id):
5354
        self.id = id
5355
    def get_ligature(self):
5356
        return self.ligature
5357
    def set_ligature(self, ligature):
5358
        self.ligature = ligature
5359
    def get_symbol(self):
5360
        return self.symbol
5361
    def set_symbol(self, symbol):
5362
        self.symbol = symbol
5363
    def get_script(self):
5364
        return self.script
5365
    def set_script(self, script):
5366
        self.script = script
5367
    def get_production(self):
5368
        return self.production
5369
    def set_production(self, production):
5370
        self.production = production
5371
    def get_custom(self):
5372
        return self.custom
5373
    def set_custom(self, custom):
5374
        self.custom = custom
5375
    def get_comments(self):
5376
        return self.comments
5377
    def set_comments(self, comments):
5378
        self.comments = comments
5379
    def validate_ScriptSimpleType(self, value):
5380
        # Validate type pc:ScriptSimpleType, a restriction on string.
5381
        if value is not None and Validate_simpletypes_ and self.gds_collector_ is not None:
5382
            if not isinstance(value, str):
5383
                lineno = self.gds_get_node_lineno_()
5384
                self.gds_collector_.add_message('Value "%(value)s"%(lineno)s is not of the correct base simple type (str)' % {"value": value, "lineno": lineno, })
5385
                return False
5386
            value = value
5387
            enumerations = ['Adlm - Adlam', 'Afak - Afaka', 'Aghb - Caucasian Albanian', 'Ahom - Ahom, Tai Ahom', 'Arab - Arabic', 'Aran - Arabic (Nastaliq variant)', 'Armi - Imperial Aramaic', 'Armn - Armenian', 'Avst - Avestan', 'Bali - Balinese', 'Bamu - Bamum', 'Bass - Bassa Vah', 'Batk - Batak', 'Beng - Bengali', 'Bhks - Bhaiksuki', 'Blis - Blissymbols', 'Bopo - Bopomofo', 'Brah - Brahmi', 'Brai - Braille', 'Bugi - Buginese', 'Buhd - Buhid', 'Cakm - Chakma', 'Cans - Unified Canadian Aboriginal Syllabics', 'Cari - Carian', 'Cham - Cham', 'Cher - Cherokee', 'Cirt - Cirth', 'Copt - Coptic', 'Cprt - Cypriot', 'Cyrl - Cyrillic', 'Cyrs - Cyrillic (Old Church Slavonic variant)', 'Deva - Devanagari (Nagari)', 'Dsrt - Deseret (Mormon)', 'Dupl - Duployan shorthand, Duployan stenography', 'Egyd - Egyptian demotic', 'Egyh - Egyptian hieratic', 'Egyp - Egyptian hieroglyphs', 'Elba - Elbasan', 'Ethi - Ethiopic', 'Geok - Khutsuri (Asomtavruli and Nuskhuri)', 'Geor - Georgian (Mkhedruli)', 'Glag - Glagolitic', 'Goth - Gothic', 'Gran - Grantha', 'Grek - Greek', 'Gujr - Gujarati', 'Guru - Gurmukhi', 'Hanb - Han with Bopomofo', 'Hang - Hangul', 'Hani - Han (Hanzi, Kanji, Hanja)', 'Hano - Hanunoo (Hanunóo)', 'Hans - Han (Simplified variant)', 'Hant - Han (Traditional variant)', 'Hatr - Hatran', 'Hebr - Hebrew', 'Hira - Hiragana', 'Hluw - Anatolian Hieroglyphs', 'Hmng - Pahawh Hmong', 'Hrkt - Japanese syllabaries', 'Hung - Old Hungarian (Hungarian Runic)', 'Inds - Indus (Harappan)', 'Ital - Old Italic (Etruscan, Oscan etc.)', 'Jamo - Jamo', 'Java - Javanese', 'Jpan - Japanese', 'Jurc - Jurchen', 'Kali - Kayah Li', 'Kana - Katakana', 'Khar - Kharoshthi', 'Khmr - Khmer', 'Khoj - Khojki', 'Kitl - Khitan large script', 'Kits - Khitan small script', 'Knda - Kannada', 'Kore - Korean (alias for Hangul + Han)', 'Kpel - Kpelle', 'Kthi - Kaithi', 'Lana - Tai Tham (Lanna)', 'Laoo - Lao', 'Latf - Latin (Fraktur variant)', 'Latg - Latin (Gaelic variant)', 'Latn - Latin', 'Leke - Leke', 'Lepc - Lepcha (Róng)', 'Limb - Limbu', 'Lina - Linear A', 'Linb - Linear B', 'Lisu - Lisu (Fraser)', 'Loma - Loma', 'Lyci - Lycian', 'Lydi - Lydian', 'Mahj - Mahajani', 'Mand - Mandaic, Mandaean', 'Mani - Manichaean', 'Marc - Marchen', 'Maya - Mayan hieroglyphs', 'Mend - Mende Kikakui', 'Merc - Meroitic Cursive', 'Mero - Meroitic Hieroglyphs', 'Mlym - Malayalam', 'Modi - Modi, Moḍī', 'Mong - Mongolian', 'Moon - Moon (Moon code, Moon script, Moon type)', 'Mroo - Mro, Mru', 'Mtei - Meitei Mayek (Meithei, Meetei)', 'Mult - Multani', 'Mymr - Myanmar (Burmese)', 'Narb - Old North Arabian (Ancient North Arabian)', 'Nbat - Nabataean', 'Newa - Newa, Newar, Newari', 'Nkgb - Nakhi Geba', 'Nkoo - N’Ko', 'Nshu - Nüshu', 'Ogam - Ogham', 'Olck - Ol Chiki (Ol Cemet’, Ol, Santali)', 'Orkh - Old Turkic, Orkhon Runic', 'Orya - Oriya', 'Osge - Osage', 'Osma - Osmanya', 'Palm - Palmyrene', 'Pauc - Pau Cin Hau', 'Perm - Old Permic', 'Phag - Phags-pa', 'Phli - Inscriptional Pahlavi', 'Phlp - Psalter Pahlavi', 'Phlv - Book Pahlavi', 'Phnx - Phoenician', 'Piqd - Klingon (KLI pIqaD)', 'Plrd - Miao (Pollard)', 'Prti - Inscriptional Parthian', 'Rjng - Rejang (Redjang, Kaganga)', 'Roro - Rongorongo', 'Runr - Runic', 'Samr - Samaritan', 'Sara - Sarati', 'Sarb - Old South Arabian', 'Saur - Saurashtra', 'Sgnw - SignWriting', 'Shaw - Shavian (Shaw)', 'Shrd - Sharada, Śāradā', 'Sidd - Siddham', 'Sind - Khudawadi, Sindhi', 'Sinh - Sinhala', 'Sora - Sora Sompeng', 'Sund - Sundanese', 'Sylo - Syloti Nagri', 'Syrc - Syriac', 'Syre - Syriac (Estrangelo variant)', 'Syrj - Syriac (Western variant)', 'Syrn - Syriac (Eastern variant)', 'Tagb - Tagbanwa', 'Takr - Takri', 'Tale - Tai Le', 'Talu - New Tai Lue', 'Taml - Tamil', 'Tang - Tangut', 'Tavt - Tai Viet', 'Telu - Telugu', 'Teng - Tengwar', 'Tfng - Tifinagh (Berber)', 'Tglg - Tagalog (Baybayin, Alibata)', 'Thaa - Thaana', 'Thai - Thai', 'Tibt - Tibetan', 'Tirh - Tirhuta', 'Ugar - Ugaritic', 'Vaii - Vai', 'Visp - Visible Speech', 'Wara - Warang Citi (Varang Kshiti)', 'Wole - Woleai', 'Xpeo - Old Persian', 'Xsux - Cuneiform, Sumero-Akkadian', 'Yiii - Yi', 'Zinh - Code for inherited script', 'Zmth - Mathematical notation', 'Zsye - Symbols (Emoji variant)', 'Zsym - Symbols', 'Zxxx - Code for unwritten documents', 'Zyyy - Code for undetermined script', 'Zzzz - Code for uncoded script', 'other']
5388
            if value not in enumerations:
5389
                lineno = self.gds_get_node_lineno_()
5390
                self.gds_collector_.add_message('Value "%(value)s"%(lineno)s does not match xsd enumeration restriction on ScriptSimpleType' % {"value" : encode_str_2_3(value), "lineno": lineno} )
5391
                result = False
5392
    def validate_ProductionSimpleType(self, value):
5393
        # Validate type pc:ProductionSimpleType, a restriction on string.
5394
        if value is not None and Validate_simpletypes_ and self.gds_collector_ is not None:
5395
            if not isinstance(value, str):
5396
                lineno = self.gds_get_node_lineno_()
5397
                self.gds_collector_.add_message('Value "%(value)s"%(lineno)s is not of the correct base simple type (str)' % {"value": value, "lineno": lineno, })
5398
                return False
5399
            value = value
5400
            enumerations = ['printed', 'typewritten', 'handwritten-cursive', 'handwritten-printscript', 'medieval-manuscript', 'other']
5401
            if value not in enumerations:
5402
                lineno = self.gds_get_node_lineno_()
5403
                self.gds_collector_.add_message('Value "%(value)s"%(lineno)s does not match xsd enumeration restriction on ProductionSimpleType' % {"value" : encode_str_2_3(value), "lineno": lineno} )
5404
                result = False
5405
    def has__content(self):
5406
        if (
5407
            self.AlternativeImage or
5408
            self.Coords is not None or
5409
            self.Graphemes is not None or
5410
            self.TextEquiv or
5411
            self.TextStyle is not None or
5412
            self.UserDefined is not None or
5413
            self.Labels
5414
        ):
5415
            return True
5416
        else:
5417
            return False
5418
    def export(self, outfile, level, namespaceprefix_='', namespacedef_='xmlns:pc="http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15"', name_='GlyphType', pretty_print=True):
5419
        imported_ns_def_ = GenerateDSNamespaceDefs_.get('GlyphType')
5420
        if imported_ns_def_ is not None:
5421
            namespacedef_ = imported_ns_def_
5422
        if pretty_print:
5423
            eol_ = '\n'
5424
        else:
5425
            eol_ = ''
5426
        if self.original_tagname_ is not None and name_ == 'GlyphType':
5427
            name_ = self.original_tagname_
5428
        if UseCapturedNS_ and self.ns_prefix_:
5429
            namespaceprefix_ = self.ns_prefix_ + ':'
5430
        showIndent(outfile, level, pretty_print)
5431
        outfile.write('<%s%s%s' % (namespaceprefix_, name_, namespacedef_ and ' ' + namespacedef_ or '', ))
5432
        already_processed = set()
5433
        self._exportAttributes(outfile, level, already_processed, namespaceprefix_, name_='GlyphType')
5434
        if self.has__content():
5435
            outfile.write('>%s' % (eol_, ))
5436
            self._exportChildren(outfile, level + 1, namespaceprefix_, namespacedef_, name_='GlyphType', pretty_print=pretty_print)
5437
            showIndent(outfile, level, pretty_print)
5438
            outfile.write('</%s%s>%s' % (namespaceprefix_, name_, eol_))
5439
        else:
5440
            outfile.write('/>%s' % (eol_, ))
5441
    def _exportAttributes(self, outfile, level, already_processed, namespaceprefix_='', name_='GlyphType'):
5442
        if self.id is not None and 'id' not in already_processed:
5443
            already_processed.add('id')
5444
            outfile.write(' id=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.id), input_name='id')), ))
5445
        if self.ligature is not None and 'ligature' not in already_processed:
5446
            already_processed.add('ligature')
5447
            outfile.write(' ligature="%s"' % self.gds_format_boolean(self.ligature, input_name='ligature'))
5448
        if self.symbol is not None and 'symbol' not in already_processed:
5449
            already_processed.add('symbol')
5450
            outfile.write(' symbol="%s"' % self.gds_format_boolean(self.symbol, input_name='symbol'))
5451
        if self.script is not None and 'script' not in already_processed:
5452
            already_processed.add('script')
5453
            outfile.write(' script=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.script), input_name='script')), ))
5454
        if self.production is not None and 'production' not in already_processed:
5455
            already_processed.add('production')
5456
            outfile.write(' production=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.production), input_name='production')), ))
5457
        if self.custom is not None and 'custom' not in already_processed:
5458
            already_processed.add('custom')
5459
            outfile.write(' custom=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.custom), input_name='custom')), ))
5460
        if self.comments is not None and 'comments' not in already_processed:
5461
            already_processed.add('comments')
5462
            outfile.write(' comments=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.comments), input_name='comments')), ))
5463 View Code Duplication
    def _exportChildren(self, outfile, level, namespaceprefix_='', namespacedef_='xmlns:pc="http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15"', name_='GlyphType', fromsubclass_=False, pretty_print=True):
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
5464
        if pretty_print:
5465
            eol_ = '\n'
5466
        else:
5467
            eol_ = ''
5468
        for AlternativeImage_ in self.AlternativeImage:
5469
            namespaceprefix_ = self.AlternativeImage_nsprefix_ + ':' if (UseCapturedNS_ and self.AlternativeImage_nsprefix_) else ''
5470
            AlternativeImage_.export(outfile, level, namespaceprefix_, namespacedef_='', name_='AlternativeImage', pretty_print=pretty_print)
5471
        if self.Coords is not None:
5472
            namespaceprefix_ = self.Coords_nsprefix_ + ':' if (UseCapturedNS_ and self.Coords_nsprefix_) else ''
5473
            self.Coords.export(outfile, level, namespaceprefix_, namespacedef_='', name_='Coords', pretty_print=pretty_print)
5474
        if self.Graphemes is not None:
5475
            namespaceprefix_ = self.Graphemes_nsprefix_ + ':' if (UseCapturedNS_ and self.Graphemes_nsprefix_) else ''
5476
            self.Graphemes.export(outfile, level, namespaceprefix_, namespacedef_='', name_='Graphemes', pretty_print=pretty_print)
5477
        for TextEquiv_ in self.TextEquiv:
5478
            namespaceprefix_ = self.TextEquiv_nsprefix_ + ':' if (UseCapturedNS_ and self.TextEquiv_nsprefix_) else ''
5479
            TextEquiv_.export(outfile, level, namespaceprefix_, namespacedef_='', name_='TextEquiv', pretty_print=pretty_print)
5480
        if self.TextStyle is not None:
5481
            namespaceprefix_ = self.TextStyle_nsprefix_ + ':' if (UseCapturedNS_ and self.TextStyle_nsprefix_) else ''
5482
            self.TextStyle.export(outfile, level, namespaceprefix_, namespacedef_='', name_='TextStyle', pretty_print=pretty_print)
5483
        if self.UserDefined is not None:
5484
            namespaceprefix_ = self.UserDefined_nsprefix_ + ':' if (UseCapturedNS_ and self.UserDefined_nsprefix_) else ''
5485
            self.UserDefined.export(outfile, level, namespaceprefix_, namespacedef_='', name_='UserDefined', pretty_print=pretty_print)
5486
        for Labels_ in self.Labels:
5487
            namespaceprefix_ = self.Labels_nsprefix_ + ':' if (UseCapturedNS_ and self.Labels_nsprefix_) else ''
5488
            Labels_.export(outfile, level, namespaceprefix_, namespacedef_='', name_='Labels', pretty_print=pretty_print)
5489
    def to_etree(self, parent_element=None, name_='GlyphType', mapping_=None, reverse_mapping_=None, nsmap_=None):
5490
        if parent_element is None:
5491
            element = etree_.Element('{http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15}' + name_, nsmap=nsmap_)
5492
        else:
5493
            element = etree_.SubElement(parent_element, '{http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15}' + name_, nsmap=nsmap_)
5494
        if self.id is not None:
5495
            element.set('id', self.gds_format_string(self.id))
5496
        if self.ligature is not None:
5497
            element.set('ligature', self.gds_format_boolean(self.ligature))
5498
        if self.symbol is not None:
5499
            element.set('symbol', self.gds_format_boolean(self.symbol))
5500
        if self.script is not None:
5501
            element.set('script', self.gds_format_string(self.script))
5502
        if self.production is not None:
5503
            element.set('production', self.gds_format_string(self.production))
5504
        if self.custom is not None:
5505
            element.set('custom', self.gds_format_string(self.custom))
5506
        if self.comments is not None:
5507
            element.set('comments', self.gds_format_string(self.comments))
5508
        for AlternativeImage_ in self.AlternativeImage:
5509
            AlternativeImage_.to_etree(element, name_='AlternativeImage', mapping_=mapping_, reverse_mapping_=reverse_mapping_, nsmap_=nsmap_)
5510
        if self.Coords is not None:
5511
            Coords_ = self.Coords
5512
            Coords_.to_etree(element, name_='Coords', mapping_=mapping_, reverse_mapping_=reverse_mapping_, nsmap_=nsmap_)
5513
        if self.Graphemes is not None:
5514
            Graphemes_ = self.Graphemes
5515
            Graphemes_.to_etree(element, name_='Graphemes', mapping_=mapping_, reverse_mapping_=reverse_mapping_, nsmap_=nsmap_)
5516
        for TextEquiv_ in self.TextEquiv:
5517
            TextEquiv_.to_etree(element, name_='TextEquiv', mapping_=mapping_, reverse_mapping_=reverse_mapping_, nsmap_=nsmap_)
5518
        if self.TextStyle is not None:
5519
            TextStyle_ = self.TextStyle
5520
            TextStyle_.to_etree(element, name_='TextStyle', mapping_=mapping_, reverse_mapping_=reverse_mapping_, nsmap_=nsmap_)
5521
        if self.UserDefined is not None:
5522
            UserDefined_ = self.UserDefined
5523
            UserDefined_.to_etree(element, name_='UserDefined', mapping_=mapping_, reverse_mapping_=reverse_mapping_, nsmap_=nsmap_)
5524
        for Labels_ in self.Labels:
5525
            Labels_.to_etree(element, name_='Labels', mapping_=mapping_, reverse_mapping_=reverse_mapping_, nsmap_=nsmap_)
5526
        if mapping_ is not None:
5527
            mapping_[id(self)] = element
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable id does not seem to be defined.
Loading history...
5528
        if reverse_mapping_ is not None:
5529
            reverse_mapping_[element] = self
5530
        return element
5531
    def build(self, node, gds_collector_=None):
5532
        self.gds_collector_ = gds_collector_
5533
        if SaveElementTreeNode:
5534
            self.gds_elementtree_node_ = node
5535
        already_processed = set()
5536
        self.ns_prefix_ = node.prefix
5537
        self._buildAttributes(node, node.attrib, already_processed)
5538
        for child in node:
5539
            nodeName_ = Tag_pattern_.match(child.tag).groups()[-1]
5540
            self._buildChildren(child, node, nodeName_, gds_collector_=gds_collector_)
5541
        return self
5542
    def _buildAttributes(self, node, attrs, already_processed):
5543
        value = find_attr_value_('id', node)
5544
        if value is not None and 'id' not in already_processed:
5545
            already_processed.add('id')
5546
            self.id = value
5547
        value = find_attr_value_('ligature', node)
5548
        if value is not None and 'ligature' not in already_processed:
5549
            already_processed.add('ligature')
5550
            if value in ('true', '1'):
5551
                self.ligature = True
5552
            elif value in ('false', '0'):
5553
                self.ligature = False
5554
            else:
5555
                raise_parse_error(node, 'Bad boolean attribute')
5556
        value = find_attr_value_('symbol', node)
5557
        if value is not None and 'symbol' not in already_processed:
5558
            already_processed.add('symbol')
5559
            if value in ('true', '1'):
5560
                self.symbol = True
5561
            elif value in ('false', '0'):
5562
                self.symbol = False
5563
            else:
5564
                raise_parse_error(node, 'Bad boolean attribute')
5565
        value = find_attr_value_('script', node)
5566
        if value is not None and 'script' not in already_processed:
5567
            already_processed.add('script')
5568
            self.script = value
5569
            self.validate_ScriptSimpleType(self.script)    # validate type ScriptSimpleType
5570
        value = find_attr_value_('production', node)
5571
        if value is not None and 'production' not in already_processed:
5572
            already_processed.add('production')
5573
            self.production = value
5574
            self.validate_ProductionSimpleType(self.production)    # validate type ProductionSimpleType
5575
        value = find_attr_value_('custom', node)
5576
        if value is not None and 'custom' not in already_processed:
5577
            already_processed.add('custom')
5578
            self.custom = value
5579
        value = find_attr_value_('comments', node)
5580
        if value is not None and 'comments' not in already_processed:
5581
            already_processed.add('comments')
5582
            self.comments = value
5583 View Code Duplication
    def _buildChildren(self, child_, node, nodeName_, fromsubclass_=False, gds_collector_=None):
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
5584
        if nodeName_ == 'AlternativeImage':
5585
            obj_ = AlternativeImageType.factory(parent_object_=self)
5586
            obj_.build(child_, gds_collector_=gds_collector_)
5587
            self.AlternativeImage.append(obj_)
5588
            obj_.original_tagname_ = 'AlternativeImage'
5589
        elif nodeName_ == 'Coords':
5590
            obj_ = CoordsType.factory(parent_object_=self)
5591
            obj_.build(child_, gds_collector_=gds_collector_)
5592
            self.Coords = obj_
5593
            obj_.original_tagname_ = 'Coords'
5594
        elif nodeName_ == 'Graphemes':
5595
            obj_ = GraphemesType.factory(parent_object_=self)
5596
            obj_.build(child_, gds_collector_=gds_collector_)
5597
            self.Graphemes = obj_
5598
            obj_.original_tagname_ = 'Graphemes'
5599
        elif nodeName_ == 'TextEquiv':
5600
            obj_ = TextEquivType.factory(parent_object_=self)
5601
            obj_.build(child_, gds_collector_=gds_collector_)
5602
            self.TextEquiv.append(obj_)
5603
            obj_.original_tagname_ = 'TextEquiv'
5604
        elif nodeName_ == 'TextStyle':
5605
            obj_ = TextStyleType.factory(parent_object_=self)
5606
            obj_.build(child_, gds_collector_=gds_collector_)
5607
            self.TextStyle = obj_
5608
            obj_.original_tagname_ = 'TextStyle'
5609
        elif nodeName_ == 'UserDefined':
5610
            obj_ = UserDefinedType.factory(parent_object_=self)
5611
            obj_.build(child_, gds_collector_=gds_collector_)
5612
            self.UserDefined = obj_
5613
            obj_.original_tagname_ = 'UserDefined'
5614
        elif nodeName_ == 'Labels':
5615
            obj_ = LabelsType.factory(parent_object_=self)
5616
            obj_.build(child_, gds_collector_=gds_collector_)
5617
            self.Labels.append(obj_)
5618
            obj_.original_tagname_ = 'Labels'
5619
    def __hash__(self):
5620
        return hash(self.id)
5621 View Code Duplication
    def invalidate_AlternativeImage(self, feature_selector=None):
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
5622
        """
5623
        Remove derived images from this segment (due to changed coordinates).
5624
    
5625
        If `feature_selector` is not none, remove only images with
5626
        matching ``@comments``, e.g. ``feature_selector=cropped,deskewed``.
5627
        """
5628
        existing_images = self.AlternativeImage or []
5629
        removed_images = []
5630
        if feature_selector:
5631
            new_images = []
5632
            for image in existing_images:
5633
                features = image.get_comments() or ''
5634
                if any(feature in features.split(',')
5635
                       for feature in feature_selector.split(',') if feature):
5636
                    removed_images.append(image)
5637
                else:
5638
                    new_images.append(image)
5639
            self.AlternativeImage = new_images
5640
        else:
5641
            removed_images = existing_images
5642
            self.AlternativeImage = []
5643
        if hasattr(self, 'id'):
5644
            name = self.id
5645
        elif hasattr(self, 'parent_object_') and hasattr(self.parent_object_, 'pcGtsId'):
5646
            name = self.parent_object_.pcGtsId
5647
        else:
5648
            name = ''
5649
        for image in removed_images:
5650
            self.gds_collector_.add_message('Removing AlternativeImage %s from "%s"' % (
5651
                image.get_comments() or '', name))
5652
    def set_Coords(self, Coords):
5653
        """
5654
        Set coordinate polygon by given :py:class:`CoordsType` object.
5655
        Moreover, invalidate self's ``pc:AlternativeImage``s
5656
        (because they will have been cropped with a bbox
5657
        of the previous polygon).
5658
        """
5659
        if hasattr(self, 'invalidate_AlternativeImage'):
5660
            # RegionType, TextLineType, WordType, GlyphType:
5661
            self.invalidate_AlternativeImage()
5662
        elif hasattr(self, 'parent_object_') and hasattr(self.parent_object_, 'invalidate_AlternativeImage'):
5663
            # BorderType:
5664
            self.parent_object_.invalidate_AlternativeImage(feature_selector='cropped')
5665
        self.Coords = Coords
5666
# end class GlyphType
5667
5668
5669
class TextEquivType(GeneratedsSuper):
5670
    """index --
5671
    Used for sort order in case multiple TextEquivs are defined.
5672
    The text content with the lowest index should be interpreted
5673
    as the main text content.
5674
      
5675
    * conf -- OCR confidence value (between 0 and 1)
5676
    * dataType --
5677
      Type of text content (is it free text or a number, for instance).
5678
      This is only a descriptive attribute, the text type
5679
      is not checked during XML validation.
5680
      
5681
    * dataTypeDetails --
5682
      Refinement for dataType attribute. Can be a regular expression, for instance.
5683
      
5684
    * PlainText --
5685
      Text in a "simple" form (ASCII or extended ASCII
5686
      as mostly used for typing). I.e. no use of
5687
      special characters for ligatures (should be
5688
      stored as two separate characters) etc.
5689
      
5690
    * Unicode --
5691
      Correct encoding of the original, always using
5692
      the corresponding Unicode code point. I.e.
5693
      ligatures have to be represented as one
5694
      character etc.
5695
    
5696
    """
5697
    __hash__ = GeneratedsSuper.__hash__
5698
    member_data_items_ = [
5699
        MemberSpec_('index', 'indexType', 0, 1, {'use': 'optional', 'name': 'index'}),
5700
        MemberSpec_('conf', 'pc:ConfSimpleType', 0, 1, {'use': 'optional', 'name': 'conf'}),
5701
        MemberSpec_('dataType', 'pc:TextDataTypeSimpleType', 0, 1, {'use': 'optional', 'name': 'dataType'}),
5702
        MemberSpec_('dataTypeDetails', 'string', 0, 1, {'use': 'optional', 'name': 'dataTypeDetails'}),
5703
        MemberSpec_('comments', 'string', 0, 1, {'use': 'optional', 'name': 'comments'}),
5704
        MemberSpec_('PlainText', 'string', 0, 1, {'minOccurs': '0', 'name': 'PlainText', 'type': 'string'}, None),
5705
        MemberSpec_('Unicode', 'string', 0, 0, {'name': 'Unicode', 'type': 'string'}, None),
5706
    ]
5707
    subclass = None
5708
    superclass = None
5709
    def __init__(self, index=None, conf=None, dataType=None, dataTypeDetails=None, comments=None, PlainText=None, Unicode=None, gds_collector_=None, **kwargs_):
5710
        self.gds_collector_ = gds_collector_
5711
        self.gds_elementtree_node_ = None
5712
        self.original_tagname_ = None
5713
        self.parent_object_ = kwargs_.get('parent_object_')
5714
        self.ns_prefix_ = None
5715
        self.index = _cast(int, index)
5716
        self.index_nsprefix_ = "pc"
5717
        self.conf = _cast(float, conf)
5718
        self.conf_nsprefix_ = "pc"
5719
        self.dataType = _cast(None, dataType)
5720
        self.dataType_nsprefix_ = "pc"
5721
        self.dataTypeDetails = _cast(None, dataTypeDetails)
5722
        self.dataTypeDetails_nsprefix_ = "pc"
5723
        self.comments = _cast(None, comments)
5724
        self.comments_nsprefix_ = "pc"
5725
        self.PlainText = PlainText
5726
        self.PlainText_nsprefix_ = "pc"
5727
        self.Unicode = Unicode
5728
        self.Unicode_nsprefix_ = "pc"
5729
    def factory(*args_, **kwargs_):
5730
        if CurrentSubclassModule_ is not None:
5731
            subclass = getSubclassFromModule_(
5732
                CurrentSubclassModule_, TextEquivType)
5733
            if subclass is not None:
5734
                return subclass(*args_, **kwargs_)
5735
        if TextEquivType.subclass:
5736
            return TextEquivType.subclass(*args_, **kwargs_)
5737
        else:
5738
            return TextEquivType(*args_, **kwargs_)
5739
    factory = staticmethod(factory)
5740
    def get_ns_prefix_(self):
5741
        return self.ns_prefix_
5742
    def set_ns_prefix_(self, ns_prefix):
5743
        self.ns_prefix_ = ns_prefix
5744
    def get_PlainText(self):
5745
        return self.PlainText
5746
    def set_PlainText(self, PlainText):
5747
        self.PlainText = PlainText
5748
    def get_Unicode(self):
5749
        return self.Unicode
5750
    def set_Unicode(self, Unicode):
5751
        self.Unicode = Unicode
5752
    def get_index(self):
5753
        return self.index
5754
    def set_index(self, index):
5755
        self.index = index
5756
    def get_conf(self):
5757
        return self.conf
5758
    def set_conf(self, conf):
5759
        self.conf = conf
5760
    def get_dataType(self):
5761
        return self.dataType
5762
    def set_dataType(self, dataType):
5763
        self.dataType = dataType
5764
    def get_dataTypeDetails(self):
5765
        return self.dataTypeDetails
5766
    def set_dataTypeDetails(self, dataTypeDetails):
5767
        self.dataTypeDetails = dataTypeDetails
5768
    def get_comments(self):
5769
        return self.comments
5770
    def set_comments(self, comments):
5771
        self.comments = comments
5772 View Code Duplication
    def validate_indexType(self, value):
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
5773
        # Validate type indexType, a restriction on integer.
5774
        if value is not None and Validate_simpletypes_ and self.gds_collector_ is not None:
5775
            if not isinstance(value, int):
5776
                lineno = self.gds_get_node_lineno_()
5777
                self.gds_collector_.add_message('Value "%(value)s"%(lineno)s is not of the correct base simple type (int)' % {"value": value, "lineno": lineno, })
5778
                return False
5779
            if value < 0:
5780
                lineno = self.gds_get_node_lineno_()
5781
                self.gds_collector_.add_message('Value "%(value)s"%(lineno)s does not match xsd minInclusive restriction on indexType' % {"value": value, "lineno": lineno} )
5782
                result = False
5783 View Code Duplication
    def validate_ConfSimpleType(self, value):
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
5784
        # Validate type pc:ConfSimpleType, a restriction on float.
5785
        if value is not None and Validate_simpletypes_ and self.gds_collector_ is not None:
5786
            if not isinstance(value, float):
5787
                lineno = self.gds_get_node_lineno_()
5788
                self.gds_collector_.add_message('Value "%(value)s"%(lineno)s is not of the correct base simple type (float)' % {"value": value, "lineno": lineno, })
5789
                return False
5790
            if value < 0:
5791
                lineno = self.gds_get_node_lineno_()
5792
                self.gds_collector_.add_message('Value "%(value)s"%(lineno)s does not match xsd minInclusive restriction on ConfSimpleType' % {"value": value, "lineno": lineno} )
5793
                result = False
5794
            if value > 1:
5795
                lineno = self.gds_get_node_lineno_()
5796
                self.gds_collector_.add_message('Value "%(value)s"%(lineno)s does not match xsd maxInclusive restriction on ConfSimpleType' % {"value": value, "lineno": lineno} )
5797
                result = False
5798
    def validate_TextDataTypeSimpleType(self, value):
5799
        # Validate type pc:TextDataTypeSimpleType, a restriction on string.
5800
        if value is not None and Validate_simpletypes_ and self.gds_collector_ is not None:
5801
            if not isinstance(value, str):
5802
                lineno = self.gds_get_node_lineno_()
5803
                self.gds_collector_.add_message('Value "%(value)s"%(lineno)s is not of the correct base simple type (str)' % {"value": value, "lineno": lineno, })
5804
                return False
5805
            value = value
5806
            enumerations = ['xsd:decimal', 'xsd:float', 'xsd:integer', 'xsd:boolean', 'xsd:date', 'xsd:time', 'xsd:dateTime', 'xsd:string', 'other']
5807
            if value not in enumerations:
5808
                lineno = self.gds_get_node_lineno_()
5809
                self.gds_collector_.add_message('Value "%(value)s"%(lineno)s does not match xsd enumeration restriction on TextDataTypeSimpleType' % {"value" : encode_str_2_3(value), "lineno": lineno} )
5810
                result = False
5811
    def has__content(self):
5812
        if (
5813
            self.PlainText is not None or
5814
            self.Unicode is not None
5815
        ):
5816
            return True
5817
        else:
5818
            return False
5819
    def export(self, outfile, level, namespaceprefix_='', namespacedef_='xmlns:pc="http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15" xmlns:None="http://www.w3.org/2001/XMLSchema" ', name_='TextEquivType', pretty_print=True):
5820
        imported_ns_def_ = GenerateDSNamespaceDefs_.get('TextEquivType')
5821
        if imported_ns_def_ is not None:
5822
            namespacedef_ = imported_ns_def_
5823
        if pretty_print:
5824
            eol_ = '\n'
5825
        else:
5826
            eol_ = ''
5827
        if self.original_tagname_ is not None and name_ == 'TextEquivType':
5828
            name_ = self.original_tagname_
5829
        if UseCapturedNS_ and self.ns_prefix_:
5830
            namespaceprefix_ = self.ns_prefix_ + ':'
5831
        showIndent(outfile, level, pretty_print)
5832
        outfile.write('<%s%s%s' % (namespaceprefix_, name_, namespacedef_ and ' ' + namespacedef_ or '', ))
5833
        already_processed = set()
5834
        self._exportAttributes(outfile, level, already_processed, namespaceprefix_, name_='TextEquivType')
5835
        if self.has__content():
5836
            outfile.write('>%s' % (eol_, ))
5837
            self._exportChildren(outfile, level + 1, namespaceprefix_, namespacedef_, name_='TextEquivType', pretty_print=pretty_print)
5838
            showIndent(outfile, level, pretty_print)
5839
            outfile.write('</%s%s>%s' % (namespaceprefix_, name_, eol_))
5840
        else:
5841
            outfile.write('/>%s' % (eol_, ))
5842
    def _exportAttributes(self, outfile, level, already_processed, namespaceprefix_='', name_='TextEquivType'):
5843
        if self.index is not None and 'index' not in already_processed:
5844
            already_processed.add('index')
5845
            outfile.write(' index="%s"' % self.gds_format_integer(self.index, input_name='index'))
5846
        if self.conf is not None and 'conf' not in already_processed:
5847
            already_processed.add('conf')
5848
            outfile.write(' conf="%s"' % self.gds_format_float(self.conf, input_name='conf'))
5849
        if self.dataType is not None and 'dataType' not in already_processed:
5850
            already_processed.add('dataType')
5851
            outfile.write(' dataType=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.dataType), input_name='dataType')), ))
5852
        if self.dataTypeDetails is not None and 'dataTypeDetails' not in already_processed:
5853
            already_processed.add('dataTypeDetails')
5854
            outfile.write(' dataTypeDetails=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.dataTypeDetails), input_name='dataTypeDetails')), ))
5855
        if self.comments is not None and 'comments' not in already_processed:
5856
            already_processed.add('comments')
5857
            outfile.write(' comments=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.comments), input_name='comments')), ))
5858
    def _exportChildren(self, outfile, level, namespaceprefix_='', namespacedef_='xmlns:pc="http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15" xmlns:None="http://www.w3.org/2001/XMLSchema" ', name_='TextEquivType', fromsubclass_=False, pretty_print=True):
5859
        if pretty_print:
5860
            eol_ = '\n'
5861
        else:
5862
            eol_ = ''
5863
        if self.PlainText is not None:
5864
            namespaceprefix_ = self.PlainText_nsprefix_ + ':' if (UseCapturedNS_ and self.PlainText_nsprefix_) else ''
5865
            showIndent(outfile, level, pretty_print)
5866
            outfile.write('<%sPlainText>%s</%sPlainText>%s' % (namespaceprefix_ , self.gds_encode(self.gds_format_string(quote_xml(self.PlainText), input_name='PlainText')), namespaceprefix_ , eol_))
5867
        if self.Unicode is not None:
5868
            namespaceprefix_ = self.Unicode_nsprefix_ + ':' if (UseCapturedNS_ and self.Unicode_nsprefix_) else ''
5869
            showIndent(outfile, level, pretty_print)
5870
            outfile.write('<%sUnicode>%s</%sUnicode>%s' % (namespaceprefix_ , self.gds_encode(self.gds_format_string(quote_xml(self.Unicode), input_name='Unicode')), namespaceprefix_ , eol_))
5871
    def to_etree(self, parent_element=None, name_='TextEquivType', mapping_=None, reverse_mapping_=None, nsmap_=None):
5872
        if parent_element is None:
5873
            element = etree_.Element('{http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15}' + name_, nsmap=nsmap_)
5874
        else:
5875
            element = etree_.SubElement(parent_element, '{http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15}' + name_, nsmap=nsmap_)
5876
        if self.index is not None:
5877
            element.set('index', self.gds_format_integer(self.index))
5878
        if self.conf is not None:
5879
            element.set('conf', self.gds_format_float(self.conf))
5880
        if self.dataType is not None:
5881
            element.set('dataType', self.gds_format_string(self.dataType))
5882
        if self.dataTypeDetails is not None:
5883
            element.set('dataTypeDetails', self.gds_format_string(self.dataTypeDetails))
5884
        if self.comments is not None:
5885
            element.set('comments', self.gds_format_string(self.comments))
5886
        if self.PlainText is not None:
5887
            PlainText_ = self.PlainText
5888
            etree_.SubElement(element, '{http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15}PlainText').text = self.gds_format_string(PlainText_)
5889
        if self.Unicode is not None:
5890
            Unicode_ = self.Unicode
5891
            etree_.SubElement(element, '{http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15}Unicode').text = self.gds_format_string(Unicode_)
5892
        if mapping_ is not None:
5893
            mapping_[id(self)] = element
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable id does not seem to be defined.
Loading history...
5894
        if reverse_mapping_ is not None:
5895
            reverse_mapping_[element] = self
5896
        return element
5897
    def build(self, node, gds_collector_=None):
5898
        self.gds_collector_ = gds_collector_
5899
        if SaveElementTreeNode:
5900
            self.gds_elementtree_node_ = node
5901
        already_processed = set()
5902
        self.ns_prefix_ = node.prefix
5903
        self._buildAttributes(node, node.attrib, already_processed)
5904
        for child in node:
5905
            nodeName_ = Tag_pattern_.match(child.tag).groups()[-1]
5906
            self._buildChildren(child, node, nodeName_, gds_collector_=gds_collector_)
5907
        return self
5908
    def _buildAttributes(self, node, attrs, already_processed):
5909
        value = find_attr_value_('index', node)
5910
        if value is not None and 'index' not in already_processed:
5911
            already_processed.add('index')
5912
            self.index = self.gds_parse_integer(value, node, 'index')
5913
            self.validate_indexType(self.index)    # validate type indexType
5914
        value = find_attr_value_('conf', node)
5915
        if value is not None and 'conf' not in already_processed:
5916
            already_processed.add('conf')
5917
            value = self.gds_parse_float(value, node, 'conf')
5918
            self.conf = value
5919
            self.validate_ConfSimpleType(self.conf)    # validate type ConfSimpleType
5920
        value = find_attr_value_('dataType', node)
5921
        if value is not None and 'dataType' not in already_processed:
5922
            already_processed.add('dataType')
5923
            self.dataType = value
5924
            self.validate_TextDataTypeSimpleType(self.dataType)    # validate type TextDataTypeSimpleType
5925
        value = find_attr_value_('dataTypeDetails', node)
5926
        if value is not None and 'dataTypeDetails' not in already_processed:
5927
            already_processed.add('dataTypeDetails')
5928
            self.dataTypeDetails = value
5929
        value = find_attr_value_('comments', node)
5930
        if value is not None and 'comments' not in already_processed:
5931
            already_processed.add('comments')
5932
            self.comments = value
5933
    def _buildChildren(self, child_, node, nodeName_, fromsubclass_=False, gds_collector_=None):
5934
        if nodeName_ == 'PlainText':
5935
            value_ = child_.text
5936
            value_ = self.gds_parse_string(value_, node, 'PlainText')
5937
            value_ = self.gds_validate_string(value_, node, 'PlainText')
5938
            self.PlainText = value_
5939
5940
        elif nodeName_ == 'Unicode':
5941
            value_ = child_.text
5942
            value_ = self.gds_parse_string(value_, node, 'Unicode')
5943
            value_ = self.gds_validate_string(value_, node, 'Unicode')
5944
            self.Unicode = value_
5945
5946
    def __hash__(self):
5947
        return hash(self.id)
5948
# end class TextEquivType
5949
5950
5951 View Code Duplication
class GridType(GeneratedsSuper):
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
5952
    """GridType --
5953
    Matrix of grid points defining the table grid on the page.
5954
      
5955
    * GridPoints --
5956
      One row in the grid point matrix.
5957
      Points with x,y coordinates.
5958
      (note: for a table with n table rows there should be n+1 grid rows)
5959
    
5960
    """
5961
    __hash__ = GeneratedsSuper.__hash__
5962
    member_data_items_ = [
5963
        MemberSpec_('GridPoints', 'GridPointsType', 1, 0, {'maxOccurs': 'unbounded', 'minOccurs': '2', 'name': 'GridPoints', 'type': 'GridPointsType'}, None),
5964
    ]
5965
    subclass = None
5966
    superclass = None
5967
    def __init__(self, GridPoints=None, gds_collector_=None, **kwargs_):
5968
        self.gds_collector_ = gds_collector_
5969
        self.gds_elementtree_node_ = None
5970
        self.original_tagname_ = None
5971
        self.parent_object_ = kwargs_.get('parent_object_')
5972
        self.ns_prefix_ = "pc"
5973
        if GridPoints is None:
5974
            self.GridPoints = []
5975
        else:
5976
            self.GridPoints = GridPoints
5977
        self.GridPoints_nsprefix_ = "pc"
5978
    def factory(*args_, **kwargs_):
5979
        if CurrentSubclassModule_ is not None:
5980
            subclass = getSubclassFromModule_(
5981
                CurrentSubclassModule_, GridType)
5982
            if subclass is not None:
5983
                return subclass(*args_, **kwargs_)
5984
        if GridType.subclass:
5985
            return GridType.subclass(*args_, **kwargs_)
5986
        else:
5987
            return GridType(*args_, **kwargs_)
5988
    factory = staticmethod(factory)
5989
    def get_ns_prefix_(self):
5990
        return self.ns_prefix_
5991
    def set_ns_prefix_(self, ns_prefix):
5992
        self.ns_prefix_ = ns_prefix
5993
    def get_GridPoints(self):
5994
        return self.GridPoints
5995
    def set_GridPoints(self, GridPoints):
5996
        self.GridPoints = GridPoints
5997
    def add_GridPoints(self, value):
5998
        self.GridPoints.append(value)
5999
    def insert_GridPoints_at(self, index, value):
6000
        self.GridPoints.insert(index, value)
6001
    def replace_GridPoints_at(self, index, value):
6002
        self.GridPoints[index] = value
6003
    def has__content(self):
6004
        if (
6005
            self.GridPoints
6006
        ):
6007
            return True
6008
        else:
6009
            return False
6010
    def export(self, outfile, level, namespaceprefix_='', namespacedef_='xmlns:pc="http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15"', name_='GridType', pretty_print=True):
6011
        imported_ns_def_ = GenerateDSNamespaceDefs_.get('GridType')
6012
        if imported_ns_def_ is not None:
6013
            namespacedef_ = imported_ns_def_
6014
        if pretty_print:
6015
            eol_ = '\n'
6016
        else:
6017
            eol_ = ''
6018
        if self.original_tagname_ is not None and name_ == 'GridType':
6019
            name_ = self.original_tagname_
6020
        if UseCapturedNS_ and self.ns_prefix_:
6021
            namespaceprefix_ = self.ns_prefix_ + ':'
6022
        showIndent(outfile, level, pretty_print)
6023
        outfile.write('<%s%s%s' % (namespaceprefix_, name_, namespacedef_ and ' ' + namespacedef_ or '', ))
6024
        already_processed = set()
6025
        self._exportAttributes(outfile, level, already_processed, namespaceprefix_, name_='GridType')
6026
        if self.has__content():
6027
            outfile.write('>%s' % (eol_, ))
6028
            self._exportChildren(outfile, level + 1, namespaceprefix_, namespacedef_, name_='GridType', pretty_print=pretty_print)
6029
            showIndent(outfile, level, pretty_print)
6030
            outfile.write('</%s%s>%s' % (namespaceprefix_, name_, eol_))
6031
        else:
6032
            outfile.write('/>%s' % (eol_, ))
6033
    def _exportAttributes(self, outfile, level, already_processed, namespaceprefix_='', name_='GridType'):
6034
        pass
6035
    def _exportChildren(self, outfile, level, namespaceprefix_='', namespacedef_='xmlns:pc="http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15"', name_='GridType', fromsubclass_=False, pretty_print=True):
6036
        if pretty_print:
6037
            eol_ = '\n'
6038
        else:
6039
            eol_ = ''
6040
        for GridPoints_ in self.GridPoints:
6041
            namespaceprefix_ = self.GridPoints_nsprefix_ + ':' if (UseCapturedNS_ and self.GridPoints_nsprefix_) else ''
6042
            GridPoints_.export(outfile, level, namespaceprefix_, namespacedef_='', name_='GridPoints', pretty_print=pretty_print)
6043
    def to_etree(self, parent_element=None, name_='GridType', mapping_=None, reverse_mapping_=None, nsmap_=None):
6044
        if parent_element is None:
6045
            element = etree_.Element('{http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15}' + name_, nsmap=nsmap_)
6046
        else:
6047
            element = etree_.SubElement(parent_element, '{http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15}' + name_, nsmap=nsmap_)
6048
        for GridPoints_ in self.GridPoints:
6049
            GridPoints_.to_etree(element, name_='GridPoints', mapping_=mapping_, reverse_mapping_=reverse_mapping_, nsmap_=nsmap_)
6050
        if mapping_ is not None:
6051
            mapping_[id(self)] = element
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable id does not seem to be defined.
Loading history...
6052
        if reverse_mapping_ is not None:
6053
            reverse_mapping_[element] = self
6054
        return element
6055
    def build(self, node, gds_collector_=None):
6056
        self.gds_collector_ = gds_collector_
6057
        if SaveElementTreeNode:
6058
            self.gds_elementtree_node_ = node
6059
        already_processed = set()
6060
        self.ns_prefix_ = node.prefix
6061
        self._buildAttributes(node, node.attrib, already_processed)
6062
        for child in node:
6063
            nodeName_ = Tag_pattern_.match(child.tag).groups()[-1]
6064
            self._buildChildren(child, node, nodeName_, gds_collector_=gds_collector_)
6065
        return self
6066
    def _buildAttributes(self, node, attrs, already_processed):
6067
        pass
6068
    def _buildChildren(self, child_, node, nodeName_, fromsubclass_=False, gds_collector_=None):
6069
        if nodeName_ == 'GridPoints':
6070
            obj_ = GridPointsType.factory(parent_object_=self)
6071
            obj_.build(child_, gds_collector_=gds_collector_)
6072
            self.GridPoints.append(obj_)
6073
            obj_.original_tagname_ = 'GridPoints'
6074
    def __hash__(self):
6075
        return hash(self.id)
6076
# end class GridType
6077
6078
6079
class GridPointsType(GeneratedsSuper):
6080
    """GridPointsType -- Points with x,y coordinates.
6081
    index --
6082
    The grid row index
6083
    
6084
    """
6085
    __hash__ = GeneratedsSuper.__hash__
6086
    member_data_items_ = [
6087
        MemberSpec_('index', 'int', 0, 0, {'use': 'required', 'name': 'index'}),
6088
        MemberSpec_('points', 'pc:PointsType', 0, 0, {'use': 'required', 'name': 'points'}),
6089
    ]
6090
    subclass = None
6091
    superclass = None
6092
    def __init__(self, index=None, points=None, gds_collector_=None, **kwargs_):
6093
        self.gds_collector_ = gds_collector_
6094
        self.gds_elementtree_node_ = None
6095
        self.original_tagname_ = None
6096
        self.parent_object_ = kwargs_.get('parent_object_')
6097
        self.ns_prefix_ = "pc"
6098
        self.index = _cast(int, index)
6099
        self.index_nsprefix_ = "pc"
6100
        self.points = _cast(None, points)
6101
        self.points_nsprefix_ = "pc"
6102
    def factory(*args_, **kwargs_):
6103
        if CurrentSubclassModule_ is not None:
6104
            subclass = getSubclassFromModule_(
6105
                CurrentSubclassModule_, GridPointsType)
6106
            if subclass is not None:
6107
                return subclass(*args_, **kwargs_)
6108
        if GridPointsType.subclass:
6109
            return GridPointsType.subclass(*args_, **kwargs_)
6110
        else:
6111
            return GridPointsType(*args_, **kwargs_)
6112
    factory = staticmethod(factory)
6113
    def get_ns_prefix_(self):
6114
        return self.ns_prefix_
6115
    def set_ns_prefix_(self, ns_prefix):
6116
        self.ns_prefix_ = ns_prefix
6117
    def get_index(self):
6118
        return self.index
6119
    def set_index(self, index):
6120
        self.index = index
6121
    def get_points(self):
6122
        return self.points
6123
    def set_points(self, points):
6124
        self.points = points
6125 View Code Duplication
    def validate_PointsType(self, value):
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
6126
        # Validate type pc:PointsType, a restriction on string.
6127
        if value is not None and Validate_simpletypes_ and self.gds_collector_ is not None:
6128
            if not isinstance(value, str):
6129
                lineno = self.gds_get_node_lineno_()
6130
                self.gds_collector_.add_message('Value "%(value)s"%(lineno)s is not of the correct base simple type (str)' % {"value": value, "lineno": lineno, })
6131
                return False
6132
            if not self.gds_validate_simple_patterns(
6133
                    self.validate_PointsType_patterns_, value):
6134
                self.gds_collector_.add_message('Value "%s" does not match xsd pattern restrictions: %s' % (encode_str_2_3(value), self.validate_PointsType_patterns_, ))
6135
    validate_PointsType_patterns_ = [['^(([0-9]+,[0-9]+ )+([0-9]+,[0-9]+))$']]
6136
    def has__content(self):
6137
        if (
6138
6139
        ):
6140
            return True
6141
        else:
6142
            return False
6143
    def export(self, outfile, level, namespaceprefix_='', namespacedef_='xmlns:pc="http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15"', name_='GridPointsType', pretty_print=True):
6144
        imported_ns_def_ = GenerateDSNamespaceDefs_.get('GridPointsType')
6145
        if imported_ns_def_ is not None:
6146
            namespacedef_ = imported_ns_def_
6147
        if pretty_print:
6148
            eol_ = '\n'
6149
        else:
6150
            eol_ = ''
6151
        if self.original_tagname_ is not None and name_ == 'GridPointsType':
6152
            name_ = self.original_tagname_
6153
        if UseCapturedNS_ and self.ns_prefix_:
6154
            namespaceprefix_ = self.ns_prefix_ + ':'
6155
        showIndent(outfile, level, pretty_print)
6156
        outfile.write('<%s%s%s' % (namespaceprefix_, name_, namespacedef_ and ' ' + namespacedef_ or '', ))
6157
        already_processed = set()
6158
        self._exportAttributes(outfile, level, already_processed, namespaceprefix_, name_='GridPointsType')
6159
        if self.has__content():
6160
            outfile.write('>%s' % (eol_, ))
6161
            self._exportChildren(outfile, level + 1, namespaceprefix_, namespacedef_, name_='GridPointsType', pretty_print=pretty_print)
6162
            outfile.write('</%s%s>%s' % (namespaceprefix_, name_, eol_))
6163
        else:
6164
            outfile.write('/>%s' % (eol_, ))
6165
    def _exportAttributes(self, outfile, level, already_processed, namespaceprefix_='', name_='GridPointsType'):
6166
        if self.index is not None and 'index' not in already_processed:
6167
            already_processed.add('index')
6168
            outfile.write(' index="%s"' % self.gds_format_integer(self.index, input_name='index'))
6169
        if self.points is not None and 'points' not in already_processed:
6170
            already_processed.add('points')
6171
            outfile.write(' points=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.points), input_name='points')), ))
6172
    def _exportChildren(self, outfile, level, namespaceprefix_='', namespacedef_='xmlns:pc="http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15"', name_='GridPointsType', fromsubclass_=False, pretty_print=True):
6173
        pass
6174 View Code Duplication
    def to_etree(self, parent_element=None, name_='GridPointsType', mapping_=None, reverse_mapping_=None, nsmap_=None):
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
6175
        if parent_element is None:
6176
            element = etree_.Element('{http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15}' + name_, nsmap=nsmap_)
6177
        else:
6178
            element = etree_.SubElement(parent_element, '{http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15}' + name_, nsmap=nsmap_)
6179
        if self.index is not None:
6180
            element.set('index', self.gds_format_integer(self.index))
6181
        if self.points is not None:
6182
            element.set('points', self.gds_format_string(self.points))
6183
        if mapping_ is not None:
6184
            mapping_[id(self)] = element
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable id does not seem to be defined.
Loading history...
6185
        if reverse_mapping_ is not None:
6186
            reverse_mapping_[element] = self
6187
        return element
6188
    def build(self, node, gds_collector_=None):
6189
        self.gds_collector_ = gds_collector_
6190
        if SaveElementTreeNode:
6191
            self.gds_elementtree_node_ = node
6192
        already_processed = set()
6193
        self.ns_prefix_ = node.prefix
6194
        self._buildAttributes(node, node.attrib, already_processed)
6195
        for child in node:
6196
            nodeName_ = Tag_pattern_.match(child.tag).groups()[-1]
6197
            self._buildChildren(child, node, nodeName_, gds_collector_=gds_collector_)
6198
        return self
6199
    def _buildAttributes(self, node, attrs, already_processed):
6200
        value = find_attr_value_('index', node)
6201
        if value is not None and 'index' not in already_processed:
6202
            already_processed.add('index')
6203
            self.index = self.gds_parse_integer(value, node, 'index')
6204
        value = find_attr_value_('points', node)
6205
        if value is not None and 'points' not in already_processed:
6206
            already_processed.add('points')
6207
            self.points = value
6208
            self.validate_PointsType(self.points)    # validate type PointsType
6209
    def _buildChildren(self, child_, node, nodeName_, fromsubclass_=False, gds_collector_=None):
6210
        pass
6211
    def __hash__(self):
6212
        return hash(self.id)
6213
# end class GridPointsType
6214
6215
6216 View Code Duplication
class PrintSpaceType(GeneratedsSuper):
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
6217
    """PrintSpaceType --
6218
    Determines the effective area on the paper of a printed page.
6219
    Its size is equal for all pages of a book
6220
    (exceptions: titlepage, multipage pictures).
6221
    It contains all living elements (except marginals)
6222
    like body type, footnotes, headings, running titles.
6223
    It does not contain pagenumber (if not part of running title),
6224
    marginals, signature mark, preview words.
6225
    
6226
    """
6227
    __hash__ = GeneratedsSuper.__hash__
6228
    member_data_items_ = [
6229
        MemberSpec_('Coords', 'CoordsType', 0, 0, {'name': 'Coords', 'type': 'CoordsType'}, None),
6230
    ]
6231
    subclass = None
6232
    superclass = None
6233
    def __init__(self, Coords=None, gds_collector_=None, **kwargs_):
6234
        self.gds_collector_ = gds_collector_
6235
        self.gds_elementtree_node_ = None
6236
        self.original_tagname_ = None
6237
        self.parent_object_ = kwargs_.get('parent_object_')
6238
        self.ns_prefix_ = "pc"
6239
        self.Coords = Coords
6240
        self.Coords_nsprefix_ = "pc"
6241
    def factory(*args_, **kwargs_):
6242
        if CurrentSubclassModule_ is not None:
6243
            subclass = getSubclassFromModule_(
6244
                CurrentSubclassModule_, PrintSpaceType)
6245
            if subclass is not None:
6246
                return subclass(*args_, **kwargs_)
6247
        if PrintSpaceType.subclass:
6248
            return PrintSpaceType.subclass(*args_, **kwargs_)
6249
        else:
6250
            return PrintSpaceType(*args_, **kwargs_)
6251
    factory = staticmethod(factory)
6252
    def get_ns_prefix_(self):
6253
        return self.ns_prefix_
6254
    def set_ns_prefix_(self, ns_prefix):
6255
        self.ns_prefix_ = ns_prefix
6256
    def get_Coords(self):
6257
        return self.Coords
6258
    def set_Coords(self, Coords):
6259
        self.Coords = Coords
6260
    def has__content(self):
6261
        if (
6262
            self.Coords is not None
6263
        ):
6264
            return True
6265
        else:
6266
            return False
6267
    def export(self, outfile, level, namespaceprefix_='', namespacedef_='xmlns:pc="http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15"', name_='PrintSpaceType', pretty_print=True):
6268
        imported_ns_def_ = GenerateDSNamespaceDefs_.get('PrintSpaceType')
6269
        if imported_ns_def_ is not None:
6270
            namespacedef_ = imported_ns_def_
6271
        if pretty_print:
6272
            eol_ = '\n'
6273
        else:
6274
            eol_ = ''
6275
        if self.original_tagname_ is not None and name_ == 'PrintSpaceType':
6276
            name_ = self.original_tagname_
6277
        if UseCapturedNS_ and self.ns_prefix_:
6278
            namespaceprefix_ = self.ns_prefix_ + ':'
6279
        showIndent(outfile, level, pretty_print)
6280
        outfile.write('<%s%s%s' % (namespaceprefix_, name_, namespacedef_ and ' ' + namespacedef_ or '', ))
6281
        already_processed = set()
6282
        self._exportAttributes(outfile, level, already_processed, namespaceprefix_, name_='PrintSpaceType')
6283
        if self.has__content():
6284
            outfile.write('>%s' % (eol_, ))
6285
            self._exportChildren(outfile, level + 1, namespaceprefix_, namespacedef_, name_='PrintSpaceType', pretty_print=pretty_print)
6286
            showIndent(outfile, level, pretty_print)
6287
            outfile.write('</%s%s>%s' % (namespaceprefix_, name_, eol_))
6288
        else:
6289
            outfile.write('/>%s' % (eol_, ))
6290
    def _exportAttributes(self, outfile, level, already_processed, namespaceprefix_='', name_='PrintSpaceType'):
6291
        pass
6292
    def _exportChildren(self, outfile, level, namespaceprefix_='', namespacedef_='xmlns:pc="http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15"', name_='PrintSpaceType', fromsubclass_=False, pretty_print=True):
6293
        if pretty_print:
6294
            eol_ = '\n'
6295
        else:
6296
            eol_ = ''
6297
        if self.Coords is not None:
6298
            namespaceprefix_ = self.Coords_nsprefix_ + ':' if (UseCapturedNS_ and self.Coords_nsprefix_) else ''
6299
            self.Coords.export(outfile, level, namespaceprefix_, namespacedef_='', name_='Coords', pretty_print=pretty_print)
6300
    def to_etree(self, parent_element=None, name_='PrintSpaceType', mapping_=None, reverse_mapping_=None, nsmap_=None):
6301
        if parent_element is None:
6302
            element = etree_.Element('{http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15}' + name_, nsmap=nsmap_)
6303
        else:
6304
            element = etree_.SubElement(parent_element, '{http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15}' + name_, nsmap=nsmap_)
6305
        if self.Coords is not None:
6306
            Coords_ = self.Coords
6307
            Coords_.to_etree(element, name_='Coords', mapping_=mapping_, reverse_mapping_=reverse_mapping_, nsmap_=nsmap_)
6308
        if mapping_ is not None:
6309
            mapping_[id(self)] = element
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable id does not seem to be defined.
Loading history...
6310
        if reverse_mapping_ is not None:
6311
            reverse_mapping_[element] = self
6312
        return element
6313
    def build(self, node, gds_collector_=None):
6314
        self.gds_collector_ = gds_collector_
6315
        if SaveElementTreeNode:
6316
            self.gds_elementtree_node_ = node
6317
        already_processed = set()
6318
        self.ns_prefix_ = node.prefix
6319
        self._buildAttributes(node, node.attrib, already_processed)
6320
        for child in node:
6321
            nodeName_ = Tag_pattern_.match(child.tag).groups()[-1]
6322
            self._buildChildren(child, node, nodeName_, gds_collector_=gds_collector_)
6323
        return self
6324
    def _buildAttributes(self, node, attrs, already_processed):
6325
        pass
6326
    def _buildChildren(self, child_, node, nodeName_, fromsubclass_=False, gds_collector_=None):
6327
        if nodeName_ == 'Coords':
6328
            obj_ = CoordsType.factory(parent_object_=self)
6329
            obj_.build(child_, gds_collector_=gds_collector_)
6330
            self.Coords = obj_
6331
            obj_.original_tagname_ = 'Coords'
6332
    def __hash__(self):
6333
        return hash(self.id)
6334
# end class PrintSpaceType
6335
6336
6337
class ReadingOrderType(GeneratedsSuper):
6338
    """ReadingOrderType --
6339
    Definition of the reading order within the page.
6340
    To express a reading order between elements
6341
    they have to be included in an OrderedGroup.
6342
    Groups may contain further groups.
6343
      
6344
    * conf -- Confidence value (between 0 and 1)
6345
    
6346
    """
6347
    __hash__ = GeneratedsSuper.__hash__
6348
    member_data_items_ = [
6349
        MemberSpec_('conf', 'pc:ConfSimpleType', 0, 1, {'use': 'optional', 'name': 'conf'}),
6350
        MemberSpec_('OrderedGroup', 'OrderedGroupType', 0, 0, {'name': 'OrderedGroup', 'type': 'OrderedGroupType'}, 2),
6351
        MemberSpec_('UnorderedGroup', 'UnorderedGroupType', 0, 0, {'name': 'UnorderedGroup', 'type': 'UnorderedGroupType'}, 2),
6352
    ]
6353
    subclass = None
6354
    superclass = None
6355
    def __init__(self, conf=None, OrderedGroup=None, UnorderedGroup=None, gds_collector_=None, **kwargs_):
6356
        self.gds_collector_ = gds_collector_
6357
        self.gds_elementtree_node_ = None
6358
        self.original_tagname_ = None
6359
        self.parent_object_ = kwargs_.get('parent_object_')
6360
        self.ns_prefix_ = "pc"
6361
        self.conf = _cast(float, conf)
6362
        self.conf_nsprefix_ = "pc"
6363
        self.OrderedGroup = OrderedGroup
6364
        self.OrderedGroup_nsprefix_ = "pc"
6365
        self.UnorderedGroup = UnorderedGroup
6366
        self.UnorderedGroup_nsprefix_ = "pc"
6367
    def factory(*args_, **kwargs_):
6368
        if CurrentSubclassModule_ is not None:
6369
            subclass = getSubclassFromModule_(
6370
                CurrentSubclassModule_, ReadingOrderType)
6371
            if subclass is not None:
6372
                return subclass(*args_, **kwargs_)
6373
        if ReadingOrderType.subclass:
6374
            return ReadingOrderType.subclass(*args_, **kwargs_)
6375
        else:
6376
            return ReadingOrderType(*args_, **kwargs_)
6377
    factory = staticmethod(factory)
6378
    def get_ns_prefix_(self):
6379
        return self.ns_prefix_
6380
    def set_ns_prefix_(self, ns_prefix):
6381
        self.ns_prefix_ = ns_prefix
6382
    def get_OrderedGroup(self):
6383
        return self.OrderedGroup
6384
    def set_OrderedGroup(self, OrderedGroup):
6385
        self.OrderedGroup = OrderedGroup
6386
    def get_UnorderedGroup(self):
6387
        return self.UnorderedGroup
6388
    def set_UnorderedGroup(self, UnorderedGroup):
6389
        self.UnorderedGroup = UnorderedGroup
6390
    def get_conf(self):
6391
        return self.conf
6392
    def set_conf(self, conf):
6393
        self.conf = conf
6394 View Code Duplication
    def validate_ConfSimpleType(self, value):
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
6395
        # Validate type pc:ConfSimpleType, a restriction on float.
6396
        if value is not None and Validate_simpletypes_ and self.gds_collector_ is not None:
6397
            if not isinstance(value, float):
6398
                lineno = self.gds_get_node_lineno_()
6399
                self.gds_collector_.add_message('Value "%(value)s"%(lineno)s is not of the correct base simple type (float)' % {"value": value, "lineno": lineno, })
6400
                return False
6401
            if value < 0:
6402
                lineno = self.gds_get_node_lineno_()
6403
                self.gds_collector_.add_message('Value "%(value)s"%(lineno)s does not match xsd minInclusive restriction on ConfSimpleType' % {"value": value, "lineno": lineno} )
6404
                result = False
6405
            if value > 1:
6406
                lineno = self.gds_get_node_lineno_()
6407
                self.gds_collector_.add_message('Value "%(value)s"%(lineno)s does not match xsd maxInclusive restriction on ConfSimpleType' % {"value": value, "lineno": lineno} )
6408
                result = False
6409
    def has__content(self):
6410
        if (
6411
            self.OrderedGroup is not None or
6412
            self.UnorderedGroup is not None
6413
        ):
6414
            return True
6415
        else:
6416
            return False
6417
    def export(self, outfile, level, namespaceprefix_='', namespacedef_='xmlns:pc="http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15"', name_='ReadingOrderType', pretty_print=True):
6418
        imported_ns_def_ = GenerateDSNamespaceDefs_.get('ReadingOrderType')
6419
        if imported_ns_def_ is not None:
6420
            namespacedef_ = imported_ns_def_
6421
        if pretty_print:
6422
            eol_ = '\n'
6423
        else:
6424
            eol_ = ''
6425
        if self.original_tagname_ is not None and name_ == 'ReadingOrderType':
6426
            name_ = self.original_tagname_
6427
        if UseCapturedNS_ and self.ns_prefix_:
6428
            namespaceprefix_ = self.ns_prefix_ + ':'
6429
        showIndent(outfile, level, pretty_print)
6430
        outfile.write('<%s%s%s' % (namespaceprefix_, name_, namespacedef_ and ' ' + namespacedef_ or '', ))
6431
        already_processed = set()
6432
        self._exportAttributes(outfile, level, already_processed, namespaceprefix_, name_='ReadingOrderType')
6433
        if self.has__content():
6434
            outfile.write('>%s' % (eol_, ))
6435
            self._exportChildren(outfile, level + 1, namespaceprefix_, namespacedef_, name_='ReadingOrderType', pretty_print=pretty_print)
6436
            showIndent(outfile, level, pretty_print)
6437
            outfile.write('</%s%s>%s' % (namespaceprefix_, name_, eol_))
6438
        else:
6439
            outfile.write('/>%s' % (eol_, ))
6440
    def _exportAttributes(self, outfile, level, already_processed, namespaceprefix_='', name_='ReadingOrderType'):
6441
        if self.conf is not None and 'conf' not in already_processed:
6442
            already_processed.add('conf')
6443
            outfile.write(' conf="%s"' % self.gds_format_float(self.conf, input_name='conf'))
6444
    def _exportChildren(self, outfile, level, namespaceprefix_='', namespacedef_='xmlns:pc="http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15"', name_='ReadingOrderType', fromsubclass_=False, pretty_print=True):
6445
        if pretty_print:
6446
            eol_ = '\n'
6447
        else:
6448
            eol_ = ''
6449
        if self.OrderedGroup is not None:
6450
            namespaceprefix_ = self.OrderedGroup_nsprefix_ + ':' if (UseCapturedNS_ and self.OrderedGroup_nsprefix_) else ''
6451
            self.OrderedGroup.export(outfile, level, namespaceprefix_, namespacedef_='', name_='OrderedGroup', pretty_print=pretty_print)
6452
        if self.UnorderedGroup is not None:
6453
            namespaceprefix_ = self.UnorderedGroup_nsprefix_ + ':' if (UseCapturedNS_ and self.UnorderedGroup_nsprefix_) else ''
6454
            self.UnorderedGroup.export(outfile, level, namespaceprefix_, namespacedef_='', name_='UnorderedGroup', pretty_print=pretty_print)
6455
    def to_etree(self, parent_element=None, name_='ReadingOrderType', mapping_=None, reverse_mapping_=None, nsmap_=None):
6456
        if parent_element is None:
6457
            element = etree_.Element('{http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15}' + name_, nsmap=nsmap_)
6458
        else:
6459
            element = etree_.SubElement(parent_element, '{http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15}' + name_, nsmap=nsmap_)
6460
        if self.conf is not None:
6461
            element.set('conf', self.gds_format_float(self.conf))
6462
        if self.OrderedGroup is not None:
6463
            OrderedGroup_ = self.OrderedGroup
6464
            OrderedGroup_.to_etree(element, name_='OrderedGroup', mapping_=mapping_, reverse_mapping_=reverse_mapping_, nsmap_=nsmap_)
6465
        if self.UnorderedGroup is not None:
6466
            UnorderedGroup_ = self.UnorderedGroup
6467
            UnorderedGroup_.to_etree(element, name_='UnorderedGroup', mapping_=mapping_, reverse_mapping_=reverse_mapping_, nsmap_=nsmap_)
6468
        if mapping_ is not None:
6469
            mapping_[id(self)] = element
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable id does not seem to be defined.
Loading history...
6470
        if reverse_mapping_ is not None:
6471
            reverse_mapping_[element] = self
6472
        return element
6473
    def build(self, node, gds_collector_=None):
6474
        self.gds_collector_ = gds_collector_
6475
        if SaveElementTreeNode:
6476
            self.gds_elementtree_node_ = node
6477
        already_processed = set()
6478
        self.ns_prefix_ = node.prefix
6479
        self._buildAttributes(node, node.attrib, already_processed)
6480
        for child in node:
6481
            nodeName_ = Tag_pattern_.match(child.tag).groups()[-1]
6482
            self._buildChildren(child, node, nodeName_, gds_collector_=gds_collector_)
6483
        return self
6484
    def _buildAttributes(self, node, attrs, already_processed):
6485
        value = find_attr_value_('conf', node)
6486
        if value is not None and 'conf' not in already_processed:
6487
            already_processed.add('conf')
6488
            value = self.gds_parse_float(value, node, 'conf')
6489
            self.conf = value
6490
            self.validate_ConfSimpleType(self.conf)    # validate type ConfSimpleType
6491
    def _buildChildren(self, child_, node, nodeName_, fromsubclass_=False, gds_collector_=None):
6492
        if nodeName_ == 'OrderedGroup':
6493
            obj_ = OrderedGroupType.factory(parent_object_=self)
6494
            obj_.build(child_, gds_collector_=gds_collector_)
6495
            self.OrderedGroup = obj_
6496
            obj_.original_tagname_ = 'OrderedGroup'
6497
        elif nodeName_ == 'UnorderedGroup':
6498
            obj_ = UnorderedGroupType.factory(parent_object_=self)
6499
            obj_.build(child_, gds_collector_=gds_collector_)
6500
            self.UnorderedGroup = obj_
6501
            obj_.original_tagname_ = 'UnorderedGroup'
6502
    def __hash__(self):
6503
        return hash(self.id)
6504
# end class ReadingOrderType
6505
6506
6507
class RegionRefIndexedType(GeneratedsSuper):
6508
    """RegionRefIndexedType -- Numbered region
6509
    index -- Position (order number) of this item within the current hierarchy level.
6510
    
6511
    """
6512
    __hash__ = GeneratedsSuper.__hash__
6513
    member_data_items_ = [
6514
        MemberSpec_('index', 'int', 0, 0, {'use': 'required', 'name': 'index'}),
6515
        MemberSpec_('regionRef', 'string', 0, 0, {'use': 'required', 'name': 'regionRef'}),
6516
    ]
6517
    subclass = None
6518
    superclass = None
6519
    def __init__(self, index=None, regionRef=None, gds_collector_=None, **kwargs_):
6520
        self.gds_collector_ = gds_collector_
6521
        self.gds_elementtree_node_ = None
6522
        self.original_tagname_ = None
6523
        self.parent_object_ = kwargs_.get('parent_object_')
6524
        self.ns_prefix_ = "pc"
6525
        self.index = _cast(int, index)
6526
        self.index_nsprefix_ = "pc"
6527
        self.regionRef = _cast(None, regionRef)
6528
        self.regionRef_nsprefix_ = "pc"
6529
    def factory(*args_, **kwargs_):
6530
        if CurrentSubclassModule_ is not None:
6531
            subclass = getSubclassFromModule_(
6532
                CurrentSubclassModule_, RegionRefIndexedType)
6533
            if subclass is not None:
6534
                return subclass(*args_, **kwargs_)
6535
        if RegionRefIndexedType.subclass:
6536
            return RegionRefIndexedType.subclass(*args_, **kwargs_)
6537
        else:
6538
            return RegionRefIndexedType(*args_, **kwargs_)
6539
    factory = staticmethod(factory)
6540
    def get_ns_prefix_(self):
6541
        return self.ns_prefix_
6542
    def set_ns_prefix_(self, ns_prefix):
6543
        self.ns_prefix_ = ns_prefix
6544
    def get_index(self):
6545
        return self.index
6546
    def set_index(self, index):
6547
        self.index = index
6548
    def get_regionRef(self):
6549
        return self.regionRef
6550
    def set_regionRef(self, regionRef):
6551
        self.regionRef = regionRef
6552
    def has__content(self):
6553
        if (
6554
6555
        ):
6556
            return True
6557
        else:
6558
            return False
6559
    def export(self, outfile, level, namespaceprefix_='', namespacedef_='xmlns:pc="http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15"', name_='RegionRefIndexedType', pretty_print=True):
6560
        imported_ns_def_ = GenerateDSNamespaceDefs_.get('RegionRefIndexedType')
6561
        if imported_ns_def_ is not None:
6562
            namespacedef_ = imported_ns_def_
6563
        if pretty_print:
6564
            eol_ = '\n'
6565
        else:
6566
            eol_ = ''
6567
        if self.original_tagname_ is not None and name_ == 'RegionRefIndexedType':
6568
            name_ = self.original_tagname_
6569
        if UseCapturedNS_ and self.ns_prefix_:
6570
            namespaceprefix_ = self.ns_prefix_ + ':'
6571
        showIndent(outfile, level, pretty_print)
6572
        outfile.write('<%s%s%s' % (namespaceprefix_, name_, namespacedef_ and ' ' + namespacedef_ or '', ))
6573
        already_processed = set()
6574
        self._exportAttributes(outfile, level, already_processed, namespaceprefix_, name_='RegionRefIndexedType')
6575
        if self.has__content():
6576
            outfile.write('>%s' % (eol_, ))
6577
            self._exportChildren(outfile, level + 1, namespaceprefix_, namespacedef_, name_='RegionRefIndexedType', pretty_print=pretty_print)
6578
            outfile.write('</%s%s>%s' % (namespaceprefix_, name_, eol_))
6579
        else:
6580
            outfile.write('/>%s' % (eol_, ))
6581
    def _exportAttributes(self, outfile, level, already_processed, namespaceprefix_='', name_='RegionRefIndexedType'):
6582
        if self.index is not None and 'index' not in already_processed:
6583
            already_processed.add('index')
6584
            outfile.write(' index="%s"' % self.gds_format_integer(self.index, input_name='index'))
6585
        if self.regionRef is not None and 'regionRef' not in already_processed:
6586
            already_processed.add('regionRef')
6587
            outfile.write(' regionRef=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.regionRef), input_name='regionRef')), ))
6588
    def _exportChildren(self, outfile, level, namespaceprefix_='', namespacedef_='xmlns:pc="http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15"', name_='RegionRefIndexedType', fromsubclass_=False, pretty_print=True):
6589
        pass
6590 View Code Duplication
    def to_etree(self, parent_element=None, name_='RegionRefIndexedType', mapping_=None, reverse_mapping_=None, nsmap_=None):
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
6591
        if parent_element is None:
6592
            element = etree_.Element('{http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15}' + name_, nsmap=nsmap_)
6593
        else:
6594
            element = etree_.SubElement(parent_element, '{http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15}' + name_, nsmap=nsmap_)
6595
        if self.index is not None:
6596
            element.set('index', self.gds_format_integer(self.index))
6597
        if self.regionRef is not None:
6598
            element.set('regionRef', self.gds_format_string(self.regionRef))
6599
        if mapping_ is not None:
6600
            mapping_[id(self)] = element
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable id does not seem to be defined.
Loading history...
6601
        if reverse_mapping_ is not None:
6602
            reverse_mapping_[element] = self
6603
        return element
6604
    def build(self, node, gds_collector_=None):
6605
        self.gds_collector_ = gds_collector_
6606
        if SaveElementTreeNode:
6607
            self.gds_elementtree_node_ = node
6608
        already_processed = set()
6609
        self.ns_prefix_ = node.prefix
6610
        self._buildAttributes(node, node.attrib, already_processed)
6611
        for child in node:
6612
            nodeName_ = Tag_pattern_.match(child.tag).groups()[-1]
6613
            self._buildChildren(child, node, nodeName_, gds_collector_=gds_collector_)
6614
        return self
6615
    def _buildAttributes(self, node, attrs, already_processed):
6616
        value = find_attr_value_('index', node)
6617
        if value is not None and 'index' not in already_processed:
6618
            already_processed.add('index')
6619
            self.index = self.gds_parse_integer(value, node, 'index')
6620
        value = find_attr_value_('regionRef', node)
6621
        if value is not None and 'regionRef' not in already_processed:
6622
            already_processed.add('regionRef')
6623
            self.regionRef = value
6624
    def _buildChildren(self, child_, node, nodeName_, fromsubclass_=False, gds_collector_=None):
6625
        pass
6626
    def __hash__(self):
6627
        return hash(self.id)
6628
# end class RegionRefIndexedType
6629
6630
6631
class OrderedGroupIndexedType(GeneratedsSuper):
6632
    """OrderedGroupIndexedType --
6633
    Indexed group containing ordered elements
6634
      
6635
    * regionRef --
6636
      Optional link to a parent region of nested regions.
6637
      The parent region doubles as reading order group.
6638
      Only the nested regions should be allowed as group members.
6639
      
6640
    * index --
6641
      Position (order number) of this item within the
6642
      current hierarchy level.
6643
      
6644
    * continuation --
6645
      Is this group a continuation of another group (from
6646
      previous column or page, for example)?
6647
      
6648
    * custom -- For generic use
6649
    * Labels -- Semantic labels / tags
6650
    
6651
    """
6652
    __hash__ = GeneratedsSuper.__hash__
6653
    member_data_items_ = [
6654
        MemberSpec_('id', 'string', 0, 0, {'use': 'required', 'name': 'id'}),
6655
        MemberSpec_('regionRef', 'string', 0, 1, {'use': 'optional', 'name': 'regionRef'}),
6656
        MemberSpec_('index', 'int', 0, 0, {'use': 'required', 'name': 'index'}),
6657
        MemberSpec_('caption', 'string', 0, 1, {'use': 'optional', 'name': 'caption'}),
6658
        MemberSpec_('type_', 'pc:GroupTypeSimpleType', 0, 1, {'use': 'optional', 'name': 'type_'}),
6659
        MemberSpec_('continuation', 'boolean', 0, 1, {'use': 'optional', 'name': 'continuation'}),
6660
        MemberSpec_('custom', 'string', 0, 1, {'use': 'optional', 'name': 'custom'}),
6661
        MemberSpec_('comments', 'string', 0, 1, {'use': 'optional', 'name': 'comments'}),
6662
        MemberSpec_('UserDefined', 'UserDefinedType', 0, 1, {'maxOccurs': '1', 'minOccurs': '0', 'name': 'UserDefined', 'type': 'UserDefinedType'}, None),
6663
        MemberSpec_('Labels', 'LabelsType', 1, 1, {'maxOccurs': 'unbounded', 'minOccurs': '0', 'name': 'Labels', 'type': 'LabelsType'}, None),
6664
        MemberSpec_('RegionRefIndexed', 'RegionRefIndexedType', 1, 0, {'name': 'RegionRefIndexed', 'type': 'RegionRefIndexedType'}, 3),
6665
        MemberSpec_('OrderedGroupIndexed', 'OrderedGroupIndexedType', 1, 0, {'name': 'OrderedGroupIndexed', 'type': 'OrderedGroupIndexedType'}, 3),
6666
        MemberSpec_('UnorderedGroupIndexed', 'UnorderedGroupIndexedType', 1, 0, {'name': 'UnorderedGroupIndexed', 'type': 'UnorderedGroupIndexedType'}, 3),
6667
    ]
6668
    subclass = None
6669
    superclass = None
6670 View Code Duplication
    def __init__(self, id=None, regionRef=None, index=None, caption=None, type_=None, continuation=None, custom=None, comments=None, UserDefined=None, Labels=None, RegionRefIndexed=None, OrderedGroupIndexed=None, UnorderedGroupIndexed=None, gds_collector_=None, **kwargs_):
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
6671
        self.gds_collector_ = gds_collector_
6672
        self.gds_elementtree_node_ = None
6673
        self.original_tagname_ = None
6674
        self.parent_object_ = kwargs_.get('parent_object_')
6675
        self.ns_prefix_ = "pc"
6676
        self.id = _cast(None, id)
6677
        self.id_nsprefix_ = "pc"
6678
        self.regionRef = _cast(None, regionRef)
6679
        self.regionRef_nsprefix_ = "pc"
6680
        self.index = _cast(int, index)
6681
        self.index_nsprefix_ = "pc"
6682
        self.caption = _cast(None, caption)
6683
        self.caption_nsprefix_ = "pc"
6684
        self.type_ = _cast(None, type_)
6685
        self.type__nsprefix_ = "pc"
6686
        self.continuation = _cast(bool, continuation)
6687
        self.continuation_nsprefix_ = "pc"
6688
        self.custom = _cast(None, custom)
6689
        self.custom_nsprefix_ = "pc"
6690
        self.comments = _cast(None, comments)
6691
        self.comments_nsprefix_ = "pc"
6692
        self.UserDefined = UserDefined
6693
        self.UserDefined_nsprefix_ = "pc"
6694
        if Labels is None:
6695
            self.Labels = []
6696
        else:
6697
            self.Labels = Labels
6698
        self.Labels_nsprefix_ = "pc"
6699
        if RegionRefIndexed is None:
6700
            self.RegionRefIndexed = []
6701
        else:
6702
            self.RegionRefIndexed = RegionRefIndexed
6703
        self.RegionRefIndexed_nsprefix_ = "pc"
6704
        if OrderedGroupIndexed is None:
6705
            self.OrderedGroupIndexed = []
6706
        else:
6707
            self.OrderedGroupIndexed = OrderedGroupIndexed
6708
        self.OrderedGroupIndexed_nsprefix_ = "pc"
6709
        if UnorderedGroupIndexed is None:
6710
            self.UnorderedGroupIndexed = []
6711
        else:
6712
            self.UnorderedGroupIndexed = UnorderedGroupIndexed
6713
        self.UnorderedGroupIndexed_nsprefix_ = "pc"
6714
    def factory(*args_, **kwargs_):
6715
        if CurrentSubclassModule_ is not None:
6716
            subclass = getSubclassFromModule_(
6717
                CurrentSubclassModule_, OrderedGroupIndexedType)
6718
            if subclass is not None:
6719
                return subclass(*args_, **kwargs_)
6720
        if OrderedGroupIndexedType.subclass:
6721
            return OrderedGroupIndexedType.subclass(*args_, **kwargs_)
6722
        else:
6723
            return OrderedGroupIndexedType(*args_, **kwargs_)
6724
    factory = staticmethod(factory)
6725
    def get_ns_prefix_(self):
6726
        return self.ns_prefix_
6727
    def set_ns_prefix_(self, ns_prefix):
6728
        self.ns_prefix_ = ns_prefix
6729
    def get_UserDefined(self):
6730
        return self.UserDefined
6731
    def set_UserDefined(self, UserDefined):
6732
        self.UserDefined = UserDefined
6733
    def get_Labels(self):
6734
        return self.Labels
6735
    def set_Labels(self, Labels):
6736
        self.Labels = Labels
6737
    def add_Labels(self, value):
6738
        self.Labels.append(value)
6739
    def insert_Labels_at(self, index, value):
6740
        self.Labels.insert(index, value)
6741
    def replace_Labels_at(self, index, value):
6742
        self.Labels[index] = value
6743
    def get_RegionRefIndexed(self):
6744
        return self.RegionRefIndexed
6745
    def set_RegionRefIndexed(self, RegionRefIndexed):
6746
        self.RegionRefIndexed = RegionRefIndexed
6747
    def add_RegionRefIndexed(self, value):
6748
        self.RegionRefIndexed.append(value)
6749
    def insert_RegionRefIndexed_at(self, index, value):
6750
        self.RegionRefIndexed.insert(index, value)
6751
    def replace_RegionRefIndexed_at(self, index, value):
6752
        self.RegionRefIndexed[index] = value
6753
    def get_OrderedGroupIndexed(self):
6754
        return self.OrderedGroupIndexed
6755
    def set_OrderedGroupIndexed(self, OrderedGroupIndexed):
6756
        self.OrderedGroupIndexed = OrderedGroupIndexed
6757
    def add_OrderedGroupIndexed(self, value):
6758
        self.OrderedGroupIndexed.append(value)
6759
    def insert_OrderedGroupIndexed_at(self, index, value):
6760
        self.OrderedGroupIndexed.insert(index, value)
6761
    def replace_OrderedGroupIndexed_at(self, index, value):
6762
        self.OrderedGroupIndexed[index] = value
6763
    def get_UnorderedGroupIndexed(self):
6764
        return self.UnorderedGroupIndexed
6765
    def set_UnorderedGroupIndexed(self, UnorderedGroupIndexed):
6766
        self.UnorderedGroupIndexed = UnorderedGroupIndexed
6767
    def add_UnorderedGroupIndexed(self, value):
6768
        self.UnorderedGroupIndexed.append(value)
6769
    def insert_UnorderedGroupIndexed_at(self, index, value):
6770
        self.UnorderedGroupIndexed.insert(index, value)
6771
    def replace_UnorderedGroupIndexed_at(self, index, value):
6772
        self.UnorderedGroupIndexed[index] = value
6773
    def get_id(self):
6774
        return self.id
6775
    def set_id(self, id):
6776
        self.id = id
6777
    def get_regionRef(self):
6778
        return self.regionRef
6779
    def set_regionRef(self, regionRef):
6780
        self.regionRef = regionRef
6781
    def get_index(self):
6782
        return self.index
6783
    def set_index(self, index):
6784
        self.index = index
6785
    def get_caption(self):
6786
        return self.caption
6787
    def set_caption(self, caption):
6788
        self.caption = caption
6789
    def get_type(self):
6790
        return self.type_
6791
    def set_type(self, type_):
6792
        self.type_ = type_
6793
    def get_continuation(self):
6794
        return self.continuation
6795
    def set_continuation(self, continuation):
6796
        self.continuation = continuation
6797
    def get_custom(self):
6798
        return self.custom
6799
    def set_custom(self, custom):
6800
        self.custom = custom
6801
    def get_comments(self):
6802
        return self.comments
6803
    def set_comments(self, comments):
6804
        self.comments = comments
6805
    def validate_GroupTypeSimpleType(self, value):
6806
        # Validate type pc:GroupTypeSimpleType, a restriction on string.
6807
        if value is not None and Validate_simpletypes_ and self.gds_collector_ is not None:
6808
            if not isinstance(value, str):
6809
                lineno = self.gds_get_node_lineno_()
6810
                self.gds_collector_.add_message('Value "%(value)s"%(lineno)s is not of the correct base simple type (str)' % {"value": value, "lineno": lineno, })
6811
                return False
6812
            value = value
6813
            enumerations = ['paragraph', 'list', 'list-item', 'figure', 'article', 'div', 'other']
6814
            if value not in enumerations:
6815
                lineno = self.gds_get_node_lineno_()
6816
                self.gds_collector_.add_message('Value "%(value)s"%(lineno)s does not match xsd enumeration restriction on GroupTypeSimpleType' % {"value" : encode_str_2_3(value), "lineno": lineno} )
6817
                result = False
6818
    def has__content(self):
6819
        if (
6820
            self.UserDefined is not None or
6821
            self.Labels or
6822
            self.RegionRefIndexed or
6823
            self.OrderedGroupIndexed or
6824
            self.UnorderedGroupIndexed
6825
        ):
6826
            return True
6827
        else:
6828
            return False
6829
    def export(self, outfile, level, namespaceprefix_='', namespacedef_='xmlns:pc="http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15"', name_='OrderedGroupIndexedType', pretty_print=True):
6830
        imported_ns_def_ = GenerateDSNamespaceDefs_.get('OrderedGroupIndexedType')
6831
        if imported_ns_def_ is not None:
6832
            namespacedef_ = imported_ns_def_
6833
        if pretty_print:
6834
            eol_ = '\n'
6835
        else:
6836
            eol_ = ''
6837
        if self.original_tagname_ is not None and name_ == 'OrderedGroupIndexedType':
6838
            name_ = self.original_tagname_
6839
        if UseCapturedNS_ and self.ns_prefix_:
6840
            namespaceprefix_ = self.ns_prefix_ + ':'
6841
        showIndent(outfile, level, pretty_print)
6842
        outfile.write('<%s%s%s' % (namespaceprefix_, name_, namespacedef_ and ' ' + namespacedef_ or '', ))
6843
        already_processed = set()
6844
        self._exportAttributes(outfile, level, already_processed, namespaceprefix_, name_='OrderedGroupIndexedType')
6845
        if self.has__content():
6846
            outfile.write('>%s' % (eol_, ))
6847
            self._exportChildren(outfile, level + 1, namespaceprefix_, namespacedef_, name_='OrderedGroupIndexedType', pretty_print=pretty_print)
6848
            showIndent(outfile, level, pretty_print)
6849
            outfile.write('</%s%s>%s' % (namespaceprefix_, name_, eol_))
6850
        else:
6851
            outfile.write('/>%s' % (eol_, ))
6852 View Code Duplication
    def _exportAttributes(self, outfile, level, already_processed, namespaceprefix_='', name_='OrderedGroupIndexedType'):
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
6853
        if self.id is not None and 'id' not in already_processed:
6854
            already_processed.add('id')
6855
            outfile.write(' id=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.id), input_name='id')), ))
6856
        if self.regionRef is not None and 'regionRef' not in already_processed:
6857
            already_processed.add('regionRef')
6858
            outfile.write(' regionRef=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.regionRef), input_name='regionRef')), ))
6859
        if self.index is not None and 'index' not in already_processed:
6860
            already_processed.add('index')
6861
            outfile.write(' index="%s"' % self.gds_format_integer(self.index, input_name='index'))
6862
        if self.caption is not None and 'caption' not in already_processed:
6863
            already_processed.add('caption')
6864
            outfile.write(' caption=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.caption), input_name='caption')), ))
6865
        if self.type_ is not None and 'type_' not in already_processed:
6866
            already_processed.add('type_')
6867
            outfile.write(' type=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.type_), input_name='type')), ))
6868
        if self.continuation is not None and 'continuation' not in already_processed:
6869
            already_processed.add('continuation')
6870
            outfile.write(' continuation="%s"' % self.gds_format_boolean(self.continuation, input_name='continuation'))
6871
        if self.custom is not None and 'custom' not in already_processed:
6872
            already_processed.add('custom')
6873
            outfile.write(' custom=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.custom), input_name='custom')), ))
6874
        if self.comments is not None and 'comments' not in already_processed:
6875
            already_processed.add('comments')
6876
            outfile.write(' comments=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.comments), input_name='comments')), ))
6877 View Code Duplication
    def _exportChildren(self, outfile, level, namespaceprefix_='', namespacedef_='xmlns:pc="http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15"', name_='OrderedGroupIndexedType', fromsubclass_=False, pretty_print=True):
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
6878
        if pretty_print:
6879
            eol_ = '\n'
6880
        else:
6881
            eol_ = ''
6882
        if self.UserDefined is not None:
6883
            namespaceprefix_ = self.UserDefined_nsprefix_ + ':' if (UseCapturedNS_ and self.UserDefined_nsprefix_) else ''
6884
            self.UserDefined.export(outfile, level, namespaceprefix_, namespacedef_='', name_='UserDefined', pretty_print=pretty_print)
6885
        for Labels_ in self.Labels:
6886
            namespaceprefix_ = self.Labels_nsprefix_ + ':' if (UseCapturedNS_ and self.Labels_nsprefix_) else ''
6887
            Labels_.export(outfile, level, namespaceprefix_, namespacedef_='', name_='Labels', pretty_print=pretty_print)
6888
        for RegionRefIndexed_ in self.RegionRefIndexed:
6889
            namespaceprefix_ = self.RegionRefIndexed_nsprefix_ + ':' if (UseCapturedNS_ and self.RegionRefIndexed_nsprefix_) else ''
6890
            RegionRefIndexed_.export(outfile, level, namespaceprefix_, namespacedef_='', name_='RegionRefIndexed', pretty_print=pretty_print)
6891
        for OrderedGroupIndexed_ in self.OrderedGroupIndexed:
6892
            namespaceprefix_ = self.OrderedGroupIndexed_nsprefix_ + ':' if (UseCapturedNS_ and self.OrderedGroupIndexed_nsprefix_) else ''
6893
            OrderedGroupIndexed_.export(outfile, level, namespaceprefix_, namespacedef_='', name_='OrderedGroupIndexed', pretty_print=pretty_print)
6894
        for UnorderedGroupIndexed_ in self.UnorderedGroupIndexed:
6895
            namespaceprefix_ = self.UnorderedGroupIndexed_nsprefix_ + ':' if (UseCapturedNS_ and self.UnorderedGroupIndexed_nsprefix_) else ''
6896
            UnorderedGroupIndexed_.export(outfile, level, namespaceprefix_, namespacedef_='', name_='UnorderedGroupIndexed', pretty_print=pretty_print)
6897 View Code Duplication
    def to_etree(self, parent_element=None, name_='OrderedGroupIndexedType', mapping_=None, reverse_mapping_=None, nsmap_=None):
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
6898
        if parent_element is None:
6899
            element = etree_.Element('{http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15}' + name_, nsmap=nsmap_)
6900
        else:
6901
            element = etree_.SubElement(parent_element, '{http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15}' + name_, nsmap=nsmap_)
6902
        if self.id is not None:
6903
            element.set('id', self.gds_format_string(self.id))
6904
        if self.regionRef is not None:
6905
            element.set('regionRef', self.gds_format_string(self.regionRef))
6906
        if self.index is not None:
6907
            element.set('index', self.gds_format_integer(self.index))
6908
        if self.caption is not None:
6909
            element.set('caption', self.gds_format_string(self.caption))
6910
        if self.type_ is not None:
6911
            element.set('type', self.gds_format_string(self.type_))
6912
        if self.continuation is not None:
6913
            element.set('continuation', self.gds_format_boolean(self.continuation))
6914
        if self.custom is not None:
6915
            element.set('custom', self.gds_format_string(self.custom))
6916
        if self.comments is not None:
6917
            element.set('comments', self.gds_format_string(self.comments))
6918
        if self.UserDefined is not None:
6919
            UserDefined_ = self.UserDefined
6920
            UserDefined_.to_etree(element, name_='UserDefined', mapping_=mapping_, reverse_mapping_=reverse_mapping_, nsmap_=nsmap_)
6921
        for Labels_ in self.Labels:
6922
            Labels_.to_etree(element, name_='Labels', mapping_=mapping_, reverse_mapping_=reverse_mapping_, nsmap_=nsmap_)
6923
        for RegionRefIndexed_ in self.RegionRefIndexed:
6924
            RegionRefIndexed_.to_etree(element, name_='RegionRefIndexed', mapping_=mapping_, reverse_mapping_=reverse_mapping_, nsmap_=nsmap_)
6925
        for OrderedGroupIndexed_ in self.OrderedGroupIndexed:
6926
            OrderedGroupIndexed_.to_etree(element, name_='OrderedGroupIndexed', mapping_=mapping_, reverse_mapping_=reverse_mapping_, nsmap_=nsmap_)
6927
        for UnorderedGroupIndexed_ in self.UnorderedGroupIndexed:
6928
            UnorderedGroupIndexed_.to_etree(element, name_='UnorderedGroupIndexed', mapping_=mapping_, reverse_mapping_=reverse_mapping_, nsmap_=nsmap_)
6929
        if mapping_ is not None:
6930
            mapping_[id(self)] = element
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable id does not seem to be defined.
Loading history...
6931
        if reverse_mapping_ is not None:
6932
            reverse_mapping_[element] = self
6933
        return element
6934
    def build(self, node, gds_collector_=None):
6935
        self.gds_collector_ = gds_collector_
6936
        if SaveElementTreeNode:
6937
            self.gds_elementtree_node_ = node
6938
        already_processed = set()
6939
        self.ns_prefix_ = node.prefix
6940
        self._buildAttributes(node, node.attrib, already_processed)
6941
        for child in node:
6942
            nodeName_ = Tag_pattern_.match(child.tag).groups()[-1]
6943
            self._buildChildren(child, node, nodeName_, gds_collector_=gds_collector_)
6944
        return self
6945 View Code Duplication
    def _buildAttributes(self, node, attrs, already_processed):
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
6946
        value = find_attr_value_('id', node)
6947
        if value is not None and 'id' not in already_processed:
6948
            already_processed.add('id')
6949
            self.id = value
6950
        value = find_attr_value_('regionRef', node)
6951
        if value is not None and 'regionRef' not in already_processed:
6952
            already_processed.add('regionRef')
6953
            self.regionRef = value
6954
        value = find_attr_value_('index', node)
6955
        if value is not None and 'index' not in already_processed:
6956
            already_processed.add('index')
6957
            self.index = self.gds_parse_integer(value, node, 'index')
6958
        value = find_attr_value_('caption', node)
6959
        if value is not None and 'caption' not in already_processed:
6960
            already_processed.add('caption')
6961
            self.caption = value
6962
        value = find_attr_value_('type', node)
6963
        if value is not None and 'type' not in already_processed:
6964
            already_processed.add('type')
6965
            self.type_ = value
6966
            self.validate_GroupTypeSimpleType(self.type_)    # validate type GroupTypeSimpleType
6967
        value = find_attr_value_('continuation', node)
6968
        if value is not None and 'continuation' not in already_processed:
6969
            already_processed.add('continuation')
6970
            if value in ('true', '1'):
6971
                self.continuation = True
6972
            elif value in ('false', '0'):
6973
                self.continuation = False
6974
            else:
6975
                raise_parse_error(node, 'Bad boolean attribute')
6976
        value = find_attr_value_('custom', node)
6977
        if value is not None and 'custom' not in already_processed:
6978
            already_processed.add('custom')
6979
            self.custom = value
6980
        value = find_attr_value_('comments', node)
6981
        if value is not None and 'comments' not in already_processed:
6982
            already_processed.add('comments')
6983
            self.comments = value
6984 View Code Duplication
    def _buildChildren(self, child_, node, nodeName_, fromsubclass_=False, gds_collector_=None):
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
6985
        if nodeName_ == 'UserDefined':
6986
            obj_ = UserDefinedType.factory(parent_object_=self)
6987
            obj_.build(child_, gds_collector_=gds_collector_)
6988
            self.UserDefined = obj_
6989
            obj_.original_tagname_ = 'UserDefined'
6990
        elif nodeName_ == 'Labels':
6991
            obj_ = LabelsType.factory(parent_object_=self)
6992
            obj_.build(child_, gds_collector_=gds_collector_)
6993
            self.Labels.append(obj_)
6994
            obj_.original_tagname_ = 'Labels'
6995
        elif nodeName_ == 'RegionRefIndexed':
6996
            obj_ = RegionRefIndexedType.factory(parent_object_=self)
6997
            obj_.build(child_, gds_collector_=gds_collector_)
6998
            self.RegionRefIndexed.append(obj_)
6999
            obj_.original_tagname_ = 'RegionRefIndexed'
7000
        elif nodeName_ == 'OrderedGroupIndexed':
7001
            obj_ = OrderedGroupIndexedType.factory(parent_object_=self)
7002
            obj_.build(child_, gds_collector_=gds_collector_)
7003
            self.OrderedGroupIndexed.append(obj_)
7004
            obj_.original_tagname_ = 'OrderedGroupIndexed'
7005
        elif nodeName_ == 'UnorderedGroupIndexed':
7006
            obj_ = UnorderedGroupIndexedType.factory(parent_object_=self)
7007
            obj_.build(child_, gds_collector_=gds_collector_)
7008
            self.UnorderedGroupIndexed.append(obj_)
7009
            obj_.original_tagname_ = 'UnorderedGroupIndexed'
7010
    def __hash__(self):
7011
        return hash(self.id)
7012
    # pylint: disable=invalid-name,missing-module-docstring,line-too-long
7013 View Code Duplication
    def get_AllIndexed(self, classes=None, index_sort=True):
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
7014
        """
7015
        Get all indexed children sorted by their ``@index``.
7016
    
7017
        Arguments:
7018
            classes (list): Type of children (sans ``Indexed``) to return. \
7019
                Default: ``['RegionRef', 'OrderedGroup', 'UnorderedGroup']``
7020
            index_sort (boolean): Whether to sort by ``@index``
7021
    
7022
        Returns:
7023
            a list of :py:class:`RegionRefIndexedType`, \
7024
                :py:class:`OrderedGroupIndexedType`, and \
7025
                :py:class:`UnorderedGroupIndexedType`
7026
        """
7027
        if not classes:
7028
            classes = ['RegionRef', 'OrderedGroup', 'UnorderedGroup']
7029
        ret = []
7030
        for class_ in classes:
7031
            ret += getattr(self, 'get_{}Indexed'.format(class_))()
7032
        if index_sort:
7033
            return sorted(ret, key=lambda x: x.index)
7034
        return ret
7035
    def clear_AllIndexed(self):
7036
        ret = self.get_AllIndexed()
7037
        self.set_RegionRefIndexed([])
7038
        self.set_OrderedGroupIndexed([])
7039
        self.set_UnorderedGroupIndexed([])
7040
        return ret
7041
    
7042
    # pylint: disable=line-too-long,invalid-name,missing-module-docstring
7043 View Code Duplication
    def extend_AllIndexed(self, elements, validate_continuity=False):
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
7044
        """
7045
        Add all elements in list `elements`, respecting ``@index`` order.
7046
        With `validate_continuity`, check that all new elements come after all old elements
7047
        (or raise an exception). 
7048
        Otherwise, ensure this condition silently (by increasing ``@index`` accordingly).
7049
        """
7050
        if not isinstance(elements, list):
7051
            elements = [elements]
7052
        siblings = self.get_AllIndexed()
7053
        highest_sibling_index = siblings[-1].index if siblings else -1
7054
        if validate_continuity:
7055
            elements = sorted(elements, key=lambda x: x.index)
7056
            lowest_element_index = elements[0].index
7057
            if lowest_element_index <= highest_sibling_index:
7058
                raise Exception("@index already used: {}".format(lowest_element_index))
7059
        else:
7060
            for element in elements:
7061
                highest_sibling_index += 1
7062
                element.index = highest_sibling_index
7063
        for element in elements:
7064
            if isinstance(element, RegionRefIndexedType): # pylint: disable=undefined-variable
7065
                self.add_RegionRefIndexed(element)
7066
            elif isinstance(element, OrderedGroupIndexedType): # pylint: disable=undefined-variable
7067
                self.add_OrderedGroupIndexed(element)
7068
            elif isinstance(element, UnorderedGroupIndexedType): # pylint: disable=undefined-variable
7069
                self.add_UnorderedGroupIndexed(element)
7070
        return self.get_AllIndexed()
7071
    # pylint: disable=line-too-long,invalid-name,missing-module-docstring
7072 View Code Duplication
    def sort_AllIndexed(self, validate_uniqueness=True):
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
7073
        """
7074
        Sort all indexed children in-place.
7075
        """
7076
        elements = self.get_AllIndexed(index_sort=True)
7077
        self.clear_AllIndexed()
7078
        for element in elements:
7079
            if isinstance(element, RegionRefIndexedType): # pylint: disable=undefined-variable
7080
                self.add_RegionRefIndexed(element)
7081
            elif isinstance(element, OrderedGroupIndexedType): # pylint: disable=undefined-variable
7082
                self.add_OrderedGroupIndexed(element)
7083
            elif isinstance(element, UnorderedGroupIndexedType): # pylint: disable=undefined-variable
7084
                self.add_UnorderedGroupIndexed(element)
7085
        return self.get_AllIndexed()
7086
    
7087
    # pylint: disable=line-too-long,invalid-name,missing-module-docstring,missing-function-docstring
7088 View Code Duplication
    def _exportChildren(self, outfile, level, namespaceprefix_='', namespacedef_='xmlns:pc="http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15"', name_='OrderedGroupType', fromsubclass_=False, pretty_print=True): # pylint: disable=unused-argument,too-many-arguments
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
7089
        if pretty_print:
7090
            eol_ = '\n'
7091
        else:
7092
            eol_ = ''
7093
        if self.UserDefined is not None:
7094
            namespaceprefix_ = self.UserDefined_nsprefix_ + ':' if (UseCapturedNS_ and self.UserDefined_nsprefix_) else ''
7095
            self.UserDefined.export(outfile, level, namespaceprefix_, namespacedef_='', name_='UserDefined', pretty_print=pretty_print)
7096
        for Labels_ in self.Labels:
7097
            namespaceprefix_ = self.Labels_nsprefix_ + ':' if (UseCapturedNS_ and self.Labels_nsprefix_) else ''
7098
            Labels_.export(outfile, level, namespaceprefix_, namespacedef_='', name_='Labels', pretty_print=pretty_print)
7099
        cleaned = []
7100
        def replaceWithRRI(group):
7101
            rri = RegionRefIndexedType.factory(parent_object_=self) # pylint: disable=undefined-variable
7102
            rri.index = group.index
7103
            rri.regionRef = group.regionRef
7104
            cleaned.append(rri)
7105
        # remove empty groups and replace with RegionRefIndexedType
7106
        for entry in self.get_AllIndexed():
7107
            # pylint: disable=undefined-variable
7108
            if isinstance(entry, (OrderedGroupIndexedType)) and not entry.get_AllIndexed():
7109
                replaceWithRRI(entry)
7110
            elif isinstance(entry, UnorderedGroupIndexedType) and not entry.get_UnorderedGroupChildren():
7111
                replaceWithRRI(entry)
7112
            else:
7113
                cleaned.append(entry)
7114
        for entry in cleaned:
7115
            entry.export(outfile, level, namespaceprefix_, namespacedef_='', name_=entry.__class__.__name__[:-4], pretty_print=pretty_print)
7116
# end class OrderedGroupIndexedType
7117
7118
7119
class UnorderedGroupIndexedType(GeneratedsSuper):
7120
    """UnorderedGroupIndexedType --
7121
    Indexed group containing unordered elements
7122
      
7123
    * regionRef --
7124
      Optional link to a parent region of nested regions.
7125
      The parent region doubles as reading order group.
7126
      Only the nested regions should be allowed as group members.
7127
      
7128
    * index --
7129
      Position (order number) of this item within the
7130
      current hierarchy level.
7131
      
7132
    * continuation --
7133
      Is this group a continuation of another group
7134
      (from previous column or page, for example)?
7135
      
7136
    * custom -- For generic use
7137
    * Labels -- Semantic labels / tags
7138
    
7139
    """
7140
    __hash__ = GeneratedsSuper.__hash__
7141
    member_data_items_ = [
7142
        MemberSpec_('id', 'string', 0, 0, {'use': 'required', 'name': 'id'}),
7143
        MemberSpec_('regionRef', 'string', 0, 1, {'use': 'optional', 'name': 'regionRef'}),
7144
        MemberSpec_('index', 'int', 0, 0, {'use': 'required', 'name': 'index'}),
7145
        MemberSpec_('caption', 'string', 0, 1, {'use': 'optional', 'name': 'caption'}),
7146
        MemberSpec_('type_', 'pc:GroupTypeSimpleType', 0, 1, {'use': 'optional', 'name': 'type_'}),
7147
        MemberSpec_('continuation', 'boolean', 0, 1, {'use': 'optional', 'name': 'continuation'}),
7148
        MemberSpec_('custom', 'string', 0, 1, {'use': 'optional', 'name': 'custom'}),
7149
        MemberSpec_('comments', 'string', 0, 1, {'use': 'optional', 'name': 'comments'}),
7150
        MemberSpec_('UserDefined', 'UserDefinedType', 0, 1, {'maxOccurs': '1', 'minOccurs': '0', 'name': 'UserDefined', 'type': 'UserDefinedType'}, None),
7151
        MemberSpec_('Labels', 'LabelsType', 1, 1, {'maxOccurs': 'unbounded', 'minOccurs': '0', 'name': 'Labels', 'type': 'LabelsType'}, None),
7152
        MemberSpec_('RegionRef', 'RegionRefType', 1, 0, {'name': 'RegionRef', 'type': 'RegionRefType'}, 4),
7153
        MemberSpec_('OrderedGroup', 'OrderedGroupType', 1, 0, {'name': 'OrderedGroup', 'type': 'OrderedGroupType'}, 4),
7154
        MemberSpec_('UnorderedGroup', 'UnorderedGroupType', 1, 0, {'name': 'UnorderedGroup', 'type': 'UnorderedGroupType'}, 4),
7155
    ]
7156
    subclass = None
7157
    superclass = None
7158
    def __init__(self, id=None, regionRef=None, index=None, caption=None, type_=None, continuation=None, custom=None, comments=None, UserDefined=None, Labels=None, RegionRef=None, OrderedGroup=None, UnorderedGroup=None, gds_collector_=None, **kwargs_):
7159
        self.gds_collector_ = gds_collector_
7160
        self.gds_elementtree_node_ = None
7161
        self.original_tagname_ = None
7162
        self.parent_object_ = kwargs_.get('parent_object_')
7163
        self.ns_prefix_ = "pc"
7164
        self.id = _cast(None, id)
7165
        self.id_nsprefix_ = "pc"
7166
        self.regionRef = _cast(None, regionRef)
7167
        self.regionRef_nsprefix_ = "pc"
7168
        self.index = _cast(int, index)
7169
        self.index_nsprefix_ = "pc"
7170
        self.caption = _cast(None, caption)
7171
        self.caption_nsprefix_ = "pc"
7172
        self.type_ = _cast(None, type_)
7173
        self.type__nsprefix_ = "pc"
7174
        self.continuation = _cast(bool, continuation)
7175
        self.continuation_nsprefix_ = "pc"
7176
        self.custom = _cast(None, custom)
7177
        self.custom_nsprefix_ = "pc"
7178
        self.comments = _cast(None, comments)
7179
        self.comments_nsprefix_ = "pc"
7180
        self.UserDefined = UserDefined
7181
        self.UserDefined_nsprefix_ = "pc"
7182
        if Labels is None:
7183
            self.Labels = []
7184
        else:
7185
            self.Labels = Labels
7186
        self.Labels_nsprefix_ = "pc"
7187
        if RegionRef is None:
7188
            self.RegionRef = []
7189
        else:
7190
            self.RegionRef = RegionRef
7191
        self.RegionRef_nsprefix_ = "pc"
7192
        if OrderedGroup is None:
7193
            self.OrderedGroup = []
7194
        else:
7195
            self.OrderedGroup = OrderedGroup
7196
        self.OrderedGroup_nsprefix_ = "pc"
7197
        if UnorderedGroup is None:
7198
            self.UnorderedGroup = []
7199
        else:
7200
            self.UnorderedGroup = UnorderedGroup
7201
        self.UnorderedGroup_nsprefix_ = "pc"
7202
    def factory(*args_, **kwargs_):
7203
        if CurrentSubclassModule_ is not None:
7204
            subclass = getSubclassFromModule_(
7205
                CurrentSubclassModule_, UnorderedGroupIndexedType)
7206
            if subclass is not None:
7207
                return subclass(*args_, **kwargs_)
7208
        if UnorderedGroupIndexedType.subclass:
7209
            return UnorderedGroupIndexedType.subclass(*args_, **kwargs_)
7210
        else:
7211
            return UnorderedGroupIndexedType(*args_, **kwargs_)
7212
    factory = staticmethod(factory)
7213
    def get_ns_prefix_(self):
7214
        return self.ns_prefix_
7215
    def set_ns_prefix_(self, ns_prefix):
7216
        self.ns_prefix_ = ns_prefix
7217
    def get_UserDefined(self):
7218
        return self.UserDefined
7219
    def set_UserDefined(self, UserDefined):
7220
        self.UserDefined = UserDefined
7221
    def get_Labels(self):
7222
        return self.Labels
7223
    def set_Labels(self, Labels):
7224
        self.Labels = Labels
7225
    def add_Labels(self, value):
7226
        self.Labels.append(value)
7227
    def insert_Labels_at(self, index, value):
7228
        self.Labels.insert(index, value)
7229
    def replace_Labels_at(self, index, value):
7230
        self.Labels[index] = value
7231
    def get_RegionRef(self):
7232
        return self.RegionRef
7233
    def set_RegionRef(self, RegionRef):
7234
        self.RegionRef = RegionRef
7235
    def add_RegionRef(self, value):
7236
        self.RegionRef.append(value)
7237
    def insert_RegionRef_at(self, index, value):
7238
        self.RegionRef.insert(index, value)
7239
    def replace_RegionRef_at(self, index, value):
7240
        self.RegionRef[index] = value
7241
    def get_OrderedGroup(self):
7242
        return self.OrderedGroup
7243
    def set_OrderedGroup(self, OrderedGroup):
7244
        self.OrderedGroup = OrderedGroup
7245
    def add_OrderedGroup(self, value):
7246
        self.OrderedGroup.append(value)
7247
    def insert_OrderedGroup_at(self, index, value):
7248
        self.OrderedGroup.insert(index, value)
7249
    def replace_OrderedGroup_at(self, index, value):
7250
        self.OrderedGroup[index] = value
7251
    def get_UnorderedGroup(self):
7252
        return self.UnorderedGroup
7253
    def set_UnorderedGroup(self, UnorderedGroup):
7254
        self.UnorderedGroup = UnorderedGroup
7255
    def add_UnorderedGroup(self, value):
7256
        self.UnorderedGroup.append(value)
7257
    def insert_UnorderedGroup_at(self, index, value):
7258
        self.UnorderedGroup.insert(index, value)
7259
    def replace_UnorderedGroup_at(self, index, value):
7260
        self.UnorderedGroup[index] = value
7261
    def get_id(self):
7262
        return self.id
7263
    def set_id(self, id):
7264
        self.id = id
7265
    def get_regionRef(self):
7266
        return self.regionRef
7267
    def set_regionRef(self, regionRef):
7268
        self.regionRef = regionRef
7269
    def get_index(self):
7270
        return self.index
7271
    def set_index(self, index):
7272
        self.index = index
7273
    def get_caption(self):
7274
        return self.caption
7275
    def set_caption(self, caption):
7276
        self.caption = caption
7277
    def get_type(self):
7278
        return self.type_
7279
    def set_type(self, type_):
7280
        self.type_ = type_
7281
    def get_continuation(self):
7282
        return self.continuation
7283
    def set_continuation(self, continuation):
7284
        self.continuation = continuation
7285
    def get_custom(self):
7286
        return self.custom
7287
    def set_custom(self, custom):
7288
        self.custom = custom
7289
    def get_comments(self):
7290
        return self.comments
7291
    def set_comments(self, comments):
7292
        self.comments = comments
7293
    def validate_GroupTypeSimpleType(self, value):
7294
        # Validate type pc:GroupTypeSimpleType, a restriction on string.
7295
        if value is not None and Validate_simpletypes_ and self.gds_collector_ is not None:
7296
            if not isinstance(value, str):
7297
                lineno = self.gds_get_node_lineno_()
7298
                self.gds_collector_.add_message('Value "%(value)s"%(lineno)s is not of the correct base simple type (str)' % {"value": value, "lineno": lineno, })
7299
                return False
7300
            value = value
7301
            enumerations = ['paragraph', 'list', 'list-item', 'figure', 'article', 'div', 'other']
7302
            if value not in enumerations:
7303
                lineno = self.gds_get_node_lineno_()
7304
                self.gds_collector_.add_message('Value "%(value)s"%(lineno)s does not match xsd enumeration restriction on GroupTypeSimpleType' % {"value" : encode_str_2_3(value), "lineno": lineno} )
7305
                result = False
7306
    def has__content(self):
7307
        if (
7308
            self.UserDefined is not None or
7309
            self.Labels or
7310
            self.RegionRef or
7311
            self.OrderedGroup or
7312
            self.UnorderedGroup
7313
        ):
7314
            return True
7315
        else:
7316
            return False
7317
    def export(self, outfile, level, namespaceprefix_='', namespacedef_='xmlns:pc="http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15"', name_='UnorderedGroupIndexedType', pretty_print=True):
7318
        imported_ns_def_ = GenerateDSNamespaceDefs_.get('UnorderedGroupIndexedType')
7319
        if imported_ns_def_ is not None:
7320
            namespacedef_ = imported_ns_def_
7321
        if pretty_print:
7322
            eol_ = '\n'
7323
        else:
7324
            eol_ = ''
7325
        if self.original_tagname_ is not None and name_ == 'UnorderedGroupIndexedType':
7326
            name_ = self.original_tagname_
7327
        if UseCapturedNS_ and self.ns_prefix_:
7328
            namespaceprefix_ = self.ns_prefix_ + ':'
7329
        showIndent(outfile, level, pretty_print)
7330
        outfile.write('<%s%s%s' % (namespaceprefix_, name_, namespacedef_ and ' ' + namespacedef_ or '', ))
7331
        already_processed = set()
7332
        self._exportAttributes(outfile, level, already_processed, namespaceprefix_, name_='UnorderedGroupIndexedType')
7333
        if self.has__content():
7334
            outfile.write('>%s' % (eol_, ))
7335
            self._exportChildren(outfile, level + 1, namespaceprefix_, namespacedef_, name_='UnorderedGroupIndexedType', pretty_print=pretty_print)
7336
            showIndent(outfile, level, pretty_print)
7337
            outfile.write('</%s%s>%s' % (namespaceprefix_, name_, eol_))
7338
        else:
7339
            outfile.write('/>%s' % (eol_, ))
7340 View Code Duplication
    def _exportAttributes(self, outfile, level, already_processed, namespaceprefix_='', name_='UnorderedGroupIndexedType'):
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
7341
        if self.id is not None and 'id' not in already_processed:
7342
            already_processed.add('id')
7343
            outfile.write(' id=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.id), input_name='id')), ))
7344
        if self.regionRef is not None and 'regionRef' not in already_processed:
7345
            already_processed.add('regionRef')
7346
            outfile.write(' regionRef=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.regionRef), input_name='regionRef')), ))
7347
        if self.index is not None and 'index' not in already_processed:
7348
            already_processed.add('index')
7349
            outfile.write(' index="%s"' % self.gds_format_integer(self.index, input_name='index'))
7350
        if self.caption is not None and 'caption' not in already_processed:
7351
            already_processed.add('caption')
7352
            outfile.write(' caption=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.caption), input_name='caption')), ))
7353
        if self.type_ is not None and 'type_' not in already_processed:
7354
            already_processed.add('type_')
7355
            outfile.write(' type=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.type_), input_name='type')), ))
7356
        if self.continuation is not None and 'continuation' not in already_processed:
7357
            already_processed.add('continuation')
7358
            outfile.write(' continuation="%s"' % self.gds_format_boolean(self.continuation, input_name='continuation'))
7359
        if self.custom is not None and 'custom' not in already_processed:
7360
            already_processed.add('custom')
7361
            outfile.write(' custom=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.custom), input_name='custom')), ))
7362
        if self.comments is not None and 'comments' not in already_processed:
7363
            already_processed.add('comments')
7364
            outfile.write(' comments=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.comments), input_name='comments')), ))
7365 View Code Duplication
    def _exportChildren(self, outfile, level, namespaceprefix_='', namespacedef_='xmlns:pc="http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15"', name_='UnorderedGroupIndexedType', fromsubclass_=False, pretty_print=True):
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
7366
        if pretty_print:
7367
            eol_ = '\n'
7368
        else:
7369
            eol_ = ''
7370
        if self.UserDefined is not None:
7371
            namespaceprefix_ = self.UserDefined_nsprefix_ + ':' if (UseCapturedNS_ and self.UserDefined_nsprefix_) else ''
7372
            self.UserDefined.export(outfile, level, namespaceprefix_, namespacedef_='', name_='UserDefined', pretty_print=pretty_print)
7373
        for Labels_ in self.Labels:
7374
            namespaceprefix_ = self.Labels_nsprefix_ + ':' if (UseCapturedNS_ and self.Labels_nsprefix_) else ''
7375
            Labels_.export(outfile, level, namespaceprefix_, namespacedef_='', name_='Labels', pretty_print=pretty_print)
7376
        for RegionRef_ in self.RegionRef:
7377
            namespaceprefix_ = self.RegionRef_nsprefix_ + ':' if (UseCapturedNS_ and self.RegionRef_nsprefix_) else ''
7378
            RegionRef_.export(outfile, level, namespaceprefix_, namespacedef_='', name_='RegionRef', pretty_print=pretty_print)
7379
        for OrderedGroup_ in self.OrderedGroup:
7380
            namespaceprefix_ = self.OrderedGroup_nsprefix_ + ':' if (UseCapturedNS_ and self.OrderedGroup_nsprefix_) else ''
7381
            OrderedGroup_.export(outfile, level, namespaceprefix_, namespacedef_='', name_='OrderedGroup', pretty_print=pretty_print)
7382
        for UnorderedGroup_ in self.UnorderedGroup:
7383
            namespaceprefix_ = self.UnorderedGroup_nsprefix_ + ':' if (UseCapturedNS_ and self.UnorderedGroup_nsprefix_) else ''
7384
            UnorderedGroup_.export(outfile, level, namespaceprefix_, namespacedef_='', name_='UnorderedGroup', pretty_print=pretty_print)
7385 View Code Duplication
    def to_etree(self, parent_element=None, name_='UnorderedGroupIndexedType', mapping_=None, reverse_mapping_=None, nsmap_=None):
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
7386
        if parent_element is None:
7387
            element = etree_.Element('{http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15}' + name_, nsmap=nsmap_)
7388
        else:
7389
            element = etree_.SubElement(parent_element, '{http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15}' + name_, nsmap=nsmap_)
7390
        if self.id is not None:
7391
            element.set('id', self.gds_format_string(self.id))
7392
        if self.regionRef is not None:
7393
            element.set('regionRef', self.gds_format_string(self.regionRef))
7394
        if self.index is not None:
7395
            element.set('index', self.gds_format_integer(self.index))
7396
        if self.caption is not None:
7397
            element.set('caption', self.gds_format_string(self.caption))
7398
        if self.type_ is not None:
7399
            element.set('type', self.gds_format_string(self.type_))
7400
        if self.continuation is not None:
7401
            element.set('continuation', self.gds_format_boolean(self.continuation))
7402
        if self.custom is not None:
7403
            element.set('custom', self.gds_format_string(self.custom))
7404
        if self.comments is not None:
7405
            element.set('comments', self.gds_format_string(self.comments))
7406
        if self.UserDefined is not None:
7407
            UserDefined_ = self.UserDefined
7408
            UserDefined_.to_etree(element, name_='UserDefined', mapping_=mapping_, reverse_mapping_=reverse_mapping_, nsmap_=nsmap_)
7409
        for Labels_ in self.Labels:
7410
            Labels_.to_etree(element, name_='Labels', mapping_=mapping_, reverse_mapping_=reverse_mapping_, nsmap_=nsmap_)
7411
        for RegionRef_ in self.RegionRef:
7412
            RegionRef_.to_etree(element, name_='RegionRef', mapping_=mapping_, reverse_mapping_=reverse_mapping_, nsmap_=nsmap_)
7413
        for OrderedGroup_ in self.OrderedGroup:
7414
            OrderedGroup_.to_etree(element, name_='OrderedGroup', mapping_=mapping_, reverse_mapping_=reverse_mapping_, nsmap_=nsmap_)
7415
        for UnorderedGroup_ in self.UnorderedGroup:
7416
            UnorderedGroup_.to_etree(element, name_='UnorderedGroup', mapping_=mapping_, reverse_mapping_=reverse_mapping_, nsmap_=nsmap_)
7417
        if mapping_ is not None:
7418
            mapping_[id(self)] = element
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable id does not seem to be defined.
Loading history...
7419
        if reverse_mapping_ is not None:
7420
            reverse_mapping_[element] = self
7421
        return element
7422
    def build(self, node, gds_collector_=None):
7423
        self.gds_collector_ = gds_collector_
7424
        if SaveElementTreeNode:
7425
            self.gds_elementtree_node_ = node
7426
        already_processed = set()
7427
        self.ns_prefix_ = node.prefix
7428
        self._buildAttributes(node, node.attrib, already_processed)
7429
        for child in node:
7430
            nodeName_ = Tag_pattern_.match(child.tag).groups()[-1]
7431
            self._buildChildren(child, node, nodeName_, gds_collector_=gds_collector_)
7432
        return self
7433 View Code Duplication
    def _buildAttributes(self, node, attrs, already_processed):
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
7434
        value = find_attr_value_('id', node)
7435
        if value is not None and 'id' not in already_processed:
7436
            already_processed.add('id')
7437
            self.id = value
7438
        value = find_attr_value_('regionRef', node)
7439
        if value is not None and 'regionRef' not in already_processed:
7440
            already_processed.add('regionRef')
7441
            self.regionRef = value
7442
        value = find_attr_value_('index', node)
7443
        if value is not None and 'index' not in already_processed:
7444
            already_processed.add('index')
7445
            self.index = self.gds_parse_integer(value, node, 'index')
7446
        value = find_attr_value_('caption', node)
7447
        if value is not None and 'caption' not in already_processed:
7448
            already_processed.add('caption')
7449
            self.caption = value
7450
        value = find_attr_value_('type', node)
7451
        if value is not None and 'type' not in already_processed:
7452
            already_processed.add('type')
7453
            self.type_ = value
7454
            self.validate_GroupTypeSimpleType(self.type_)    # validate type GroupTypeSimpleType
7455
        value = find_attr_value_('continuation', node)
7456
        if value is not None and 'continuation' not in already_processed:
7457
            already_processed.add('continuation')
7458
            if value in ('true', '1'):
7459
                self.continuation = True
7460
            elif value in ('false', '0'):
7461
                self.continuation = False
7462
            else:
7463
                raise_parse_error(node, 'Bad boolean attribute')
7464
        value = find_attr_value_('custom', node)
7465
        if value is not None and 'custom' not in already_processed:
7466
            already_processed.add('custom')
7467
            self.custom = value
7468
        value = find_attr_value_('comments', node)
7469
        if value is not None and 'comments' not in already_processed:
7470
            already_processed.add('comments')
7471
            self.comments = value
7472 View Code Duplication
    def _buildChildren(self, child_, node, nodeName_, fromsubclass_=False, gds_collector_=None):
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
7473
        if nodeName_ == 'UserDefined':
7474
            obj_ = UserDefinedType.factory(parent_object_=self)
7475
            obj_.build(child_, gds_collector_=gds_collector_)
7476
            self.UserDefined = obj_
7477
            obj_.original_tagname_ = 'UserDefined'
7478
        elif nodeName_ == 'Labels':
7479
            obj_ = LabelsType.factory(parent_object_=self)
7480
            obj_.build(child_, gds_collector_=gds_collector_)
7481
            self.Labels.append(obj_)
7482
            obj_.original_tagname_ = 'Labels'
7483
        elif nodeName_ == 'RegionRef':
7484
            obj_ = RegionRefType.factory(parent_object_=self)
7485
            obj_.build(child_, gds_collector_=gds_collector_)
7486
            self.RegionRef.append(obj_)
7487
            obj_.original_tagname_ = 'RegionRef'
7488
        elif nodeName_ == 'OrderedGroup':
7489
            obj_ = OrderedGroupType.factory(parent_object_=self)
7490
            obj_.build(child_, gds_collector_=gds_collector_)
7491
            self.OrderedGroup.append(obj_)
7492
            obj_.original_tagname_ = 'OrderedGroup'
7493
        elif nodeName_ == 'UnorderedGroup':
7494
            obj_ = UnorderedGroupType.factory(parent_object_=self)
7495
            obj_.build(child_, gds_collector_=gds_collector_)
7496
            self.UnorderedGroup.append(obj_)
7497
            obj_.original_tagname_ = 'UnorderedGroup'
7498
    def __hash__(self):
7499
        return hash(self.id)
7500
    def get_UnorderedGroupChildren(self):
7501
        """
7502
        List all non-metadata children of an :py:class:`UnorderedGroupType`
7503
        """
7504
        # TODO: should not change order
7505
        return self.get_RegionRef() + self.get_OrderedGroup() + self.get_UnorderedGroup()
7506
    
7507
# end class UnorderedGroupIndexedType
7508
7509
7510
class RegionRefType(GeneratedsSuper):
7511
    __hash__ = GeneratedsSuper.__hash__
7512
    member_data_items_ = [
7513
        MemberSpec_('regionRef', 'string', 0, 0, {'use': 'required', 'name': 'regionRef'}),
7514
    ]
7515
    subclass = None
7516
    superclass = None
7517
    def __init__(self, regionRef=None, gds_collector_=None, **kwargs_):
7518
        self.gds_collector_ = gds_collector_
7519
        self.gds_elementtree_node_ = None
7520
        self.original_tagname_ = None
7521
        self.parent_object_ = kwargs_.get('parent_object_')
7522
        self.ns_prefix_ = "pc"
7523
        self.regionRef = _cast(None, regionRef)
7524
        self.regionRef_nsprefix_ = "pc"
7525
    def factory(*args_, **kwargs_):
7526
        if CurrentSubclassModule_ is not None:
7527
            subclass = getSubclassFromModule_(
7528
                CurrentSubclassModule_, RegionRefType)
7529
            if subclass is not None:
7530
                return subclass(*args_, **kwargs_)
7531
        if RegionRefType.subclass:
7532
            return RegionRefType.subclass(*args_, **kwargs_)
7533
        else:
7534
            return RegionRefType(*args_, **kwargs_)
7535
    factory = staticmethod(factory)
7536
    def get_ns_prefix_(self):
7537
        return self.ns_prefix_
7538
    def set_ns_prefix_(self, ns_prefix):
7539
        self.ns_prefix_ = ns_prefix
7540
    def get_regionRef(self):
7541
        return self.regionRef
7542
    def set_regionRef(self, regionRef):
7543
        self.regionRef = regionRef
7544
    def has__content(self):
7545
        if (
7546
7547
        ):
7548
            return True
7549
        else:
7550
            return False
7551
    def export(self, outfile, level, namespaceprefix_='', namespacedef_='xmlns:pc="http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15"', name_='RegionRefType', pretty_print=True):
7552
        imported_ns_def_ = GenerateDSNamespaceDefs_.get('RegionRefType')
7553
        if imported_ns_def_ is not None:
7554
            namespacedef_ = imported_ns_def_
7555
        if pretty_print:
7556
            eol_ = '\n'
7557
        else:
7558
            eol_ = ''
7559
        if self.original_tagname_ is not None and name_ == 'RegionRefType':
7560
            name_ = self.original_tagname_
7561
        if UseCapturedNS_ and self.ns_prefix_:
7562
            namespaceprefix_ = self.ns_prefix_ + ':'
7563
        showIndent(outfile, level, pretty_print)
7564
        outfile.write('<%s%s%s' % (namespaceprefix_, name_, namespacedef_ and ' ' + namespacedef_ or '', ))
7565
        already_processed = set()
7566
        self._exportAttributes(outfile, level, already_processed, namespaceprefix_, name_='RegionRefType')
7567
        if self.has__content():
7568
            outfile.write('>%s' % (eol_, ))
7569
            self._exportChildren(outfile, level + 1, namespaceprefix_, namespacedef_, name_='RegionRefType', pretty_print=pretty_print)
7570
            outfile.write('</%s%s>%s' % (namespaceprefix_, name_, eol_))
7571
        else:
7572
            outfile.write('/>%s' % (eol_, ))
7573
    def _exportAttributes(self, outfile, level, already_processed, namespaceprefix_='', name_='RegionRefType'):
7574
        if self.regionRef is not None and 'regionRef' not in already_processed:
7575
            already_processed.add('regionRef')
7576
            outfile.write(' regionRef=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.regionRef), input_name='regionRef')), ))
7577
    def _exportChildren(self, outfile, level, namespaceprefix_='', namespacedef_='xmlns:pc="http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15"', name_='RegionRefType', fromsubclass_=False, pretty_print=True):
7578
        pass
7579
    def to_etree(self, parent_element=None, name_='RegionRefType', mapping_=None, reverse_mapping_=None, nsmap_=None):
7580
        if parent_element is None:
7581
            element = etree_.Element('{http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15}' + name_, nsmap=nsmap_)
7582
        else:
7583
            element = etree_.SubElement(parent_element, '{http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15}' + name_, nsmap=nsmap_)
7584
        if self.regionRef is not None:
7585
            element.set('regionRef', self.gds_format_string(self.regionRef))
7586
        if mapping_ is not None:
7587
            mapping_[id(self)] = element
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable id does not seem to be defined.
Loading history...
7588
        if reverse_mapping_ is not None:
7589
            reverse_mapping_[element] = self
7590
        return element
7591
    def build(self, node, gds_collector_=None):
7592
        self.gds_collector_ = gds_collector_
7593
        if SaveElementTreeNode:
7594
            self.gds_elementtree_node_ = node
7595
        already_processed = set()
7596
        self.ns_prefix_ = node.prefix
7597
        self._buildAttributes(node, node.attrib, already_processed)
7598
        for child in node:
7599
            nodeName_ = Tag_pattern_.match(child.tag).groups()[-1]
7600
            self._buildChildren(child, node, nodeName_, gds_collector_=gds_collector_)
7601
        return self
7602
    def _buildAttributes(self, node, attrs, already_processed):
7603
        value = find_attr_value_('regionRef', node)
7604
        if value is not None and 'regionRef' not in already_processed:
7605
            already_processed.add('regionRef')
7606
            self.regionRef = value
7607
    def _buildChildren(self, child_, node, nodeName_, fromsubclass_=False, gds_collector_=None):
7608
        pass
7609
    def __hash__(self):
7610
        return hash(self.id)
7611
# end class RegionRefType
7612
7613
7614
class OrderedGroupType(GeneratedsSuper):
7615
    """OrderedGroupType --
7616
    Numbered group (contains ordered elements)
7617
      
7618
    * regionRef --
7619
      Optional link to a parent region of nested regions.
7620
      The parent region doubles as reading order group.
7621
      Only the nested regions should be allowed as group members.
7622
      
7623
    * continuation --
7624
      Is this group a continuation of another group
7625
      (from previous column or page, for example)?
7626
      
7627
    * custom -- For generic use
7628
    * Labels -- Semantic labels / tags
7629
    
7630
    """
7631
    __hash__ = GeneratedsSuper.__hash__
7632
    member_data_items_ = [
7633
        MemberSpec_('id', 'string', 0, 0, {'use': 'required', 'name': 'id'}),
7634
        MemberSpec_('regionRef', 'string', 0, 1, {'use': 'optional', 'name': 'regionRef'}),
7635
        MemberSpec_('caption', 'string', 0, 1, {'use': 'optional', 'name': 'caption'}),
7636
        MemberSpec_('type_', 'pc:GroupTypeSimpleType', 0, 1, {'use': 'optional', 'name': 'type_'}),
7637
        MemberSpec_('continuation', 'boolean', 0, 1, {'use': 'optional', 'name': 'continuation'}),
7638
        MemberSpec_('custom', 'string', 0, 1, {'use': 'optional', 'name': 'custom'}),
7639
        MemberSpec_('comments', 'string', 0, 1, {'use': 'optional', 'name': 'comments'}),
7640
        MemberSpec_('UserDefined', 'UserDefinedType', 0, 1, {'maxOccurs': '1', 'minOccurs': '0', 'name': 'UserDefined', 'type': 'UserDefinedType'}, None),
7641
        MemberSpec_('Labels', 'LabelsType', 1, 1, {'maxOccurs': 'unbounded', 'minOccurs': '0', 'name': 'Labels', 'type': 'LabelsType'}, None),
7642
        MemberSpec_('RegionRefIndexed', 'RegionRefIndexedType', 1, 0, {'name': 'RegionRefIndexed', 'type': 'RegionRefIndexedType'}, 5),
7643
        MemberSpec_('OrderedGroupIndexed', 'OrderedGroupIndexedType', 1, 0, {'name': 'OrderedGroupIndexed', 'type': 'OrderedGroupIndexedType'}, 5),
7644
        MemberSpec_('UnorderedGroupIndexed', 'UnorderedGroupIndexedType', 1, 0, {'name': 'UnorderedGroupIndexed', 'type': 'UnorderedGroupIndexedType'}, 5),
7645
    ]
7646
    subclass = None
7647
    superclass = None
7648 View Code Duplication
    def __init__(self, id=None, regionRef=None, caption=None, type_=None, continuation=None, custom=None, comments=None, UserDefined=None, Labels=None, RegionRefIndexed=None, OrderedGroupIndexed=None, UnorderedGroupIndexed=None, gds_collector_=None, **kwargs_):
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
7649
        self.gds_collector_ = gds_collector_
7650
        self.gds_elementtree_node_ = None
7651
        self.original_tagname_ = None
7652
        self.parent_object_ = kwargs_.get('parent_object_')
7653
        self.ns_prefix_ = "pc"
7654
        self.id = _cast(None, id)
7655
        self.id_nsprefix_ = "pc"
7656
        self.regionRef = _cast(None, regionRef)
7657
        self.regionRef_nsprefix_ = "pc"
7658
        self.caption = _cast(None, caption)
7659
        self.caption_nsprefix_ = "pc"
7660
        self.type_ = _cast(None, type_)
7661
        self.type__nsprefix_ = "pc"
7662
        self.continuation = _cast(bool, continuation)
7663
        self.continuation_nsprefix_ = "pc"
7664
        self.custom = _cast(None, custom)
7665
        self.custom_nsprefix_ = "pc"
7666
        self.comments = _cast(None, comments)
7667
        self.comments_nsprefix_ = "pc"
7668
        self.UserDefined = UserDefined
7669
        self.UserDefined_nsprefix_ = "pc"
7670
        if Labels is None:
7671
            self.Labels = []
7672
        else:
7673
            self.Labels = Labels
7674
        self.Labels_nsprefix_ = "pc"
7675
        if RegionRefIndexed is None:
7676
            self.RegionRefIndexed = []
7677
        else:
7678
            self.RegionRefIndexed = RegionRefIndexed
7679
        self.RegionRefIndexed_nsprefix_ = "pc"
7680
        if OrderedGroupIndexed is None:
7681
            self.OrderedGroupIndexed = []
7682
        else:
7683
            self.OrderedGroupIndexed = OrderedGroupIndexed
7684
        self.OrderedGroupIndexed_nsprefix_ = "pc"
7685
        if UnorderedGroupIndexed is None:
7686
            self.UnorderedGroupIndexed = []
7687
        else:
7688
            self.UnorderedGroupIndexed = UnorderedGroupIndexed
7689
        self.UnorderedGroupIndexed_nsprefix_ = "pc"
7690
    def factory(*args_, **kwargs_):
7691
        if CurrentSubclassModule_ is not None:
7692
            subclass = getSubclassFromModule_(
7693
                CurrentSubclassModule_, OrderedGroupType)
7694
            if subclass is not None:
7695
                return subclass(*args_, **kwargs_)
7696
        if OrderedGroupType.subclass:
7697
            return OrderedGroupType.subclass(*args_, **kwargs_)
7698
        else:
7699
            return OrderedGroupType(*args_, **kwargs_)
7700
    factory = staticmethod(factory)
7701
    def get_ns_prefix_(self):
7702
        return self.ns_prefix_
7703
    def set_ns_prefix_(self, ns_prefix):
7704
        self.ns_prefix_ = ns_prefix
7705
    def get_UserDefined(self):
7706
        return self.UserDefined
7707
    def set_UserDefined(self, UserDefined):
7708
        self.UserDefined = UserDefined
7709
    def get_Labels(self):
7710
        return self.Labels
7711
    def set_Labels(self, Labels):
7712
        self.Labels = Labels
7713
    def add_Labels(self, value):
7714
        self.Labels.append(value)
7715
    def insert_Labels_at(self, index, value):
7716
        self.Labels.insert(index, value)
7717
    def replace_Labels_at(self, index, value):
7718
        self.Labels[index] = value
7719
    def get_RegionRefIndexed(self):
7720
        return self.RegionRefIndexed
7721
    def set_RegionRefIndexed(self, RegionRefIndexed):
7722
        self.RegionRefIndexed = RegionRefIndexed
7723
    def add_RegionRefIndexed(self, value):
7724
        self.RegionRefIndexed.append(value)
7725
    def insert_RegionRefIndexed_at(self, index, value):
7726
        self.RegionRefIndexed.insert(index, value)
7727
    def replace_RegionRefIndexed_at(self, index, value):
7728
        self.RegionRefIndexed[index] = value
7729
    def get_OrderedGroupIndexed(self):
7730
        return self.OrderedGroupIndexed
7731
    def set_OrderedGroupIndexed(self, OrderedGroupIndexed):
7732
        self.OrderedGroupIndexed = OrderedGroupIndexed
7733
    def add_OrderedGroupIndexed(self, value):
7734
        self.OrderedGroupIndexed.append(value)
7735
    def insert_OrderedGroupIndexed_at(self, index, value):
7736
        self.OrderedGroupIndexed.insert(index, value)
7737
    def replace_OrderedGroupIndexed_at(self, index, value):
7738
        self.OrderedGroupIndexed[index] = value
7739
    def get_UnorderedGroupIndexed(self):
7740
        return self.UnorderedGroupIndexed
7741
    def set_UnorderedGroupIndexed(self, UnorderedGroupIndexed):
7742
        self.UnorderedGroupIndexed = UnorderedGroupIndexed
7743
    def add_UnorderedGroupIndexed(self, value):
7744
        self.UnorderedGroupIndexed.append(value)
7745
    def insert_UnorderedGroupIndexed_at(self, index, value):
7746
        self.UnorderedGroupIndexed.insert(index, value)
7747
    def replace_UnorderedGroupIndexed_at(self, index, value):
7748
        self.UnorderedGroupIndexed[index] = value
7749
    def get_id(self):
7750
        return self.id
7751
    def set_id(self, id):
7752
        self.id = id
7753
    def get_regionRef(self):
7754
        return self.regionRef
7755
    def set_regionRef(self, regionRef):
7756
        self.regionRef = regionRef
7757
    def get_caption(self):
7758
        return self.caption
7759
    def set_caption(self, caption):
7760
        self.caption = caption
7761
    def get_type(self):
7762
        return self.type_
7763
    def set_type(self, type_):
7764
        self.type_ = type_
7765
    def get_continuation(self):
7766
        return self.continuation
7767
    def set_continuation(self, continuation):
7768
        self.continuation = continuation
7769
    def get_custom(self):
7770
        return self.custom
7771
    def set_custom(self, custom):
7772
        self.custom = custom
7773
    def get_comments(self):
7774
        return self.comments
7775
    def set_comments(self, comments):
7776
        self.comments = comments
7777
    def validate_GroupTypeSimpleType(self, value):
7778
        # Validate type pc:GroupTypeSimpleType, a restriction on string.
7779
        if value is not None and Validate_simpletypes_ and self.gds_collector_ is not None:
7780
            if not isinstance(value, str):
7781
                lineno = self.gds_get_node_lineno_()
7782
                self.gds_collector_.add_message('Value "%(value)s"%(lineno)s is not of the correct base simple type (str)' % {"value": value, "lineno": lineno, })
7783
                return False
7784
            value = value
7785
            enumerations = ['paragraph', 'list', 'list-item', 'figure', 'article', 'div', 'other']
7786
            if value not in enumerations:
7787
                lineno = self.gds_get_node_lineno_()
7788
                self.gds_collector_.add_message('Value "%(value)s"%(lineno)s does not match xsd enumeration restriction on GroupTypeSimpleType' % {"value" : encode_str_2_3(value), "lineno": lineno} )
7789
                result = False
7790
    def has__content(self):
7791
        if (
7792
            self.UserDefined is not None or
7793
            self.Labels or
7794
            self.RegionRefIndexed or
7795
            self.OrderedGroupIndexed or
7796
            self.UnorderedGroupIndexed
7797
        ):
7798
            return True
7799
        else:
7800
            return False
7801
    def export(self, outfile, level, namespaceprefix_='', namespacedef_='xmlns:pc="http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15"', name_='OrderedGroupType', pretty_print=True):
7802
        imported_ns_def_ = GenerateDSNamespaceDefs_.get('OrderedGroupType')
7803
        if imported_ns_def_ is not None:
7804
            namespacedef_ = imported_ns_def_
7805
        if pretty_print:
7806
            eol_ = '\n'
7807
        else:
7808
            eol_ = ''
7809
        if self.original_tagname_ is not None and name_ == 'OrderedGroupType':
7810
            name_ = self.original_tagname_
7811
        if UseCapturedNS_ and self.ns_prefix_:
7812
            namespaceprefix_ = self.ns_prefix_ + ':'
7813
        showIndent(outfile, level, pretty_print)
7814
        outfile.write('<%s%s%s' % (namespaceprefix_, name_, namespacedef_ and ' ' + namespacedef_ or '', ))
7815
        already_processed = set()
7816
        self._exportAttributes(outfile, level, already_processed, namespaceprefix_, name_='OrderedGroupType')
7817
        if self.has__content():
7818
            outfile.write('>%s' % (eol_, ))
7819
            self._exportChildren(outfile, level + 1, namespaceprefix_, namespacedef_, name_='OrderedGroupType', pretty_print=pretty_print)
7820
            showIndent(outfile, level, pretty_print)
7821
            outfile.write('</%s%s>%s' % (namespaceprefix_, name_, eol_))
7822
        else:
7823
            outfile.write('/>%s' % (eol_, ))
7824 View Code Duplication
    def _exportAttributes(self, outfile, level, already_processed, namespaceprefix_='', name_='OrderedGroupType'):
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
7825
        if self.id is not None and 'id' not in already_processed:
7826
            already_processed.add('id')
7827
            outfile.write(' id=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.id), input_name='id')), ))
7828
        if self.regionRef is not None and 'regionRef' not in already_processed:
7829
            already_processed.add('regionRef')
7830
            outfile.write(' regionRef=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.regionRef), input_name='regionRef')), ))
7831
        if self.caption is not None and 'caption' not in already_processed:
7832
            already_processed.add('caption')
7833
            outfile.write(' caption=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.caption), input_name='caption')), ))
7834
        if self.type_ is not None and 'type_' not in already_processed:
7835
            already_processed.add('type_')
7836
            outfile.write(' type=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.type_), input_name='type')), ))
7837
        if self.continuation is not None and 'continuation' not in already_processed:
7838
            already_processed.add('continuation')
7839
            outfile.write(' continuation="%s"' % self.gds_format_boolean(self.continuation, input_name='continuation'))
7840
        if self.custom is not None and 'custom' not in already_processed:
7841
            already_processed.add('custom')
7842
            outfile.write(' custom=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.custom), input_name='custom')), ))
7843
        if self.comments is not None and 'comments' not in already_processed:
7844
            already_processed.add('comments')
7845
            outfile.write(' comments=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.comments), input_name='comments')), ))
7846 View Code Duplication
    def _exportChildren(self, outfile, level, namespaceprefix_='', namespacedef_='xmlns:pc="http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15"', name_='OrderedGroupType', fromsubclass_=False, pretty_print=True):
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
7847
        if pretty_print:
7848
            eol_ = '\n'
7849
        else:
7850
            eol_ = ''
7851
        if self.UserDefined is not None:
7852
            namespaceprefix_ = self.UserDefined_nsprefix_ + ':' if (UseCapturedNS_ and self.UserDefined_nsprefix_) else ''
7853
            self.UserDefined.export(outfile, level, namespaceprefix_, namespacedef_='', name_='UserDefined', pretty_print=pretty_print)
7854
        for Labels_ in self.Labels:
7855
            namespaceprefix_ = self.Labels_nsprefix_ + ':' if (UseCapturedNS_ and self.Labels_nsprefix_) else ''
7856
            Labels_.export(outfile, level, namespaceprefix_, namespacedef_='', name_='Labels', pretty_print=pretty_print)
7857
        for RegionRefIndexed_ in self.RegionRefIndexed:
7858
            namespaceprefix_ = self.RegionRefIndexed_nsprefix_ + ':' if (UseCapturedNS_ and self.RegionRefIndexed_nsprefix_) else ''
7859
            RegionRefIndexed_.export(outfile, level, namespaceprefix_, namespacedef_='', name_='RegionRefIndexed', pretty_print=pretty_print)
7860
        for OrderedGroupIndexed_ in self.OrderedGroupIndexed:
7861
            namespaceprefix_ = self.OrderedGroupIndexed_nsprefix_ + ':' if (UseCapturedNS_ and self.OrderedGroupIndexed_nsprefix_) else ''
7862
            OrderedGroupIndexed_.export(outfile, level, namespaceprefix_, namespacedef_='', name_='OrderedGroupIndexed', pretty_print=pretty_print)
7863
        for UnorderedGroupIndexed_ in self.UnorderedGroupIndexed:
7864
            namespaceprefix_ = self.UnorderedGroupIndexed_nsprefix_ + ':' if (UseCapturedNS_ and self.UnorderedGroupIndexed_nsprefix_) else ''
7865
            UnorderedGroupIndexed_.export(outfile, level, namespaceprefix_, namespacedef_='', name_='UnorderedGroupIndexed', pretty_print=pretty_print)
7866
    def to_etree(self, parent_element=None, name_='OrderedGroupType', mapping_=None, reverse_mapping_=None, nsmap_=None):
7867
        if parent_element is None:
7868
            element = etree_.Element('{http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15}' + name_, nsmap=nsmap_)
7869
        else:
7870
            element = etree_.SubElement(parent_element, '{http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15}' + name_, nsmap=nsmap_)
7871
        if self.id is not None:
7872
            element.set('id', self.gds_format_string(self.id))
7873
        if self.regionRef is not None:
7874
            element.set('regionRef', self.gds_format_string(self.regionRef))
7875
        if self.caption is not None:
7876
            element.set('caption', self.gds_format_string(self.caption))
7877
        if self.type_ is not None:
7878
            element.set('type', self.gds_format_string(self.type_))
7879
        if self.continuation is not None:
7880
            element.set('continuation', self.gds_format_boolean(self.continuation))
7881
        if self.custom is not None:
7882
            element.set('custom', self.gds_format_string(self.custom))
7883
        if self.comments is not None:
7884
            element.set('comments', self.gds_format_string(self.comments))
7885
        if self.UserDefined is not None:
7886
            UserDefined_ = self.UserDefined
7887
            UserDefined_.to_etree(element, name_='UserDefined', mapping_=mapping_, reverse_mapping_=reverse_mapping_, nsmap_=nsmap_)
7888
        for Labels_ in self.Labels:
7889
            Labels_.to_etree(element, name_='Labels', mapping_=mapping_, reverse_mapping_=reverse_mapping_, nsmap_=nsmap_)
7890
        for RegionRefIndexed_ in self.RegionRefIndexed:
7891
            RegionRefIndexed_.to_etree(element, name_='RegionRefIndexed', mapping_=mapping_, reverse_mapping_=reverse_mapping_, nsmap_=nsmap_)
7892
        for OrderedGroupIndexed_ in self.OrderedGroupIndexed:
7893
            OrderedGroupIndexed_.to_etree(element, name_='OrderedGroupIndexed', mapping_=mapping_, reverse_mapping_=reverse_mapping_, nsmap_=nsmap_)
7894
        for UnorderedGroupIndexed_ in self.UnorderedGroupIndexed:
7895
            UnorderedGroupIndexed_.to_etree(element, name_='UnorderedGroupIndexed', mapping_=mapping_, reverse_mapping_=reverse_mapping_, nsmap_=nsmap_)
7896
        if mapping_ is not None:
7897
            mapping_[id(self)] = element
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable id does not seem to be defined.
Loading history...
7898
        if reverse_mapping_ is not None:
7899
            reverse_mapping_[element] = self
7900
        return element
7901
    def build(self, node, gds_collector_=None):
7902
        self.gds_collector_ = gds_collector_
7903
        if SaveElementTreeNode:
7904
            self.gds_elementtree_node_ = node
7905
        already_processed = set()
7906
        self.ns_prefix_ = node.prefix
7907
        self._buildAttributes(node, node.attrib, already_processed)
7908
        for child in node:
7909
            nodeName_ = Tag_pattern_.match(child.tag).groups()[-1]
7910
            self._buildChildren(child, node, nodeName_, gds_collector_=gds_collector_)
7911
        return self
7912 View Code Duplication
    def _buildAttributes(self, node, attrs, already_processed):
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
7913
        value = find_attr_value_('id', node)
7914
        if value is not None and 'id' not in already_processed:
7915
            already_processed.add('id')
7916
            self.id = value
7917
        value = find_attr_value_('regionRef', node)
7918
        if value is not None and 'regionRef' not in already_processed:
7919
            already_processed.add('regionRef')
7920
            self.regionRef = value
7921
        value = find_attr_value_('caption', node)
7922
        if value is not None and 'caption' not in already_processed:
7923
            already_processed.add('caption')
7924
            self.caption = value
7925
        value = find_attr_value_('type', node)
7926
        if value is not None and 'type' not in already_processed:
7927
            already_processed.add('type')
7928
            self.type_ = value
7929
            self.validate_GroupTypeSimpleType(self.type_)    # validate type GroupTypeSimpleType
7930
        value = find_attr_value_('continuation', node)
7931
        if value is not None and 'continuation' not in already_processed:
7932
            already_processed.add('continuation')
7933
            if value in ('true', '1'):
7934
                self.continuation = True
7935
            elif value in ('false', '0'):
7936
                self.continuation = False
7937
            else:
7938
                raise_parse_error(node, 'Bad boolean attribute')
7939
        value = find_attr_value_('custom', node)
7940
        if value is not None and 'custom' not in already_processed:
7941
            already_processed.add('custom')
7942
            self.custom = value
7943
        value = find_attr_value_('comments', node)
7944
        if value is not None and 'comments' not in already_processed:
7945
            already_processed.add('comments')
7946
            self.comments = value
7947 View Code Duplication
    def _buildChildren(self, child_, node, nodeName_, fromsubclass_=False, gds_collector_=None):
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
7948
        if nodeName_ == 'UserDefined':
7949
            obj_ = UserDefinedType.factory(parent_object_=self)
7950
            obj_.build(child_, gds_collector_=gds_collector_)
7951
            self.UserDefined = obj_
7952
            obj_.original_tagname_ = 'UserDefined'
7953
        elif nodeName_ == 'Labels':
7954
            obj_ = LabelsType.factory(parent_object_=self)
7955
            obj_.build(child_, gds_collector_=gds_collector_)
7956
            self.Labels.append(obj_)
7957
            obj_.original_tagname_ = 'Labels'
7958
        elif nodeName_ == 'RegionRefIndexed':
7959
            obj_ = RegionRefIndexedType.factory(parent_object_=self)
7960
            obj_.build(child_, gds_collector_=gds_collector_)
7961
            self.RegionRefIndexed.append(obj_)
7962
            obj_.original_tagname_ = 'RegionRefIndexed'
7963
        elif nodeName_ == 'OrderedGroupIndexed':
7964
            obj_ = OrderedGroupIndexedType.factory(parent_object_=self)
7965
            obj_.build(child_, gds_collector_=gds_collector_)
7966
            self.OrderedGroupIndexed.append(obj_)
7967
            obj_.original_tagname_ = 'OrderedGroupIndexed'
7968
        elif nodeName_ == 'UnorderedGroupIndexed':
7969
            obj_ = UnorderedGroupIndexedType.factory(parent_object_=self)
7970
            obj_.build(child_, gds_collector_=gds_collector_)
7971
            self.UnorderedGroupIndexed.append(obj_)
7972
            obj_.original_tagname_ = 'UnorderedGroupIndexed'
7973
    def __hash__(self):
7974
        return hash(self.id)
7975
    # pylint: disable=invalid-name,missing-module-docstring,line-too-long
7976 View Code Duplication
    def get_AllIndexed(self, classes=None, index_sort=True):
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
7977
        """
7978
        Get all indexed children sorted by their ``@index``.
7979
    
7980
        Arguments:
7981
            classes (list): Type of children (sans ``Indexed``) to return. \
7982
                Default: ``['RegionRef', 'OrderedGroup', 'UnorderedGroup']``
7983
            index_sort (boolean): Whether to sort by ``@index``
7984
    
7985
        Returns:
7986
            a list of :py:class:`RegionRefIndexedType`, \
7987
                :py:class:`OrderedGroupIndexedType`, and \
7988
                :py:class:`UnorderedGroupIndexedType`
7989
        """
7990
        if not classes:
7991
            classes = ['RegionRef', 'OrderedGroup', 'UnorderedGroup']
7992
        ret = []
7993
        for class_ in classes:
7994
            ret += getattr(self, 'get_{}Indexed'.format(class_))()
7995
        if index_sort:
7996
            return sorted(ret, key=lambda x: x.index)
7997
        return ret
7998
    def clear_AllIndexed(self):
7999
        ret = self.get_AllIndexed()
8000
        self.set_RegionRefIndexed([])
8001
        self.set_OrderedGroupIndexed([])
8002
        self.set_UnorderedGroupIndexed([])
8003
        return ret
8004
    
8005
    # pylint: disable=line-too-long,invalid-name,missing-module-docstring
8006 View Code Duplication
    def extend_AllIndexed(self, elements, validate_continuity=False):
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
8007
        """
8008
        Add all elements in list `elements`, respecting ``@index`` order.
8009
        With `validate_continuity`, check that all new elements come after all old elements
8010
        (or raise an exception). 
8011
        Otherwise, ensure this condition silently (by increasing ``@index`` accordingly).
8012
        """
8013
        if not isinstance(elements, list):
8014
            elements = [elements]
8015
        siblings = self.get_AllIndexed()
8016
        highest_sibling_index = siblings[-1].index if siblings else -1
8017
        if validate_continuity:
8018
            elements = sorted(elements, key=lambda x: x.index)
8019
            lowest_element_index = elements[0].index
8020
            if lowest_element_index <= highest_sibling_index:
8021
                raise Exception("@index already used: {}".format(lowest_element_index))
8022
        else:
8023
            for element in elements:
8024
                highest_sibling_index += 1
8025
                element.index = highest_sibling_index
8026
        for element in elements:
8027
            if isinstance(element, RegionRefIndexedType): # pylint: disable=undefined-variable
8028
                self.add_RegionRefIndexed(element)
8029
            elif isinstance(element, OrderedGroupIndexedType): # pylint: disable=undefined-variable
8030
                self.add_OrderedGroupIndexed(element)
8031
            elif isinstance(element, UnorderedGroupIndexedType): # pylint: disable=undefined-variable
8032
                self.add_UnorderedGroupIndexed(element)
8033
        return self.get_AllIndexed()
8034
    # pylint: disable=line-too-long,invalid-name,missing-module-docstring
8035 View Code Duplication
    def sort_AllIndexed(self, validate_uniqueness=True):
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
8036
        """
8037
        Sort all indexed children in-place.
8038
        """
8039
        elements = self.get_AllIndexed(index_sort=True)
8040
        self.clear_AllIndexed()
8041
        for element in elements:
8042
            if isinstance(element, RegionRefIndexedType): # pylint: disable=undefined-variable
8043
                self.add_RegionRefIndexed(element)
8044
            elif isinstance(element, OrderedGroupIndexedType): # pylint: disable=undefined-variable
8045
                self.add_OrderedGroupIndexed(element)
8046
            elif isinstance(element, UnorderedGroupIndexedType): # pylint: disable=undefined-variable
8047
                self.add_UnorderedGroupIndexed(element)
8048
        return self.get_AllIndexed()
8049
    
8050
    # pylint: disable=line-too-long,invalid-name,missing-module-docstring,missing-function-docstring
8051 View Code Duplication
    def _exportChildren(self, outfile, level, namespaceprefix_='', namespacedef_='xmlns:pc="http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15"', name_='OrderedGroupType', fromsubclass_=False, pretty_print=True): # pylint: disable=unused-argument,too-many-arguments
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
8052
        if pretty_print:
8053
            eol_ = '\n'
8054
        else:
8055
            eol_ = ''
8056
        if self.UserDefined is not None:
8057
            namespaceprefix_ = self.UserDefined_nsprefix_ + ':' if (UseCapturedNS_ and self.UserDefined_nsprefix_) else ''
8058
            self.UserDefined.export(outfile, level, namespaceprefix_, namespacedef_='', name_='UserDefined', pretty_print=pretty_print)
8059
        for Labels_ in self.Labels:
8060
            namespaceprefix_ = self.Labels_nsprefix_ + ':' if (UseCapturedNS_ and self.Labels_nsprefix_) else ''
8061
            Labels_.export(outfile, level, namespaceprefix_, namespacedef_='', name_='Labels', pretty_print=pretty_print)
8062
        cleaned = []
8063
        def replaceWithRRI(group):
8064
            rri = RegionRefIndexedType.factory(parent_object_=self) # pylint: disable=undefined-variable
8065
            rri.index = group.index
8066
            rri.regionRef = group.regionRef
8067
            cleaned.append(rri)
8068
        # remove empty groups and replace with RegionRefIndexedType
8069
        for entry in self.get_AllIndexed():
8070
            # pylint: disable=undefined-variable
8071
            if isinstance(entry, (OrderedGroupIndexedType)) and not entry.get_AllIndexed():
8072
                replaceWithRRI(entry)
8073
            elif isinstance(entry, UnorderedGroupIndexedType) and not entry.get_UnorderedGroupChildren():
8074
                replaceWithRRI(entry)
8075
            else:
8076
                cleaned.append(entry)
8077
        for entry in cleaned:
8078
            entry.export(outfile, level, namespaceprefix_, namespacedef_='', name_=entry.__class__.__name__[:-4], pretty_print=pretty_print)
8079
# end class OrderedGroupType
8080
8081
8082
class UnorderedGroupType(GeneratedsSuper):
8083
    """UnorderedGroupType --
8084
    Numbered group (contains unordered elements)
8085
      
8086
    * regionRef --
8087
      Optional link to a parent region of nested regions.
8088
      The parent region doubles as reading order group.
8089
      Only the nested regions should be allowed as group members.
8090
      
8091
    * continuation --
8092
      Is this group a continuation of another group
8093
      (from previous column or page, for example)?
8094
      
8095
    * custom -- For generic use
8096
    * Labels -- Semantic labels / tags
8097
    
8098
    """
8099
    __hash__ = GeneratedsSuper.__hash__
8100
    member_data_items_ = [
8101
        MemberSpec_('id', 'string', 0, 0, {'use': 'required', 'name': 'id'}),
8102
        MemberSpec_('regionRef', 'string', 0, 1, {'use': 'optional', 'name': 'regionRef'}),
8103
        MemberSpec_('caption', 'string', 0, 1, {'use': 'optional', 'name': 'caption'}),
8104
        MemberSpec_('type_', 'pc:GroupTypeSimpleType', 0, 1, {'use': 'optional', 'name': 'type_'}),
8105
        MemberSpec_('continuation', 'boolean', 0, 1, {'use': 'optional', 'name': 'continuation'}),
8106
        MemberSpec_('custom', 'string', 0, 1, {'use': 'optional', 'name': 'custom'}),
8107
        MemberSpec_('comments', 'string', 0, 1, {'use': 'optional', 'name': 'comments'}),
8108
        MemberSpec_('UserDefined', 'UserDefinedType', 0, 1, {'maxOccurs': '1', 'minOccurs': '0', 'name': 'UserDefined', 'type': 'UserDefinedType'}, None),
8109
        MemberSpec_('Labels', 'LabelsType', 1, 1, {'maxOccurs': 'unbounded', 'minOccurs': '0', 'name': 'Labels', 'type': 'LabelsType'}, None),
8110
        MemberSpec_('RegionRef', 'RegionRefType', 1, 0, {'name': 'RegionRef', 'type': 'RegionRefType'}, 6),
8111
        MemberSpec_('OrderedGroup', 'OrderedGroupType', 1, 0, {'name': 'OrderedGroup', 'type': 'OrderedGroupType'}, 6),
8112
        MemberSpec_('UnorderedGroup', 'UnorderedGroupType', 1, 0, {'name': 'UnorderedGroup', 'type': 'UnorderedGroupType'}, 6),
8113
    ]
8114
    subclass = None
8115
    superclass = None
8116 View Code Duplication
    def __init__(self, id=None, regionRef=None, caption=None, type_=None, continuation=None, custom=None, comments=None, UserDefined=None, Labels=None, RegionRef=None, OrderedGroup=None, UnorderedGroup=None, gds_collector_=None, **kwargs_):
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
8117
        self.gds_collector_ = gds_collector_
8118
        self.gds_elementtree_node_ = None
8119
        self.original_tagname_ = None
8120
        self.parent_object_ = kwargs_.get('parent_object_')
8121
        self.ns_prefix_ = "pc"
8122
        self.id = _cast(None, id)
8123
        self.id_nsprefix_ = "pc"
8124
        self.regionRef = _cast(None, regionRef)
8125
        self.regionRef_nsprefix_ = "pc"
8126
        self.caption = _cast(None, caption)
8127
        self.caption_nsprefix_ = "pc"
8128
        self.type_ = _cast(None, type_)
8129
        self.type__nsprefix_ = "pc"
8130
        self.continuation = _cast(bool, continuation)
8131
        self.continuation_nsprefix_ = "pc"
8132
        self.custom = _cast(None, custom)
8133
        self.custom_nsprefix_ = "pc"
8134
        self.comments = _cast(None, comments)
8135
        self.comments_nsprefix_ = "pc"
8136
        self.UserDefined = UserDefined
8137
        self.UserDefined_nsprefix_ = "pc"
8138
        if Labels is None:
8139
            self.Labels = []
8140
        else:
8141
            self.Labels = Labels
8142
        self.Labels_nsprefix_ = "pc"
8143
        if RegionRef is None:
8144
            self.RegionRef = []
8145
        else:
8146
            self.RegionRef = RegionRef
8147
        self.RegionRef_nsprefix_ = "pc"
8148
        if OrderedGroup is None:
8149
            self.OrderedGroup = []
8150
        else:
8151
            self.OrderedGroup = OrderedGroup
8152
        self.OrderedGroup_nsprefix_ = "pc"
8153
        if UnorderedGroup is None:
8154
            self.UnorderedGroup = []
8155
        else:
8156
            self.UnorderedGroup = UnorderedGroup
8157
        self.UnorderedGroup_nsprefix_ = "pc"
8158
    def factory(*args_, **kwargs_):
8159
        if CurrentSubclassModule_ is not None:
8160
            subclass = getSubclassFromModule_(
8161
                CurrentSubclassModule_, UnorderedGroupType)
8162
            if subclass is not None:
8163
                return subclass(*args_, **kwargs_)
8164
        if UnorderedGroupType.subclass:
8165
            return UnorderedGroupType.subclass(*args_, **kwargs_)
8166
        else:
8167
            return UnorderedGroupType(*args_, **kwargs_)
8168
    factory = staticmethod(factory)
8169
    def get_ns_prefix_(self):
8170
        return self.ns_prefix_
8171
    def set_ns_prefix_(self, ns_prefix):
8172
        self.ns_prefix_ = ns_prefix
8173
    def get_UserDefined(self):
8174
        return self.UserDefined
8175
    def set_UserDefined(self, UserDefined):
8176
        self.UserDefined = UserDefined
8177
    def get_Labels(self):
8178
        return self.Labels
8179
    def set_Labels(self, Labels):
8180
        self.Labels = Labels
8181
    def add_Labels(self, value):
8182
        self.Labels.append(value)
8183
    def insert_Labels_at(self, index, value):
8184
        self.Labels.insert(index, value)
8185
    def replace_Labels_at(self, index, value):
8186
        self.Labels[index] = value
8187
    def get_RegionRef(self):
8188
        return self.RegionRef
8189
    def set_RegionRef(self, RegionRef):
8190
        self.RegionRef = RegionRef
8191
    def add_RegionRef(self, value):
8192
        self.RegionRef.append(value)
8193
    def insert_RegionRef_at(self, index, value):
8194
        self.RegionRef.insert(index, value)
8195
    def replace_RegionRef_at(self, index, value):
8196
        self.RegionRef[index] = value
8197
    def get_OrderedGroup(self):
8198
        return self.OrderedGroup
8199
    def set_OrderedGroup(self, OrderedGroup):
8200
        self.OrderedGroup = OrderedGroup
8201
    def add_OrderedGroup(self, value):
8202
        self.OrderedGroup.append(value)
8203
    def insert_OrderedGroup_at(self, index, value):
8204
        self.OrderedGroup.insert(index, value)
8205
    def replace_OrderedGroup_at(self, index, value):
8206
        self.OrderedGroup[index] = value
8207
    def get_UnorderedGroup(self):
8208
        return self.UnorderedGroup
8209
    def set_UnorderedGroup(self, UnorderedGroup):
8210
        self.UnorderedGroup = UnorderedGroup
8211
    def add_UnorderedGroup(self, value):
8212
        self.UnorderedGroup.append(value)
8213
    def insert_UnorderedGroup_at(self, index, value):
8214
        self.UnorderedGroup.insert(index, value)
8215
    def replace_UnorderedGroup_at(self, index, value):
8216
        self.UnorderedGroup[index] = value
8217
    def get_id(self):
8218
        return self.id
8219
    def set_id(self, id):
8220
        self.id = id
8221
    def get_regionRef(self):
8222
        return self.regionRef
8223
    def set_regionRef(self, regionRef):
8224
        self.regionRef = regionRef
8225
    def get_caption(self):
8226
        return self.caption
8227
    def set_caption(self, caption):
8228
        self.caption = caption
8229
    def get_type(self):
8230
        return self.type_
8231
    def set_type(self, type_):
8232
        self.type_ = type_
8233
    def get_continuation(self):
8234
        return self.continuation
8235
    def set_continuation(self, continuation):
8236
        self.continuation = continuation
8237
    def get_custom(self):
8238
        return self.custom
8239
    def set_custom(self, custom):
8240
        self.custom = custom
8241
    def get_comments(self):
8242
        return self.comments
8243
    def set_comments(self, comments):
8244
        self.comments = comments
8245
    def validate_GroupTypeSimpleType(self, value):
8246
        # Validate type pc:GroupTypeSimpleType, a restriction on string.
8247
        if value is not None and Validate_simpletypes_ and self.gds_collector_ is not None:
8248
            if not isinstance(value, str):
8249
                lineno = self.gds_get_node_lineno_()
8250
                self.gds_collector_.add_message('Value "%(value)s"%(lineno)s is not of the correct base simple type (str)' % {"value": value, "lineno": lineno, })
8251
                return False
8252
            value = value
8253
            enumerations = ['paragraph', 'list', 'list-item', 'figure', 'article', 'div', 'other']
8254
            if value not in enumerations:
8255
                lineno = self.gds_get_node_lineno_()
8256
                self.gds_collector_.add_message('Value "%(value)s"%(lineno)s does not match xsd enumeration restriction on GroupTypeSimpleType' % {"value" : encode_str_2_3(value), "lineno": lineno} )
8257
                result = False
8258
    def has__content(self):
8259
        if (
8260
            self.UserDefined is not None or
8261
            self.Labels or
8262
            self.RegionRef or
8263
            self.OrderedGroup or
8264
            self.UnorderedGroup
8265
        ):
8266
            return True
8267
        else:
8268
            return False
8269
    def export(self, outfile, level, namespaceprefix_='', namespacedef_='xmlns:pc="http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15"', name_='UnorderedGroupType', pretty_print=True):
8270
        imported_ns_def_ = GenerateDSNamespaceDefs_.get('UnorderedGroupType')
8271
        if imported_ns_def_ is not None:
8272
            namespacedef_ = imported_ns_def_
8273
        if pretty_print:
8274
            eol_ = '\n'
8275
        else:
8276
            eol_ = ''
8277
        if self.original_tagname_ is not None and name_ == 'UnorderedGroupType':
8278
            name_ = self.original_tagname_
8279
        if UseCapturedNS_ and self.ns_prefix_:
8280
            namespaceprefix_ = self.ns_prefix_ + ':'
8281
        showIndent(outfile, level, pretty_print)
8282
        outfile.write('<%s%s%s' % (namespaceprefix_, name_, namespacedef_ and ' ' + namespacedef_ or '', ))
8283
        already_processed = set()
8284
        self._exportAttributes(outfile, level, already_processed, namespaceprefix_, name_='UnorderedGroupType')
8285
        if self.has__content():
8286
            outfile.write('>%s' % (eol_, ))
8287
            self._exportChildren(outfile, level + 1, namespaceprefix_, namespacedef_, name_='UnorderedGroupType', pretty_print=pretty_print)
8288
            showIndent(outfile, level, pretty_print)
8289
            outfile.write('</%s%s>%s' % (namespaceprefix_, name_, eol_))
8290
        else:
8291
            outfile.write('/>%s' % (eol_, ))
8292 View Code Duplication
    def _exportAttributes(self, outfile, level, already_processed, namespaceprefix_='', name_='UnorderedGroupType'):
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
8293
        if self.id is not None and 'id' not in already_processed:
8294
            already_processed.add('id')
8295
            outfile.write(' id=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.id), input_name='id')), ))
8296
        if self.regionRef is not None and 'regionRef' not in already_processed:
8297
            already_processed.add('regionRef')
8298
            outfile.write(' regionRef=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.regionRef), input_name='regionRef')), ))
8299
        if self.caption is not None and 'caption' not in already_processed:
8300
            already_processed.add('caption')
8301
            outfile.write(' caption=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.caption), input_name='caption')), ))
8302
        if self.type_ is not None and 'type_' not in already_processed:
8303
            already_processed.add('type_')
8304
            outfile.write(' type=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.type_), input_name='type')), ))
8305
        if self.continuation is not None and 'continuation' not in already_processed:
8306
            already_processed.add('continuation')
8307
            outfile.write(' continuation="%s"' % self.gds_format_boolean(self.continuation, input_name='continuation'))
8308
        if self.custom is not None and 'custom' not in already_processed:
8309
            already_processed.add('custom')
8310
            outfile.write(' custom=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.custom), input_name='custom')), ))
8311
        if self.comments is not None and 'comments' not in already_processed:
8312
            already_processed.add('comments')
8313
            outfile.write(' comments=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.comments), input_name='comments')), ))
8314 View Code Duplication
    def _exportChildren(self, outfile, level, namespaceprefix_='', namespacedef_='xmlns:pc="http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15"', name_='UnorderedGroupType', fromsubclass_=False, pretty_print=True):
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
8315
        if pretty_print:
8316
            eol_ = '\n'
8317
        else:
8318
            eol_ = ''
8319
        if self.UserDefined is not None:
8320
            namespaceprefix_ = self.UserDefined_nsprefix_ + ':' if (UseCapturedNS_ and self.UserDefined_nsprefix_) else ''
8321
            self.UserDefined.export(outfile, level, namespaceprefix_, namespacedef_='', name_='UserDefined', pretty_print=pretty_print)
8322
        for Labels_ in self.Labels:
8323
            namespaceprefix_ = self.Labels_nsprefix_ + ':' if (UseCapturedNS_ and self.Labels_nsprefix_) else ''
8324
            Labels_.export(outfile, level, namespaceprefix_, namespacedef_='', name_='Labels', pretty_print=pretty_print)
8325
        for RegionRef_ in self.RegionRef:
8326
            namespaceprefix_ = self.RegionRef_nsprefix_ + ':' if (UseCapturedNS_ and self.RegionRef_nsprefix_) else ''
8327
            RegionRef_.export(outfile, level, namespaceprefix_, namespacedef_='', name_='RegionRef', pretty_print=pretty_print)
8328
        for OrderedGroup_ in self.OrderedGroup:
8329
            namespaceprefix_ = self.OrderedGroup_nsprefix_ + ':' if (UseCapturedNS_ and self.OrderedGroup_nsprefix_) else ''
8330
            OrderedGroup_.export(outfile, level, namespaceprefix_, namespacedef_='', name_='OrderedGroup', pretty_print=pretty_print)
8331
        for UnorderedGroup_ in self.UnorderedGroup:
8332
            namespaceprefix_ = self.UnorderedGroup_nsprefix_ + ':' if (UseCapturedNS_ and self.UnorderedGroup_nsprefix_) else ''
8333
            UnorderedGroup_.export(outfile, level, namespaceprefix_, namespacedef_='', name_='UnorderedGroup', pretty_print=pretty_print)
8334
    def to_etree(self, parent_element=None, name_='UnorderedGroupType', mapping_=None, reverse_mapping_=None, nsmap_=None):
8335
        if parent_element is None:
8336
            element = etree_.Element('{http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15}' + name_, nsmap=nsmap_)
8337
        else:
8338
            element = etree_.SubElement(parent_element, '{http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15}' + name_, nsmap=nsmap_)
8339
        if self.id is not None:
8340
            element.set('id', self.gds_format_string(self.id))
8341
        if self.regionRef is not None:
8342
            element.set('regionRef', self.gds_format_string(self.regionRef))
8343
        if self.caption is not None:
8344
            element.set('caption', self.gds_format_string(self.caption))
8345
        if self.type_ is not None:
8346
            element.set('type', self.gds_format_string(self.type_))
8347
        if self.continuation is not None:
8348
            element.set('continuation', self.gds_format_boolean(self.continuation))
8349
        if self.custom is not None:
8350
            element.set('custom', self.gds_format_string(self.custom))
8351
        if self.comments is not None:
8352
            element.set('comments', self.gds_format_string(self.comments))
8353
        if self.UserDefined is not None:
8354
            UserDefined_ = self.UserDefined
8355
            UserDefined_.to_etree(element, name_='UserDefined', mapping_=mapping_, reverse_mapping_=reverse_mapping_, nsmap_=nsmap_)
8356
        for Labels_ in self.Labels:
8357
            Labels_.to_etree(element, name_='Labels', mapping_=mapping_, reverse_mapping_=reverse_mapping_, nsmap_=nsmap_)
8358
        for RegionRef_ in self.RegionRef:
8359
            RegionRef_.to_etree(element, name_='RegionRef', mapping_=mapping_, reverse_mapping_=reverse_mapping_, nsmap_=nsmap_)
8360
        for OrderedGroup_ in self.OrderedGroup:
8361
            OrderedGroup_.to_etree(element, name_='OrderedGroup', mapping_=mapping_, reverse_mapping_=reverse_mapping_, nsmap_=nsmap_)
8362
        for UnorderedGroup_ in self.UnorderedGroup:
8363
            UnorderedGroup_.to_etree(element, name_='UnorderedGroup', mapping_=mapping_, reverse_mapping_=reverse_mapping_, nsmap_=nsmap_)
8364
        if mapping_ is not None:
8365
            mapping_[id(self)] = element
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable id does not seem to be defined.
Loading history...
8366
        if reverse_mapping_ is not None:
8367
            reverse_mapping_[element] = self
8368
        return element
8369
    def build(self, node, gds_collector_=None):
8370
        self.gds_collector_ = gds_collector_
8371
        if SaveElementTreeNode:
8372
            self.gds_elementtree_node_ = node
8373
        already_processed = set()
8374
        self.ns_prefix_ = node.prefix
8375
        self._buildAttributes(node, node.attrib, already_processed)
8376
        for child in node:
8377
            nodeName_ = Tag_pattern_.match(child.tag).groups()[-1]
8378
            self._buildChildren(child, node, nodeName_, gds_collector_=gds_collector_)
8379
        return self
8380 View Code Duplication
    def _buildAttributes(self, node, attrs, already_processed):
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
8381
        value = find_attr_value_('id', node)
8382
        if value is not None and 'id' not in already_processed:
8383
            already_processed.add('id')
8384
            self.id = value
8385
        value = find_attr_value_('regionRef', node)
8386
        if value is not None and 'regionRef' not in already_processed:
8387
            already_processed.add('regionRef')
8388
            self.regionRef = value
8389
        value = find_attr_value_('caption', node)
8390
        if value is not None and 'caption' not in already_processed:
8391
            already_processed.add('caption')
8392
            self.caption = value
8393
        value = find_attr_value_('type', node)
8394
        if value is not None and 'type' not in already_processed:
8395
            already_processed.add('type')
8396
            self.type_ = value
8397
            self.validate_GroupTypeSimpleType(self.type_)    # validate type GroupTypeSimpleType
8398
        value = find_attr_value_('continuation', node)
8399
        if value is not None and 'continuation' not in already_processed:
8400
            already_processed.add('continuation')
8401
            if value in ('true', '1'):
8402
                self.continuation = True
8403
            elif value in ('false', '0'):
8404
                self.continuation = False
8405
            else:
8406
                raise_parse_error(node, 'Bad boolean attribute')
8407
        value = find_attr_value_('custom', node)
8408
        if value is not None and 'custom' not in already_processed:
8409
            already_processed.add('custom')
8410
            self.custom = value
8411
        value = find_attr_value_('comments', node)
8412
        if value is not None and 'comments' not in already_processed:
8413
            already_processed.add('comments')
8414
            self.comments = value
8415 View Code Duplication
    def _buildChildren(self, child_, node, nodeName_, fromsubclass_=False, gds_collector_=None):
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
8416
        if nodeName_ == 'UserDefined':
8417
            obj_ = UserDefinedType.factory(parent_object_=self)
8418
            obj_.build(child_, gds_collector_=gds_collector_)
8419
            self.UserDefined = obj_
8420
            obj_.original_tagname_ = 'UserDefined'
8421
        elif nodeName_ == 'Labels':
8422
            obj_ = LabelsType.factory(parent_object_=self)
8423
            obj_.build(child_, gds_collector_=gds_collector_)
8424
            self.Labels.append(obj_)
8425
            obj_.original_tagname_ = 'Labels'
8426
        elif nodeName_ == 'RegionRef':
8427
            obj_ = RegionRefType.factory(parent_object_=self)
8428
            obj_.build(child_, gds_collector_=gds_collector_)
8429
            self.RegionRef.append(obj_)
8430
            obj_.original_tagname_ = 'RegionRef'
8431
        elif nodeName_ == 'OrderedGroup':
8432
            obj_ = OrderedGroupType.factory(parent_object_=self)
8433
            obj_.build(child_, gds_collector_=gds_collector_)
8434
            self.OrderedGroup.append(obj_)
8435
            obj_.original_tagname_ = 'OrderedGroup'
8436
        elif nodeName_ == 'UnorderedGroup':
8437
            obj_ = UnorderedGroupType.factory(parent_object_=self)
8438
            obj_.build(child_, gds_collector_=gds_collector_)
8439
            self.UnorderedGroup.append(obj_)
8440
            obj_.original_tagname_ = 'UnorderedGroup'
8441
    def __hash__(self):
8442
        return hash(self.id)
8443
    def get_UnorderedGroupChildren(self):
8444
        """
8445
        List all non-metadata children of an :py:class:`UnorderedGroupType`
8446
        """
8447
        # TODO: should not change order
8448
        return self.get_RegionRef() + self.get_OrderedGroup() + self.get_UnorderedGroup()
8449
    
8450
# end class UnorderedGroupType
8451
8452
8453
class BorderType(GeneratedsSuper):
8454
    """BorderType --
8455
    Border of the actual page (if the scanned image
8456
    contains parts not belonging to the page).
8457
    
8458
    """
8459
    __hash__ = GeneratedsSuper.__hash__
8460
    member_data_items_ = [
8461
        MemberSpec_('Coords', 'CoordsType', 0, 0, {'name': 'Coords', 'type': 'CoordsType'}, None),
8462
    ]
8463
    subclass = None
8464
    superclass = None
8465
    def __init__(self, Coords=None, gds_collector_=None, **kwargs_):
8466
        self.gds_collector_ = gds_collector_
8467
        self.gds_elementtree_node_ = None
8468
        self.original_tagname_ = None
8469
        self.parent_object_ = kwargs_.get('parent_object_')
8470
        self.ns_prefix_ = "pc"
8471
        self.Coords = Coords
8472
        self.Coords_nsprefix_ = "pc"
8473
    def factory(*args_, **kwargs_):
8474
        if CurrentSubclassModule_ is not None:
8475
            subclass = getSubclassFromModule_(
8476
                CurrentSubclassModule_, BorderType)
8477
            if subclass is not None:
8478
                return subclass(*args_, **kwargs_)
8479
        if BorderType.subclass:
8480
            return BorderType.subclass(*args_, **kwargs_)
8481
        else:
8482
            return BorderType(*args_, **kwargs_)
8483
    factory = staticmethod(factory)
8484
    def get_ns_prefix_(self):
8485
        return self.ns_prefix_
8486
    def set_ns_prefix_(self, ns_prefix):
8487
        self.ns_prefix_ = ns_prefix
8488
    def get_Coords(self):
8489
        return self.Coords
8490
    def set_Coords(self, Coords):
8491
        self.Coords = Coords
8492
    def has__content(self):
8493
        if (
8494
            self.Coords is not None
8495
        ):
8496
            return True
8497
        else:
8498
            return False
8499
    def export(self, outfile, level, namespaceprefix_='', namespacedef_='xmlns:pc="http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15"', name_='BorderType', pretty_print=True):
8500
        imported_ns_def_ = GenerateDSNamespaceDefs_.get('BorderType')
8501
        if imported_ns_def_ is not None:
8502
            namespacedef_ = imported_ns_def_
8503
        if pretty_print:
8504
            eol_ = '\n'
8505
        else:
8506
            eol_ = ''
8507
        if self.original_tagname_ is not None and name_ == 'BorderType':
8508
            name_ = self.original_tagname_
8509
        if UseCapturedNS_ and self.ns_prefix_:
8510
            namespaceprefix_ = self.ns_prefix_ + ':'
8511
        showIndent(outfile, level, pretty_print)
8512
        outfile.write('<%s%s%s' % (namespaceprefix_, name_, namespacedef_ and ' ' + namespacedef_ or '', ))
8513
        already_processed = set()
8514
        self._exportAttributes(outfile, level, already_processed, namespaceprefix_, name_='BorderType')
8515
        if self.has__content():
8516
            outfile.write('>%s' % (eol_, ))
8517
            self._exportChildren(outfile, level + 1, namespaceprefix_, namespacedef_, name_='BorderType', pretty_print=pretty_print)
8518
            showIndent(outfile, level, pretty_print)
8519
            outfile.write('</%s%s>%s' % (namespaceprefix_, name_, eol_))
8520
        else:
8521
            outfile.write('/>%s' % (eol_, ))
8522
    def _exportAttributes(self, outfile, level, already_processed, namespaceprefix_='', name_='BorderType'):
8523
        pass
8524
    def _exportChildren(self, outfile, level, namespaceprefix_='', namespacedef_='xmlns:pc="http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15"', name_='BorderType', fromsubclass_=False, pretty_print=True):
8525
        if pretty_print:
8526
            eol_ = '\n'
8527
        else:
8528
            eol_ = ''
8529
        if self.Coords is not None:
8530
            namespaceprefix_ = self.Coords_nsprefix_ + ':' if (UseCapturedNS_ and self.Coords_nsprefix_) else ''
8531
            self.Coords.export(outfile, level, namespaceprefix_, namespacedef_='', name_='Coords', pretty_print=pretty_print)
8532
    def to_etree(self, parent_element=None, name_='BorderType', mapping_=None, reverse_mapping_=None, nsmap_=None):
8533
        if parent_element is None:
8534
            element = etree_.Element('{http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15}' + name_, nsmap=nsmap_)
8535
        else:
8536
            element = etree_.SubElement(parent_element, '{http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15}' + name_, nsmap=nsmap_)
8537
        if self.Coords is not None:
8538
            Coords_ = self.Coords
8539
            Coords_.to_etree(element, name_='Coords', mapping_=mapping_, reverse_mapping_=reverse_mapping_, nsmap_=nsmap_)
8540
        if mapping_ is not None:
8541
            mapping_[id(self)] = element
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable id does not seem to be defined.
Loading history...
8542
        if reverse_mapping_ is not None:
8543
            reverse_mapping_[element] = self
8544
        return element
8545
    def build(self, node, gds_collector_=None):
8546
        self.gds_collector_ = gds_collector_
8547
        if SaveElementTreeNode:
8548
            self.gds_elementtree_node_ = node
8549
        already_processed = set()
8550
        self.ns_prefix_ = node.prefix
8551
        self._buildAttributes(node, node.attrib, already_processed)
8552
        for child in node:
8553
            nodeName_ = Tag_pattern_.match(child.tag).groups()[-1]
8554
            self._buildChildren(child, node, nodeName_, gds_collector_=gds_collector_)
8555
        return self
8556
    def _buildAttributes(self, node, attrs, already_processed):
8557
        pass
8558
    def _buildChildren(self, child_, node, nodeName_, fromsubclass_=False, gds_collector_=None):
8559
        if nodeName_ == 'Coords':
8560
            obj_ = CoordsType.factory(parent_object_=self)
8561
            obj_.build(child_, gds_collector_=gds_collector_)
8562
            self.Coords = obj_
8563
            obj_.original_tagname_ = 'Coords'
8564
    def __hash__(self):
8565
        return hash(self.id)
8566
    def set_Coords(self, Coords):
8567
        """
8568
        Set coordinate polygon by given :py:class:`CoordsType` object.
8569
        Moreover, invalidate self's ``pc:AlternativeImage``s
8570
        (because they will have been cropped with a bbox
8571
        of the previous polygon).
8572
        """
8573
        if hasattr(self, 'invalidate_AlternativeImage'):
8574
            # RegionType, TextLineType, WordType, GlyphType:
8575
            self.invalidate_AlternativeImage()
8576
        elif hasattr(self, 'parent_object_') and hasattr(self.parent_object_, 'invalidate_AlternativeImage'):
8577
            # BorderType:
8578
            self.parent_object_.invalidate_AlternativeImage(feature_selector='cropped')
8579
        self.Coords = Coords
8580
# end class BorderType
8581
8582
8583 View Code Duplication
class LayersType(GeneratedsSuper):
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
8584
    """LayersType --
8585
    Can be used to express the z-index of overlapping
8586
    regions. An element with a greater z-index is always in
8587
    front of another element with lower z-index.
8588
    
8589
    """
8590
    __hash__ = GeneratedsSuper.__hash__
8591
    member_data_items_ = [
8592
        MemberSpec_('Layer', 'LayerType', 1, 0, {'maxOccurs': 'unbounded', 'minOccurs': '1', 'name': 'Layer', 'type': 'LayerType'}, None),
8593
    ]
8594
    subclass = None
8595
    superclass = None
8596
    def __init__(self, Layer=None, gds_collector_=None, **kwargs_):
8597
        self.gds_collector_ = gds_collector_
8598
        self.gds_elementtree_node_ = None
8599
        self.original_tagname_ = None
8600
        self.parent_object_ = kwargs_.get('parent_object_')
8601
        self.ns_prefix_ = "pc"
8602
        if Layer is None:
8603
            self.Layer = []
8604
        else:
8605
            self.Layer = Layer
8606
        self.Layer_nsprefix_ = "pc"
8607
    def factory(*args_, **kwargs_):
8608
        if CurrentSubclassModule_ is not None:
8609
            subclass = getSubclassFromModule_(
8610
                CurrentSubclassModule_, LayersType)
8611
            if subclass is not None:
8612
                return subclass(*args_, **kwargs_)
8613
        if LayersType.subclass:
8614
            return LayersType.subclass(*args_, **kwargs_)
8615
        else:
8616
            return LayersType(*args_, **kwargs_)
8617
    factory = staticmethod(factory)
8618
    def get_ns_prefix_(self):
8619
        return self.ns_prefix_
8620
    def set_ns_prefix_(self, ns_prefix):
8621
        self.ns_prefix_ = ns_prefix
8622
    def get_Layer(self):
8623
        return self.Layer
8624
    def set_Layer(self, Layer):
8625
        self.Layer = Layer
8626
    def add_Layer(self, value):
8627
        self.Layer.append(value)
8628
    def insert_Layer_at(self, index, value):
8629
        self.Layer.insert(index, value)
8630
    def replace_Layer_at(self, index, value):
8631
        self.Layer[index] = value
8632
    def has__content(self):
8633
        if (
8634
            self.Layer
8635
        ):
8636
            return True
8637
        else:
8638
            return False
8639
    def export(self, outfile, level, namespaceprefix_='', namespacedef_='xmlns:pc="http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15"', name_='LayersType', pretty_print=True):
8640
        imported_ns_def_ = GenerateDSNamespaceDefs_.get('LayersType')
8641
        if imported_ns_def_ is not None:
8642
            namespacedef_ = imported_ns_def_
8643
        if pretty_print:
8644
            eol_ = '\n'
8645
        else:
8646
            eol_ = ''
8647
        if self.original_tagname_ is not None and name_ == 'LayersType':
8648
            name_ = self.original_tagname_
8649
        if UseCapturedNS_ and self.ns_prefix_:
8650
            namespaceprefix_ = self.ns_prefix_ + ':'
8651
        showIndent(outfile, level, pretty_print)
8652
        outfile.write('<%s%s%s' % (namespaceprefix_, name_, namespacedef_ and ' ' + namespacedef_ or '', ))
8653
        already_processed = set()
8654
        self._exportAttributes(outfile, level, already_processed, namespaceprefix_, name_='LayersType')
8655
        if self.has__content():
8656
            outfile.write('>%s' % (eol_, ))
8657
            self._exportChildren(outfile, level + 1, namespaceprefix_, namespacedef_, name_='LayersType', pretty_print=pretty_print)
8658
            showIndent(outfile, level, pretty_print)
8659
            outfile.write('</%s%s>%s' % (namespaceprefix_, name_, eol_))
8660
        else:
8661
            outfile.write('/>%s' % (eol_, ))
8662
    def _exportAttributes(self, outfile, level, already_processed, namespaceprefix_='', name_='LayersType'):
8663
        pass
8664
    def _exportChildren(self, outfile, level, namespaceprefix_='', namespacedef_='xmlns:pc="http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15"', name_='LayersType', fromsubclass_=False, pretty_print=True):
8665
        if pretty_print:
8666
            eol_ = '\n'
8667
        else:
8668
            eol_ = ''
8669
        for Layer_ in self.Layer:
8670
            namespaceprefix_ = self.Layer_nsprefix_ + ':' if (UseCapturedNS_ and self.Layer_nsprefix_) else ''
8671
            Layer_.export(outfile, level, namespaceprefix_, namespacedef_='', name_='Layer', pretty_print=pretty_print)
8672
    def to_etree(self, parent_element=None, name_='LayersType', mapping_=None, reverse_mapping_=None, nsmap_=None):
8673
        if parent_element is None:
8674
            element = etree_.Element('{http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15}' + name_, nsmap=nsmap_)
8675
        else:
8676
            element = etree_.SubElement(parent_element, '{http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15}' + name_, nsmap=nsmap_)
8677
        for Layer_ in self.Layer:
8678
            Layer_.to_etree(element, name_='Layer', mapping_=mapping_, reverse_mapping_=reverse_mapping_, nsmap_=nsmap_)
8679
        if mapping_ is not None:
8680
            mapping_[id(self)] = element
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable id does not seem to be defined.
Loading history...
8681
        if reverse_mapping_ is not None:
8682
            reverse_mapping_[element] = self
8683
        return element
8684
    def build(self, node, gds_collector_=None):
8685
        self.gds_collector_ = gds_collector_
8686
        if SaveElementTreeNode:
8687
            self.gds_elementtree_node_ = node
8688
        already_processed = set()
8689
        self.ns_prefix_ = node.prefix
8690
        self._buildAttributes(node, node.attrib, already_processed)
8691
        for child in node:
8692
            nodeName_ = Tag_pattern_.match(child.tag).groups()[-1]
8693
            self._buildChildren(child, node, nodeName_, gds_collector_=gds_collector_)
8694
        return self
8695
    def _buildAttributes(self, node, attrs, already_processed):
8696
        pass
8697
    def _buildChildren(self, child_, node, nodeName_, fromsubclass_=False, gds_collector_=None):
8698
        if nodeName_ == 'Layer':
8699
            obj_ = LayerType.factory(parent_object_=self)
8700
            obj_.build(child_, gds_collector_=gds_collector_)
8701
            self.Layer.append(obj_)
8702
            obj_.original_tagname_ = 'Layer'
8703
    def __hash__(self):
8704
        return hash(self.id)
8705
# end class LayersType
8706
8707
8708
class LayerType(GeneratedsSuper):
8709
    __hash__ = GeneratedsSuper.__hash__
8710
    member_data_items_ = [
8711
        MemberSpec_('id', 'string', 0, 0, {'use': 'required', 'name': 'id'}),
8712
        MemberSpec_('zIndex', 'int', 0, 0, {'use': 'required', 'name': 'zIndex'}),
8713
        MemberSpec_('caption', 'string', 0, 1, {'use': 'optional', 'name': 'caption'}),
8714
        MemberSpec_('RegionRef', 'RegionRefType', 1, 0, {'maxOccurs': 'unbounded', 'minOccurs': '1', 'name': 'RegionRef', 'type': 'RegionRefType'}, None),
8715
    ]
8716
    subclass = None
8717
    superclass = None
8718
    def __init__(self, id=None, zIndex=None, caption=None, RegionRef=None, gds_collector_=None, **kwargs_):
8719
        self.gds_collector_ = gds_collector_
8720
        self.gds_elementtree_node_ = None
8721
        self.original_tagname_ = None
8722
        self.parent_object_ = kwargs_.get('parent_object_')
8723
        self.ns_prefix_ = "pc"
8724
        self.id = _cast(None, id)
8725
        self.id_nsprefix_ = "pc"
8726
        self.zIndex = _cast(int, zIndex)
8727
        self.zIndex_nsprefix_ = "pc"
8728
        self.caption = _cast(None, caption)
8729
        self.caption_nsprefix_ = "pc"
8730
        if RegionRef is None:
8731
            self.RegionRef = []
8732
        else:
8733
            self.RegionRef = RegionRef
8734
        self.RegionRef_nsprefix_ = "pc"
8735
    def factory(*args_, **kwargs_):
8736
        if CurrentSubclassModule_ is not None:
8737
            subclass = getSubclassFromModule_(
8738
                CurrentSubclassModule_, LayerType)
8739
            if subclass is not None:
8740
                return subclass(*args_, **kwargs_)
8741
        if LayerType.subclass:
8742
            return LayerType.subclass(*args_, **kwargs_)
8743
        else:
8744
            return LayerType(*args_, **kwargs_)
8745
    factory = staticmethod(factory)
8746
    def get_ns_prefix_(self):
8747
        return self.ns_prefix_
8748
    def set_ns_prefix_(self, ns_prefix):
8749
        self.ns_prefix_ = ns_prefix
8750
    def get_RegionRef(self):
8751
        return self.RegionRef
8752
    def set_RegionRef(self, RegionRef):
8753
        self.RegionRef = RegionRef
8754
    def add_RegionRef(self, value):
8755
        self.RegionRef.append(value)
8756
    def insert_RegionRef_at(self, index, value):
8757
        self.RegionRef.insert(index, value)
8758
    def replace_RegionRef_at(self, index, value):
8759
        self.RegionRef[index] = value
8760
    def get_id(self):
8761
        return self.id
8762
    def set_id(self, id):
8763
        self.id = id
8764
    def get_zIndex(self):
8765
        return self.zIndex
8766
    def set_zIndex(self, zIndex):
8767
        self.zIndex = zIndex
8768
    def get_caption(self):
8769
        return self.caption
8770
    def set_caption(self, caption):
8771
        self.caption = caption
8772
    def has__content(self):
8773
        if (
8774
            self.RegionRef
8775
        ):
8776
            return True
8777
        else:
8778
            return False
8779
    def export(self, outfile, level, namespaceprefix_='', namespacedef_='xmlns:pc="http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15"', name_='LayerType', pretty_print=True):
8780
        imported_ns_def_ = GenerateDSNamespaceDefs_.get('LayerType')
8781
        if imported_ns_def_ is not None:
8782
            namespacedef_ = imported_ns_def_
8783
        if pretty_print:
8784
            eol_ = '\n'
8785
        else:
8786
            eol_ = ''
8787
        if self.original_tagname_ is not None and name_ == 'LayerType':
8788
            name_ = self.original_tagname_
8789
        if UseCapturedNS_ and self.ns_prefix_:
8790
            namespaceprefix_ = self.ns_prefix_ + ':'
8791
        showIndent(outfile, level, pretty_print)
8792
        outfile.write('<%s%s%s' % (namespaceprefix_, name_, namespacedef_ and ' ' + namespacedef_ or '', ))
8793
        already_processed = set()
8794
        self._exportAttributes(outfile, level, already_processed, namespaceprefix_, name_='LayerType')
8795
        if self.has__content():
8796
            outfile.write('>%s' % (eol_, ))
8797
            self._exportChildren(outfile, level + 1, namespaceprefix_, namespacedef_, name_='LayerType', pretty_print=pretty_print)
8798
            showIndent(outfile, level, pretty_print)
8799
            outfile.write('</%s%s>%s' % (namespaceprefix_, name_, eol_))
8800
        else:
8801
            outfile.write('/>%s' % (eol_, ))
8802
    def _exportAttributes(self, outfile, level, already_processed, namespaceprefix_='', name_='LayerType'):
8803
        if self.id is not None and 'id' not in already_processed:
8804
            already_processed.add('id')
8805
            outfile.write(' id=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.id), input_name='id')), ))
8806
        if self.zIndex is not None and 'zIndex' not in already_processed:
8807
            already_processed.add('zIndex')
8808
            outfile.write(' zIndex="%s"' % self.gds_format_integer(self.zIndex, input_name='zIndex'))
8809
        if self.caption is not None and 'caption' not in already_processed:
8810
            already_processed.add('caption')
8811
            outfile.write(' caption=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.caption), input_name='caption')), ))
8812
    def _exportChildren(self, outfile, level, namespaceprefix_='', namespacedef_='xmlns:pc="http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15"', name_='LayerType', fromsubclass_=False, pretty_print=True):
8813
        if pretty_print:
8814
            eol_ = '\n'
8815
        else:
8816
            eol_ = ''
8817
        for RegionRef_ in self.RegionRef:
8818
            namespaceprefix_ = self.RegionRef_nsprefix_ + ':' if (UseCapturedNS_ and self.RegionRef_nsprefix_) else ''
8819
            RegionRef_.export(outfile, level, namespaceprefix_, namespacedef_='', name_='RegionRef', pretty_print=pretty_print)
8820
    def to_etree(self, parent_element=None, name_='LayerType', mapping_=None, reverse_mapping_=None, nsmap_=None):
8821
        if parent_element is None:
8822
            element = etree_.Element('{http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15}' + name_, nsmap=nsmap_)
8823
        else:
8824
            element = etree_.SubElement(parent_element, '{http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15}' + name_, nsmap=nsmap_)
8825
        if self.id is not None:
8826
            element.set('id', self.gds_format_string(self.id))
8827
        if self.zIndex is not None:
8828
            element.set('zIndex', self.gds_format_integer(self.zIndex))
8829
        if self.caption is not None:
8830
            element.set('caption', self.gds_format_string(self.caption))
8831
        for RegionRef_ in self.RegionRef:
8832
            RegionRef_.to_etree(element, name_='RegionRef', mapping_=mapping_, reverse_mapping_=reverse_mapping_, nsmap_=nsmap_)
8833
        if mapping_ is not None:
8834
            mapping_[id(self)] = element
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable id does not seem to be defined.
Loading history...
8835
        if reverse_mapping_ is not None:
8836
            reverse_mapping_[element] = self
8837
        return element
8838
    def build(self, node, gds_collector_=None):
8839
        self.gds_collector_ = gds_collector_
8840
        if SaveElementTreeNode:
8841
            self.gds_elementtree_node_ = node
8842
        already_processed = set()
8843
        self.ns_prefix_ = node.prefix
8844
        self._buildAttributes(node, node.attrib, already_processed)
8845
        for child in node:
8846
            nodeName_ = Tag_pattern_.match(child.tag).groups()[-1]
8847
            self._buildChildren(child, node, nodeName_, gds_collector_=gds_collector_)
8848
        return self
8849
    def _buildAttributes(self, node, attrs, already_processed):
8850
        value = find_attr_value_('id', node)
8851
        if value is not None and 'id' not in already_processed:
8852
            already_processed.add('id')
8853
            self.id = value
8854
        value = find_attr_value_('zIndex', node)
8855
        if value is not None and 'zIndex' not in already_processed:
8856
            already_processed.add('zIndex')
8857
            self.zIndex = self.gds_parse_integer(value, node, 'zIndex')
8858
        value = find_attr_value_('caption', node)
8859
        if value is not None and 'caption' not in already_processed:
8860
            already_processed.add('caption')
8861
            self.caption = value
8862
    def _buildChildren(self, child_, node, nodeName_, fromsubclass_=False, gds_collector_=None):
8863
        if nodeName_ == 'RegionRef':
8864
            obj_ = RegionRefType.factory(parent_object_=self)
8865
            obj_.build(child_, gds_collector_=gds_collector_)
8866
            self.RegionRef.append(obj_)
8867
            obj_.original_tagname_ = 'RegionRef'
8868
    def __hash__(self):
8869
        return hash(self.id)
8870
# end class LayerType
8871
8872
8873
class BaselineType(GeneratedsSuper):
8874
    """conf -- Confidence value (between 0 and 1)
8875
    
8876
    """
8877
    __hash__ = GeneratedsSuper.__hash__
8878
    member_data_items_ = [
8879
        MemberSpec_('points', 'pc:PointsType', 0, 0, {'use': 'required', 'name': 'points'}),
8880
        MemberSpec_('conf', 'pc:ConfSimpleType', 0, 1, {'use': 'optional', 'name': 'conf'}),
8881
    ]
8882
    subclass = None
8883
    superclass = None
8884 View Code Duplication
    def __init__(self, points=None, conf=None, gds_collector_=None, **kwargs_):
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
8885
        self.gds_collector_ = gds_collector_
8886
        self.gds_elementtree_node_ = None
8887
        self.original_tagname_ = None
8888
        self.parent_object_ = kwargs_.get('parent_object_')
8889
        self.ns_prefix_ = "pc"
8890
        self.points = _cast(None, points)
8891
        self.points_nsprefix_ = "pc"
8892
        self.conf = _cast(float, conf)
8893
        self.conf_nsprefix_ = "pc"
8894
    def factory(*args_, **kwargs_):
8895
        if CurrentSubclassModule_ is not None:
8896
            subclass = getSubclassFromModule_(
8897
                CurrentSubclassModule_, BaselineType)
8898
            if subclass is not None:
8899
                return subclass(*args_, **kwargs_)
8900
        if BaselineType.subclass:
8901
            return BaselineType.subclass(*args_, **kwargs_)
8902
        else:
8903
            return BaselineType(*args_, **kwargs_)
8904
    factory = staticmethod(factory)
8905
    def get_ns_prefix_(self):
8906
        return self.ns_prefix_
8907
    def set_ns_prefix_(self, ns_prefix):
8908
        self.ns_prefix_ = ns_prefix
8909
    def get_points(self):
8910
        return self.points
8911
    def set_points(self, points):
8912
        self.points = points
8913
    def get_conf(self):
8914
        return self.conf
8915
    def set_conf(self, conf):
8916
        self.conf = conf
8917 View Code Duplication
    def validate_PointsType(self, value):
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
8918
        # Validate type pc:PointsType, a restriction on string.
8919
        if value is not None and Validate_simpletypes_ and self.gds_collector_ is not None:
8920
            if not isinstance(value, str):
8921
                lineno = self.gds_get_node_lineno_()
8922
                self.gds_collector_.add_message('Value "%(value)s"%(lineno)s is not of the correct base simple type (str)' % {"value": value, "lineno": lineno, })
8923
                return False
8924
            if not self.gds_validate_simple_patterns(
8925
                    self.validate_PointsType_patterns_, value):
8926
                self.gds_collector_.add_message('Value "%s" does not match xsd pattern restrictions: %s' % (encode_str_2_3(value), self.validate_PointsType_patterns_, ))
8927
    validate_PointsType_patterns_ = [['^(([0-9]+,[0-9]+ )+([0-9]+,[0-9]+))$']]
8928 View Code Duplication
    def validate_ConfSimpleType(self, value):
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
8929
        # Validate type pc:ConfSimpleType, a restriction on float.
8930
        if value is not None and Validate_simpletypes_ and self.gds_collector_ is not None:
8931
            if not isinstance(value, float):
8932
                lineno = self.gds_get_node_lineno_()
8933
                self.gds_collector_.add_message('Value "%(value)s"%(lineno)s is not of the correct base simple type (float)' % {"value": value, "lineno": lineno, })
8934
                return False
8935
            if value < 0:
8936
                lineno = self.gds_get_node_lineno_()
8937
                self.gds_collector_.add_message('Value "%(value)s"%(lineno)s does not match xsd minInclusive restriction on ConfSimpleType' % {"value": value, "lineno": lineno} )
8938
                result = False
8939
            if value > 1:
8940
                lineno = self.gds_get_node_lineno_()
8941
                self.gds_collector_.add_message('Value "%(value)s"%(lineno)s does not match xsd maxInclusive restriction on ConfSimpleType' % {"value": value, "lineno": lineno} )
8942
                result = False
8943
    def has__content(self):
8944
        if (
8945
8946
        ):
8947
            return True
8948
        else:
8949
            return False
8950
    def export(self, outfile, level, namespaceprefix_='', namespacedef_='xmlns:pc="http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15"', name_='BaselineType', pretty_print=True):
8951
        imported_ns_def_ = GenerateDSNamespaceDefs_.get('BaselineType')
8952
        if imported_ns_def_ is not None:
8953
            namespacedef_ = imported_ns_def_
8954
        if pretty_print:
8955
            eol_ = '\n'
8956
        else:
8957
            eol_ = ''
8958
        if self.original_tagname_ is not None and name_ == 'BaselineType':
8959
            name_ = self.original_tagname_
8960
        if UseCapturedNS_ and self.ns_prefix_:
8961
            namespaceprefix_ = self.ns_prefix_ + ':'
8962
        showIndent(outfile, level, pretty_print)
8963
        outfile.write('<%s%s%s' % (namespaceprefix_, name_, namespacedef_ and ' ' + namespacedef_ or '', ))
8964
        already_processed = set()
8965
        self._exportAttributes(outfile, level, already_processed, namespaceprefix_, name_='BaselineType')
8966
        if self.has__content():
8967
            outfile.write('>%s' % (eol_, ))
8968
            self._exportChildren(outfile, level + 1, namespaceprefix_, namespacedef_, name_='BaselineType', pretty_print=pretty_print)
8969
            outfile.write('</%s%s>%s' % (namespaceprefix_, name_, eol_))
8970
        else:
8971
            outfile.write('/>%s' % (eol_, ))
8972
    def _exportAttributes(self, outfile, level, already_processed, namespaceprefix_='', name_='BaselineType'):
8973
        if self.points is not None and 'points' not in already_processed:
8974
            already_processed.add('points')
8975
            outfile.write(' points=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.points), input_name='points')), ))
8976
        if self.conf is not None and 'conf' not in already_processed:
8977
            already_processed.add('conf')
8978
            outfile.write(' conf="%s"' % self.gds_format_float(self.conf, input_name='conf'))
8979
    def _exportChildren(self, outfile, level, namespaceprefix_='', namespacedef_='xmlns:pc="http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15"', name_='BaselineType', fromsubclass_=False, pretty_print=True):
8980
        pass
8981 View Code Duplication
    def to_etree(self, parent_element=None, name_='BaselineType', mapping_=None, reverse_mapping_=None, nsmap_=None):
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
8982
        if parent_element is None:
8983
            element = etree_.Element('{http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15}' + name_, nsmap=nsmap_)
8984
        else:
8985
            element = etree_.SubElement(parent_element, '{http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15}' + name_, nsmap=nsmap_)
8986
        if self.points is not None:
8987
            element.set('points', self.gds_format_string(self.points))
8988
        if self.conf is not None:
8989
            element.set('conf', self.gds_format_float(self.conf))
8990
        if mapping_ is not None:
8991
            mapping_[id(self)] = element
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable id does not seem to be defined.
Loading history...
8992
        if reverse_mapping_ is not None:
8993
            reverse_mapping_[element] = self
8994
        return element
8995
    def build(self, node, gds_collector_=None):
8996
        self.gds_collector_ = gds_collector_
8997
        if SaveElementTreeNode:
8998
            self.gds_elementtree_node_ = node
8999
        already_processed = set()
9000
        self.ns_prefix_ = node.prefix
9001
        self._buildAttributes(node, node.attrib, already_processed)
9002
        for child in node:
9003
            nodeName_ = Tag_pattern_.match(child.tag).groups()[-1]
9004
            self._buildChildren(child, node, nodeName_, gds_collector_=gds_collector_)
9005
        return self
9006 View Code Duplication
    def _buildAttributes(self, node, attrs, already_processed):
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
9007
        value = find_attr_value_('points', node)
9008
        if value is not None and 'points' not in already_processed:
9009
            already_processed.add('points')
9010
            self.points = value
9011
            self.validate_PointsType(self.points)    # validate type PointsType
9012
        value = find_attr_value_('conf', node)
9013
        if value is not None and 'conf' not in already_processed:
9014
            already_processed.add('conf')
9015
            value = self.gds_parse_float(value, node, 'conf')
9016
            self.conf = value
9017
            self.validate_ConfSimpleType(self.conf)    # validate type ConfSimpleType
9018
    def _buildChildren(self, child_, node, nodeName_, fromsubclass_=False, gds_collector_=None):
9019
        pass
9020
    def __hash__(self):
9021
        return hash(self.id)
9022
# end class BaselineType
9023
9024
9025 View Code Duplication
class RelationsType(GeneratedsSuper):
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
9026
    """RelationsType --
9027
    Container for one-to-one relations between layout
9028
    objects (for example: DropCap - paragraph, caption -
9029
    image).
9030
    
9031
    """
9032
    __hash__ = GeneratedsSuper.__hash__
9033
    member_data_items_ = [
9034
        MemberSpec_('Relation', 'RelationType', 1, 0, {'maxOccurs': 'unbounded', 'minOccurs': '1', 'name': 'Relation', 'type': 'RelationType'}, None),
9035
    ]
9036
    subclass = None
9037
    superclass = None
9038
    def __init__(self, Relation=None, gds_collector_=None, **kwargs_):
9039
        self.gds_collector_ = gds_collector_
9040
        self.gds_elementtree_node_ = None
9041
        self.original_tagname_ = None
9042
        self.parent_object_ = kwargs_.get('parent_object_')
9043
        self.ns_prefix_ = "pc"
9044
        if Relation is None:
9045
            self.Relation = []
9046
        else:
9047
            self.Relation = Relation
9048
        self.Relation_nsprefix_ = "pc"
9049
    def factory(*args_, **kwargs_):
9050
        if CurrentSubclassModule_ is not None:
9051
            subclass = getSubclassFromModule_(
9052
                CurrentSubclassModule_, RelationsType)
9053
            if subclass is not None:
9054
                return subclass(*args_, **kwargs_)
9055
        if RelationsType.subclass:
9056
            return RelationsType.subclass(*args_, **kwargs_)
9057
        else:
9058
            return RelationsType(*args_, **kwargs_)
9059
    factory = staticmethod(factory)
9060
    def get_ns_prefix_(self):
9061
        return self.ns_prefix_
9062
    def set_ns_prefix_(self, ns_prefix):
9063
        self.ns_prefix_ = ns_prefix
9064
    def get_Relation(self):
9065
        return self.Relation
9066
    def set_Relation(self, Relation):
9067
        self.Relation = Relation
9068
    def add_Relation(self, value):
9069
        self.Relation.append(value)
9070
    def insert_Relation_at(self, index, value):
9071
        self.Relation.insert(index, value)
9072
    def replace_Relation_at(self, index, value):
9073
        self.Relation[index] = value
9074
    def has__content(self):
9075
        if (
9076
            self.Relation
9077
        ):
9078
            return True
9079
        else:
9080
            return False
9081
    def export(self, outfile, level, namespaceprefix_='', namespacedef_='xmlns:pc="http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15"', name_='RelationsType', pretty_print=True):
9082
        imported_ns_def_ = GenerateDSNamespaceDefs_.get('RelationsType')
9083
        if imported_ns_def_ is not None:
9084
            namespacedef_ = imported_ns_def_
9085
        if pretty_print:
9086
            eol_ = '\n'
9087
        else:
9088
            eol_ = ''
9089
        if self.original_tagname_ is not None and name_ == 'RelationsType':
9090
            name_ = self.original_tagname_
9091
        if UseCapturedNS_ and self.ns_prefix_:
9092
            namespaceprefix_ = self.ns_prefix_ + ':'
9093
        showIndent(outfile, level, pretty_print)
9094
        outfile.write('<%s%s%s' % (namespaceprefix_, name_, namespacedef_ and ' ' + namespacedef_ or '', ))
9095
        already_processed = set()
9096
        self._exportAttributes(outfile, level, already_processed, namespaceprefix_, name_='RelationsType')
9097
        if self.has__content():
9098
            outfile.write('>%s' % (eol_, ))
9099
            self._exportChildren(outfile, level + 1, namespaceprefix_, namespacedef_, name_='RelationsType', pretty_print=pretty_print)
9100
            showIndent(outfile, level, pretty_print)
9101
            outfile.write('</%s%s>%s' % (namespaceprefix_, name_, eol_))
9102
        else:
9103
            outfile.write('/>%s' % (eol_, ))
9104
    def _exportAttributes(self, outfile, level, already_processed, namespaceprefix_='', name_='RelationsType'):
9105
        pass
9106
    def _exportChildren(self, outfile, level, namespaceprefix_='', namespacedef_='xmlns:pc="http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15"', name_='RelationsType', fromsubclass_=False, pretty_print=True):
9107
        if pretty_print:
9108
            eol_ = '\n'
9109
        else:
9110
            eol_ = ''
9111
        for Relation_ in self.Relation:
9112
            namespaceprefix_ = self.Relation_nsprefix_ + ':' if (UseCapturedNS_ and self.Relation_nsprefix_) else ''
9113
            Relation_.export(outfile, level, namespaceprefix_, namespacedef_='', name_='Relation', pretty_print=pretty_print)
9114
    def to_etree(self, parent_element=None, name_='RelationsType', mapping_=None, reverse_mapping_=None, nsmap_=None):
9115
        if parent_element is None:
9116
            element = etree_.Element('{http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15}' + name_, nsmap=nsmap_)
9117
        else:
9118
            element = etree_.SubElement(parent_element, '{http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15}' + name_, nsmap=nsmap_)
9119
        for Relation_ in self.Relation:
9120
            Relation_.to_etree(element, name_='Relation', mapping_=mapping_, reverse_mapping_=reverse_mapping_, nsmap_=nsmap_)
9121
        if mapping_ is not None:
9122
            mapping_[id(self)] = element
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable id does not seem to be defined.
Loading history...
9123
        if reverse_mapping_ is not None:
9124
            reverse_mapping_[element] = self
9125
        return element
9126
    def build(self, node, gds_collector_=None):
9127
        self.gds_collector_ = gds_collector_
9128
        if SaveElementTreeNode:
9129
            self.gds_elementtree_node_ = node
9130
        already_processed = set()
9131
        self.ns_prefix_ = node.prefix
9132
        self._buildAttributes(node, node.attrib, already_processed)
9133
        for child in node:
9134
            nodeName_ = Tag_pattern_.match(child.tag).groups()[-1]
9135
            self._buildChildren(child, node, nodeName_, gds_collector_=gds_collector_)
9136
        return self
9137
    def _buildAttributes(self, node, attrs, already_processed):
9138
        pass
9139
    def _buildChildren(self, child_, node, nodeName_, fromsubclass_=False, gds_collector_=None):
9140
        if nodeName_ == 'Relation':
9141
            obj_ = RelationType.factory(parent_object_=self)
9142
            obj_.build(child_, gds_collector_=gds_collector_)
9143
            self.Relation.append(obj_)
9144
            obj_.original_tagname_ = 'Relation'
9145
    def __hash__(self):
9146
        return hash(self.id)
9147
# end class RelationsType
9148
9149
9150
class RelationType(GeneratedsSuper):
9151
    """RelationType --
9152
    One-to-one relation between to layout object. Use 'link'
9153
    for loose relations and 'join' for strong relations
9154
    (where something is fragmented for instance).
9155
    Examples for 'link': caption - image floating -
9156
    paragraph paragraph - paragraph (when a paragraph is
9157
    split across columns and the last word of the first
9158
    paragraph DOES NOT continue in the second paragraph)
9159
    drop-cap - paragraph (when the drop-cap is a whole word)
9160
    Examples for 'join': word - word (separated word at the
9161
    end of a line) drop-cap - paragraph (when the drop-cap
9162
    is not a whole word) paragraph - paragraph (when a
9163
    pragraph is split across columns and the last word of
9164
    the first paragraph DOES continue in the second
9165
    paragraph)
9166
      
9167
    * custom -- For generic use
9168
    * Labels -- Semantic labels / tags
9169
    
9170
    """
9171
    __hash__ = GeneratedsSuper.__hash__
9172
    member_data_items_ = [
9173
        MemberSpec_('id', 'string', 0, 0, {'use': 'required', 'name': 'id'}),
9174
        MemberSpec_('type_', 'typeType1', 0, 1, {'use': 'optional', 'name': 'type_'}),
9175
        MemberSpec_('custom', 'string', 0, 1, {'use': 'optional', 'name': 'custom'}),
9176
        MemberSpec_('comments', 'string', 0, 1, {'use': 'optional', 'name': 'comments'}),
9177
        MemberSpec_('Labels', 'LabelsType', 1, 1, {'maxOccurs': 'unbounded', 'minOccurs': '0', 'name': 'Labels', 'type': 'LabelsType'}, None),
9178
        MemberSpec_('SourceRegionRef', 'RegionRefType', 0, 0, {'maxOccurs': '1', 'minOccurs': '1', 'name': 'SourceRegionRef', 'type': 'RegionRefType'}, None),
9179
        MemberSpec_('TargetRegionRef', 'RegionRefType', 0, 0, {'maxOccurs': '1', 'minOccurs': '1', 'name': 'TargetRegionRef', 'type': 'RegionRefType'}, None),
9180
    ]
9181
    subclass = None
9182
    superclass = None
9183
    def __init__(self, id=None, type_=None, custom=None, comments=None, Labels=None, SourceRegionRef=None, TargetRegionRef=None, gds_collector_=None, **kwargs_):
9184
        self.gds_collector_ = gds_collector_
9185
        self.gds_elementtree_node_ = None
9186
        self.original_tagname_ = None
9187
        self.parent_object_ = kwargs_.get('parent_object_')
9188
        self.ns_prefix_ = "pc"
9189
        self.id = _cast(None, id)
9190
        self.id_nsprefix_ = "pc"
9191
        self.type_ = _cast(None, type_)
9192
        self.type__nsprefix_ = "pc"
9193
        self.custom = _cast(None, custom)
9194
        self.custom_nsprefix_ = "pc"
9195
        self.comments = _cast(None, comments)
9196
        self.comments_nsprefix_ = "pc"
9197
        if Labels is None:
9198
            self.Labels = []
9199
        else:
9200
            self.Labels = Labels
9201
        self.Labels_nsprefix_ = "pc"
9202
        self.SourceRegionRef = SourceRegionRef
9203
        self.SourceRegionRef_nsprefix_ = "pc"
9204
        self.TargetRegionRef = TargetRegionRef
9205
        self.TargetRegionRef_nsprefix_ = "pc"
9206
    def factory(*args_, **kwargs_):
9207
        if CurrentSubclassModule_ is not None:
9208
            subclass = getSubclassFromModule_(
9209
                CurrentSubclassModule_, RelationType)
9210
            if subclass is not None:
9211
                return subclass(*args_, **kwargs_)
9212
        if RelationType.subclass:
9213
            return RelationType.subclass(*args_, **kwargs_)
9214
        else:
9215
            return RelationType(*args_, **kwargs_)
9216
    factory = staticmethod(factory)
9217
    def get_ns_prefix_(self):
9218
        return self.ns_prefix_
9219
    def set_ns_prefix_(self, ns_prefix):
9220
        self.ns_prefix_ = ns_prefix
9221
    def get_Labels(self):
9222
        return self.Labels
9223
    def set_Labels(self, Labels):
9224
        self.Labels = Labels
9225
    def add_Labels(self, value):
9226
        self.Labels.append(value)
9227
    def insert_Labels_at(self, index, value):
9228
        self.Labels.insert(index, value)
9229
    def replace_Labels_at(self, index, value):
9230
        self.Labels[index] = value
9231
    def get_SourceRegionRef(self):
9232
        return self.SourceRegionRef
9233
    def set_SourceRegionRef(self, SourceRegionRef):
9234
        self.SourceRegionRef = SourceRegionRef
9235
    def get_TargetRegionRef(self):
9236
        return self.TargetRegionRef
9237
    def set_TargetRegionRef(self, TargetRegionRef):
9238
        self.TargetRegionRef = TargetRegionRef
9239
    def get_id(self):
9240
        return self.id
9241
    def set_id(self, id):
9242
        self.id = id
9243
    def get_type(self):
9244
        return self.type_
9245
    def set_type(self, type_):
9246
        self.type_ = type_
9247
    def get_custom(self):
9248
        return self.custom
9249
    def set_custom(self, custom):
9250
        self.custom = custom
9251
    def get_comments(self):
9252
        return self.comments
9253
    def set_comments(self, comments):
9254
        self.comments = comments
9255
    def validate_typeType1(self, value):
9256
        # Validate type typeType1, a restriction on string.
9257
        if value is not None and Validate_simpletypes_ and self.gds_collector_ is not None:
9258
            if not isinstance(value, str):
9259
                lineno = self.gds_get_node_lineno_()
9260
                self.gds_collector_.add_message('Value "%(value)s"%(lineno)s is not of the correct base simple type (str)' % {"value": value, "lineno": lineno, })
9261
                return False
9262
            value = value
9263
            enumerations = ['link', 'join']
9264
            if value not in enumerations:
9265
                lineno = self.gds_get_node_lineno_()
9266
                self.gds_collector_.add_message('Value "%(value)s"%(lineno)s does not match xsd enumeration restriction on typeType1' % {"value" : encode_str_2_3(value), "lineno": lineno} )
9267
                result = False
9268
    def has__content(self):
9269
        if (
9270
            self.Labels or
9271
            self.SourceRegionRef is not None or
9272
            self.TargetRegionRef is not None
9273
        ):
9274
            return True
9275
        else:
9276
            return False
9277
    def export(self, outfile, level, namespaceprefix_='', namespacedef_='xmlns:pc="http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15"', name_='RelationType', pretty_print=True):
9278
        imported_ns_def_ = GenerateDSNamespaceDefs_.get('RelationType')
9279
        if imported_ns_def_ is not None:
9280
            namespacedef_ = imported_ns_def_
9281
        if pretty_print:
9282
            eol_ = '\n'
9283
        else:
9284
            eol_ = ''
9285
        if self.original_tagname_ is not None and name_ == 'RelationType':
9286
            name_ = self.original_tagname_
9287
        if UseCapturedNS_ and self.ns_prefix_:
9288
            namespaceprefix_ = self.ns_prefix_ + ':'
9289
        showIndent(outfile, level, pretty_print)
9290
        outfile.write('<%s%s%s' % (namespaceprefix_, name_, namespacedef_ and ' ' + namespacedef_ or '', ))
9291
        already_processed = set()
9292
        self._exportAttributes(outfile, level, already_processed, namespaceprefix_, name_='RelationType')
9293
        if self.has__content():
9294
            outfile.write('>%s' % (eol_, ))
9295
            self._exportChildren(outfile, level + 1, namespaceprefix_, namespacedef_, name_='RelationType', pretty_print=pretty_print)
9296
            showIndent(outfile, level, pretty_print)
9297
            outfile.write('</%s%s>%s' % (namespaceprefix_, name_, eol_))
9298
        else:
9299
            outfile.write('/>%s' % (eol_, ))
9300 View Code Duplication
    def _exportAttributes(self, outfile, level, already_processed, namespaceprefix_='', name_='RelationType'):
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
9301
        if self.id is not None and 'id' not in already_processed:
9302
            already_processed.add('id')
9303
            outfile.write(' id=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.id), input_name='id')), ))
9304
        if self.type_ is not None and 'type_' not in already_processed:
9305
            already_processed.add('type_')
9306
            outfile.write(' type=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.type_), input_name='type')), ))
9307
        if self.custom is not None and 'custom' not in already_processed:
9308
            already_processed.add('custom')
9309
            outfile.write(' custom=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.custom), input_name='custom')), ))
9310
        if self.comments is not None and 'comments' not in already_processed:
9311
            already_processed.add('comments')
9312
            outfile.write(' comments=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.comments), input_name='comments')), ))
9313
    def _exportChildren(self, outfile, level, namespaceprefix_='', namespacedef_='xmlns:pc="http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15"', name_='RelationType', fromsubclass_=False, pretty_print=True):
9314
        if pretty_print:
9315
            eol_ = '\n'
9316
        else:
9317
            eol_ = ''
9318
        for Labels_ in self.Labels:
9319
            namespaceprefix_ = self.Labels_nsprefix_ + ':' if (UseCapturedNS_ and self.Labels_nsprefix_) else ''
9320
            Labels_.export(outfile, level, namespaceprefix_, namespacedef_='', name_='Labels', pretty_print=pretty_print)
9321
        if self.SourceRegionRef is not None:
9322
            namespaceprefix_ = self.SourceRegionRef_nsprefix_ + ':' if (UseCapturedNS_ and self.SourceRegionRef_nsprefix_) else ''
9323
            self.SourceRegionRef.export(outfile, level, namespaceprefix_, namespacedef_='', name_='SourceRegionRef', pretty_print=pretty_print)
9324
        if self.TargetRegionRef is not None:
9325
            namespaceprefix_ = self.TargetRegionRef_nsprefix_ + ':' if (UseCapturedNS_ and self.TargetRegionRef_nsprefix_) else ''
9326
            self.TargetRegionRef.export(outfile, level, namespaceprefix_, namespacedef_='', name_='TargetRegionRef', pretty_print=pretty_print)
9327
    def to_etree(self, parent_element=None, name_='RelationType', mapping_=None, reverse_mapping_=None, nsmap_=None):
9328
        if parent_element is None:
9329
            element = etree_.Element('{http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15}' + name_, nsmap=nsmap_)
9330
        else:
9331
            element = etree_.SubElement(parent_element, '{http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15}' + name_, nsmap=nsmap_)
9332
        if self.id is not None:
9333
            element.set('id', self.gds_format_string(self.id))
9334
        if self.type_ is not None:
9335
            element.set('type', self.gds_format_string(self.type_))
9336
        if self.custom is not None:
9337
            element.set('custom', self.gds_format_string(self.custom))
9338
        if self.comments is not None:
9339
            element.set('comments', self.gds_format_string(self.comments))
9340
        for Labels_ in self.Labels:
9341
            Labels_.to_etree(element, name_='Labels', mapping_=mapping_, reverse_mapping_=reverse_mapping_, nsmap_=nsmap_)
9342
        if self.SourceRegionRef is not None:
9343
            SourceRegionRef_ = self.SourceRegionRef
9344
            SourceRegionRef_.to_etree(element, name_='SourceRegionRef', mapping_=mapping_, reverse_mapping_=reverse_mapping_, nsmap_=nsmap_)
9345
        if self.TargetRegionRef is not None:
9346
            TargetRegionRef_ = self.TargetRegionRef
9347
            TargetRegionRef_.to_etree(element, name_='TargetRegionRef', mapping_=mapping_, reverse_mapping_=reverse_mapping_, nsmap_=nsmap_)
9348
        if mapping_ is not None:
9349
            mapping_[id(self)] = element
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable id does not seem to be defined.
Loading history...
9350
        if reverse_mapping_ is not None:
9351
            reverse_mapping_[element] = self
9352
        return element
9353
    def build(self, node, gds_collector_=None):
9354
        self.gds_collector_ = gds_collector_
9355
        if SaveElementTreeNode:
9356
            self.gds_elementtree_node_ = node
9357
        already_processed = set()
9358
        self.ns_prefix_ = node.prefix
9359
        self._buildAttributes(node, node.attrib, already_processed)
9360
        for child in node:
9361
            nodeName_ = Tag_pattern_.match(child.tag).groups()[-1]
9362
            self._buildChildren(child, node, nodeName_, gds_collector_=gds_collector_)
9363
        return self
9364
    def _buildAttributes(self, node, attrs, already_processed):
9365
        value = find_attr_value_('id', node)
9366
        if value is not None and 'id' not in already_processed:
9367
            already_processed.add('id')
9368
            self.id = value
9369
        value = find_attr_value_('type', node)
9370
        if value is not None and 'type' not in already_processed:
9371
            already_processed.add('type')
9372
            self.type_ = value
9373
            self.validate_typeType1(self.type_)    # validate type typeType1
9374
        value = find_attr_value_('custom', node)
9375
        if value is not None and 'custom' not in already_processed:
9376
            already_processed.add('custom')
9377
            self.custom = value
9378
        value = find_attr_value_('comments', node)
9379
        if value is not None and 'comments' not in already_processed:
9380
            already_processed.add('comments')
9381
            self.comments = value
9382
    def _buildChildren(self, child_, node, nodeName_, fromsubclass_=False, gds_collector_=None):
9383
        if nodeName_ == 'Labels':
9384
            obj_ = LabelsType.factory(parent_object_=self)
9385
            obj_.build(child_, gds_collector_=gds_collector_)
9386
            self.Labels.append(obj_)
9387
            obj_.original_tagname_ = 'Labels'
9388
        elif nodeName_ == 'SourceRegionRef':
9389
            obj_ = RegionRefType.factory(parent_object_=self)
9390
            obj_.build(child_, gds_collector_=gds_collector_)
9391
            self.SourceRegionRef = obj_
9392
            obj_.original_tagname_ = 'SourceRegionRef'
9393
        elif nodeName_ == 'TargetRegionRef':
9394
            obj_ = RegionRefType.factory(parent_object_=self)
9395
            obj_.build(child_, gds_collector_=gds_collector_)
9396
            self.TargetRegionRef = obj_
9397
            obj_.original_tagname_ = 'TargetRegionRef'
9398
    def __hash__(self):
9399
        return hash(self.id)
9400
# end class RelationType
9401
9402
9403
class TextStyleType(GeneratedsSuper):
9404
    """TextStyleType --
9405
    Monospace (fixed-pitch, non-proportional) or
9406
    proportional font.
9407
      
9408
    * fontFamily --
9409
      For instance: Arial, Times New Roman.
9410
      Add more information if necessary
9411
      (e.g. blackletter, antiqua).
9412
      
9413
    * serif --
9414
      Serif or sans-serif typeface.
9415
      
9416
    * fontSize --
9417
      The size of the characters in points.
9418
      
9419
    * xHeight --
9420
      The x-height or corpus size refers to the distance
9421
      between the baseline and the mean line of
9422
      lower-case letters in a typeface.
9423
      The unit is assumed to be pixels.
9424
      
9425
    * kerning --
9426
      The degree of space (in points) between
9427
      the characters in a string of text.
9428
      
9429
    * textColourRgb --
9430
      Text colour in RGB encoded format
9431
      (red value) + (256 x green value) + (65536 x blue value).
9432
      
9433
    * bgColour -- Background colour
9434
    * bgColourRgb --
9435
      Background colour in RGB encoded format
9436
      (red value) + (256 x green value) + (65536 x blue value).
9437
      
9438
    * reverseVideo --
9439
      Specifies whether the colour of the text appears
9440
      reversed against a background colour.
9441
      
9442
    * underlineStyle -- Line style details if "underlined" is TRUE
9443
    
9444
    """
9445
    __hash__ = GeneratedsSuper.__hash__
9446
    member_data_items_ = [
9447
        MemberSpec_('fontFamily', 'string', 0, 1, {'use': 'optional', 'name': 'fontFamily'}),
9448
        MemberSpec_('serif', 'boolean', 0, 1, {'use': 'optional', 'name': 'serif'}),
9449
        MemberSpec_('monospace', 'boolean', 0, 1, {'use': 'optional', 'name': 'monospace'}),
9450
        MemberSpec_('fontSize', 'float', 0, 1, {'use': 'optional', 'name': 'fontSize'}),
9451
        MemberSpec_('xHeight', 'integer', 0, 1, {'use': 'optional', 'name': 'xHeight'}),
9452
        MemberSpec_('kerning', 'int', 0, 1, {'use': 'optional', 'name': 'kerning'}),
9453
        MemberSpec_('textColour', 'pc:ColourSimpleType', 0, 1, {'use': 'optional', 'name': 'textColour'}),
9454
        MemberSpec_('textColourRgb', 'integer', 0, 1, {'use': 'optional', 'name': 'textColourRgb'}),
9455
        MemberSpec_('bgColour', 'pc:ColourSimpleType', 0, 1, {'use': 'optional', 'name': 'bgColour'}),
9456
        MemberSpec_('bgColourRgb', 'integer', 0, 1, {'use': 'optional', 'name': 'bgColourRgb'}),
9457
        MemberSpec_('reverseVideo', 'boolean', 0, 1, {'use': 'optional', 'name': 'reverseVideo'}),
9458
        MemberSpec_('bold', 'boolean', 0, 1, {'use': 'optional', 'name': 'bold'}),
9459
        MemberSpec_('italic', 'boolean', 0, 1, {'use': 'optional', 'name': 'italic'}),
9460
        MemberSpec_('underlined', 'boolean', 0, 1, {'use': 'optional', 'name': 'underlined'}),
9461
        MemberSpec_('underlineStyle', 'pc:UnderlineStyleSimpleType', 0, 1, {'use': 'optional', 'name': 'underlineStyle'}),
9462
        MemberSpec_('subscript', 'boolean', 0, 1, {'use': 'optional', 'name': 'subscript'}),
9463
        MemberSpec_('superscript', 'boolean', 0, 1, {'use': 'optional', 'name': 'superscript'}),
9464
        MemberSpec_('strikethrough', 'boolean', 0, 1, {'use': 'optional', 'name': 'strikethrough'}),
9465
        MemberSpec_('smallCaps', 'boolean', 0, 1, {'use': 'optional', 'name': 'smallCaps'}),
9466
        MemberSpec_('letterSpaced', 'boolean', 0, 1, {'use': 'optional', 'name': 'letterSpaced'}),
9467
    ]
9468
    subclass = None
9469
    superclass = None
9470
    def __init__(self, fontFamily=None, serif=None, monospace=None, fontSize=None, xHeight=None, kerning=None, textColour=None, textColourRgb=None, bgColour=None, bgColourRgb=None, reverseVideo=None, bold=None, italic=None, underlined=None, underlineStyle=None, subscript=None, superscript=None, strikethrough=None, smallCaps=None, letterSpaced=None, gds_collector_=None, **kwargs_):
9471
        self.gds_collector_ = gds_collector_
9472
        self.gds_elementtree_node_ = None
9473
        self.original_tagname_ = None
9474
        self.parent_object_ = kwargs_.get('parent_object_')
9475
        self.ns_prefix_ = "pc"
9476
        self.fontFamily = _cast(None, fontFamily)
9477
        self.fontFamily_nsprefix_ = "pc"
9478
        self.serif = _cast(bool, serif)
9479
        self.serif_nsprefix_ = "pc"
9480
        self.monospace = _cast(bool, monospace)
9481
        self.monospace_nsprefix_ = "pc"
9482
        self.fontSize = _cast(float, fontSize)
9483
        self.fontSize_nsprefix_ = "pc"
9484
        self.xHeight = _cast(int, xHeight)
9485
        self.xHeight_nsprefix_ = "pc"
9486
        self.kerning = _cast(int, kerning)
9487
        self.kerning_nsprefix_ = "pc"
9488
        self.textColour = _cast(None, textColour)
9489
        self.textColour_nsprefix_ = "pc"
9490
        self.textColourRgb = _cast(int, textColourRgb)
9491
        self.textColourRgb_nsprefix_ = "pc"
9492
        self.bgColour = _cast(None, bgColour)
9493
        self.bgColour_nsprefix_ = "pc"
9494
        self.bgColourRgb = _cast(int, bgColourRgb)
9495
        self.bgColourRgb_nsprefix_ = "pc"
9496
        self.reverseVideo = _cast(bool, reverseVideo)
9497
        self.reverseVideo_nsprefix_ = "pc"
9498
        self.bold = _cast(bool, bold)
9499
        self.bold_nsprefix_ = "pc"
9500
        self.italic = _cast(bool, italic)
9501
        self.italic_nsprefix_ = "pc"
9502
        self.underlined = _cast(bool, underlined)
9503
        self.underlined_nsprefix_ = "pc"
9504
        self.underlineStyle = _cast(None, underlineStyle)
9505
        self.underlineStyle_nsprefix_ = "pc"
9506
        self.subscript = _cast(bool, subscript)
9507
        self.subscript_nsprefix_ = "pc"
9508
        self.superscript = _cast(bool, superscript)
9509
        self.superscript_nsprefix_ = "pc"
9510
        self.strikethrough = _cast(bool, strikethrough)
9511
        self.strikethrough_nsprefix_ = "pc"
9512
        self.smallCaps = _cast(bool, smallCaps)
9513
        self.smallCaps_nsprefix_ = "pc"
9514
        self.letterSpaced = _cast(bool, letterSpaced)
9515
        self.letterSpaced_nsprefix_ = "pc"
9516
    def factory(*args_, **kwargs_):
9517
        if CurrentSubclassModule_ is not None:
9518
            subclass = getSubclassFromModule_(
9519
                CurrentSubclassModule_, TextStyleType)
9520
            if subclass is not None:
9521
                return subclass(*args_, **kwargs_)
9522
        if TextStyleType.subclass:
9523
            return TextStyleType.subclass(*args_, **kwargs_)
9524
        else:
9525
            return TextStyleType(*args_, **kwargs_)
9526
    factory = staticmethod(factory)
9527
    def get_ns_prefix_(self):
9528
        return self.ns_prefix_
9529
    def set_ns_prefix_(self, ns_prefix):
9530
        self.ns_prefix_ = ns_prefix
9531
    def get_fontFamily(self):
9532
        return self.fontFamily
9533
    def set_fontFamily(self, fontFamily):
9534
        self.fontFamily = fontFamily
9535
    def get_serif(self):
9536
        return self.serif
9537
    def set_serif(self, serif):
9538
        self.serif = serif
9539
    def get_monospace(self):
9540
        return self.monospace
9541
    def set_monospace(self, monospace):
9542
        self.monospace = monospace
9543
    def get_fontSize(self):
9544
        return self.fontSize
9545
    def set_fontSize(self, fontSize):
9546
        self.fontSize = fontSize
9547
    def get_xHeight(self):
9548
        return self.xHeight
9549
    def set_xHeight(self, xHeight):
9550
        self.xHeight = xHeight
9551
    def get_kerning(self):
9552
        return self.kerning
9553
    def set_kerning(self, kerning):
9554
        self.kerning = kerning
9555
    def get_textColour(self):
9556
        return self.textColour
9557
    def set_textColour(self, textColour):
9558
        self.textColour = textColour
9559
    def get_textColourRgb(self):
9560
        return self.textColourRgb
9561
    def set_textColourRgb(self, textColourRgb):
9562
        self.textColourRgb = textColourRgb
9563
    def get_bgColour(self):
9564
        return self.bgColour
9565
    def set_bgColour(self, bgColour):
9566
        self.bgColour = bgColour
9567
    def get_bgColourRgb(self):
9568
        return self.bgColourRgb
9569
    def set_bgColourRgb(self, bgColourRgb):
9570
        self.bgColourRgb = bgColourRgb
9571
    def get_reverseVideo(self):
9572
        return self.reverseVideo
9573
    def set_reverseVideo(self, reverseVideo):
9574
        self.reverseVideo = reverseVideo
9575
    def get_bold(self):
9576
        return self.bold
9577
    def set_bold(self, bold):
9578
        self.bold = bold
9579
    def get_italic(self):
9580
        return self.italic
9581
    def set_italic(self, italic):
9582
        self.italic = italic
9583
    def get_underlined(self):
9584
        return self.underlined
9585
    def set_underlined(self, underlined):
9586
        self.underlined = underlined
9587
    def get_underlineStyle(self):
9588
        return self.underlineStyle
9589
    def set_underlineStyle(self, underlineStyle):
9590
        self.underlineStyle = underlineStyle
9591
    def get_subscript(self):
9592
        return self.subscript
9593
    def set_subscript(self, subscript):
9594
        self.subscript = subscript
9595
    def get_superscript(self):
9596
        return self.superscript
9597
    def set_superscript(self, superscript):
9598
        self.superscript = superscript
9599
    def get_strikethrough(self):
9600
        return self.strikethrough
9601
    def set_strikethrough(self, strikethrough):
9602
        self.strikethrough = strikethrough
9603
    def get_smallCaps(self):
9604
        return self.smallCaps
9605
    def set_smallCaps(self, smallCaps):
9606
        self.smallCaps = smallCaps
9607
    def get_letterSpaced(self):
9608
        return self.letterSpaced
9609
    def set_letterSpaced(self, letterSpaced):
9610
        self.letterSpaced = letterSpaced
9611
    def validate_ColourSimpleType(self, value):
9612
        # Validate type pc:ColourSimpleType, a restriction on string.
9613
        if value is not None and Validate_simpletypes_ and self.gds_collector_ is not None:
9614
            if not isinstance(value, str):
9615
                lineno = self.gds_get_node_lineno_()
9616
                self.gds_collector_.add_message('Value "%(value)s"%(lineno)s is not of the correct base simple type (str)' % {"value": value, "lineno": lineno, })
9617
                return False
9618
            value = value
9619
            enumerations = ['black', 'blue', 'brown', 'cyan', 'green', 'grey', 'indigo', 'magenta', 'orange', 'pink', 'red', 'turquoise', 'violet', 'white', 'yellow', 'other']
9620
            if value not in enumerations:
9621
                lineno = self.gds_get_node_lineno_()
9622
                self.gds_collector_.add_message('Value "%(value)s"%(lineno)s does not match xsd enumeration restriction on ColourSimpleType' % {"value" : encode_str_2_3(value), "lineno": lineno} )
9623
                result = False
9624
    def validate_UnderlineStyleSimpleType(self, value):
9625
        # Validate type pc:UnderlineStyleSimpleType, a restriction on string.
9626
        if value is not None and Validate_simpletypes_ and self.gds_collector_ is not None:
9627
            if not isinstance(value, str):
9628
                lineno = self.gds_get_node_lineno_()
9629
                self.gds_collector_.add_message('Value "%(value)s"%(lineno)s is not of the correct base simple type (str)' % {"value": value, "lineno": lineno, })
9630
                return False
9631
            value = value
9632
            enumerations = ['singleLine', 'doubleLine', 'other']
9633
            if value not in enumerations:
9634
                lineno = self.gds_get_node_lineno_()
9635
                self.gds_collector_.add_message('Value "%(value)s"%(lineno)s does not match xsd enumeration restriction on UnderlineStyleSimpleType' % {"value" : encode_str_2_3(value), "lineno": lineno} )
9636
                result = False
9637
    def has__content(self):
9638
        if (
9639
9640
        ):
9641
            return True
9642
        else:
9643
            return False
9644
    def export(self, outfile, level, namespaceprefix_='', namespacedef_='xmlns:pc="http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15"', name_='TextStyleType', pretty_print=True):
9645
        imported_ns_def_ = GenerateDSNamespaceDefs_.get('TextStyleType')
9646
        if imported_ns_def_ is not None:
9647
            namespacedef_ = imported_ns_def_
9648
        if pretty_print:
9649
            eol_ = '\n'
9650
        else:
9651
            eol_ = ''
9652
        if self.original_tagname_ is not None and name_ == 'TextStyleType':
9653
            name_ = self.original_tagname_
9654
        if UseCapturedNS_ and self.ns_prefix_:
9655
            namespaceprefix_ = self.ns_prefix_ + ':'
9656
        showIndent(outfile, level, pretty_print)
9657
        outfile.write('<%s%s%s' % (namespaceprefix_, name_, namespacedef_ and ' ' + namespacedef_ or '', ))
9658
        already_processed = set()
9659
        self._exportAttributes(outfile, level, already_processed, namespaceprefix_, name_='TextStyleType')
9660
        if self.has__content():
9661
            outfile.write('>%s' % (eol_, ))
9662
            self._exportChildren(outfile, level + 1, namespaceprefix_, namespacedef_, name_='TextStyleType', pretty_print=pretty_print)
9663
            outfile.write('</%s%s>%s' % (namespaceprefix_, name_, eol_))
9664
        else:
9665
            outfile.write('/>%s' % (eol_, ))
9666
    def _exportAttributes(self, outfile, level, already_processed, namespaceprefix_='', name_='TextStyleType'):
9667
        if self.fontFamily is not None and 'fontFamily' not in already_processed:
9668
            already_processed.add('fontFamily')
9669
            outfile.write(' fontFamily=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.fontFamily), input_name='fontFamily')), ))
9670
        if self.serif is not None and 'serif' not in already_processed:
9671
            already_processed.add('serif')
9672
            outfile.write(' serif="%s"' % self.gds_format_boolean(self.serif, input_name='serif'))
9673
        if self.monospace is not None and 'monospace' not in already_processed:
9674
            already_processed.add('monospace')
9675
            outfile.write(' monospace="%s"' % self.gds_format_boolean(self.monospace, input_name='monospace'))
9676
        if self.fontSize is not None and 'fontSize' not in already_processed:
9677
            already_processed.add('fontSize')
9678
            outfile.write(' fontSize="%s"' % self.gds_format_float(self.fontSize, input_name='fontSize'))
9679
        if self.xHeight is not None and 'xHeight' not in already_processed:
9680
            already_processed.add('xHeight')
9681
            outfile.write(' xHeight="%s"' % self.gds_format_integer(self.xHeight, input_name='xHeight'))
9682
        if self.kerning is not None and 'kerning' not in already_processed:
9683
            already_processed.add('kerning')
9684
            outfile.write(' kerning="%s"' % self.gds_format_integer(self.kerning, input_name='kerning'))
9685
        if self.textColour is not None and 'textColour' not in already_processed:
9686
            already_processed.add('textColour')
9687
            outfile.write(' textColour=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.textColour), input_name='textColour')), ))
9688
        if self.textColourRgb is not None and 'textColourRgb' not in already_processed:
9689
            already_processed.add('textColourRgb')
9690
            outfile.write(' textColourRgb="%s"' % self.gds_format_integer(self.textColourRgb, input_name='textColourRgb'))
9691
        if self.bgColour is not None and 'bgColour' not in already_processed:
9692
            already_processed.add('bgColour')
9693
            outfile.write(' bgColour=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.bgColour), input_name='bgColour')), ))
9694
        if self.bgColourRgb is not None and 'bgColourRgb' not in already_processed:
9695
            already_processed.add('bgColourRgb')
9696
            outfile.write(' bgColourRgb="%s"' % self.gds_format_integer(self.bgColourRgb, input_name='bgColourRgb'))
9697
        if self.reverseVideo is not None and 'reverseVideo' not in already_processed:
9698
            already_processed.add('reverseVideo')
9699
            outfile.write(' reverseVideo="%s"' % self.gds_format_boolean(self.reverseVideo, input_name='reverseVideo'))
9700
        if self.bold is not None and 'bold' not in already_processed:
9701
            already_processed.add('bold')
9702
            outfile.write(' bold="%s"' % self.gds_format_boolean(self.bold, input_name='bold'))
9703
        if self.italic is not None and 'italic' not in already_processed:
9704
            already_processed.add('italic')
9705
            outfile.write(' italic="%s"' % self.gds_format_boolean(self.italic, input_name='italic'))
9706
        if self.underlined is not None and 'underlined' not in already_processed:
9707
            already_processed.add('underlined')
9708
            outfile.write(' underlined="%s"' % self.gds_format_boolean(self.underlined, input_name='underlined'))
9709
        if self.underlineStyle is not None and 'underlineStyle' not in already_processed:
9710
            already_processed.add('underlineStyle')
9711
            outfile.write(' underlineStyle=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.underlineStyle), input_name='underlineStyle')), ))
9712
        if self.subscript is not None and 'subscript' not in already_processed:
9713
            already_processed.add('subscript')
9714
            outfile.write(' subscript="%s"' % self.gds_format_boolean(self.subscript, input_name='subscript'))
9715
        if self.superscript is not None and 'superscript' not in already_processed:
9716
            already_processed.add('superscript')
9717
            outfile.write(' superscript="%s"' % self.gds_format_boolean(self.superscript, input_name='superscript'))
9718
        if self.strikethrough is not None and 'strikethrough' not in already_processed:
9719
            already_processed.add('strikethrough')
9720
            outfile.write(' strikethrough="%s"' % self.gds_format_boolean(self.strikethrough, input_name='strikethrough'))
9721
        if self.smallCaps is not None and 'smallCaps' not in already_processed:
9722
            already_processed.add('smallCaps')
9723
            outfile.write(' smallCaps="%s"' % self.gds_format_boolean(self.smallCaps, input_name='smallCaps'))
9724
        if self.letterSpaced is not None and 'letterSpaced' not in already_processed:
9725
            already_processed.add('letterSpaced')
9726
            outfile.write(' letterSpaced="%s"' % self.gds_format_boolean(self.letterSpaced, input_name='letterSpaced'))
9727
    def _exportChildren(self, outfile, level, namespaceprefix_='', namespacedef_='xmlns:pc="http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15"', name_='TextStyleType', fromsubclass_=False, pretty_print=True):
9728
        pass
9729
    def to_etree(self, parent_element=None, name_='TextStyleType', mapping_=None, reverse_mapping_=None, nsmap_=None):
9730
        if parent_element is None:
9731
            element = etree_.Element('{http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15}' + name_, nsmap=nsmap_)
9732
        else:
9733
            element = etree_.SubElement(parent_element, '{http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15}' + name_, nsmap=nsmap_)
9734
        if self.fontFamily is not None:
9735
            element.set('fontFamily', self.gds_format_string(self.fontFamily))
9736
        if self.serif is not None:
9737
            element.set('serif', self.gds_format_boolean(self.serif))
9738
        if self.monospace is not None:
9739
            element.set('monospace', self.gds_format_boolean(self.monospace))
9740
        if self.fontSize is not None:
9741
            element.set('fontSize', self.gds_format_float(self.fontSize))
9742
        if self.xHeight is not None:
9743
            element.set('xHeight', self.gds_format_integer(self.xHeight))
9744
        if self.kerning is not None:
9745
            element.set('kerning', self.gds_format_integer(self.kerning))
9746
        if self.textColour is not None:
9747
            element.set('textColour', self.gds_format_string(self.textColour))
9748
        if self.textColourRgb is not None:
9749
            element.set('textColourRgb', self.gds_format_integer(self.textColourRgb))
9750
        if self.bgColour is not None:
9751
            element.set('bgColour', self.gds_format_string(self.bgColour))
9752
        if self.bgColourRgb is not None:
9753
            element.set('bgColourRgb', self.gds_format_integer(self.bgColourRgb))
9754
        if self.reverseVideo is not None:
9755
            element.set('reverseVideo', self.gds_format_boolean(self.reverseVideo))
9756
        if self.bold is not None:
9757
            element.set('bold', self.gds_format_boolean(self.bold))
9758
        if self.italic is not None:
9759
            element.set('italic', self.gds_format_boolean(self.italic))
9760
        if self.underlined is not None:
9761
            element.set('underlined', self.gds_format_boolean(self.underlined))
9762
        if self.underlineStyle is not None:
9763
            element.set('underlineStyle', self.gds_format_string(self.underlineStyle))
9764
        if self.subscript is not None:
9765
            element.set('subscript', self.gds_format_boolean(self.subscript))
9766
        if self.superscript is not None:
9767
            element.set('superscript', self.gds_format_boolean(self.superscript))
9768
        if self.strikethrough is not None:
9769
            element.set('strikethrough', self.gds_format_boolean(self.strikethrough))
9770
        if self.smallCaps is not None:
9771
            element.set('smallCaps', self.gds_format_boolean(self.smallCaps))
9772
        if self.letterSpaced is not None:
9773
            element.set('letterSpaced', self.gds_format_boolean(self.letterSpaced))
9774
        if mapping_ is not None:
9775
            mapping_[id(self)] = element
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable id does not seem to be defined.
Loading history...
9776
        if reverse_mapping_ is not None:
9777
            reverse_mapping_[element] = self
9778
        return element
9779
    def build(self, node, gds_collector_=None):
9780
        self.gds_collector_ = gds_collector_
9781
        if SaveElementTreeNode:
9782
            self.gds_elementtree_node_ = node
9783
        already_processed = set()
9784
        self.ns_prefix_ = node.prefix
9785
        self._buildAttributes(node, node.attrib, already_processed)
9786
        for child in node:
9787
            nodeName_ = Tag_pattern_.match(child.tag).groups()[-1]
9788
            self._buildChildren(child, node, nodeName_, gds_collector_=gds_collector_)
9789
        return self
9790
    def _buildAttributes(self, node, attrs, already_processed):
9791
        value = find_attr_value_('fontFamily', node)
9792
        if value is not None and 'fontFamily' not in already_processed:
9793
            already_processed.add('fontFamily')
9794
            self.fontFamily = value
9795
        value = find_attr_value_('serif', node)
9796
        if value is not None and 'serif' not in already_processed:
9797
            already_processed.add('serif')
9798
            if value in ('true', '1'):
9799
                self.serif = True
9800
            elif value in ('false', '0'):
9801
                self.serif = False
9802
            else:
9803
                raise_parse_error(node, 'Bad boolean attribute')
9804
        value = find_attr_value_('monospace', node)
9805
        if value is not None and 'monospace' not in already_processed:
9806
            already_processed.add('monospace')
9807
            if value in ('true', '1'):
9808
                self.monospace = True
9809
            elif value in ('false', '0'):
9810
                self.monospace = False
9811
            else:
9812
                raise_parse_error(node, 'Bad boolean attribute')
9813
        value = find_attr_value_('fontSize', node)
9814
        if value is not None and 'fontSize' not in already_processed:
9815
            already_processed.add('fontSize')
9816
            value = self.gds_parse_float(value, node, 'fontSize')
9817
            self.fontSize = value
9818
        value = find_attr_value_('xHeight', node)
9819
        if value is not None and 'xHeight' not in already_processed:
9820
            already_processed.add('xHeight')
9821
            self.xHeight = self.gds_parse_integer(value, node, 'xHeight')
9822
        value = find_attr_value_('kerning', node)
9823
        if value is not None and 'kerning' not in already_processed:
9824
            already_processed.add('kerning')
9825
            self.kerning = self.gds_parse_integer(value, node, 'kerning')
9826
        value = find_attr_value_('textColour', node)
9827
        if value is not None and 'textColour' not in already_processed:
9828
            already_processed.add('textColour')
9829
            self.textColour = value
9830
            self.validate_ColourSimpleType(self.textColour)    # validate type ColourSimpleType
9831
        value = find_attr_value_('textColourRgb', node)
9832
        if value is not None and 'textColourRgb' not in already_processed:
9833
            already_processed.add('textColourRgb')
9834
            self.textColourRgb = self.gds_parse_integer(value, node, 'textColourRgb')
9835
        value = find_attr_value_('bgColour', node)
9836
        if value is not None and 'bgColour' not in already_processed:
9837
            already_processed.add('bgColour')
9838
            self.bgColour = value
9839
            self.validate_ColourSimpleType(self.bgColour)    # validate type ColourSimpleType
9840
        value = find_attr_value_('bgColourRgb', node)
9841
        if value is not None and 'bgColourRgb' not in already_processed:
9842
            already_processed.add('bgColourRgb')
9843
            self.bgColourRgb = self.gds_parse_integer(value, node, 'bgColourRgb')
9844
        value = find_attr_value_('reverseVideo', node)
9845
        if value is not None and 'reverseVideo' not in already_processed:
9846
            already_processed.add('reverseVideo')
9847
            if value in ('true', '1'):
9848
                self.reverseVideo = True
9849
            elif value in ('false', '0'):
9850
                self.reverseVideo = False
9851
            else:
9852
                raise_parse_error(node, 'Bad boolean attribute')
9853
        value = find_attr_value_('bold', node)
9854
        if value is not None and 'bold' not in already_processed:
9855
            already_processed.add('bold')
9856
            if value in ('true', '1'):
9857
                self.bold = True
9858
            elif value in ('false', '0'):
9859
                self.bold = False
9860
            else:
9861
                raise_parse_error(node, 'Bad boolean attribute')
9862
        value = find_attr_value_('italic', node)
9863
        if value is not None and 'italic' not in already_processed:
9864
            already_processed.add('italic')
9865
            if value in ('true', '1'):
9866
                self.italic = True
9867
            elif value in ('false', '0'):
9868
                self.italic = False
9869
            else:
9870
                raise_parse_error(node, 'Bad boolean attribute')
9871
        value = find_attr_value_('underlined', node)
9872
        if value is not None and 'underlined' not in already_processed:
9873
            already_processed.add('underlined')
9874
            if value in ('true', '1'):
9875
                self.underlined = True
9876
            elif value in ('false', '0'):
9877
                self.underlined = False
9878
            else:
9879
                raise_parse_error(node, 'Bad boolean attribute')
9880
        value = find_attr_value_('underlineStyle', node)
9881
        if value is not None and 'underlineStyle' not in already_processed:
9882
            already_processed.add('underlineStyle')
9883
            self.underlineStyle = value
9884
            self.validate_UnderlineStyleSimpleType(self.underlineStyle)    # validate type UnderlineStyleSimpleType
9885
        value = find_attr_value_('subscript', node)
9886
        if value is not None and 'subscript' not in already_processed:
9887
            already_processed.add('subscript')
9888
            if value in ('true', '1'):
9889
                self.subscript = True
9890
            elif value in ('false', '0'):
9891
                self.subscript = False
9892
            else:
9893
                raise_parse_error(node, 'Bad boolean attribute')
9894
        value = find_attr_value_('superscript', node)
9895
        if value is not None and 'superscript' not in already_processed:
9896
            already_processed.add('superscript')
9897
            if value in ('true', '1'):
9898
                self.superscript = True
9899
            elif value in ('false', '0'):
9900
                self.superscript = False
9901
            else:
9902
                raise_parse_error(node, 'Bad boolean attribute')
9903
        value = find_attr_value_('strikethrough', node)
9904
        if value is not None and 'strikethrough' not in already_processed:
9905
            already_processed.add('strikethrough')
9906
            if value in ('true', '1'):
9907
                self.strikethrough = True
9908
            elif value in ('false', '0'):
9909
                self.strikethrough = False
9910
            else:
9911
                raise_parse_error(node, 'Bad boolean attribute')
9912
        value = find_attr_value_('smallCaps', node)
9913
        if value is not None and 'smallCaps' not in already_processed:
9914
            already_processed.add('smallCaps')
9915
            if value in ('true', '1'):
9916
                self.smallCaps = True
9917
            elif value in ('false', '0'):
9918
                self.smallCaps = False
9919
            else:
9920
                raise_parse_error(node, 'Bad boolean attribute')
9921
        value = find_attr_value_('letterSpaced', node)
9922
        if value is not None and 'letterSpaced' not in already_processed:
9923
            already_processed.add('letterSpaced')
9924
            if value in ('true', '1'):
9925
                self.letterSpaced = True
9926
            elif value in ('false', '0'):
9927
                self.letterSpaced = False
9928
            else:
9929
                raise_parse_error(node, 'Bad boolean attribute')
9930
    def _buildChildren(self, child_, node, nodeName_, fromsubclass_=False, gds_collector_=None):
9931
        pass
9932
    def __hash__(self):
9933
        return hash(self.id)
9934
# end class TextStyleType
9935
9936
9937
class RegionType(GeneratedsSuper):
9938
    """custom -- For generic use
9939
    continuation --
9940
    Is this region a continuation of another region
9941
    (in previous column or page, for example)?
9942
      
9943
    * AlternativeImage --
9944
      Alternative region images
9945
      (e.g. black-and-white).
9946
      
9947
    * Labels -- Semantic labels / tags
9948
    * Roles --
9949
      Roles the region takes
9950
      (e.g. in context of a parent region).
9951
    
9952
    """
9953
    __hash__ = GeneratedsSuper.__hash__
9954
    member_data_items_ = [
9955
        MemberSpec_('id', 'string', 0, 0, {'use': 'required', 'name': 'id'}),
9956
        MemberSpec_('custom', 'string', 0, 1, {'use': 'optional', 'name': 'custom'}),
9957
        MemberSpec_('comments', 'string', 0, 1, {'use': 'optional', 'name': 'comments'}),
9958
        MemberSpec_('continuation', 'boolean', 0, 1, {'use': 'optional', 'name': 'continuation'}),
9959
        MemberSpec_('AlternativeImage', 'AlternativeImageType', 1, 1, {'maxOccurs': 'unbounded', 'minOccurs': '0', 'name': 'AlternativeImage', 'type': 'AlternativeImageType'}, None),
9960
        MemberSpec_('Coords', 'CoordsType', 0, 0, {'name': 'Coords', 'type': 'CoordsType'}, None),
9961
        MemberSpec_('UserDefined', 'UserDefinedType', 0, 1, {'maxOccurs': '1', 'minOccurs': '0', 'name': 'UserDefined', 'type': 'UserDefinedType'}, None),
9962
        MemberSpec_('Labels', 'LabelsType', 1, 1, {'maxOccurs': 'unbounded', 'minOccurs': '0', 'name': 'Labels', 'type': 'LabelsType'}, None),
9963
        MemberSpec_('Roles', 'RolesType', 0, 1, {'maxOccurs': '1', 'minOccurs': '0', 'name': 'Roles', 'type': 'RolesType'}, None),
9964
        MemberSpec_('TextRegion', 'TextRegionType', 1, 1, {'name': 'TextRegion', 'type': 'TextRegionType'}, 7),
9965
        MemberSpec_('ImageRegion', 'ImageRegionType', 1, 1, {'name': 'ImageRegion', 'type': 'ImageRegionType'}, 7),
9966
        MemberSpec_('LineDrawingRegion', 'LineDrawingRegionType', 1, 1, {'name': 'LineDrawingRegion', 'type': 'LineDrawingRegionType'}, 7),
9967
        MemberSpec_('GraphicRegion', 'GraphicRegionType', 1, 1, {'name': 'GraphicRegion', 'type': 'GraphicRegionType'}, 7),
9968
        MemberSpec_('TableRegion', 'TableRegionType', 1, 1, {'name': 'TableRegion', 'type': 'TableRegionType'}, 7),
9969
        MemberSpec_('ChartRegion', 'ChartRegionType', 1, 1, {'name': 'ChartRegion', 'type': 'ChartRegionType'}, 7),
9970
        MemberSpec_('SeparatorRegion', 'SeparatorRegionType', 1, 1, {'name': 'SeparatorRegion', 'type': 'SeparatorRegionType'}, 7),
9971
        MemberSpec_('MathsRegion', 'MathsRegionType', 1, 1, {'name': 'MathsRegion', 'type': 'MathsRegionType'}, 7),
9972
        MemberSpec_('ChemRegion', 'ChemRegionType', 1, 1, {'name': 'ChemRegion', 'type': 'ChemRegionType'}, 7),
9973
        MemberSpec_('MusicRegion', 'MusicRegionType', 1, 1, {'name': 'MusicRegion', 'type': 'MusicRegionType'}, 7),
9974
        MemberSpec_('AdvertRegion', 'AdvertRegionType', 1, 1, {'name': 'AdvertRegion', 'type': 'AdvertRegionType'}, 7),
9975
        MemberSpec_('NoiseRegion', 'NoiseRegionType', 1, 1, {'name': 'NoiseRegion', 'type': 'NoiseRegionType'}, 7),
9976
        MemberSpec_('UnknownRegion', 'UnknownRegionType', 1, 1, {'name': 'UnknownRegion', 'type': 'UnknownRegionType'}, 7),
9977
        MemberSpec_('CustomRegion', 'CustomRegionType', 1, 1, {'name': 'CustomRegion', 'type': 'CustomRegionType'}, 7),
9978
    ]
9979
    subclass = None
9980
    superclass = None
9981
    def __init__(self, id=None, custom=None, comments=None, continuation=None, AlternativeImage=None, Coords=None, UserDefined=None, Labels=None, Roles=None, TextRegion=None, ImageRegion=None, LineDrawingRegion=None, GraphicRegion=None, TableRegion=None, ChartRegion=None, SeparatorRegion=None, MathsRegion=None, ChemRegion=None, MusicRegion=None, AdvertRegion=None, NoiseRegion=None, UnknownRegion=None, CustomRegion=None, extensiontype_=None, gds_collector_=None, **kwargs_):
9982
        self.gds_collector_ = gds_collector_
9983
        self.gds_elementtree_node_ = None
9984
        self.original_tagname_ = None
9985
        self.parent_object_ = kwargs_.get('parent_object_')
9986
        self.ns_prefix_ = "pc"
9987
        self.id = _cast(None, id)
9988
        self.id_nsprefix_ = "pc"
9989
        self.custom = _cast(None, custom)
9990
        self.custom_nsprefix_ = "pc"
9991
        self.comments = _cast(None, comments)
9992
        self.comments_nsprefix_ = "pc"
9993
        self.continuation = _cast(bool, continuation)
9994
        self.continuation_nsprefix_ = "pc"
9995
        if AlternativeImage is None:
9996
            self.AlternativeImage = []
9997
        else:
9998
            self.AlternativeImage = AlternativeImage
9999
        self.AlternativeImage_nsprefix_ = "pc"
10000
        self.Coords = Coords
10001
        self.Coords_nsprefix_ = "pc"
10002
        self.UserDefined = UserDefined
10003
        self.UserDefined_nsprefix_ = "pc"
10004
        if Labels is None:
10005
            self.Labels = []
10006
        else:
10007
            self.Labels = Labels
10008
        self.Labels_nsprefix_ = "pc"
10009
        self.Roles = Roles
10010
        self.Roles_nsprefix_ = "pc"
10011
        if TextRegion is None:
10012
            self.TextRegion = []
10013
        else:
10014
            self.TextRegion = TextRegion
10015
        self.TextRegion_nsprefix_ = "pc"
10016
        if ImageRegion is None:
10017
            self.ImageRegion = []
10018
        else:
10019
            self.ImageRegion = ImageRegion
10020
        self.ImageRegion_nsprefix_ = "pc"
10021
        if LineDrawingRegion is None:
10022
            self.LineDrawingRegion = []
10023
        else:
10024
            self.LineDrawingRegion = LineDrawingRegion
10025
        self.LineDrawingRegion_nsprefix_ = "pc"
10026
        if GraphicRegion is None:
10027
            self.GraphicRegion = []
10028
        else:
10029
            self.GraphicRegion = GraphicRegion
10030
        self.GraphicRegion_nsprefix_ = "pc"
10031
        if TableRegion is None:
10032
            self.TableRegion = []
10033
        else:
10034
            self.TableRegion = TableRegion
10035
        self.TableRegion_nsprefix_ = "pc"
10036
        if ChartRegion is None:
10037
            self.ChartRegion = []
10038
        else:
10039
            self.ChartRegion = ChartRegion
10040
        self.ChartRegion_nsprefix_ = "pc"
10041
        if SeparatorRegion is None:
10042
            self.SeparatorRegion = []
10043
        else:
10044
            self.SeparatorRegion = SeparatorRegion
10045
        self.SeparatorRegion_nsprefix_ = "pc"
10046
        if MathsRegion is None:
10047
            self.MathsRegion = []
10048
        else:
10049
            self.MathsRegion = MathsRegion
10050
        self.MathsRegion_nsprefix_ = "pc"
10051
        if ChemRegion is None:
10052
            self.ChemRegion = []
10053
        else:
10054
            self.ChemRegion = ChemRegion
10055
        self.ChemRegion_nsprefix_ = "pc"
10056
        if MusicRegion is None:
10057
            self.MusicRegion = []
10058
        else:
10059
            self.MusicRegion = MusicRegion
10060
        self.MusicRegion_nsprefix_ = "pc"
10061
        if AdvertRegion is None:
10062
            self.AdvertRegion = []
10063
        else:
10064
            self.AdvertRegion = AdvertRegion
10065
        self.AdvertRegion_nsprefix_ = "pc"
10066
        if NoiseRegion is None:
10067
            self.NoiseRegion = []
10068
        else:
10069
            self.NoiseRegion = NoiseRegion
10070
        self.NoiseRegion_nsprefix_ = "pc"
10071
        if UnknownRegion is None:
10072
            self.UnknownRegion = []
10073
        else:
10074
            self.UnknownRegion = UnknownRegion
10075
        self.UnknownRegion_nsprefix_ = "pc"
10076
        if CustomRegion is None:
10077
            self.CustomRegion = []
10078
        else:
10079
            self.CustomRegion = CustomRegion
10080
        self.CustomRegion_nsprefix_ = "pc"
10081
        self.extensiontype_ = extensiontype_
10082
    def factory(*args_, **kwargs_):
10083
        if CurrentSubclassModule_ is not None:
10084
            subclass = getSubclassFromModule_(
10085
                CurrentSubclassModule_, RegionType)
10086
            if subclass is not None:
10087
                return subclass(*args_, **kwargs_)
10088
        if RegionType.subclass:
10089
            return RegionType.subclass(*args_, **kwargs_)
10090
        else:
10091
            return RegionType(*args_, **kwargs_)
10092
    factory = staticmethod(factory)
10093
    def get_ns_prefix_(self):
10094
        return self.ns_prefix_
10095
    def set_ns_prefix_(self, ns_prefix):
10096
        self.ns_prefix_ = ns_prefix
10097
    def get_AlternativeImage(self):
10098
        return self.AlternativeImage
10099
    def set_AlternativeImage(self, AlternativeImage):
10100
        self.AlternativeImage = AlternativeImage
10101
    def add_AlternativeImage(self, value):
10102
        self.AlternativeImage.append(value)
10103
    def insert_AlternativeImage_at(self, index, value):
10104
        self.AlternativeImage.insert(index, value)
10105
    def replace_AlternativeImage_at(self, index, value):
10106
        self.AlternativeImage[index] = value
10107
    def get_Coords(self):
10108
        return self.Coords
10109
    def set_Coords(self, Coords):
10110
        self.Coords = Coords
10111
    def get_UserDefined(self):
10112
        return self.UserDefined
10113
    def set_UserDefined(self, UserDefined):
10114
        self.UserDefined = UserDefined
10115
    def get_Labels(self):
10116
        return self.Labels
10117
    def set_Labels(self, Labels):
10118
        self.Labels = Labels
10119
    def add_Labels(self, value):
10120
        self.Labels.append(value)
10121
    def insert_Labels_at(self, index, value):
10122
        self.Labels.insert(index, value)
10123
    def replace_Labels_at(self, index, value):
10124
        self.Labels[index] = value
10125
    def get_Roles(self):
10126
        return self.Roles
10127
    def set_Roles(self, Roles):
10128
        self.Roles = Roles
10129
    def get_TextRegion(self):
10130
        return self.TextRegion
10131
    def set_TextRegion(self, TextRegion):
10132
        self.TextRegion = TextRegion
10133
    def add_TextRegion(self, value):
10134
        self.TextRegion.append(value)
10135
    def insert_TextRegion_at(self, index, value):
10136
        self.TextRegion.insert(index, value)
10137
    def replace_TextRegion_at(self, index, value):
10138
        self.TextRegion[index] = value
10139
    def get_ImageRegion(self):
10140
        return self.ImageRegion
10141
    def set_ImageRegion(self, ImageRegion):
10142
        self.ImageRegion = ImageRegion
10143
    def add_ImageRegion(self, value):
10144
        self.ImageRegion.append(value)
10145
    def insert_ImageRegion_at(self, index, value):
10146
        self.ImageRegion.insert(index, value)
10147
    def replace_ImageRegion_at(self, index, value):
10148
        self.ImageRegion[index] = value
10149
    def get_LineDrawingRegion(self):
10150
        return self.LineDrawingRegion
10151
    def set_LineDrawingRegion(self, LineDrawingRegion):
10152
        self.LineDrawingRegion = LineDrawingRegion
10153
    def add_LineDrawingRegion(self, value):
10154
        self.LineDrawingRegion.append(value)
10155
    def insert_LineDrawingRegion_at(self, index, value):
10156
        self.LineDrawingRegion.insert(index, value)
10157
    def replace_LineDrawingRegion_at(self, index, value):
10158
        self.LineDrawingRegion[index] = value
10159
    def get_GraphicRegion(self):
10160
        return self.GraphicRegion
10161
    def set_GraphicRegion(self, GraphicRegion):
10162
        self.GraphicRegion = GraphicRegion
10163
    def add_GraphicRegion(self, value):
10164
        self.GraphicRegion.append(value)
10165
    def insert_GraphicRegion_at(self, index, value):
10166
        self.GraphicRegion.insert(index, value)
10167
    def replace_GraphicRegion_at(self, index, value):
10168
        self.GraphicRegion[index] = value
10169
    def get_TableRegion(self):
10170
        return self.TableRegion
10171
    def set_TableRegion(self, TableRegion):
10172
        self.TableRegion = TableRegion
10173
    def add_TableRegion(self, value):
10174
        self.TableRegion.append(value)
10175
    def insert_TableRegion_at(self, index, value):
10176
        self.TableRegion.insert(index, value)
10177
    def replace_TableRegion_at(self, index, value):
10178
        self.TableRegion[index] = value
10179
    def get_ChartRegion(self):
10180
        return self.ChartRegion
10181
    def set_ChartRegion(self, ChartRegion):
10182
        self.ChartRegion = ChartRegion
10183
    def add_ChartRegion(self, value):
10184
        self.ChartRegion.append(value)
10185
    def insert_ChartRegion_at(self, index, value):
10186
        self.ChartRegion.insert(index, value)
10187
    def replace_ChartRegion_at(self, index, value):
10188
        self.ChartRegion[index] = value
10189
    def get_SeparatorRegion(self):
10190
        return self.SeparatorRegion
10191
    def set_SeparatorRegion(self, SeparatorRegion):
10192
        self.SeparatorRegion = SeparatorRegion
10193
    def add_SeparatorRegion(self, value):
10194
        self.SeparatorRegion.append(value)
10195
    def insert_SeparatorRegion_at(self, index, value):
10196
        self.SeparatorRegion.insert(index, value)
10197
    def replace_SeparatorRegion_at(self, index, value):
10198
        self.SeparatorRegion[index] = value
10199
    def get_MathsRegion(self):
10200
        return self.MathsRegion
10201
    def set_MathsRegion(self, MathsRegion):
10202
        self.MathsRegion = MathsRegion
10203
    def add_MathsRegion(self, value):
10204
        self.MathsRegion.append(value)
10205
    def insert_MathsRegion_at(self, index, value):
10206
        self.MathsRegion.insert(index, value)
10207
    def replace_MathsRegion_at(self, index, value):
10208
        self.MathsRegion[index] = value
10209
    def get_ChemRegion(self):
10210
        return self.ChemRegion
10211
    def set_ChemRegion(self, ChemRegion):
10212
        self.ChemRegion = ChemRegion
10213
    def add_ChemRegion(self, value):
10214
        self.ChemRegion.append(value)
10215
    def insert_ChemRegion_at(self, index, value):
10216
        self.ChemRegion.insert(index, value)
10217
    def replace_ChemRegion_at(self, index, value):
10218
        self.ChemRegion[index] = value
10219
    def get_MusicRegion(self):
10220
        return self.MusicRegion
10221
    def set_MusicRegion(self, MusicRegion):
10222
        self.MusicRegion = MusicRegion
10223
    def add_MusicRegion(self, value):
10224
        self.MusicRegion.append(value)
10225
    def insert_MusicRegion_at(self, index, value):
10226
        self.MusicRegion.insert(index, value)
10227
    def replace_MusicRegion_at(self, index, value):
10228
        self.MusicRegion[index] = value
10229
    def get_AdvertRegion(self):
10230
        return self.AdvertRegion
10231
    def set_AdvertRegion(self, AdvertRegion):
10232
        self.AdvertRegion = AdvertRegion
10233
    def add_AdvertRegion(self, value):
10234
        self.AdvertRegion.append(value)
10235
    def insert_AdvertRegion_at(self, index, value):
10236
        self.AdvertRegion.insert(index, value)
10237
    def replace_AdvertRegion_at(self, index, value):
10238
        self.AdvertRegion[index] = value
10239
    def get_NoiseRegion(self):
10240
        return self.NoiseRegion
10241
    def set_NoiseRegion(self, NoiseRegion):
10242
        self.NoiseRegion = NoiseRegion
10243
    def add_NoiseRegion(self, value):
10244
        self.NoiseRegion.append(value)
10245
    def insert_NoiseRegion_at(self, index, value):
10246
        self.NoiseRegion.insert(index, value)
10247
    def replace_NoiseRegion_at(self, index, value):
10248
        self.NoiseRegion[index] = value
10249
    def get_UnknownRegion(self):
10250
        return self.UnknownRegion
10251
    def set_UnknownRegion(self, UnknownRegion):
10252
        self.UnknownRegion = UnknownRegion
10253
    def add_UnknownRegion(self, value):
10254
        self.UnknownRegion.append(value)
10255
    def insert_UnknownRegion_at(self, index, value):
10256
        self.UnknownRegion.insert(index, value)
10257
    def replace_UnknownRegion_at(self, index, value):
10258
        self.UnknownRegion[index] = value
10259
    def get_CustomRegion(self):
10260
        return self.CustomRegion
10261
    def set_CustomRegion(self, CustomRegion):
10262
        self.CustomRegion = CustomRegion
10263
    def add_CustomRegion(self, value):
10264
        self.CustomRegion.append(value)
10265
    def insert_CustomRegion_at(self, index, value):
10266
        self.CustomRegion.insert(index, value)
10267
    def replace_CustomRegion_at(self, index, value):
10268
        self.CustomRegion[index] = value
10269
    def get_id(self):
10270
        return self.id
10271
    def set_id(self, id):
10272
        self.id = id
10273
    def get_custom(self):
10274
        return self.custom
10275
    def set_custom(self, custom):
10276
        self.custom = custom
10277
    def get_comments(self):
10278
        return self.comments
10279
    def set_comments(self, comments):
10280
        self.comments = comments
10281
    def get_continuation(self):
10282
        return self.continuation
10283
    def set_continuation(self, continuation):
10284
        self.continuation = continuation
10285
    def get_extensiontype_(self): return self.extensiontype_
10286
    def set_extensiontype_(self, extensiontype_): self.extensiontype_ = extensiontype_
10287
    def has__content(self):
10288
        if (
10289
            self.AlternativeImage or
10290
            self.Coords is not None or
10291
            self.UserDefined is not None or
10292
            self.Labels or
10293
            self.Roles is not None or
10294
            self.TextRegion or
10295
            self.ImageRegion or
10296
            self.LineDrawingRegion or
10297
            self.GraphicRegion or
10298
            self.TableRegion or
10299
            self.ChartRegion or
10300
            self.SeparatorRegion or
10301
            self.MathsRegion or
10302
            self.ChemRegion or
10303
            self.MusicRegion or
10304
            self.AdvertRegion or
10305
            self.NoiseRegion or
10306
            self.UnknownRegion or
10307
            self.CustomRegion
10308
        ):
10309
            return True
10310
        else:
10311
            return False
10312
    def export(self, outfile, level, namespaceprefix_='', namespacedef_='xmlns:pc="http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15"', name_='RegionType', pretty_print=True):
10313
        imported_ns_def_ = GenerateDSNamespaceDefs_.get('RegionType')
10314
        if imported_ns_def_ is not None:
10315
            namespacedef_ = imported_ns_def_
10316
        if pretty_print:
10317
            eol_ = '\n'
10318
        else:
10319
            eol_ = ''
10320
        if self.original_tagname_ is not None and name_ == 'RegionType':
10321
            name_ = self.original_tagname_
10322
        if UseCapturedNS_ and self.ns_prefix_:
10323
            namespaceprefix_ = self.ns_prefix_ + ':'
10324
        showIndent(outfile, level, pretty_print)
10325
        outfile.write('<%s%s%s' % (namespaceprefix_, name_, namespacedef_ and ' ' + namespacedef_ or '', ))
10326
        already_processed = set()
10327
        self._exportAttributes(outfile, level, already_processed, namespaceprefix_, name_='RegionType')
10328
        if self.has__content():
10329
            outfile.write('>%s' % (eol_, ))
10330
            self._exportChildren(outfile, level + 1, namespaceprefix_, namespacedef_, name_='RegionType', pretty_print=pretty_print)
10331
            showIndent(outfile, level, pretty_print)
10332
            outfile.write('</%s%s>%s' % (namespaceprefix_, name_, eol_))
10333
        else:
10334
            outfile.write('/>%s' % (eol_, ))
10335
    def _exportAttributes(self, outfile, level, already_processed, namespaceprefix_='', name_='RegionType'):
10336
        if self.id is not None and 'id' not in already_processed:
10337
            already_processed.add('id')
10338
            outfile.write(' id=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.id), input_name='id')), ))
10339
        if self.custom is not None and 'custom' not in already_processed:
10340
            already_processed.add('custom')
10341
            outfile.write(' custom=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.custom), input_name='custom')), ))
10342
        if self.comments is not None and 'comments' not in already_processed:
10343
            already_processed.add('comments')
10344
            outfile.write(' comments=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.comments), input_name='comments')), ))
10345
        if self.continuation is not None and 'continuation' not in already_processed:
10346
            already_processed.add('continuation')
10347
            outfile.write(' continuation="%s"' % self.gds_format_boolean(self.continuation, input_name='continuation'))
10348
        if self.extensiontype_ is not None and 'xsi:type' not in already_processed:
10349
            already_processed.add('xsi:type')
10350
            outfile.write(' xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"')
10351
            if ":" not in self.extensiontype_:
10352
                imported_ns_type_prefix_ = GenerateDSNamespaceTypePrefixes_.get(self.extensiontype_, '')
10353
                outfile.write(' xsi:type="%s%s"' % (imported_ns_type_prefix_, self.extensiontype_))
10354
            else:
10355
                outfile.write(' xsi:type="%s"' % self.extensiontype_)
10356
    def _exportChildren(self, outfile, level, namespaceprefix_='', namespacedef_='xmlns:pc="http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15"', name_='RegionType', fromsubclass_=False, pretty_print=True):
10357
        if pretty_print:
10358
            eol_ = '\n'
10359
        else:
10360
            eol_ = ''
10361
        for AlternativeImage_ in self.AlternativeImage:
10362
            namespaceprefix_ = self.AlternativeImage_nsprefix_ + ':' if (UseCapturedNS_ and self.AlternativeImage_nsprefix_) else ''
10363
            AlternativeImage_.export(outfile, level, namespaceprefix_, namespacedef_='', name_='AlternativeImage', pretty_print=pretty_print)
10364
        if self.Coords is not None:
10365
            namespaceprefix_ = self.Coords_nsprefix_ + ':' if (UseCapturedNS_ and self.Coords_nsprefix_) else ''
10366
            self.Coords.export(outfile, level, namespaceprefix_, namespacedef_='', name_='Coords', pretty_print=pretty_print)
10367
        if self.UserDefined is not None:
10368
            namespaceprefix_ = self.UserDefined_nsprefix_ + ':' if (UseCapturedNS_ and self.UserDefined_nsprefix_) else ''
10369
            self.UserDefined.export(outfile, level, namespaceprefix_, namespacedef_='', name_='UserDefined', pretty_print=pretty_print)
10370
        for Labels_ in self.Labels:
10371
            namespaceprefix_ = self.Labels_nsprefix_ + ':' if (UseCapturedNS_ and self.Labels_nsprefix_) else ''
10372
            Labels_.export(outfile, level, namespaceprefix_, namespacedef_='', name_='Labels', pretty_print=pretty_print)
10373
        if self.Roles is not None:
10374
            namespaceprefix_ = self.Roles_nsprefix_ + ':' if (UseCapturedNS_ and self.Roles_nsprefix_) else ''
10375
            self.Roles.export(outfile, level, namespaceprefix_, namespacedef_='', name_='Roles', pretty_print=pretty_print)
10376
        for TextRegion_ in self.TextRegion:
10377
            namespaceprefix_ = self.TextRegion_nsprefix_ + ':' if (UseCapturedNS_ and self.TextRegion_nsprefix_) else ''
10378
            TextRegion_.export(outfile, level, namespaceprefix_, namespacedef_='', name_='TextRegion', pretty_print=pretty_print)
10379
        for ImageRegion_ in self.ImageRegion:
10380
            namespaceprefix_ = self.ImageRegion_nsprefix_ + ':' if (UseCapturedNS_ and self.ImageRegion_nsprefix_) else ''
10381
            ImageRegion_.export(outfile, level, namespaceprefix_, namespacedef_='', name_='ImageRegion', pretty_print=pretty_print)
10382
        for LineDrawingRegion_ in self.LineDrawingRegion:
10383
            namespaceprefix_ = self.LineDrawingRegion_nsprefix_ + ':' if (UseCapturedNS_ and self.LineDrawingRegion_nsprefix_) else ''
10384
            LineDrawingRegion_.export(outfile, level, namespaceprefix_, namespacedef_='', name_='LineDrawingRegion', pretty_print=pretty_print)
10385
        for GraphicRegion_ in self.GraphicRegion:
10386
            namespaceprefix_ = self.GraphicRegion_nsprefix_ + ':' if (UseCapturedNS_ and self.GraphicRegion_nsprefix_) else ''
10387
            GraphicRegion_.export(outfile, level, namespaceprefix_, namespacedef_='', name_='GraphicRegion', pretty_print=pretty_print)
10388
        for TableRegion_ in self.TableRegion:
10389
            namespaceprefix_ = self.TableRegion_nsprefix_ + ':' if (UseCapturedNS_ and self.TableRegion_nsprefix_) else ''
10390
            TableRegion_.export(outfile, level, namespaceprefix_, namespacedef_='', name_='TableRegion', pretty_print=pretty_print)
10391
        for ChartRegion_ in self.ChartRegion:
10392
            namespaceprefix_ = self.ChartRegion_nsprefix_ + ':' if (UseCapturedNS_ and self.ChartRegion_nsprefix_) else ''
10393
            ChartRegion_.export(outfile, level, namespaceprefix_, namespacedef_='', name_='ChartRegion', pretty_print=pretty_print)
10394
        for SeparatorRegion_ in self.SeparatorRegion:
10395
            namespaceprefix_ = self.SeparatorRegion_nsprefix_ + ':' if (UseCapturedNS_ and self.SeparatorRegion_nsprefix_) else ''
10396
            SeparatorRegion_.export(outfile, level, namespaceprefix_, namespacedef_='', name_='SeparatorRegion', pretty_print=pretty_print)
10397
        for MathsRegion_ in self.MathsRegion:
10398
            namespaceprefix_ = self.MathsRegion_nsprefix_ + ':' if (UseCapturedNS_ and self.MathsRegion_nsprefix_) else ''
10399
            MathsRegion_.export(outfile, level, namespaceprefix_, namespacedef_='', name_='MathsRegion', pretty_print=pretty_print)
10400
        for ChemRegion_ in self.ChemRegion:
10401
            namespaceprefix_ = self.ChemRegion_nsprefix_ + ':' if (UseCapturedNS_ and self.ChemRegion_nsprefix_) else ''
10402
            ChemRegion_.export(outfile, level, namespaceprefix_, namespacedef_='', name_='ChemRegion', pretty_print=pretty_print)
10403
        for MusicRegion_ in self.MusicRegion:
10404
            namespaceprefix_ = self.MusicRegion_nsprefix_ + ':' if (UseCapturedNS_ and self.MusicRegion_nsprefix_) else ''
10405
            MusicRegion_.export(outfile, level, namespaceprefix_, namespacedef_='', name_='MusicRegion', pretty_print=pretty_print)
10406
        for AdvertRegion_ in self.AdvertRegion:
10407
            namespaceprefix_ = self.AdvertRegion_nsprefix_ + ':' if (UseCapturedNS_ and self.AdvertRegion_nsprefix_) else ''
10408
            AdvertRegion_.export(outfile, level, namespaceprefix_, namespacedef_='', name_='AdvertRegion', pretty_print=pretty_print)
10409
        for NoiseRegion_ in self.NoiseRegion:
10410
            namespaceprefix_ = self.NoiseRegion_nsprefix_ + ':' if (UseCapturedNS_ and self.NoiseRegion_nsprefix_) else ''
10411
            NoiseRegion_.export(outfile, level, namespaceprefix_, namespacedef_='', name_='NoiseRegion', pretty_print=pretty_print)
10412
        for UnknownRegion_ in self.UnknownRegion:
10413
            namespaceprefix_ = self.UnknownRegion_nsprefix_ + ':' if (UseCapturedNS_ and self.UnknownRegion_nsprefix_) else ''
10414
            UnknownRegion_.export(outfile, level, namespaceprefix_, namespacedef_='', name_='UnknownRegion', pretty_print=pretty_print)
10415
        for CustomRegion_ in self.CustomRegion:
10416
            namespaceprefix_ = self.CustomRegion_nsprefix_ + ':' if (UseCapturedNS_ and self.CustomRegion_nsprefix_) else ''
10417
            CustomRegion_.export(outfile, level, namespaceprefix_, namespacedef_='', name_='CustomRegion', pretty_print=pretty_print)
10418
    def to_etree(self, parent_element=None, name_='RegionType', mapping_=None, reverse_mapping_=None, nsmap_=None):
10419
        if parent_element is None:
10420
            element = etree_.Element('{http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15}' + name_, nsmap=nsmap_)
10421
        else:
10422
            element = etree_.SubElement(parent_element, '{http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15}' + name_, nsmap=nsmap_)
10423
        if self.extensiontype_ is not None:
10424
            element.set('{http://www.w3.org/2001/XMLSchema-instance}type', self.extensiontype_)
10425
        if self.id is not None:
10426
            element.set('id', self.gds_format_string(self.id))
10427
        if self.custom is not None:
10428
            element.set('custom', self.gds_format_string(self.custom))
10429
        if self.comments is not None:
10430
            element.set('comments', self.gds_format_string(self.comments))
10431
        if self.continuation is not None:
10432
            element.set('continuation', self.gds_format_boolean(self.continuation))
10433
        for AlternativeImage_ in self.AlternativeImage:
10434
            AlternativeImage_.to_etree(element, name_='AlternativeImage', mapping_=mapping_, reverse_mapping_=reverse_mapping_, nsmap_=nsmap_)
10435
        if self.Coords is not None:
10436
            Coords_ = self.Coords
10437
            Coords_.to_etree(element, name_='Coords', mapping_=mapping_, reverse_mapping_=reverse_mapping_, nsmap_=nsmap_)
10438
        if self.UserDefined is not None:
10439
            UserDefined_ = self.UserDefined
10440
            UserDefined_.to_etree(element, name_='UserDefined', mapping_=mapping_, reverse_mapping_=reverse_mapping_, nsmap_=nsmap_)
10441
        for Labels_ in self.Labels:
10442
            Labels_.to_etree(element, name_='Labels', mapping_=mapping_, reverse_mapping_=reverse_mapping_, nsmap_=nsmap_)
10443
        if self.Roles is not None:
10444
            Roles_ = self.Roles
10445
            Roles_.to_etree(element, name_='Roles', mapping_=mapping_, reverse_mapping_=reverse_mapping_, nsmap_=nsmap_)
10446
        for TextRegion_ in self.TextRegion:
10447
            TextRegion_.to_etree(element, name_='TextRegion', mapping_=mapping_, reverse_mapping_=reverse_mapping_, nsmap_=nsmap_)
10448
        for ImageRegion_ in self.ImageRegion:
10449
            ImageRegion_.to_etree(element, name_='ImageRegion', mapping_=mapping_, reverse_mapping_=reverse_mapping_, nsmap_=nsmap_)
10450
        for LineDrawingRegion_ in self.LineDrawingRegion:
10451
            LineDrawingRegion_.to_etree(element, name_='LineDrawingRegion', mapping_=mapping_, reverse_mapping_=reverse_mapping_, nsmap_=nsmap_)
10452
        for GraphicRegion_ in self.GraphicRegion:
10453
            GraphicRegion_.to_etree(element, name_='GraphicRegion', mapping_=mapping_, reverse_mapping_=reverse_mapping_, nsmap_=nsmap_)
10454
        for TableRegion_ in self.TableRegion:
10455
            TableRegion_.to_etree(element, name_='TableRegion', mapping_=mapping_, reverse_mapping_=reverse_mapping_, nsmap_=nsmap_)
10456
        for ChartRegion_ in self.ChartRegion:
10457
            ChartRegion_.to_etree(element, name_='ChartRegion', mapping_=mapping_, reverse_mapping_=reverse_mapping_, nsmap_=nsmap_)
10458
        for SeparatorRegion_ in self.SeparatorRegion:
10459
            SeparatorRegion_.to_etree(element, name_='SeparatorRegion', mapping_=mapping_, reverse_mapping_=reverse_mapping_, nsmap_=nsmap_)
10460
        for MathsRegion_ in self.MathsRegion:
10461
            MathsRegion_.to_etree(element, name_='MathsRegion', mapping_=mapping_, reverse_mapping_=reverse_mapping_, nsmap_=nsmap_)
10462
        for ChemRegion_ in self.ChemRegion:
10463
            ChemRegion_.to_etree(element, name_='ChemRegion', mapping_=mapping_, reverse_mapping_=reverse_mapping_, nsmap_=nsmap_)
10464
        for MusicRegion_ in self.MusicRegion:
10465
            MusicRegion_.to_etree(element, name_='MusicRegion', mapping_=mapping_, reverse_mapping_=reverse_mapping_, nsmap_=nsmap_)
10466
        for AdvertRegion_ in self.AdvertRegion:
10467
            AdvertRegion_.to_etree(element, name_='AdvertRegion', mapping_=mapping_, reverse_mapping_=reverse_mapping_, nsmap_=nsmap_)
10468
        for NoiseRegion_ in self.NoiseRegion:
10469
            NoiseRegion_.to_etree(element, name_='NoiseRegion', mapping_=mapping_, reverse_mapping_=reverse_mapping_, nsmap_=nsmap_)
10470
        for UnknownRegion_ in self.UnknownRegion:
10471
            UnknownRegion_.to_etree(element, name_='UnknownRegion', mapping_=mapping_, reverse_mapping_=reverse_mapping_, nsmap_=nsmap_)
10472
        for CustomRegion_ in self.CustomRegion:
10473
            CustomRegion_.to_etree(element, name_='CustomRegion', mapping_=mapping_, reverse_mapping_=reverse_mapping_, nsmap_=nsmap_)
10474
        if mapping_ is not None:
10475
            mapping_[id(self)] = element
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable id does not seem to be defined.
Loading history...
10476
        if reverse_mapping_ is not None:
10477
            reverse_mapping_[element] = self
10478
        return element
10479
    def build(self, node, gds_collector_=None):
10480
        self.gds_collector_ = gds_collector_
10481
        if SaveElementTreeNode:
10482
            self.gds_elementtree_node_ = node
10483
        already_processed = set()
10484
        self.ns_prefix_ = node.prefix
10485
        self._buildAttributes(node, node.attrib, already_processed)
10486
        for child in node:
10487
            nodeName_ = Tag_pattern_.match(child.tag).groups()[-1]
10488
            self._buildChildren(child, node, nodeName_, gds_collector_=gds_collector_)
10489
        return self
10490
    def _buildAttributes(self, node, attrs, already_processed):
10491
        value = find_attr_value_('id', node)
10492
        if value is not None and 'id' not in already_processed:
10493
            already_processed.add('id')
10494
            self.id = value
10495
        value = find_attr_value_('custom', node)
10496
        if value is not None and 'custom' not in already_processed:
10497
            already_processed.add('custom')
10498
            self.custom = value
10499
        value = find_attr_value_('comments', node)
10500
        if value is not None and 'comments' not in already_processed:
10501
            already_processed.add('comments')
10502
            self.comments = value
10503
        value = find_attr_value_('continuation', node)
10504
        if value is not None and 'continuation' not in already_processed:
10505
            already_processed.add('continuation')
10506
            if value in ('true', '1'):
10507
                self.continuation = True
10508
            elif value in ('false', '0'):
10509
                self.continuation = False
10510
            else:
10511
                raise_parse_error(node, 'Bad boolean attribute')
10512
        value = find_attr_value_('xsi:type', node)
10513
        if value is not None and 'xsi:type' not in already_processed:
10514
            already_processed.add('xsi:type')
10515
            self.extensiontype_ = value
10516
    def _buildChildren(self, child_, node, nodeName_, fromsubclass_=False, gds_collector_=None):
10517
        if nodeName_ == 'AlternativeImage':
10518
            obj_ = AlternativeImageType.factory(parent_object_=self)
10519
            obj_.build(child_, gds_collector_=gds_collector_)
10520
            self.AlternativeImage.append(obj_)
10521
            obj_.original_tagname_ = 'AlternativeImage'
10522
        elif nodeName_ == 'Coords':
10523
            obj_ = CoordsType.factory(parent_object_=self)
10524
            obj_.build(child_, gds_collector_=gds_collector_)
10525
            self.Coords = obj_
10526
            obj_.original_tagname_ = 'Coords'
10527
        elif nodeName_ == 'UserDefined':
10528
            obj_ = UserDefinedType.factory(parent_object_=self)
10529
            obj_.build(child_, gds_collector_=gds_collector_)
10530
            self.UserDefined = obj_
10531
            obj_.original_tagname_ = 'UserDefined'
10532
        elif nodeName_ == 'Labels':
10533
            obj_ = LabelsType.factory(parent_object_=self)
10534
            obj_.build(child_, gds_collector_=gds_collector_)
10535
            self.Labels.append(obj_)
10536
            obj_.original_tagname_ = 'Labels'
10537
        elif nodeName_ == 'Roles':
10538
            obj_ = RolesType.factory(parent_object_=self)
10539
            obj_.build(child_, gds_collector_=gds_collector_)
10540
            self.Roles = obj_
10541
            obj_.original_tagname_ = 'Roles'
10542
        elif nodeName_ == 'TextRegion':
10543
            obj_ = TextRegionType.factory(parent_object_=self)
10544
            obj_.build(child_, gds_collector_=gds_collector_)
10545
            self.TextRegion.append(obj_)
10546
            obj_.original_tagname_ = 'TextRegion'
10547
        elif nodeName_ == 'ImageRegion':
10548
            obj_ = ImageRegionType.factory(parent_object_=self)
10549
            obj_.build(child_, gds_collector_=gds_collector_)
10550
            self.ImageRegion.append(obj_)
10551
            obj_.original_tagname_ = 'ImageRegion'
10552
        elif nodeName_ == 'LineDrawingRegion':
10553
            obj_ = LineDrawingRegionType.factory(parent_object_=self)
10554
            obj_.build(child_, gds_collector_=gds_collector_)
10555
            self.LineDrawingRegion.append(obj_)
10556
            obj_.original_tagname_ = 'LineDrawingRegion'
10557
        elif nodeName_ == 'GraphicRegion':
10558
            obj_ = GraphicRegionType.factory(parent_object_=self)
10559
            obj_.build(child_, gds_collector_=gds_collector_)
10560
            self.GraphicRegion.append(obj_)
10561
            obj_.original_tagname_ = 'GraphicRegion'
10562
        elif nodeName_ == 'TableRegion':
10563
            obj_ = TableRegionType.factory(parent_object_=self)
10564
            obj_.build(child_, gds_collector_=gds_collector_)
10565
            self.TableRegion.append(obj_)
10566
            obj_.original_tagname_ = 'TableRegion'
10567
        elif nodeName_ == 'ChartRegion':
10568
            obj_ = ChartRegionType.factory(parent_object_=self)
10569
            obj_.build(child_, gds_collector_=gds_collector_)
10570
            self.ChartRegion.append(obj_)
10571
            obj_.original_tagname_ = 'ChartRegion'
10572
        elif nodeName_ == 'SeparatorRegion':
10573
            obj_ = SeparatorRegionType.factory(parent_object_=self)
10574
            obj_.build(child_, gds_collector_=gds_collector_)
10575
            self.SeparatorRegion.append(obj_)
10576
            obj_.original_tagname_ = 'SeparatorRegion'
10577
        elif nodeName_ == 'MathsRegion':
10578
            obj_ = MathsRegionType.factory(parent_object_=self)
10579
            obj_.build(child_, gds_collector_=gds_collector_)
10580
            self.MathsRegion.append(obj_)
10581
            obj_.original_tagname_ = 'MathsRegion'
10582
        elif nodeName_ == 'ChemRegion':
10583
            obj_ = ChemRegionType.factory(parent_object_=self)
10584
            obj_.build(child_, gds_collector_=gds_collector_)
10585
            self.ChemRegion.append(obj_)
10586
            obj_.original_tagname_ = 'ChemRegion'
10587
        elif nodeName_ == 'MusicRegion':
10588
            obj_ = MusicRegionType.factory(parent_object_=self)
10589
            obj_.build(child_, gds_collector_=gds_collector_)
10590
            self.MusicRegion.append(obj_)
10591
            obj_.original_tagname_ = 'MusicRegion'
10592
        elif nodeName_ == 'AdvertRegion':
10593
            obj_ = AdvertRegionType.factory(parent_object_=self)
10594
            obj_.build(child_, gds_collector_=gds_collector_)
10595
            self.AdvertRegion.append(obj_)
10596
            obj_.original_tagname_ = 'AdvertRegion'
10597
        elif nodeName_ == 'NoiseRegion':
10598
            obj_ = NoiseRegionType.factory(parent_object_=self)
10599
            obj_.build(child_, gds_collector_=gds_collector_)
10600
            self.NoiseRegion.append(obj_)
10601
            obj_.original_tagname_ = 'NoiseRegion'
10602
        elif nodeName_ == 'UnknownRegion':
10603
            obj_ = UnknownRegionType.factory(parent_object_=self)
10604
            obj_.build(child_, gds_collector_=gds_collector_)
10605
            self.UnknownRegion.append(obj_)
10606
            obj_.original_tagname_ = 'UnknownRegion'
10607
        elif nodeName_ == 'CustomRegion':
10608
            obj_ = CustomRegionType.factory(parent_object_=self)
10609
            obj_.build(child_, gds_collector_=gds_collector_)
10610
            self.CustomRegion.append(obj_)
10611
            obj_.original_tagname_ = 'CustomRegion'
10612
    def __hash__(self):
10613
        return hash(self.id)
10614 View Code Duplication
    def invalidate_AlternativeImage(self, feature_selector=None):
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
10615
        """
10616
        Remove derived images from this segment (due to changed coordinates).
10617
    
10618
        If `feature_selector` is not none, remove only images with
10619
        matching ``@comments``, e.g. ``feature_selector=cropped,deskewed``.
10620
        """
10621
        existing_images = self.AlternativeImage or []
10622
        removed_images = []
10623
        if feature_selector:
10624
            new_images = []
10625
            for image in existing_images:
10626
                features = image.get_comments() or ''
10627
                if any(feature in features.split(',')
10628
                       for feature in feature_selector.split(',') if feature):
10629
                    removed_images.append(image)
10630
                else:
10631
                    new_images.append(image)
10632
            self.AlternativeImage = new_images
10633
        else:
10634
            removed_images = existing_images
10635
            self.AlternativeImage = []
10636
        if hasattr(self, 'id'):
10637
            name = self.id
10638
        elif hasattr(self, 'parent_object_') and hasattr(self.parent_object_, 'pcGtsId'):
10639
            name = self.parent_object_.pcGtsId
10640
        else:
10641
            name = ''
10642
        for image in removed_images:
10643
            self.gds_collector_.add_message('Removing AlternativeImage %s from "%s"' % (
10644
                image.get_comments() or '', name))
10645
    def set_Coords(self, Coords):
10646
        """
10647
        Set coordinate polygon by given :py:class:`CoordsType` object.
10648
        Moreover, invalidate self's ``pc:AlternativeImage``s
10649
        (because they will have been cropped with a bbox
10650
        of the previous polygon).
10651
        """
10652
        if hasattr(self, 'invalidate_AlternativeImage'):
10653
            # RegionType, TextLineType, WordType, GlyphType:
10654
            self.invalidate_AlternativeImage()
10655
        elif hasattr(self, 'parent_object_') and hasattr(self.parent_object_, 'invalidate_AlternativeImage'):
10656
            # BorderType:
10657
            self.parent_object_.invalidate_AlternativeImage(feature_selector='cropped')
10658
        self.Coords = Coords
10659
# end class RegionType
10660
10661
10662
class AlternativeImageType(GeneratedsSuper):
10663
    """conf -- Confidence value (between 0 and 1)
10664
    
10665
    """
10666
    __hash__ = GeneratedsSuper.__hash__
10667
    member_data_items_ = [
10668
        MemberSpec_('filename', 'string', 0, 0, {'use': 'required', 'name': 'filename'}),
10669
        MemberSpec_('comments', 'string', 0, 1, {'use': 'optional', 'name': 'comments'}),
10670
        MemberSpec_('conf', 'pc:ConfSimpleType', 0, 1, {'use': 'optional', 'name': 'conf'}),
10671
    ]
10672
    subclass = None
10673
    superclass = None
10674
    def __init__(self, filename=None, comments=None, conf=None, gds_collector_=None, **kwargs_):
10675
        self.gds_collector_ = gds_collector_
10676
        self.gds_elementtree_node_ = None
10677
        self.original_tagname_ = None
10678
        self.parent_object_ = kwargs_.get('parent_object_')
10679
        self.ns_prefix_ = "pc"
10680
        self.filename = _cast(None, filename)
10681
        self.filename_nsprefix_ = "pc"
10682
        self.comments = _cast(None, comments)
10683
        self.comments_nsprefix_ = "pc"
10684
        self.conf = _cast(float, conf)
10685
        self.conf_nsprefix_ = "pc"
10686
    def factory(*args_, **kwargs_):
10687
        if CurrentSubclassModule_ is not None:
10688
            subclass = getSubclassFromModule_(
10689
                CurrentSubclassModule_, AlternativeImageType)
10690
            if subclass is not None:
10691
                return subclass(*args_, **kwargs_)
10692
        if AlternativeImageType.subclass:
10693
            return AlternativeImageType.subclass(*args_, **kwargs_)
10694
        else:
10695
            return AlternativeImageType(*args_, **kwargs_)
10696
    factory = staticmethod(factory)
10697
    def get_ns_prefix_(self):
10698
        return self.ns_prefix_
10699
    def set_ns_prefix_(self, ns_prefix):
10700
        self.ns_prefix_ = ns_prefix
10701
    def get_filename(self):
10702
        return self.filename
10703
    def set_filename(self, filename):
10704
        self.filename = filename
10705
    def get_comments(self):
10706
        return self.comments
10707
    def set_comments(self, comments):
10708
        self.comments = comments
10709
    def get_conf(self):
10710
        return self.conf
10711
    def set_conf(self, conf):
10712
        self.conf = conf
10713 View Code Duplication
    def validate_ConfSimpleType(self, value):
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
10714
        # Validate type pc:ConfSimpleType, a restriction on float.
10715
        if value is not None and Validate_simpletypes_ and self.gds_collector_ is not None:
10716
            if not isinstance(value, float):
10717
                lineno = self.gds_get_node_lineno_()
10718
                self.gds_collector_.add_message('Value "%(value)s"%(lineno)s is not of the correct base simple type (float)' % {"value": value, "lineno": lineno, })
10719
                return False
10720
            if value < 0:
10721
                lineno = self.gds_get_node_lineno_()
10722
                self.gds_collector_.add_message('Value "%(value)s"%(lineno)s does not match xsd minInclusive restriction on ConfSimpleType' % {"value": value, "lineno": lineno} )
10723
                result = False
10724
            if value > 1:
10725
                lineno = self.gds_get_node_lineno_()
10726
                self.gds_collector_.add_message('Value "%(value)s"%(lineno)s does not match xsd maxInclusive restriction on ConfSimpleType' % {"value": value, "lineno": lineno} )
10727
                result = False
10728
    def has__content(self):
10729
        if (
10730
10731
        ):
10732
            return True
10733
        else:
10734
            return False
10735
    def export(self, outfile, level, namespaceprefix_='', namespacedef_='xmlns:pc="http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15"', name_='AlternativeImageType', pretty_print=True):
10736
        imported_ns_def_ = GenerateDSNamespaceDefs_.get('AlternativeImageType')
10737
        if imported_ns_def_ is not None:
10738
            namespacedef_ = imported_ns_def_
10739
        if pretty_print:
10740
            eol_ = '\n'
10741
        else:
10742
            eol_ = ''
10743
        if self.original_tagname_ is not None and name_ == 'AlternativeImageType':
10744
            name_ = self.original_tagname_
10745
        if UseCapturedNS_ and self.ns_prefix_:
10746
            namespaceprefix_ = self.ns_prefix_ + ':'
10747
        showIndent(outfile, level, pretty_print)
10748
        outfile.write('<%s%s%s' % (namespaceprefix_, name_, namespacedef_ and ' ' + namespacedef_ or '', ))
10749
        already_processed = set()
10750
        self._exportAttributes(outfile, level, already_processed, namespaceprefix_, name_='AlternativeImageType')
10751
        if self.has__content():
10752
            outfile.write('>%s' % (eol_, ))
10753
            self._exportChildren(outfile, level + 1, namespaceprefix_, namespacedef_, name_='AlternativeImageType', pretty_print=pretty_print)
10754
            outfile.write('</%s%s>%s' % (namespaceprefix_, name_, eol_))
10755
        else:
10756
            outfile.write('/>%s' % (eol_, ))
10757 View Code Duplication
    def _exportAttributes(self, outfile, level, already_processed, namespaceprefix_='', name_='AlternativeImageType'):
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
10758
        if self.filename is not None and 'filename' not in already_processed:
10759
            already_processed.add('filename')
10760
            outfile.write(' filename=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.filename), input_name='filename')), ))
10761
        if self.comments is not None and 'comments' not in already_processed:
10762
            already_processed.add('comments')
10763
            outfile.write(' comments=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.comments), input_name='comments')), ))
10764
        if self.conf is not None and 'conf' not in already_processed:
10765
            already_processed.add('conf')
10766
            outfile.write(' conf="%s"' % self.gds_format_float(self.conf, input_name='conf'))
10767
    def _exportChildren(self, outfile, level, namespaceprefix_='', namespacedef_='xmlns:pc="http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15"', name_='AlternativeImageType', fromsubclass_=False, pretty_print=True):
10768
        pass
10769 View Code Duplication
    def to_etree(self, parent_element=None, name_='AlternativeImageType', mapping_=None, reverse_mapping_=None, nsmap_=None):
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
10770
        if parent_element is None:
10771
            element = etree_.Element('{http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15}' + name_, nsmap=nsmap_)
10772
        else:
10773
            element = etree_.SubElement(parent_element, '{http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15}' + name_, nsmap=nsmap_)
10774
        if self.filename is not None:
10775
            element.set('filename', self.gds_format_string(self.filename))
10776
        if self.comments is not None:
10777
            element.set('comments', self.gds_format_string(self.comments))
10778
        if self.conf is not None:
10779
            element.set('conf', self.gds_format_float(self.conf))
10780
        if mapping_ is not None:
10781
            mapping_[id(self)] = element
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable id does not seem to be defined.
Loading history...
10782
        if reverse_mapping_ is not None:
10783
            reverse_mapping_[element] = self
10784
        return element
10785
    def build(self, node, gds_collector_=None):
10786
        self.gds_collector_ = gds_collector_
10787
        if SaveElementTreeNode:
10788
            self.gds_elementtree_node_ = node
10789
        already_processed = set()
10790
        self.ns_prefix_ = node.prefix
10791
        self._buildAttributes(node, node.attrib, already_processed)
10792
        for child in node:
10793
            nodeName_ = Tag_pattern_.match(child.tag).groups()[-1]
10794
            self._buildChildren(child, node, nodeName_, gds_collector_=gds_collector_)
10795
        return self
10796
    def _buildAttributes(self, node, attrs, already_processed):
10797
        value = find_attr_value_('filename', node)
10798
        if value is not None and 'filename' not in already_processed:
10799
            already_processed.add('filename')
10800
            self.filename = value
10801
        value = find_attr_value_('comments', node)
10802
        if value is not None and 'comments' not in already_processed:
10803
            already_processed.add('comments')
10804
            self.comments = value
10805
        value = find_attr_value_('conf', node)
10806
        if value is not None and 'conf' not in already_processed:
10807
            already_processed.add('conf')
10808
            value = self.gds_parse_float(value, node, 'conf')
10809
            self.conf = value
10810
            self.validate_ConfSimpleType(self.conf)    # validate type ConfSimpleType
10811
    def _buildChildren(self, child_, node, nodeName_, fromsubclass_=False, gds_collector_=None):
10812
        pass
10813
    def __hash__(self):
10814
        return hash(self.id)
10815
# end class AlternativeImageType
10816
10817
10818
class GraphemesType(GeneratedsSuper):
10819
    """GraphemesType --
10820
    Container for graphemes, grapheme groups and
10821
    non-printing characters.
10822
    
10823
    """
10824
    __hash__ = GeneratedsSuper.__hash__
10825
    member_data_items_ = [
10826
        MemberSpec_('Grapheme', 'GraphemeType', 1, 0, {'name': 'Grapheme', 'type': 'GraphemeType'}, 8),
10827
        MemberSpec_('NonPrintingChar', 'NonPrintingCharType', 1, 0, {'name': 'NonPrintingChar', 'type': 'NonPrintingCharType'}, 8),
10828
        MemberSpec_('GraphemeGroup', 'GraphemeGroupType', 1, 0, {'name': 'GraphemeGroup', 'type': 'GraphemeGroupType'}, 8),
10829
    ]
10830
    subclass = None
10831
    superclass = None
10832
    def __init__(self, Grapheme=None, NonPrintingChar=None, GraphemeGroup=None, gds_collector_=None, **kwargs_):
10833
        self.gds_collector_ = gds_collector_
10834
        self.gds_elementtree_node_ = None
10835
        self.original_tagname_ = None
10836
        self.parent_object_ = kwargs_.get('parent_object_')
10837
        self.ns_prefix_ = "pc"
10838
        if Grapheme is None:
10839
            self.Grapheme = []
10840
        else:
10841
            self.Grapheme = Grapheme
10842
        self.Grapheme_nsprefix_ = "pc"
10843
        if NonPrintingChar is None:
10844
            self.NonPrintingChar = []
10845
        else:
10846
            self.NonPrintingChar = NonPrintingChar
10847
        self.NonPrintingChar_nsprefix_ = "pc"
10848
        if GraphemeGroup is None:
10849
            self.GraphemeGroup = []
10850
        else:
10851
            self.GraphemeGroup = GraphemeGroup
10852
        self.GraphemeGroup_nsprefix_ = "pc"
10853
    def factory(*args_, **kwargs_):
10854
        if CurrentSubclassModule_ is not None:
10855
            subclass = getSubclassFromModule_(
10856
                CurrentSubclassModule_, GraphemesType)
10857
            if subclass is not None:
10858
                return subclass(*args_, **kwargs_)
10859
        if GraphemesType.subclass:
10860
            return GraphemesType.subclass(*args_, **kwargs_)
10861
        else:
10862
            return GraphemesType(*args_, **kwargs_)
10863
    factory = staticmethod(factory)
10864
    def get_ns_prefix_(self):
10865
        return self.ns_prefix_
10866
    def set_ns_prefix_(self, ns_prefix):
10867
        self.ns_prefix_ = ns_prefix
10868
    def get_Grapheme(self):
10869
        return self.Grapheme
10870
    def set_Grapheme(self, Grapheme):
10871
        self.Grapheme = Grapheme
10872
    def add_Grapheme(self, value):
10873
        self.Grapheme.append(value)
10874
    def insert_Grapheme_at(self, index, value):
10875
        self.Grapheme.insert(index, value)
10876
    def replace_Grapheme_at(self, index, value):
10877
        self.Grapheme[index] = value
10878
    def get_NonPrintingChar(self):
10879
        return self.NonPrintingChar
10880
    def set_NonPrintingChar(self, NonPrintingChar):
10881
        self.NonPrintingChar = NonPrintingChar
10882
    def add_NonPrintingChar(self, value):
10883
        self.NonPrintingChar.append(value)
10884
    def insert_NonPrintingChar_at(self, index, value):
10885
        self.NonPrintingChar.insert(index, value)
10886
    def replace_NonPrintingChar_at(self, index, value):
10887
        self.NonPrintingChar[index] = value
10888
    def get_GraphemeGroup(self):
10889
        return self.GraphemeGroup
10890
    def set_GraphemeGroup(self, GraphemeGroup):
10891
        self.GraphemeGroup = GraphemeGroup
10892
    def add_GraphemeGroup(self, value):
10893
        self.GraphemeGroup.append(value)
10894
    def insert_GraphemeGroup_at(self, index, value):
10895
        self.GraphemeGroup.insert(index, value)
10896
    def replace_GraphemeGroup_at(self, index, value):
10897
        self.GraphemeGroup[index] = value
10898
    def has__content(self):
10899
        if (
10900
            self.Grapheme or
10901
            self.NonPrintingChar or
10902
            self.GraphemeGroup
10903
        ):
10904
            return True
10905
        else:
10906
            return False
10907
    def export(self, outfile, level, namespaceprefix_='', namespacedef_='xmlns:pc="http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15"', name_='GraphemesType', pretty_print=True):
10908
        imported_ns_def_ = GenerateDSNamespaceDefs_.get('GraphemesType')
10909
        if imported_ns_def_ is not None:
10910
            namespacedef_ = imported_ns_def_
10911
        if pretty_print:
10912
            eol_ = '\n'
10913
        else:
10914
            eol_ = ''
10915
        if self.original_tagname_ is not None and name_ == 'GraphemesType':
10916
            name_ = self.original_tagname_
10917
        if UseCapturedNS_ and self.ns_prefix_:
10918
            namespaceprefix_ = self.ns_prefix_ + ':'
10919
        showIndent(outfile, level, pretty_print)
10920
        outfile.write('<%s%s%s' % (namespaceprefix_, name_, namespacedef_ and ' ' + namespacedef_ or '', ))
10921
        already_processed = set()
10922
        self._exportAttributes(outfile, level, already_processed, namespaceprefix_, name_='GraphemesType')
10923
        if self.has__content():
10924
            outfile.write('>%s' % (eol_, ))
10925
            self._exportChildren(outfile, level + 1, namespaceprefix_, namespacedef_, name_='GraphemesType', pretty_print=pretty_print)
10926
            showIndent(outfile, level, pretty_print)
10927
            outfile.write('</%s%s>%s' % (namespaceprefix_, name_, eol_))
10928
        else:
10929
            outfile.write('/>%s' % (eol_, ))
10930
    def _exportAttributes(self, outfile, level, already_processed, namespaceprefix_='', name_='GraphemesType'):
10931
        pass
10932
    def _exportChildren(self, outfile, level, namespaceprefix_='', namespacedef_='xmlns:pc="http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15"', name_='GraphemesType', fromsubclass_=False, pretty_print=True):
10933
        if pretty_print:
10934
            eol_ = '\n'
10935
        else:
10936
            eol_ = ''
10937
        for Grapheme_ in self.Grapheme:
10938
            namespaceprefix_ = self.Grapheme_nsprefix_ + ':' if (UseCapturedNS_ and self.Grapheme_nsprefix_) else ''
10939
            Grapheme_.export(outfile, level, namespaceprefix_, namespacedef_='', name_='Grapheme', pretty_print=pretty_print)
10940
        for NonPrintingChar_ in self.NonPrintingChar:
10941
            namespaceprefix_ = self.NonPrintingChar_nsprefix_ + ':' if (UseCapturedNS_ and self.NonPrintingChar_nsprefix_) else ''
10942
            NonPrintingChar_.export(outfile, level, namespaceprefix_, namespacedef_='', name_='NonPrintingChar', pretty_print=pretty_print)
10943
        for GraphemeGroup_ in self.GraphemeGroup:
10944
            namespaceprefix_ = self.GraphemeGroup_nsprefix_ + ':' if (UseCapturedNS_ and self.GraphemeGroup_nsprefix_) else ''
10945
            GraphemeGroup_.export(outfile, level, namespaceprefix_, namespacedef_='', name_='GraphemeGroup', pretty_print=pretty_print)
10946
    def to_etree(self, parent_element=None, name_='GraphemesType', mapping_=None, reverse_mapping_=None, nsmap_=None):
10947
        if parent_element is None:
10948
            element = etree_.Element('{http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15}' + name_, nsmap=nsmap_)
10949
        else:
10950
            element = etree_.SubElement(parent_element, '{http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15}' + name_, nsmap=nsmap_)
10951
        for Grapheme_ in self.Grapheme:
10952
            Grapheme_.to_etree(element, name_='Grapheme', mapping_=mapping_, reverse_mapping_=reverse_mapping_, nsmap_=nsmap_)
10953
        for NonPrintingChar_ in self.NonPrintingChar:
10954
            NonPrintingChar_.to_etree(element, name_='NonPrintingChar', mapping_=mapping_, reverse_mapping_=reverse_mapping_, nsmap_=nsmap_)
10955
        for GraphemeGroup_ in self.GraphemeGroup:
10956
            GraphemeGroup_.to_etree(element, name_='GraphemeGroup', mapping_=mapping_, reverse_mapping_=reverse_mapping_, nsmap_=nsmap_)
10957
        if mapping_ is not None:
10958
            mapping_[id(self)] = element
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable id does not seem to be defined.
Loading history...
10959
        if reverse_mapping_ is not None:
10960
            reverse_mapping_[element] = self
10961
        return element
10962
    def build(self, node, gds_collector_=None):
10963
        self.gds_collector_ = gds_collector_
10964
        if SaveElementTreeNode:
10965
            self.gds_elementtree_node_ = node
10966
        already_processed = set()
10967
        self.ns_prefix_ = node.prefix
10968
        self._buildAttributes(node, node.attrib, already_processed)
10969
        for child in node:
10970
            nodeName_ = Tag_pattern_.match(child.tag).groups()[-1]
10971
            self._buildChildren(child, node, nodeName_, gds_collector_=gds_collector_)
10972
        return self
10973
    def _buildAttributes(self, node, attrs, already_processed):
10974
        pass
10975
    def _buildChildren(self, child_, node, nodeName_, fromsubclass_=False, gds_collector_=None):
10976
        if nodeName_ == 'Grapheme':
10977
            obj_ = GraphemeType.factory(parent_object_=self)
10978
            obj_.build(child_, gds_collector_=gds_collector_)
10979
            self.Grapheme.append(obj_)
10980
            obj_.original_tagname_ = 'Grapheme'
10981
        elif nodeName_ == 'NonPrintingChar':
10982
            obj_ = NonPrintingCharType.factory(parent_object_=self)
10983
            obj_.build(child_, gds_collector_=gds_collector_)
10984
            self.NonPrintingChar.append(obj_)
10985
            obj_.original_tagname_ = 'NonPrintingChar'
10986
        elif nodeName_ == 'GraphemeGroup':
10987
            obj_ = GraphemeGroupType.factory(parent_object_=self)
10988
            obj_.build(child_, gds_collector_=gds_collector_)
10989
            self.GraphemeGroup.append(obj_)
10990
            obj_.original_tagname_ = 'GraphemeGroup'
10991
    def __hash__(self):
10992
        return hash(self.id)
10993
# end class GraphemesType
10994
10995
10996
class GraphemeBaseType(GeneratedsSuper):
10997
    """GraphemeBaseType --
10998
    Base type for graphemes, grapheme groups and non-printing characters.
10999
      
11000
    * index --
11001
      Order index of grapheme, group, or non-printing character
11002
      within the parent container (graphemes or glyph or grapheme group).
11003
      
11004
    * charType --
11005
      Type of character represented by the
11006
      grapheme, group, or non-printing character element.
11007
      
11008
    * custom -- For generic use
11009
    * comments -- For generic use
11010
    
11011
    """
11012
    __hash__ = GeneratedsSuper.__hash__
11013
    member_data_items_ = [
11014
        MemberSpec_('id', 'string', 0, 0, {'use': 'required', 'name': 'id'}),
11015
        MemberSpec_('index', 'indexType2', 0, 0, {'use': 'required', 'name': 'index'}),
11016
        MemberSpec_('ligature', 'boolean', 0, 1, {'use': 'optional', 'name': 'ligature'}),
11017
        MemberSpec_('charType', 'charTypeType', 0, 1, {'use': 'optional', 'name': 'charType'}),
11018
        MemberSpec_('custom', 'string', 0, 1, {'use': 'optional', 'name': 'custom'}),
11019
        MemberSpec_('comments', 'string', 0, 1, {'use': 'optional', 'name': 'comments'}),
11020
        MemberSpec_('TextEquiv', 'TextEquivType', 1, 1, {'maxOccurs': 'unbounded', 'minOccurs': '0', 'name': 'TextEquiv', 'type': 'TextEquivType'}, None),
11021
    ]
11022
    subclass = None
11023
    superclass = None
11024
    def __init__(self, id=None, index=None, ligature=None, charType=None, custom=None, comments=None, TextEquiv=None, extensiontype_=None, gds_collector_=None, **kwargs_):
11025
        self.gds_collector_ = gds_collector_
11026
        self.gds_elementtree_node_ = None
11027
        self.original_tagname_ = None
11028
        self.parent_object_ = kwargs_.get('parent_object_')
11029
        self.ns_prefix_ = "pc"
11030
        self.id = _cast(None, id)
11031
        self.id_nsprefix_ = "pc"
11032
        self.index = _cast(int, index)
11033
        self.index_nsprefix_ = "pc"
11034
        self.ligature = _cast(bool, ligature)
11035
        self.ligature_nsprefix_ = "pc"
11036
        self.charType = _cast(None, charType)
11037
        self.charType_nsprefix_ = "pc"
11038
        self.custom = _cast(None, custom)
11039
        self.custom_nsprefix_ = "pc"
11040
        self.comments = _cast(None, comments)
11041
        self.comments_nsprefix_ = "pc"
11042
        if TextEquiv is None:
11043
            self.TextEquiv = []
11044
        else:
11045
            self.TextEquiv = TextEquiv
11046
        self.TextEquiv_nsprefix_ = "pc"
11047
        self.extensiontype_ = extensiontype_
11048
    def factory(*args_, **kwargs_):
11049
        if CurrentSubclassModule_ is not None:
11050
            subclass = getSubclassFromModule_(
11051
                CurrentSubclassModule_, GraphemeBaseType)
11052
            if subclass is not None:
11053
                return subclass(*args_, **kwargs_)
11054
        if GraphemeBaseType.subclass:
11055
            return GraphemeBaseType.subclass(*args_, **kwargs_)
11056
        else:
11057
            return GraphemeBaseType(*args_, **kwargs_)
11058
    factory = staticmethod(factory)
11059
    def get_ns_prefix_(self):
11060
        return self.ns_prefix_
11061
    def set_ns_prefix_(self, ns_prefix):
11062
        self.ns_prefix_ = ns_prefix
11063
    def get_TextEquiv(self):
11064
        return self.TextEquiv
11065
    def set_TextEquiv(self, TextEquiv):
11066
        self.TextEquiv = TextEquiv
11067
    def add_TextEquiv(self, value):
11068
        self.TextEquiv.append(value)
11069
    def insert_TextEquiv_at(self, index, value):
11070
        self.TextEquiv.insert(index, value)
11071
    def replace_TextEquiv_at(self, index, value):
11072
        self.TextEquiv[index] = value
11073
    def get_id(self):
11074
        return self.id
11075
    def set_id(self, id):
11076
        self.id = id
11077
    def get_index(self):
11078
        return self.index
11079
    def set_index(self, index):
11080
        self.index = index
11081
    def get_ligature(self):
11082
        return self.ligature
11083
    def set_ligature(self, ligature):
11084
        self.ligature = ligature
11085
    def get_charType(self):
11086
        return self.charType
11087
    def set_charType(self, charType):
11088
        self.charType = charType
11089
    def get_custom(self):
11090
        return self.custom
11091
    def set_custom(self, custom):
11092
        self.custom = custom
11093
    def get_comments(self):
11094
        return self.comments
11095
    def set_comments(self, comments):
11096
        self.comments = comments
11097
    def get_extensiontype_(self): return self.extensiontype_
11098
    def set_extensiontype_(self, extensiontype_): self.extensiontype_ = extensiontype_
11099 View Code Duplication
    def validate_indexType2(self, value):
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
11100
        # Validate type indexType2, a restriction on int.
11101
        if value is not None and Validate_simpletypes_ and self.gds_collector_ is not None:
11102
            if not isinstance(value, int):
11103
                lineno = self.gds_get_node_lineno_()
11104
                self.gds_collector_.add_message('Value "%(value)s"%(lineno)s is not of the correct base simple type (int)' % {"value": value, "lineno": lineno, })
11105
                return False
11106
            if value < 0:
11107
                lineno = self.gds_get_node_lineno_()
11108
                self.gds_collector_.add_message('Value "%(value)s"%(lineno)s does not match xsd minInclusive restriction on indexType2' % {"value": value, "lineno": lineno} )
11109
                result = False
11110
    def validate_charTypeType(self, value):
11111
        # Validate type charTypeType, a restriction on string.
11112
        if value is not None and Validate_simpletypes_ and self.gds_collector_ is not None:
11113
            if not isinstance(value, str):
11114
                lineno = self.gds_get_node_lineno_()
11115
                self.gds_collector_.add_message('Value "%(value)s"%(lineno)s is not of the correct base simple type (str)' % {"value": value, "lineno": lineno, })
11116
                return False
11117
            value = value
11118
            enumerations = ['base', 'combining']
11119
            if value not in enumerations:
11120
                lineno = self.gds_get_node_lineno_()
11121
                self.gds_collector_.add_message('Value "%(value)s"%(lineno)s does not match xsd enumeration restriction on charTypeType' % {"value" : encode_str_2_3(value), "lineno": lineno} )
11122
                result = False
11123
    def has__content(self):
11124
        if (
11125
            self.TextEquiv
11126
        ):
11127
            return True
11128
        else:
11129
            return False
11130
    def export(self, outfile, level, namespaceprefix_='', namespacedef_='xmlns:pc="http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15"', name_='GraphemeBaseType', pretty_print=True):
11131
        imported_ns_def_ = GenerateDSNamespaceDefs_.get('GraphemeBaseType')
11132
        if imported_ns_def_ is not None:
11133
            namespacedef_ = imported_ns_def_
11134
        if pretty_print:
11135
            eol_ = '\n'
11136
        else:
11137
            eol_ = ''
11138
        if self.original_tagname_ is not None and name_ == 'GraphemeBaseType':
11139
            name_ = self.original_tagname_
11140
        if UseCapturedNS_ and self.ns_prefix_:
11141
            namespaceprefix_ = self.ns_prefix_ + ':'
11142
        showIndent(outfile, level, pretty_print)
11143
        outfile.write('<%s%s%s' % (namespaceprefix_, name_, namespacedef_ and ' ' + namespacedef_ or '', ))
11144
        already_processed = set()
11145
        self._exportAttributes(outfile, level, already_processed, namespaceprefix_, name_='GraphemeBaseType')
11146
        if self.has__content():
11147
            outfile.write('>%s' % (eol_, ))
11148
            self._exportChildren(outfile, level + 1, namespaceprefix_, namespacedef_, name_='GraphemeBaseType', pretty_print=pretty_print)
11149
            showIndent(outfile, level, pretty_print)
11150
            outfile.write('</%s%s>%s' % (namespaceprefix_, name_, eol_))
11151
        else:
11152
            outfile.write('/>%s' % (eol_, ))
11153
    def _exportAttributes(self, outfile, level, already_processed, namespaceprefix_='', name_='GraphemeBaseType'):
11154
        if self.id is not None and 'id' not in already_processed:
11155
            already_processed.add('id')
11156
            outfile.write(' id=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.id), input_name='id')), ))
11157
        if self.index is not None and 'index' not in already_processed:
11158
            already_processed.add('index')
11159
            outfile.write(' index="%s"' % self.gds_format_integer(self.index, input_name='index'))
11160
        if self.ligature is not None and 'ligature' not in already_processed:
11161
            already_processed.add('ligature')
11162
            outfile.write(' ligature="%s"' % self.gds_format_boolean(self.ligature, input_name='ligature'))
11163
        if self.charType is not None and 'charType' not in already_processed:
11164
            already_processed.add('charType')
11165
            outfile.write(' charType=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.charType), input_name='charType')), ))
11166
        if self.custom is not None and 'custom' not in already_processed:
11167
            already_processed.add('custom')
11168
            outfile.write(' custom=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.custom), input_name='custom')), ))
11169
        if self.comments is not None and 'comments' not in already_processed:
11170
            already_processed.add('comments')
11171
            outfile.write(' comments=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.comments), input_name='comments')), ))
11172
        if self.extensiontype_ is not None and 'xsi:type' not in already_processed:
11173
            already_processed.add('xsi:type')
11174
            outfile.write(' xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"')
11175
            if ":" not in self.extensiontype_:
11176
                imported_ns_type_prefix_ = GenerateDSNamespaceTypePrefixes_.get(self.extensiontype_, '')
11177
                outfile.write(' xsi:type="%s%s"' % (imported_ns_type_prefix_, self.extensiontype_))
11178
            else:
11179
                outfile.write(' xsi:type="%s"' % self.extensiontype_)
11180
    def _exportChildren(self, outfile, level, namespaceprefix_='', namespacedef_='xmlns:pc="http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15"', name_='GraphemeBaseType', fromsubclass_=False, pretty_print=True):
11181
        if pretty_print:
11182
            eol_ = '\n'
11183
        else:
11184
            eol_ = ''
11185
        for TextEquiv_ in self.TextEquiv:
11186
            namespaceprefix_ = self.TextEquiv_nsprefix_ + ':' if (UseCapturedNS_ and self.TextEquiv_nsprefix_) else ''
11187
            TextEquiv_.export(outfile, level, namespaceprefix_, namespacedef_='', name_='TextEquiv', pretty_print=pretty_print)
11188
    def to_etree(self, parent_element=None, name_='GraphemeBaseType', mapping_=None, reverse_mapping_=None, nsmap_=None):
11189
        if parent_element is None:
11190
            element = etree_.Element('{http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15}' + name_, nsmap=nsmap_)
11191
        else:
11192
            element = etree_.SubElement(parent_element, '{http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15}' + name_, nsmap=nsmap_)
11193
        if self.extensiontype_ is not None:
11194
            element.set('{http://www.w3.org/2001/XMLSchema-instance}type', self.extensiontype_)
11195
        if self.id is not None:
11196
            element.set('id', self.gds_format_string(self.id))
11197
        if self.index is not None:
11198
            element.set('index', self.gds_format_integer(self.index))
11199
        if self.ligature is not None:
11200
            element.set('ligature', self.gds_format_boolean(self.ligature))
11201
        if self.charType is not None:
11202
            element.set('charType', self.gds_format_string(self.charType))
11203
        if self.custom is not None:
11204
            element.set('custom', self.gds_format_string(self.custom))
11205
        if self.comments is not None:
11206
            element.set('comments', self.gds_format_string(self.comments))
11207
        for TextEquiv_ in self.TextEquiv:
11208
            TextEquiv_.to_etree(element, name_='TextEquiv', mapping_=mapping_, reverse_mapping_=reverse_mapping_, nsmap_=nsmap_)
11209
        if mapping_ is not None:
11210
            mapping_[id(self)] = element
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable id does not seem to be defined.
Loading history...
11211
        if reverse_mapping_ is not None:
11212
            reverse_mapping_[element] = self
11213
        return element
11214
    def build(self, node, gds_collector_=None):
11215
        self.gds_collector_ = gds_collector_
11216
        if SaveElementTreeNode:
11217
            self.gds_elementtree_node_ = node
11218
        already_processed = set()
11219
        self.ns_prefix_ = node.prefix
11220
        self._buildAttributes(node, node.attrib, already_processed)
11221
        for child in node:
11222
            nodeName_ = Tag_pattern_.match(child.tag).groups()[-1]
11223
            self._buildChildren(child, node, nodeName_, gds_collector_=gds_collector_)
11224
        return self
11225
    def _buildAttributes(self, node, attrs, already_processed):
11226
        value = find_attr_value_('id', node)
11227
        if value is not None and 'id' not in already_processed:
11228
            already_processed.add('id')
11229
            self.id = value
11230
        value = find_attr_value_('index', node)
11231
        if value is not None and 'index' not in already_processed:
11232
            already_processed.add('index')
11233
            self.index = self.gds_parse_integer(value, node, 'index')
11234
            self.validate_indexType2(self.index)    # validate type indexType2
11235
        value = find_attr_value_('ligature', node)
11236
        if value is not None and 'ligature' not in already_processed:
11237
            already_processed.add('ligature')
11238
            if value in ('true', '1'):
11239
                self.ligature = True
11240
            elif value in ('false', '0'):
11241
                self.ligature = False
11242
            else:
11243
                raise_parse_error(node, 'Bad boolean attribute')
11244
        value = find_attr_value_('charType', node)
11245
        if value is not None and 'charType' not in already_processed:
11246
            already_processed.add('charType')
11247
            self.charType = value
11248
            self.validate_charTypeType(self.charType)    # validate type charTypeType
11249
        value = find_attr_value_('custom', node)
11250
        if value is not None and 'custom' not in already_processed:
11251
            already_processed.add('custom')
11252
            self.custom = value
11253
        value = find_attr_value_('comments', node)
11254
        if value is not None and 'comments' not in already_processed:
11255
            already_processed.add('comments')
11256
            self.comments = value
11257
        value = find_attr_value_('xsi:type', node)
11258
        if value is not None and 'xsi:type' not in already_processed:
11259
            already_processed.add('xsi:type')
11260
            self.extensiontype_ = value
11261
    def _buildChildren(self, child_, node, nodeName_, fromsubclass_=False, gds_collector_=None):
11262
        if nodeName_ == 'TextEquiv':
11263
            obj_ = TextEquivType.factory(parent_object_=self)
11264
            obj_.build(child_, gds_collector_=gds_collector_)
11265
            self.TextEquiv.append(obj_)
11266
            obj_.original_tagname_ = 'TextEquiv'
11267
    def __hash__(self):
11268
        return hash(self.id)
11269
# end class GraphemeBaseType
11270
11271
11272
class GraphemeType(GraphemeBaseType):
11273
    """GraphemeType --
11274
    Represents a sub-element of a glyph.
11275
    Smallest graphical unit that can be
11276
    assigned a Unicode code point.
11277
    
11278
    """
11279
    __hash__ = GeneratedsSuper.__hash__
11280
    member_data_items_ = [
11281
        MemberSpec_('Coords', 'CoordsType', 0, 0, {'name': 'Coords', 'type': 'CoordsType'}, None),
11282
    ]
11283
    subclass = None
11284
    superclass = GraphemeBaseType
11285
    def __init__(self, id=None, index=None, ligature=None, charType=None, custom=None, comments=None, TextEquiv=None, Coords=None, gds_collector_=None, **kwargs_):
11286
        self.gds_collector_ = gds_collector_
11287
        self.gds_elementtree_node_ = None
11288
        self.original_tagname_ = None
11289
        self.parent_object_ = kwargs_.get('parent_object_')
11290
        self.ns_prefix_ = "pc"
11291
        super(globals().get("GraphemeType"), self).__init__(id, index, ligature, charType, custom, comments, TextEquiv,  **kwargs_)
11292
        self.Coords = Coords
11293
        self.Coords_nsprefix_ = "pc"
11294
    def factory(*args_, **kwargs_):
11295
        if CurrentSubclassModule_ is not None:
11296
            subclass = getSubclassFromModule_(
11297
                CurrentSubclassModule_, GraphemeType)
11298
            if subclass is not None:
11299
                return subclass(*args_, **kwargs_)
11300
        if GraphemeType.subclass:
11301
            return GraphemeType.subclass(*args_, **kwargs_)
11302
        else:
11303
            return GraphemeType(*args_, **kwargs_)
11304
    factory = staticmethod(factory)
11305
    def get_ns_prefix_(self):
11306
        return self.ns_prefix_
11307
    def set_ns_prefix_(self, ns_prefix):
11308
        self.ns_prefix_ = ns_prefix
11309
    def get_Coords(self):
11310
        return self.Coords
11311
    def set_Coords(self, Coords):
11312
        self.Coords = Coords
11313
    def has__content(self):
11314
        if (
11315
            self.Coords is not None or
11316
            super(GraphemeType, self).has__content()
11317
        ):
11318
            return True
11319
        else:
11320
            return False
11321
    def export(self, outfile, level, namespaceprefix_='', namespacedef_='xmlns:pc="http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15"', name_='GraphemeType', pretty_print=True):
11322
        imported_ns_def_ = GenerateDSNamespaceDefs_.get('GraphemeType')
11323
        if imported_ns_def_ is not None:
11324
            namespacedef_ = imported_ns_def_
11325
        if pretty_print:
11326
            eol_ = '\n'
11327
        else:
11328
            eol_ = ''
11329
        if self.original_tagname_ is not None and name_ == 'GraphemeType':
11330
            name_ = self.original_tagname_
11331
        if UseCapturedNS_ and self.ns_prefix_:
11332
            namespaceprefix_ = self.ns_prefix_ + ':'
11333
        showIndent(outfile, level, pretty_print)
11334
        outfile.write('<%s%s%s' % (namespaceprefix_, name_, namespacedef_ and ' ' + namespacedef_ or '', ))
11335
        already_processed = set()
11336
        self._exportAttributes(outfile, level, already_processed, namespaceprefix_, name_='GraphemeType')
11337
        if self.has__content():
11338
            outfile.write('>%s' % (eol_, ))
11339
            self._exportChildren(outfile, level + 1, namespaceprefix_, namespacedef_, name_='GraphemeType', pretty_print=pretty_print)
11340
            showIndent(outfile, level, pretty_print)
11341
            outfile.write('</%s%s>%s' % (namespaceprefix_, name_, eol_))
11342
        else:
11343
            outfile.write('/>%s' % (eol_, ))
11344
    def _exportAttributes(self, outfile, level, already_processed, namespaceprefix_='', name_='GraphemeType'):
11345
        super(GraphemeType, self)._exportAttributes(outfile, level, already_processed, namespaceprefix_, name_='GraphemeType')
11346
    def _exportChildren(self, outfile, level, namespaceprefix_='', namespacedef_='xmlns:pc="http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15"', name_='GraphemeType', fromsubclass_=False, pretty_print=True):
11347
        super(GraphemeType, self)._exportChildren(outfile, level, namespaceprefix_, namespacedef_, name_, True, pretty_print=pretty_print)
11348
        if pretty_print:
11349
            eol_ = '\n'
11350
        else:
11351
            eol_ = ''
11352
        if self.Coords is not None:
11353
            namespaceprefix_ = self.Coords_nsprefix_ + ':' if (UseCapturedNS_ and self.Coords_nsprefix_) else ''
11354
            self.Coords.export(outfile, level, namespaceprefix_, namespacedef_='', name_='Coords', pretty_print=pretty_print)
11355
    def to_etree(self, parent_element=None, name_='GraphemeType', mapping_=None, reverse_mapping_=None, nsmap_=None):
11356
        element = super(GraphemeType, self).to_etree(parent_element, name_, mapping_, reverse_mapping_, nsmap_)
11357
        if self.Coords is not None:
11358
            Coords_ = self.Coords
11359
            Coords_.to_etree(element, name_='Coords', mapping_=mapping_, reverse_mapping_=reverse_mapping_, nsmap_=nsmap_)
11360
        if mapping_ is not None:
11361
            mapping_[id(self)] = element
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable id does not seem to be defined.
Loading history...
11362
        if reverse_mapping_ is not None:
11363
            reverse_mapping_[element] = self
11364
        return element
11365
    def build(self, node, gds_collector_=None):
11366
        self.gds_collector_ = gds_collector_
11367
        if SaveElementTreeNode:
11368
            self.gds_elementtree_node_ = node
11369
        already_processed = set()
11370
        self.ns_prefix_ = node.prefix
11371
        self._buildAttributes(node, node.attrib, already_processed)
11372
        for child in node:
11373
            nodeName_ = Tag_pattern_.match(child.tag).groups()[-1]
11374
            self._buildChildren(child, node, nodeName_, gds_collector_=gds_collector_)
11375
        return self
11376
    def _buildAttributes(self, node, attrs, already_processed):
11377
        super(GraphemeType, self)._buildAttributes(node, attrs, already_processed)
11378
    def _buildChildren(self, child_, node, nodeName_, fromsubclass_=False, gds_collector_=None):
11379
        if nodeName_ == 'Coords':
11380
            obj_ = CoordsType.factory(parent_object_=self)
11381
            obj_.build(child_, gds_collector_=gds_collector_)
11382
            self.Coords = obj_
11383
            obj_.original_tagname_ = 'Coords'
11384
        super(GraphemeType, self)._buildChildren(child_, node, nodeName_, True)
11385
    def __hash__(self):
11386
        return hash(self.id)
11387
# end class GraphemeType
11388
11389
11390
class NonPrintingCharType(GraphemeBaseType):
11391
    """NonPrintingCharType --
11392
    A glyph component without visual representation
11393
    but with Unicode code point.
11394
    Non-visual / non-printing / control character.
11395
    Part of grapheme container (of glyph) or grapheme sub group.
11396
    
11397
    """
11398
    __hash__ = GeneratedsSuper.__hash__
11399
    member_data_items_ = [
11400
    ]
11401
    subclass = None
11402
    superclass = GraphemeBaseType
11403
    def __init__(self, id=None, index=None, ligature=None, charType=None, custom=None, comments=None, TextEquiv=None, gds_collector_=None, **kwargs_):
11404
        self.gds_collector_ = gds_collector_
11405
        self.gds_elementtree_node_ = None
11406
        self.original_tagname_ = None
11407
        self.parent_object_ = kwargs_.get('parent_object_')
11408
        self.ns_prefix_ = "pc"
11409
        super(globals().get("NonPrintingCharType"), self).__init__(id, index, ligature, charType, custom, comments, TextEquiv,  **kwargs_)
11410
    def factory(*args_, **kwargs_):
11411
        if CurrentSubclassModule_ is not None:
11412
            subclass = getSubclassFromModule_(
11413
                CurrentSubclassModule_, NonPrintingCharType)
11414
            if subclass is not None:
11415
                return subclass(*args_, **kwargs_)
11416
        if NonPrintingCharType.subclass:
11417
            return NonPrintingCharType.subclass(*args_, **kwargs_)
11418
        else:
11419
            return NonPrintingCharType(*args_, **kwargs_)
11420
    factory = staticmethod(factory)
11421
    def get_ns_prefix_(self):
11422
        return self.ns_prefix_
11423
    def set_ns_prefix_(self, ns_prefix):
11424
        self.ns_prefix_ = ns_prefix
11425
    def has__content(self):
11426
        if (
11427
            super(NonPrintingCharType, self).has__content()
11428
        ):
11429
            return True
11430
        else:
11431
            return False
11432
    def export(self, outfile, level, namespaceprefix_='', namespacedef_='xmlns:pc="http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15"', name_='NonPrintingCharType', pretty_print=True):
11433
        imported_ns_def_ = GenerateDSNamespaceDefs_.get('NonPrintingCharType')
11434
        if imported_ns_def_ is not None:
11435
            namespacedef_ = imported_ns_def_
11436
        if pretty_print:
11437
            eol_ = '\n'
11438
        else:
11439
            eol_ = ''
11440
        if self.original_tagname_ is not None and name_ == 'NonPrintingCharType':
11441
            name_ = self.original_tagname_
11442
        if UseCapturedNS_ and self.ns_prefix_:
11443
            namespaceprefix_ = self.ns_prefix_ + ':'
11444
        showIndent(outfile, level, pretty_print)
11445
        outfile.write('<%s%s%s' % (namespaceprefix_, name_, namespacedef_ and ' ' + namespacedef_ or '', ))
11446
        already_processed = set()
11447
        self._exportAttributes(outfile, level, already_processed, namespaceprefix_, name_='NonPrintingCharType')
11448
        if self.has__content():
11449
            outfile.write('>%s' % (eol_, ))
11450
            self._exportChildren(outfile, level + 1, namespaceprefix_, namespacedef_, name_='NonPrintingCharType', pretty_print=pretty_print)
11451
            showIndent(outfile, level, pretty_print)
11452
            outfile.write('</%s%s>%s' % (namespaceprefix_, name_, eol_))
11453
        else:
11454
            outfile.write('/>%s' % (eol_, ))
11455
    def _exportAttributes(self, outfile, level, already_processed, namespaceprefix_='', name_='NonPrintingCharType'):
11456
        super(NonPrintingCharType, self)._exportAttributes(outfile, level, already_processed, namespaceprefix_, name_='NonPrintingCharType')
11457
    def _exportChildren(self, outfile, level, namespaceprefix_='', namespacedef_='xmlns:pc="http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15"', name_='NonPrintingCharType', fromsubclass_=False, pretty_print=True):
11458
        super(NonPrintingCharType, self)._exportChildren(outfile, level, namespaceprefix_, namespacedef_, name_, True, pretty_print=pretty_print)
11459
    def to_etree(self, parent_element=None, name_='NonPrintingCharType', mapping_=None, reverse_mapping_=None, nsmap_=None):
11460
        element = super(NonPrintingCharType, self).to_etree(parent_element, name_, mapping_, reverse_mapping_, nsmap_)
11461
        if mapping_ is not None:
11462
            mapping_[id(self)] = element
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable id does not seem to be defined.
Loading history...
11463
        if reverse_mapping_ is not None:
11464
            reverse_mapping_[element] = self
11465
        return element
11466
    def build(self, node, gds_collector_=None):
11467
        self.gds_collector_ = gds_collector_
11468
        if SaveElementTreeNode:
11469
            self.gds_elementtree_node_ = node
11470
        already_processed = set()
11471
        self.ns_prefix_ = node.prefix
11472
        self._buildAttributes(node, node.attrib, already_processed)
11473
        for child in node:
11474
            nodeName_ = Tag_pattern_.match(child.tag).groups()[-1]
11475
            self._buildChildren(child, node, nodeName_, gds_collector_=gds_collector_)
11476
        return self
11477
    def _buildAttributes(self, node, attrs, already_processed):
11478
        super(NonPrintingCharType, self)._buildAttributes(node, attrs, already_processed)
11479
    def _buildChildren(self, child_, node, nodeName_, fromsubclass_=False, gds_collector_=None):
11480
        super(NonPrintingCharType, self)._buildChildren(child_, node, nodeName_, True)
11481
        pass
11482
    def __hash__(self):
11483
        return hash(self.id)
11484
# end class NonPrintingCharType
11485
11486
11487
class GraphemeGroupType(GraphemeBaseType):
11488
    __hash__ = GeneratedsSuper.__hash__
11489
    member_data_items_ = [
11490
        MemberSpec_('Grapheme', 'GraphemeType', 1, 1, {'name': 'Grapheme', 'type': 'GraphemeType'}, 9),
11491
        MemberSpec_('NonPrintingChar', 'NonPrintingCharType', 1, 1, {'name': 'NonPrintingChar', 'type': 'NonPrintingCharType'}, 9),
11492
    ]
11493
    subclass = None
11494
    superclass = GraphemeBaseType
11495
    def __init__(self, id=None, index=None, ligature=None, charType=None, custom=None, comments=None, TextEquiv=None, Grapheme=None, NonPrintingChar=None, gds_collector_=None, **kwargs_):
11496
        self.gds_collector_ = gds_collector_
11497
        self.gds_elementtree_node_ = None
11498
        self.original_tagname_ = None
11499
        self.parent_object_ = kwargs_.get('parent_object_')
11500
        self.ns_prefix_ = "pc"
11501
        super(globals().get("GraphemeGroupType"), self).__init__(id, index, ligature, charType, custom, comments, TextEquiv,  **kwargs_)
11502
        if Grapheme is None:
11503
            self.Grapheme = []
11504
        else:
11505
            self.Grapheme = Grapheme
11506
        self.Grapheme_nsprefix_ = "pc"
11507
        if NonPrintingChar is None:
11508
            self.NonPrintingChar = []
11509
        else:
11510
            self.NonPrintingChar = NonPrintingChar
11511
        self.NonPrintingChar_nsprefix_ = "pc"
11512
    def factory(*args_, **kwargs_):
11513
        if CurrentSubclassModule_ is not None:
11514
            subclass = getSubclassFromModule_(
11515
                CurrentSubclassModule_, GraphemeGroupType)
11516
            if subclass is not None:
11517
                return subclass(*args_, **kwargs_)
11518
        if GraphemeGroupType.subclass:
11519
            return GraphemeGroupType.subclass(*args_, **kwargs_)
11520
        else:
11521
            return GraphemeGroupType(*args_, **kwargs_)
11522
    factory = staticmethod(factory)
11523
    def get_ns_prefix_(self):
11524
        return self.ns_prefix_
11525
    def set_ns_prefix_(self, ns_prefix):
11526
        self.ns_prefix_ = ns_prefix
11527
    def get_Grapheme(self):
11528
        return self.Grapheme
11529
    def set_Grapheme(self, Grapheme):
11530
        self.Grapheme = Grapheme
11531
    def add_Grapheme(self, value):
11532
        self.Grapheme.append(value)
11533
    def insert_Grapheme_at(self, index, value):
11534
        self.Grapheme.insert(index, value)
11535
    def replace_Grapheme_at(self, index, value):
11536
        self.Grapheme[index] = value
11537
    def get_NonPrintingChar(self):
11538
        return self.NonPrintingChar
11539
    def set_NonPrintingChar(self, NonPrintingChar):
11540
        self.NonPrintingChar = NonPrintingChar
11541
    def add_NonPrintingChar(self, value):
11542
        self.NonPrintingChar.append(value)
11543
    def insert_NonPrintingChar_at(self, index, value):
11544
        self.NonPrintingChar.insert(index, value)
11545
    def replace_NonPrintingChar_at(self, index, value):
11546
        self.NonPrintingChar[index] = value
11547
    def has__content(self):
11548
        if (
11549
            self.Grapheme or
11550
            self.NonPrintingChar or
11551
            super(GraphemeGroupType, self).has__content()
11552
        ):
11553
            return True
11554
        else:
11555
            return False
11556
    def export(self, outfile, level, namespaceprefix_='', namespacedef_='xmlns:pc="http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15"', name_='GraphemeGroupType', pretty_print=True):
11557
        imported_ns_def_ = GenerateDSNamespaceDefs_.get('GraphemeGroupType')
11558
        if imported_ns_def_ is not None:
11559
            namespacedef_ = imported_ns_def_
11560
        if pretty_print:
11561
            eol_ = '\n'
11562
        else:
11563
            eol_ = ''
11564
        if self.original_tagname_ is not None and name_ == 'GraphemeGroupType':
11565
            name_ = self.original_tagname_
11566
        if UseCapturedNS_ and self.ns_prefix_:
11567
            namespaceprefix_ = self.ns_prefix_ + ':'
11568
        showIndent(outfile, level, pretty_print)
11569
        outfile.write('<%s%s%s' % (namespaceprefix_, name_, namespacedef_ and ' ' + namespacedef_ or '', ))
11570
        already_processed = set()
11571
        self._exportAttributes(outfile, level, already_processed, namespaceprefix_, name_='GraphemeGroupType')
11572
        if self.has__content():
11573
            outfile.write('>%s' % (eol_, ))
11574
            self._exportChildren(outfile, level + 1, namespaceprefix_, namespacedef_, name_='GraphemeGroupType', pretty_print=pretty_print)
11575
            showIndent(outfile, level, pretty_print)
11576
            outfile.write('</%s%s>%s' % (namespaceprefix_, name_, eol_))
11577
        else:
11578
            outfile.write('/>%s' % (eol_, ))
11579
    def _exportAttributes(self, outfile, level, already_processed, namespaceprefix_='', name_='GraphemeGroupType'):
11580
        super(GraphemeGroupType, self)._exportAttributes(outfile, level, already_processed, namespaceprefix_, name_='GraphemeGroupType')
11581
    def _exportChildren(self, outfile, level, namespaceprefix_='', namespacedef_='xmlns:pc="http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15"', name_='GraphemeGroupType', fromsubclass_=False, pretty_print=True):
11582
        super(GraphemeGroupType, self)._exportChildren(outfile, level, namespaceprefix_, namespacedef_, name_, True, pretty_print=pretty_print)
11583
        if pretty_print:
11584
            eol_ = '\n'
11585
        else:
11586
            eol_ = ''
11587
        for Grapheme_ in self.Grapheme:
11588
            namespaceprefix_ = self.Grapheme_nsprefix_ + ':' if (UseCapturedNS_ and self.Grapheme_nsprefix_) else ''
11589
            Grapheme_.export(outfile, level, namespaceprefix_, namespacedef_='', name_='Grapheme', pretty_print=pretty_print)
11590
        for NonPrintingChar_ in self.NonPrintingChar:
11591
            namespaceprefix_ = self.NonPrintingChar_nsprefix_ + ':' if (UseCapturedNS_ and self.NonPrintingChar_nsprefix_) else ''
11592
            NonPrintingChar_.export(outfile, level, namespaceprefix_, namespacedef_='', name_='NonPrintingChar', pretty_print=pretty_print)
11593
    def to_etree(self, parent_element=None, name_='GraphemeGroupType', mapping_=None, reverse_mapping_=None, nsmap_=None):
11594
        element = super(GraphemeGroupType, self).to_etree(parent_element, name_, mapping_, reverse_mapping_, nsmap_)
11595
        for Grapheme_ in self.Grapheme:
11596
            Grapheme_.to_etree(element, name_='Grapheme', mapping_=mapping_, reverse_mapping_=reverse_mapping_, nsmap_=nsmap_)
11597
        for NonPrintingChar_ in self.NonPrintingChar:
11598
            NonPrintingChar_.to_etree(element, name_='NonPrintingChar', mapping_=mapping_, reverse_mapping_=reverse_mapping_, nsmap_=nsmap_)
11599
        if mapping_ is not None:
11600
            mapping_[id(self)] = element
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable id does not seem to be defined.
Loading history...
11601
        if reverse_mapping_ is not None:
11602
            reverse_mapping_[element] = self
11603
        return element
11604
    def build(self, node, gds_collector_=None):
11605
        self.gds_collector_ = gds_collector_
11606
        if SaveElementTreeNode:
11607
            self.gds_elementtree_node_ = node
11608
        already_processed = set()
11609
        self.ns_prefix_ = node.prefix
11610
        self._buildAttributes(node, node.attrib, already_processed)
11611
        for child in node:
11612
            nodeName_ = Tag_pattern_.match(child.tag).groups()[-1]
11613
            self._buildChildren(child, node, nodeName_, gds_collector_=gds_collector_)
11614
        return self
11615
    def _buildAttributes(self, node, attrs, already_processed):
11616
        super(GraphemeGroupType, self)._buildAttributes(node, attrs, already_processed)
11617
    def _buildChildren(self, child_, node, nodeName_, fromsubclass_=False, gds_collector_=None):
11618
        if nodeName_ == 'Grapheme':
11619
            obj_ = GraphemeType.factory(parent_object_=self)
11620
            obj_.build(child_, gds_collector_=gds_collector_)
11621
            self.Grapheme.append(obj_)
11622
            obj_.original_tagname_ = 'Grapheme'
11623
        elif nodeName_ == 'NonPrintingChar':
11624
            obj_ = NonPrintingCharType.factory(parent_object_=self)
11625
            obj_.build(child_, gds_collector_=gds_collector_)
11626
            self.NonPrintingChar.append(obj_)
11627
            obj_.original_tagname_ = 'NonPrintingChar'
11628
        super(GraphemeGroupType, self)._buildChildren(child_, node, nodeName_, True)
11629
    def __hash__(self):
11630
        return hash(self.id)
11631
# end class GraphemeGroupType
11632
11633
11634 View Code Duplication
class UserDefinedType(GeneratedsSuper):
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
11635
    """UserDefinedType -- Container for user-defined attributes
11636
    
11637
    """
11638
    __hash__ = GeneratedsSuper.__hash__
11639
    member_data_items_ = [
11640
        MemberSpec_('UserAttribute', 'UserAttributeType', 1, 0, {'maxOccurs': 'unbounded', 'minOccurs': '1', 'name': 'UserAttribute', 'type': 'UserAttributeType'}, None),
11641
    ]
11642
    subclass = None
11643
    superclass = None
11644
    def __init__(self, UserAttribute=None, gds_collector_=None, **kwargs_):
11645
        self.gds_collector_ = gds_collector_
11646
        self.gds_elementtree_node_ = None
11647
        self.original_tagname_ = None
11648
        self.parent_object_ = kwargs_.get('parent_object_')
11649
        self.ns_prefix_ = "pc"
11650
        if UserAttribute is None:
11651
            self.UserAttribute = []
11652
        else:
11653
            self.UserAttribute = UserAttribute
11654
        self.UserAttribute_nsprefix_ = "pc"
11655
    def factory(*args_, **kwargs_):
11656
        if CurrentSubclassModule_ is not None:
11657
            subclass = getSubclassFromModule_(
11658
                CurrentSubclassModule_, UserDefinedType)
11659
            if subclass is not None:
11660
                return subclass(*args_, **kwargs_)
11661
        if UserDefinedType.subclass:
11662
            return UserDefinedType.subclass(*args_, **kwargs_)
11663
        else:
11664
            return UserDefinedType(*args_, **kwargs_)
11665
    factory = staticmethod(factory)
11666
    def get_ns_prefix_(self):
11667
        return self.ns_prefix_
11668
    def set_ns_prefix_(self, ns_prefix):
11669
        self.ns_prefix_ = ns_prefix
11670
    def get_UserAttribute(self):
11671
        return self.UserAttribute
11672
    def set_UserAttribute(self, UserAttribute):
11673
        self.UserAttribute = UserAttribute
11674
    def add_UserAttribute(self, value):
11675
        self.UserAttribute.append(value)
11676
    def insert_UserAttribute_at(self, index, value):
11677
        self.UserAttribute.insert(index, value)
11678
    def replace_UserAttribute_at(self, index, value):
11679
        self.UserAttribute[index] = value
11680
    def has__content(self):
11681
        if (
11682
            self.UserAttribute
11683
        ):
11684
            return True
11685
        else:
11686
            return False
11687
    def export(self, outfile, level, namespaceprefix_='', namespacedef_='xmlns:pc="http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15"', name_='UserDefinedType', pretty_print=True):
11688
        imported_ns_def_ = GenerateDSNamespaceDefs_.get('UserDefinedType')
11689
        if imported_ns_def_ is not None:
11690
            namespacedef_ = imported_ns_def_
11691
        if pretty_print:
11692
            eol_ = '\n'
11693
        else:
11694
            eol_ = ''
11695
        if self.original_tagname_ is not None and name_ == 'UserDefinedType':
11696
            name_ = self.original_tagname_
11697
        if UseCapturedNS_ and self.ns_prefix_:
11698
            namespaceprefix_ = self.ns_prefix_ + ':'
11699
        showIndent(outfile, level, pretty_print)
11700
        outfile.write('<%s%s%s' % (namespaceprefix_, name_, namespacedef_ and ' ' + namespacedef_ or '', ))
11701
        already_processed = set()
11702
        self._exportAttributes(outfile, level, already_processed, namespaceprefix_, name_='UserDefinedType')
11703
        if self.has__content():
11704
            outfile.write('>%s' % (eol_, ))
11705
            self._exportChildren(outfile, level + 1, namespaceprefix_, namespacedef_, name_='UserDefinedType', pretty_print=pretty_print)
11706
            showIndent(outfile, level, pretty_print)
11707
            outfile.write('</%s%s>%s' % (namespaceprefix_, name_, eol_))
11708
        else:
11709
            outfile.write('/>%s' % (eol_, ))
11710
    def _exportAttributes(self, outfile, level, already_processed, namespaceprefix_='', name_='UserDefinedType'):
11711
        pass
11712
    def _exportChildren(self, outfile, level, namespaceprefix_='', namespacedef_='xmlns:pc="http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15"', name_='UserDefinedType', fromsubclass_=False, pretty_print=True):
11713
        if pretty_print:
11714
            eol_ = '\n'
11715
        else:
11716
            eol_ = ''
11717
        for UserAttribute_ in self.UserAttribute:
11718
            namespaceprefix_ = self.UserAttribute_nsprefix_ + ':' if (UseCapturedNS_ and self.UserAttribute_nsprefix_) else ''
11719
            UserAttribute_.export(outfile, level, namespaceprefix_, namespacedef_='', name_='UserAttribute', pretty_print=pretty_print)
11720
    def to_etree(self, parent_element=None, name_='UserDefinedType', mapping_=None, reverse_mapping_=None, nsmap_=None):
11721
        if parent_element is None:
11722
            element = etree_.Element('{http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15}' + name_, nsmap=nsmap_)
11723
        else:
11724
            element = etree_.SubElement(parent_element, '{http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15}' + name_, nsmap=nsmap_)
11725
        for UserAttribute_ in self.UserAttribute:
11726
            UserAttribute_.to_etree(element, name_='UserAttribute', mapping_=mapping_, reverse_mapping_=reverse_mapping_, nsmap_=nsmap_)
11727
        if mapping_ is not None:
11728
            mapping_[id(self)] = element
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable id does not seem to be defined.
Loading history...
11729
        if reverse_mapping_ is not None:
11730
            reverse_mapping_[element] = self
11731
        return element
11732
    def build(self, node, gds_collector_=None):
11733
        self.gds_collector_ = gds_collector_
11734
        if SaveElementTreeNode:
11735
            self.gds_elementtree_node_ = node
11736
        already_processed = set()
11737
        self.ns_prefix_ = node.prefix
11738
        self._buildAttributes(node, node.attrib, already_processed)
11739
        for child in node:
11740
            nodeName_ = Tag_pattern_.match(child.tag).groups()[-1]
11741
            self._buildChildren(child, node, nodeName_, gds_collector_=gds_collector_)
11742
        return self
11743
    def _buildAttributes(self, node, attrs, already_processed):
11744
        pass
11745
    def _buildChildren(self, child_, node, nodeName_, fromsubclass_=False, gds_collector_=None):
11746
        if nodeName_ == 'UserAttribute':
11747
            obj_ = UserAttributeType.factory(parent_object_=self)
11748
            obj_.build(child_, gds_collector_=gds_collector_)
11749
            self.UserAttribute.append(obj_)
11750
            obj_.original_tagname_ = 'UserAttribute'
11751
    def __hash__(self):
11752
        return hash(self.id)
11753
# end class UserDefinedType
11754
11755
11756
class UserAttributeType(GeneratedsSuper):
11757
    """UserAttributeType -- Structured custom data defined by name, type and value.
11758
    
11759
    """
11760
    __hash__ = GeneratedsSuper.__hash__
11761
    member_data_items_ = [
11762
        MemberSpec_('name', 'string', 0, 1, {'use': 'optional', 'name': 'name'}),
11763
        MemberSpec_('description', 'string', 0, 1, {'use': 'optional', 'name': 'description'}),
11764
        MemberSpec_('type_', 'typeType3', 0, 1, {'use': 'optional', 'name': 'type_'}),
11765
        MemberSpec_('value', 'string', 0, 1, {'use': 'optional', 'name': 'value'}),
11766
    ]
11767
    subclass = None
11768
    superclass = None
11769
    def __init__(self, name=None, description=None, type_=None, value=None, gds_collector_=None, **kwargs_):
11770
        self.gds_collector_ = gds_collector_
11771
        self.gds_elementtree_node_ = None
11772
        self.original_tagname_ = None
11773
        self.parent_object_ = kwargs_.get('parent_object_')
11774
        self.ns_prefix_ = "pc"
11775
        self.name = _cast(None, name)
11776
        self.name_nsprefix_ = "pc"
11777
        self.description = _cast(None, description)
11778
        self.description_nsprefix_ = "pc"
11779
        self.type_ = _cast(None, type_)
11780
        self.type__nsprefix_ = "pc"
11781
        self.value = _cast(None, value)
11782
        self.value_nsprefix_ = "pc"
11783
    def factory(*args_, **kwargs_):
11784
        if CurrentSubclassModule_ is not None:
11785
            subclass = getSubclassFromModule_(
11786
                CurrentSubclassModule_, UserAttributeType)
11787
            if subclass is not None:
11788
                return subclass(*args_, **kwargs_)
11789
        if UserAttributeType.subclass:
11790
            return UserAttributeType.subclass(*args_, **kwargs_)
11791
        else:
11792
            return UserAttributeType(*args_, **kwargs_)
11793
    factory = staticmethod(factory)
11794
    def get_ns_prefix_(self):
11795
        return self.ns_prefix_
11796
    def set_ns_prefix_(self, ns_prefix):
11797
        self.ns_prefix_ = ns_prefix
11798
    def get_name(self):
11799
        return self.name
11800
    def set_name(self, name):
11801
        self.name = name
11802
    def get_description(self):
11803
        return self.description
11804
    def set_description(self, description):
11805
        self.description = description
11806
    def get_type(self):
11807
        return self.type_
11808
    def set_type(self, type_):
11809
        self.type_ = type_
11810
    def get_value(self):
11811
        return self.value
11812
    def set_value(self, value):
11813
        self.value = value
11814
    def validate_typeType3(self, value):
11815
        # Validate type typeType3, a restriction on string.
11816
        if value is not None and Validate_simpletypes_ and self.gds_collector_ is not None:
11817
            if not isinstance(value, str):
11818
                lineno = self.gds_get_node_lineno_()
11819
                self.gds_collector_.add_message('Value "%(value)s"%(lineno)s is not of the correct base simple type (str)' % {"value": value, "lineno": lineno, })
11820
                return False
11821
            value = value
11822
            enumerations = ['xsd:string', 'xsd:integer', 'xsd:boolean', 'xsd:float']
11823
            if value not in enumerations:
11824
                lineno = self.gds_get_node_lineno_()
11825
                self.gds_collector_.add_message('Value "%(value)s"%(lineno)s does not match xsd enumeration restriction on typeType3' % {"value" : encode_str_2_3(value), "lineno": lineno} )
11826
                result = False
11827
    def has__content(self):
11828
        if (
11829
11830
        ):
11831
            return True
11832
        else:
11833
            return False
11834
    def export(self, outfile, level, namespaceprefix_='', namespacedef_='xmlns:pc="http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15"', name_='UserAttributeType', pretty_print=True):
11835
        imported_ns_def_ = GenerateDSNamespaceDefs_.get('UserAttributeType')
11836
        if imported_ns_def_ is not None:
11837
            namespacedef_ = imported_ns_def_
11838
        if pretty_print:
11839
            eol_ = '\n'
11840
        else:
11841
            eol_ = ''
11842
        if self.original_tagname_ is not None and name_ == 'UserAttributeType':
11843
            name_ = self.original_tagname_
11844
        if UseCapturedNS_ and self.ns_prefix_:
11845
            namespaceprefix_ = self.ns_prefix_ + ':'
11846
        showIndent(outfile, level, pretty_print)
11847
        outfile.write('<%s%s%s' % (namespaceprefix_, name_, namespacedef_ and ' ' + namespacedef_ or '', ))
11848
        already_processed = set()
11849
        self._exportAttributes(outfile, level, already_processed, namespaceprefix_, name_='UserAttributeType')
11850
        if self.has__content():
11851
            outfile.write('>%s' % (eol_, ))
11852
            self._exportChildren(outfile, level + 1, namespaceprefix_, namespacedef_, name_='UserAttributeType', pretty_print=pretty_print)
11853
            outfile.write('</%s%s>%s' % (namespaceprefix_, name_, eol_))
11854
        else:
11855
            outfile.write('/>%s' % (eol_, ))
11856
    def _exportAttributes(self, outfile, level, already_processed, namespaceprefix_='', name_='UserAttributeType'):
11857
        if self.name is not None and 'name' not in already_processed:
11858
            already_processed.add('name')
11859
            outfile.write(' name=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.name), input_name='name')), ))
11860
        if self.description is not None and 'description' not in already_processed:
11861
            already_processed.add('description')
11862
            outfile.write(' description=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.description), input_name='description')), ))
11863
        if self.type_ is not None and 'type_' not in already_processed:
11864
            already_processed.add('type_')
11865
            outfile.write(' type=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.type_), input_name='type')), ))
11866
        if self.value is not None and 'value' not in already_processed:
11867
            already_processed.add('value')
11868
            outfile.write(' value=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.value), input_name='value')), ))
11869
    def _exportChildren(self, outfile, level, namespaceprefix_='', namespacedef_='xmlns:pc="http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15"', name_='UserAttributeType', fromsubclass_=False, pretty_print=True):
11870
        pass
11871
    def to_etree(self, parent_element=None, name_='UserAttributeType', mapping_=None, reverse_mapping_=None, nsmap_=None):
11872
        if parent_element is None:
11873
            element = etree_.Element('{http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15}' + name_, nsmap=nsmap_)
11874
        else:
11875
            element = etree_.SubElement(parent_element, '{http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15}' + name_, nsmap=nsmap_)
11876
        if self.name is not None:
11877
            element.set('name', self.gds_format_string(self.name))
11878
        if self.description is not None:
11879
            element.set('description', self.gds_format_string(self.description))
11880
        if self.type_ is not None:
11881
            element.set('type', self.gds_format_string(self.type_))
11882
        if self.value is not None:
11883
            element.set('value', self.gds_format_string(self.value))
11884
        if mapping_ is not None:
11885
            mapping_[id(self)] = element
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable id does not seem to be defined.
Loading history...
11886
        if reverse_mapping_ is not None:
11887
            reverse_mapping_[element] = self
11888
        return element
11889
    def build(self, node, gds_collector_=None):
11890
        self.gds_collector_ = gds_collector_
11891
        if SaveElementTreeNode:
11892
            self.gds_elementtree_node_ = node
11893
        already_processed = set()
11894
        self.ns_prefix_ = node.prefix
11895
        self._buildAttributes(node, node.attrib, already_processed)
11896
        for child in node:
11897
            nodeName_ = Tag_pattern_.match(child.tag).groups()[-1]
11898
            self._buildChildren(child, node, nodeName_, gds_collector_=gds_collector_)
11899
        return self
11900
    def _buildAttributes(self, node, attrs, already_processed):
11901
        value = find_attr_value_('name', node)
11902
        if value is not None and 'name' not in already_processed:
11903
            already_processed.add('name')
11904
            self.name = value
11905
        value = find_attr_value_('description', node)
11906
        if value is not None and 'description' not in already_processed:
11907
            already_processed.add('description')
11908
            self.description = value
11909
        value = find_attr_value_('type', node)
11910
        if value is not None and 'type' not in already_processed:
11911
            already_processed.add('type')
11912
            self.type_ = value
11913
            self.validate_typeType3(self.type_)    # validate type typeType3
11914
        value = find_attr_value_('value', node)
11915
        if value is not None and 'value' not in already_processed:
11916
            already_processed.add('value')
11917
            self.value = value
11918
    def _buildChildren(self, child_, node, nodeName_, fromsubclass_=False, gds_collector_=None):
11919
        pass
11920
    def __hash__(self):
11921
        return hash(self.id)
11922
# end class UserAttributeType
11923
11924
11925
class TableCellRoleType(GeneratedsSuper):
11926
    """rowIndex -- Cell position in table starting with row 0
11927
    columnIndex -- Cell position in table starting with column 0
11928
    rowSpan -- Number of rows the cell spans (optional; default is 1)
11929
    colSpan -- Number of columns the cell spans (optional; default is 1)
11930
    header --
11931
    Is the cell a column or row header?
11932
    
11933
    """
11934
    __hash__ = GeneratedsSuper.__hash__
11935
    member_data_items_ = [
11936
        MemberSpec_('rowIndex', 'int', 0, 0, {'use': 'required', 'name': 'rowIndex'}),
11937
        MemberSpec_('columnIndex', 'int', 0, 0, {'use': 'required', 'name': 'columnIndex'}),
11938
        MemberSpec_('rowSpan', 'int', 0, 1, {'use': 'optional', 'name': 'rowSpan'}),
11939
        MemberSpec_('colSpan', 'int', 0, 1, {'use': 'optional', 'name': 'colSpan'}),
11940
        MemberSpec_('header', 'boolean', 0, 1, {'use': 'optional', 'name': 'header'}),
11941
    ]
11942
    subclass = None
11943
    superclass = None
11944
    def __init__(self, rowIndex=None, columnIndex=None, rowSpan=None, colSpan=None, header=None, gds_collector_=None, **kwargs_):
11945
        self.gds_collector_ = gds_collector_
11946
        self.gds_elementtree_node_ = None
11947
        self.original_tagname_ = None
11948
        self.parent_object_ = kwargs_.get('parent_object_')
11949
        self.ns_prefix_ = "pc"
11950
        self.rowIndex = _cast(int, rowIndex)
11951
        self.rowIndex_nsprefix_ = "pc"
11952
        self.columnIndex = _cast(int, columnIndex)
11953
        self.columnIndex_nsprefix_ = "pc"
11954
        self.rowSpan = _cast(int, rowSpan)
11955
        self.rowSpan_nsprefix_ = "pc"
11956
        self.colSpan = _cast(int, colSpan)
11957
        self.colSpan_nsprefix_ = "pc"
11958
        self.header = _cast(bool, header)
11959
        self.header_nsprefix_ = "pc"
11960
    def factory(*args_, **kwargs_):
11961
        if CurrentSubclassModule_ is not None:
11962
            subclass = getSubclassFromModule_(
11963
                CurrentSubclassModule_, TableCellRoleType)
11964
            if subclass is not None:
11965
                return subclass(*args_, **kwargs_)
11966
        if TableCellRoleType.subclass:
11967
            return TableCellRoleType.subclass(*args_, **kwargs_)
11968
        else:
11969
            return TableCellRoleType(*args_, **kwargs_)
11970
    factory = staticmethod(factory)
11971
    def get_ns_prefix_(self):
11972
        return self.ns_prefix_
11973
    def set_ns_prefix_(self, ns_prefix):
11974
        self.ns_prefix_ = ns_prefix
11975
    def get_rowIndex(self):
11976
        return self.rowIndex
11977
    def set_rowIndex(self, rowIndex):
11978
        self.rowIndex = rowIndex
11979
    def get_columnIndex(self):
11980
        return self.columnIndex
11981
    def set_columnIndex(self, columnIndex):
11982
        self.columnIndex = columnIndex
11983
    def get_rowSpan(self):
11984
        return self.rowSpan
11985
    def set_rowSpan(self, rowSpan):
11986
        self.rowSpan = rowSpan
11987
    def get_colSpan(self):
11988
        return self.colSpan
11989
    def set_colSpan(self, colSpan):
11990
        self.colSpan = colSpan
11991
    def get_header(self):
11992
        return self.header
11993
    def set_header(self, header):
11994
        self.header = header
11995
    def has__content(self):
11996
        if (
11997
11998
        ):
11999
            return True
12000
        else:
12001
            return False
12002
    def export(self, outfile, level, namespaceprefix_='', namespacedef_='xmlns:pc="http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15"', name_='TableCellRoleType', pretty_print=True):
12003
        imported_ns_def_ = GenerateDSNamespaceDefs_.get('TableCellRoleType')
12004
        if imported_ns_def_ is not None:
12005
            namespacedef_ = imported_ns_def_
12006
        if pretty_print:
12007
            eol_ = '\n'
12008
        else:
12009
            eol_ = ''
12010
        if self.original_tagname_ is not None and name_ == 'TableCellRoleType':
12011
            name_ = self.original_tagname_
12012
        if UseCapturedNS_ and self.ns_prefix_:
12013
            namespaceprefix_ = self.ns_prefix_ + ':'
12014
        showIndent(outfile, level, pretty_print)
12015
        outfile.write('<%s%s%s' % (namespaceprefix_, name_, namespacedef_ and ' ' + namespacedef_ or '', ))
12016
        already_processed = set()
12017
        self._exportAttributes(outfile, level, already_processed, namespaceprefix_, name_='TableCellRoleType')
12018
        if self.has__content():
12019
            outfile.write('>%s' % (eol_, ))
12020
            self._exportChildren(outfile, level + 1, namespaceprefix_, namespacedef_, name_='TableCellRoleType', pretty_print=pretty_print)
12021
            outfile.write('</%s%s>%s' % (namespaceprefix_, name_, eol_))
12022
        else:
12023
            outfile.write('/>%s' % (eol_, ))
12024
    def _exportAttributes(self, outfile, level, already_processed, namespaceprefix_='', name_='TableCellRoleType'):
12025
        if self.rowIndex is not None and 'rowIndex' not in already_processed:
12026
            already_processed.add('rowIndex')
12027
            outfile.write(' rowIndex="%s"' % self.gds_format_integer(self.rowIndex, input_name='rowIndex'))
12028
        if self.columnIndex is not None and 'columnIndex' not in already_processed:
12029
            already_processed.add('columnIndex')
12030
            outfile.write(' columnIndex="%s"' % self.gds_format_integer(self.columnIndex, input_name='columnIndex'))
12031
        if self.rowSpan is not None and 'rowSpan' not in already_processed:
12032
            already_processed.add('rowSpan')
12033
            outfile.write(' rowSpan="%s"' % self.gds_format_integer(self.rowSpan, input_name='rowSpan'))
12034
        if self.colSpan is not None and 'colSpan' not in already_processed:
12035
            already_processed.add('colSpan')
12036
            outfile.write(' colSpan="%s"' % self.gds_format_integer(self.colSpan, input_name='colSpan'))
12037
        if self.header is not None and 'header' not in already_processed:
12038
            already_processed.add('header')
12039
            outfile.write(' header="%s"' % self.gds_format_boolean(self.header, input_name='header'))
12040
    def _exportChildren(self, outfile, level, namespaceprefix_='', namespacedef_='xmlns:pc="http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15"', name_='TableCellRoleType', fromsubclass_=False, pretty_print=True):
12041
        pass
12042
    def to_etree(self, parent_element=None, name_='TableCellRoleType', mapping_=None, reverse_mapping_=None, nsmap_=None):
12043
        if parent_element is None:
12044
            element = etree_.Element('{http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15}' + name_, nsmap=nsmap_)
12045
        else:
12046
            element = etree_.SubElement(parent_element, '{http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15}' + name_, nsmap=nsmap_)
12047
        if self.rowIndex is not None:
12048
            element.set('rowIndex', self.gds_format_integer(self.rowIndex))
12049
        if self.columnIndex is not None:
12050
            element.set('columnIndex', self.gds_format_integer(self.columnIndex))
12051
        if self.rowSpan is not None:
12052
            element.set('rowSpan', self.gds_format_integer(self.rowSpan))
12053
        if self.colSpan is not None:
12054
            element.set('colSpan', self.gds_format_integer(self.colSpan))
12055
        if self.header is not None:
12056
            element.set('header', self.gds_format_boolean(self.header))
12057
        if mapping_ is not None:
12058
            mapping_[id(self)] = element
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable id does not seem to be defined.
Loading history...
12059
        if reverse_mapping_ is not None:
12060
            reverse_mapping_[element] = self
12061
        return element
12062
    def build(self, node, gds_collector_=None):
12063
        self.gds_collector_ = gds_collector_
12064
        if SaveElementTreeNode:
12065
            self.gds_elementtree_node_ = node
12066
        already_processed = set()
12067
        self.ns_prefix_ = node.prefix
12068
        self._buildAttributes(node, node.attrib, already_processed)
12069
        for child in node:
12070
            nodeName_ = Tag_pattern_.match(child.tag).groups()[-1]
12071
            self._buildChildren(child, node, nodeName_, gds_collector_=gds_collector_)
12072
        return self
12073
    def _buildAttributes(self, node, attrs, already_processed):
12074
        value = find_attr_value_('rowIndex', node)
12075
        if value is not None and 'rowIndex' not in already_processed:
12076
            already_processed.add('rowIndex')
12077
            self.rowIndex = self.gds_parse_integer(value, node, 'rowIndex')
12078
        value = find_attr_value_('columnIndex', node)
12079
        if value is not None and 'columnIndex' not in already_processed:
12080
            already_processed.add('columnIndex')
12081
            self.columnIndex = self.gds_parse_integer(value, node, 'columnIndex')
12082
        value = find_attr_value_('rowSpan', node)
12083
        if value is not None and 'rowSpan' not in already_processed:
12084
            already_processed.add('rowSpan')
12085
            self.rowSpan = self.gds_parse_integer(value, node, 'rowSpan')
12086
        value = find_attr_value_('colSpan', node)
12087
        if value is not None and 'colSpan' not in already_processed:
12088
            already_processed.add('colSpan')
12089
            self.colSpan = self.gds_parse_integer(value, node, 'colSpan')
12090
        value = find_attr_value_('header', node)
12091
        if value is not None and 'header' not in already_processed:
12092
            already_processed.add('header')
12093
            if value in ('true', '1'):
12094
                self.header = True
12095
            elif value in ('false', '0'):
12096
                self.header = False
12097
            else:
12098
                raise_parse_error(node, 'Bad boolean attribute')
12099
    def _buildChildren(self, child_, node, nodeName_, fromsubclass_=False, gds_collector_=None):
12100
        pass
12101
    def __hash__(self):
12102
        return hash(self.id)
12103
# end class TableCellRoleType
12104
12105
12106 View Code Duplication
class RolesType(GeneratedsSuper):
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
12107
    """TableCellRole --
12108
    Data for a region that takes on the role
12109
    of a table cell within a parent table region.
12110
    
12111
    """
12112
    __hash__ = GeneratedsSuper.__hash__
12113
    member_data_items_ = [
12114
        MemberSpec_('TableCellRole', 'TableCellRoleType', 0, 1, {'maxOccurs': '1', 'minOccurs': '0', 'name': 'TableCellRole', 'type': 'TableCellRoleType'}, None),
12115
    ]
12116
    subclass = None
12117
    superclass = None
12118
    def __init__(self, TableCellRole=None, gds_collector_=None, **kwargs_):
12119
        self.gds_collector_ = gds_collector_
12120
        self.gds_elementtree_node_ = None
12121
        self.original_tagname_ = None
12122
        self.parent_object_ = kwargs_.get('parent_object_')
12123
        self.ns_prefix_ = "pc"
12124
        self.TableCellRole = TableCellRole
12125
        self.TableCellRole_nsprefix_ = "pc"
12126
    def factory(*args_, **kwargs_):
12127
        if CurrentSubclassModule_ is not None:
12128
            subclass = getSubclassFromModule_(
12129
                CurrentSubclassModule_, RolesType)
12130
            if subclass is not None:
12131
                return subclass(*args_, **kwargs_)
12132
        if RolesType.subclass:
12133
            return RolesType.subclass(*args_, **kwargs_)
12134
        else:
12135
            return RolesType(*args_, **kwargs_)
12136
    factory = staticmethod(factory)
12137
    def get_ns_prefix_(self):
12138
        return self.ns_prefix_
12139
    def set_ns_prefix_(self, ns_prefix):
12140
        self.ns_prefix_ = ns_prefix
12141
    def get_TableCellRole(self):
12142
        return self.TableCellRole
12143
    def set_TableCellRole(self, TableCellRole):
12144
        self.TableCellRole = TableCellRole
12145
    def has__content(self):
12146
        if (
12147
            self.TableCellRole is not None
12148
        ):
12149
            return True
12150
        else:
12151
            return False
12152
    def export(self, outfile, level, namespaceprefix_='', namespacedef_='xmlns:pc="http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15"', name_='RolesType', pretty_print=True):
12153
        imported_ns_def_ = GenerateDSNamespaceDefs_.get('RolesType')
12154
        if imported_ns_def_ is not None:
12155
            namespacedef_ = imported_ns_def_
12156
        if pretty_print:
12157
            eol_ = '\n'
12158
        else:
12159
            eol_ = ''
12160
        if self.original_tagname_ is not None and name_ == 'RolesType':
12161
            name_ = self.original_tagname_
12162
        if UseCapturedNS_ and self.ns_prefix_:
12163
            namespaceprefix_ = self.ns_prefix_ + ':'
12164
        showIndent(outfile, level, pretty_print)
12165
        outfile.write('<%s%s%s' % (namespaceprefix_, name_, namespacedef_ and ' ' + namespacedef_ or '', ))
12166
        already_processed = set()
12167
        self._exportAttributes(outfile, level, already_processed, namespaceprefix_, name_='RolesType')
12168
        if self.has__content():
12169
            outfile.write('>%s' % (eol_, ))
12170
            self._exportChildren(outfile, level + 1, namespaceprefix_, namespacedef_, name_='RolesType', pretty_print=pretty_print)
12171
            showIndent(outfile, level, pretty_print)
12172
            outfile.write('</%s%s>%s' % (namespaceprefix_, name_, eol_))
12173
        else:
12174
            outfile.write('/>%s' % (eol_, ))
12175
    def _exportAttributes(self, outfile, level, already_processed, namespaceprefix_='', name_='RolesType'):
12176
        pass
12177
    def _exportChildren(self, outfile, level, namespaceprefix_='', namespacedef_='xmlns:pc="http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15"', name_='RolesType', fromsubclass_=False, pretty_print=True):
12178
        if pretty_print:
12179
            eol_ = '\n'
12180
        else:
12181
            eol_ = ''
12182
        if self.TableCellRole is not None:
12183
            namespaceprefix_ = self.TableCellRole_nsprefix_ + ':' if (UseCapturedNS_ and self.TableCellRole_nsprefix_) else ''
12184
            self.TableCellRole.export(outfile, level, namespaceprefix_, namespacedef_='', name_='TableCellRole', pretty_print=pretty_print)
12185
    def to_etree(self, parent_element=None, name_='RolesType', mapping_=None, reverse_mapping_=None, nsmap_=None):
12186
        if parent_element is None:
12187
            element = etree_.Element('{http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15}' + name_, nsmap=nsmap_)
12188
        else:
12189
            element = etree_.SubElement(parent_element, '{http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15}' + name_, nsmap=nsmap_)
12190
        if self.TableCellRole is not None:
12191
            TableCellRole_ = self.TableCellRole
12192
            TableCellRole_.to_etree(element, name_='TableCellRole', mapping_=mapping_, reverse_mapping_=reverse_mapping_, nsmap_=nsmap_)
12193
        if mapping_ is not None:
12194
            mapping_[id(self)] = element
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable id does not seem to be defined.
Loading history...
12195
        if reverse_mapping_ is not None:
12196
            reverse_mapping_[element] = self
12197
        return element
12198
    def build(self, node, gds_collector_=None):
12199
        self.gds_collector_ = gds_collector_
12200
        if SaveElementTreeNode:
12201
            self.gds_elementtree_node_ = node
12202
        already_processed = set()
12203
        self.ns_prefix_ = node.prefix
12204
        self._buildAttributes(node, node.attrib, already_processed)
12205
        for child in node:
12206
            nodeName_ = Tag_pattern_.match(child.tag).groups()[-1]
12207
            self._buildChildren(child, node, nodeName_, gds_collector_=gds_collector_)
12208
        return self
12209
    def _buildAttributes(self, node, attrs, already_processed):
12210
        pass
12211
    def _buildChildren(self, child_, node, nodeName_, fromsubclass_=False, gds_collector_=None):
12212
        if nodeName_ == 'TableCellRole':
12213
            obj_ = TableCellRoleType.factory(parent_object_=self)
12214
            obj_.build(child_, gds_collector_=gds_collector_)
12215
            self.TableCellRole = obj_
12216
            obj_.original_tagname_ = 'TableCellRole'
12217
    def __hash__(self):
12218
        return hash(self.id)
12219
# end class RolesType
12220
12221
12222
class CustomRegionType(RegionType):
12223
    """CustomRegionType --
12224
    Regions containing content that is not covered
12225
    by the default types (text, graphic, image,
12226
    line drawing, chart, table, separator, maths,
12227
    map, music, chem, advert, noise, unknown).
12228
      
12229
    * type --
12230
      Information on the type of content represented by this region
12231
    
12232
    """
12233
    __hash__ = GeneratedsSuper.__hash__
12234
    member_data_items_ = [
12235
        MemberSpec_('type_', 'string', 0, 1, {'use': 'optional', 'name': 'type_'}),
12236
    ]
12237
    subclass = None
12238
    superclass = RegionType
12239
    def __init__(self, id=None, custom=None, comments=None, continuation=None, AlternativeImage=None, Coords=None, UserDefined=None, Labels=None, Roles=None, TextRegion=None, ImageRegion=None, LineDrawingRegion=None, GraphicRegion=None, TableRegion=None, ChartRegion=None, SeparatorRegion=None, MathsRegion=None, ChemRegion=None, MusicRegion=None, AdvertRegion=None, NoiseRegion=None, UnknownRegion=None, CustomRegion=None, type_=None, gds_collector_=None, **kwargs_):
12240
        self.gds_collector_ = gds_collector_
12241
        self.gds_elementtree_node_ = None
12242
        self.original_tagname_ = None
12243
        self.parent_object_ = kwargs_.get('parent_object_')
12244
        self.ns_prefix_ = "pc"
12245
        super(globals().get("CustomRegionType"), self).__init__(id, custom, comments, continuation, AlternativeImage, Coords, UserDefined, Labels, Roles, TextRegion, ImageRegion, LineDrawingRegion, GraphicRegion, TableRegion, ChartRegion, SeparatorRegion, MathsRegion, ChemRegion, MusicRegion, AdvertRegion, NoiseRegion, UnknownRegion, CustomRegion,  **kwargs_)
12246
        self.type_ = _cast(None, type_)
12247
        self.type__nsprefix_ = "pc"
12248
    def factory(*args_, **kwargs_):
12249
        if CurrentSubclassModule_ is not None:
12250
            subclass = getSubclassFromModule_(
12251
                CurrentSubclassModule_, CustomRegionType)
12252
            if subclass is not None:
12253
                return subclass(*args_, **kwargs_)
12254
        if CustomRegionType.subclass:
12255
            return CustomRegionType.subclass(*args_, **kwargs_)
12256
        else:
12257
            return CustomRegionType(*args_, **kwargs_)
12258
    factory = staticmethod(factory)
12259
    def get_ns_prefix_(self):
12260
        return self.ns_prefix_
12261
    def set_ns_prefix_(self, ns_prefix):
12262
        self.ns_prefix_ = ns_prefix
12263
    def get_type(self):
12264
        return self.type_
12265
    def set_type(self, type_):
12266
        self.type_ = type_
12267
    def has__content(self):
12268
        if (
12269
            super(CustomRegionType, self).has__content()
12270
        ):
12271
            return True
12272
        else:
12273
            return False
12274
    def export(self, outfile, level, namespaceprefix_='', namespacedef_='xmlns:pc="http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15"', name_='CustomRegionType', pretty_print=True):
12275
        imported_ns_def_ = GenerateDSNamespaceDefs_.get('CustomRegionType')
12276
        if imported_ns_def_ is not None:
12277
            namespacedef_ = imported_ns_def_
12278
        if pretty_print:
12279
            eol_ = '\n'
12280
        else:
12281
            eol_ = ''
12282
        if self.original_tagname_ is not None and name_ == 'CustomRegionType':
12283
            name_ = self.original_tagname_
12284
        if UseCapturedNS_ and self.ns_prefix_:
12285
            namespaceprefix_ = self.ns_prefix_ + ':'
12286
        showIndent(outfile, level, pretty_print)
12287
        outfile.write('<%s%s%s' % (namespaceprefix_, name_, namespacedef_ and ' ' + namespacedef_ or '', ))
12288
        already_processed = set()
12289
        self._exportAttributes(outfile, level, already_processed, namespaceprefix_, name_='CustomRegionType')
12290
        if self.has__content():
12291
            outfile.write('>%s' % (eol_, ))
12292
            self._exportChildren(outfile, level + 1, namespaceprefix_, namespacedef_, name_='CustomRegionType', pretty_print=pretty_print)
12293
            showIndent(outfile, level, pretty_print)
12294
            outfile.write('</%s%s>%s' % (namespaceprefix_, name_, eol_))
12295
        else:
12296
            outfile.write('/>%s' % (eol_, ))
12297
    def _exportAttributes(self, outfile, level, already_processed, namespaceprefix_='', name_='CustomRegionType'):
12298
        super(CustomRegionType, self)._exportAttributes(outfile, level, already_processed, namespaceprefix_, name_='CustomRegionType')
12299
        if self.type_ is not None and 'type_' not in already_processed:
12300
            already_processed.add('type_')
12301
            outfile.write(' type=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.type_), input_name='type')), ))
12302
    def _exportChildren(self, outfile, level, namespaceprefix_='', namespacedef_='xmlns:pc="http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15"', name_='CustomRegionType', fromsubclass_=False, pretty_print=True):
12303
        super(CustomRegionType, self)._exportChildren(outfile, level, namespaceprefix_, namespacedef_, name_, True, pretty_print=pretty_print)
12304
    def to_etree(self, parent_element=None, name_='CustomRegionType', mapping_=None, reverse_mapping_=None, nsmap_=None):
12305
        element = super(CustomRegionType, self).to_etree(parent_element, name_, mapping_, reverse_mapping_, nsmap_)
12306
        if self.type_ is not None:
12307
            element.set('type', self.gds_format_string(self.type_))
12308
        if mapping_ is not None:
12309
            mapping_[id(self)] = element
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable id does not seem to be defined.
Loading history...
12310
        if reverse_mapping_ is not None:
12311
            reverse_mapping_[element] = self
12312
        return element
12313
    def build(self, node, gds_collector_=None):
12314
        self.gds_collector_ = gds_collector_
12315
        if SaveElementTreeNode:
12316
            self.gds_elementtree_node_ = node
12317
        already_processed = set()
12318
        self.ns_prefix_ = node.prefix
12319
        self._buildAttributes(node, node.attrib, already_processed)
12320
        for child in node:
12321
            nodeName_ = Tag_pattern_.match(child.tag).groups()[-1]
12322
            self._buildChildren(child, node, nodeName_, gds_collector_=gds_collector_)
12323
        return self
12324
    def _buildAttributes(self, node, attrs, already_processed):
12325
        value = find_attr_value_('type', node)
12326
        if value is not None and 'type' not in already_processed:
12327
            already_processed.add('type')
12328
            self.type_ = value
12329
        super(CustomRegionType, self)._buildAttributes(node, attrs, already_processed)
12330
    def _buildChildren(self, child_, node, nodeName_, fromsubclass_=False, gds_collector_=None):
12331
        super(CustomRegionType, self)._buildChildren(child_, node, nodeName_, True)
12332
        pass
12333
    def __hash__(self):
12334
        return hash(self.id)
12335
# end class CustomRegionType
12336
12337
12338 View Code Duplication
class UnknownRegionType(RegionType):
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
12339
    """UnknownRegionType --
12340
    To be used if the region type cannot be ascertained.
12341
    
12342
    """
12343
    __hash__ = GeneratedsSuper.__hash__
12344
    member_data_items_ = [
12345
    ]
12346
    subclass = None
12347
    superclass = RegionType
12348
    def __init__(self, id=None, custom=None, comments=None, continuation=None, AlternativeImage=None, Coords=None, UserDefined=None, Labels=None, Roles=None, TextRegion=None, ImageRegion=None, LineDrawingRegion=None, GraphicRegion=None, TableRegion=None, ChartRegion=None, SeparatorRegion=None, MathsRegion=None, ChemRegion=None, MusicRegion=None, AdvertRegion=None, NoiseRegion=None, UnknownRegion=None, CustomRegion=None, gds_collector_=None, **kwargs_):
12349
        self.gds_collector_ = gds_collector_
12350
        self.gds_elementtree_node_ = None
12351
        self.original_tagname_ = None
12352
        self.parent_object_ = kwargs_.get('parent_object_')
12353
        self.ns_prefix_ = "pc"
12354
        super(globals().get("UnknownRegionType"), self).__init__(id, custom, comments, continuation, AlternativeImage, Coords, UserDefined, Labels, Roles, TextRegion, ImageRegion, LineDrawingRegion, GraphicRegion, TableRegion, ChartRegion, SeparatorRegion, MathsRegion, ChemRegion, MusicRegion, AdvertRegion, NoiseRegion, UnknownRegion, CustomRegion,  **kwargs_)
12355
    def factory(*args_, **kwargs_):
12356
        if CurrentSubclassModule_ is not None:
12357
            subclass = getSubclassFromModule_(
12358
                CurrentSubclassModule_, UnknownRegionType)
12359
            if subclass is not None:
12360
                return subclass(*args_, **kwargs_)
12361
        if UnknownRegionType.subclass:
12362
            return UnknownRegionType.subclass(*args_, **kwargs_)
12363
        else:
12364
            return UnknownRegionType(*args_, **kwargs_)
12365
    factory = staticmethod(factory)
12366
    def get_ns_prefix_(self):
12367
        return self.ns_prefix_
12368
    def set_ns_prefix_(self, ns_prefix):
12369
        self.ns_prefix_ = ns_prefix
12370
    def has__content(self):
12371
        if (
12372
            super(UnknownRegionType, self).has__content()
12373
        ):
12374
            return True
12375
        else:
12376
            return False
12377
    def export(self, outfile, level, namespaceprefix_='', namespacedef_='xmlns:pc="http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15"', name_='UnknownRegionType', pretty_print=True):
12378
        imported_ns_def_ = GenerateDSNamespaceDefs_.get('UnknownRegionType')
12379
        if imported_ns_def_ is not None:
12380
            namespacedef_ = imported_ns_def_
12381
        if pretty_print:
12382
            eol_ = '\n'
12383
        else:
12384
            eol_ = ''
12385
        if self.original_tagname_ is not None and name_ == 'UnknownRegionType':
12386
            name_ = self.original_tagname_
12387
        if UseCapturedNS_ and self.ns_prefix_:
12388
            namespaceprefix_ = self.ns_prefix_ + ':'
12389
        showIndent(outfile, level, pretty_print)
12390
        outfile.write('<%s%s%s' % (namespaceprefix_, name_, namespacedef_ and ' ' + namespacedef_ or '', ))
12391
        already_processed = set()
12392
        self._exportAttributes(outfile, level, already_processed, namespaceprefix_, name_='UnknownRegionType')
12393
        if self.has__content():
12394
            outfile.write('>%s' % (eol_, ))
12395
            self._exportChildren(outfile, level + 1, namespaceprefix_, namespacedef_, name_='UnknownRegionType', pretty_print=pretty_print)
12396
            showIndent(outfile, level, pretty_print)
12397
            outfile.write('</%s%s>%s' % (namespaceprefix_, name_, eol_))
12398
        else:
12399
            outfile.write('/>%s' % (eol_, ))
12400
    def _exportAttributes(self, outfile, level, already_processed, namespaceprefix_='', name_='UnknownRegionType'):
12401
        super(UnknownRegionType, self)._exportAttributes(outfile, level, already_processed, namespaceprefix_, name_='UnknownRegionType')
12402
    def _exportChildren(self, outfile, level, namespaceprefix_='', namespacedef_='xmlns:pc="http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15"', name_='UnknownRegionType', fromsubclass_=False, pretty_print=True):
12403
        super(UnknownRegionType, self)._exportChildren(outfile, level, namespaceprefix_, namespacedef_, name_, True, pretty_print=pretty_print)
12404
    def to_etree(self, parent_element=None, name_='UnknownRegionType', mapping_=None, reverse_mapping_=None, nsmap_=None):
12405
        element = super(UnknownRegionType, self).to_etree(parent_element, name_, mapping_, reverse_mapping_, nsmap_)
12406
        if mapping_ is not None:
12407
            mapping_[id(self)] = element
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable id does not seem to be defined.
Loading history...
12408
        if reverse_mapping_ is not None:
12409
            reverse_mapping_[element] = self
12410
        return element
12411
    def build(self, node, gds_collector_=None):
12412
        self.gds_collector_ = gds_collector_
12413
        if SaveElementTreeNode:
12414
            self.gds_elementtree_node_ = node
12415
        already_processed = set()
12416
        self.ns_prefix_ = node.prefix
12417
        self._buildAttributes(node, node.attrib, already_processed)
12418
        for child in node:
12419
            nodeName_ = Tag_pattern_.match(child.tag).groups()[-1]
12420
            self._buildChildren(child, node, nodeName_, gds_collector_=gds_collector_)
12421
        return self
12422
    def _buildAttributes(self, node, attrs, already_processed):
12423
        super(UnknownRegionType, self)._buildAttributes(node, attrs, already_processed)
12424
    def _buildChildren(self, child_, node, nodeName_, fromsubclass_=False, gds_collector_=None):
12425
        super(UnknownRegionType, self)._buildChildren(child_, node, nodeName_, True)
12426
        pass
12427
    def __hash__(self):
12428
        return hash(self.id)
12429
# end class UnknownRegionType
12430
12431
12432 View Code Duplication
class NoiseRegionType(RegionType):
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
12433
    """NoiseRegionType --
12434
    Noise regions are regions where no real data lies, only
12435
    false data created by artifacts on the document or
12436
    scanner noise.
12437
    
12438
    """
12439
    __hash__ = GeneratedsSuper.__hash__
12440
    member_data_items_ = [
12441
    ]
12442
    subclass = None
12443
    superclass = RegionType
12444
    def __init__(self, id=None, custom=None, comments=None, continuation=None, AlternativeImage=None, Coords=None, UserDefined=None, Labels=None, Roles=None, TextRegion=None, ImageRegion=None, LineDrawingRegion=None, GraphicRegion=None, TableRegion=None, ChartRegion=None, SeparatorRegion=None, MathsRegion=None, ChemRegion=None, MusicRegion=None, AdvertRegion=None, NoiseRegion=None, UnknownRegion=None, CustomRegion=None, gds_collector_=None, **kwargs_):
12445
        self.gds_collector_ = gds_collector_
12446
        self.gds_elementtree_node_ = None
12447
        self.original_tagname_ = None
12448
        self.parent_object_ = kwargs_.get('parent_object_')
12449
        self.ns_prefix_ = "pc"
12450
        super(globals().get("NoiseRegionType"), self).__init__(id, custom, comments, continuation, AlternativeImage, Coords, UserDefined, Labels, Roles, TextRegion, ImageRegion, LineDrawingRegion, GraphicRegion, TableRegion, ChartRegion, SeparatorRegion, MathsRegion, ChemRegion, MusicRegion, AdvertRegion, NoiseRegion, UnknownRegion, CustomRegion,  **kwargs_)
12451
    def factory(*args_, **kwargs_):
12452
        if CurrentSubclassModule_ is not None:
12453
            subclass = getSubclassFromModule_(
12454
                CurrentSubclassModule_, NoiseRegionType)
12455
            if subclass is not None:
12456
                return subclass(*args_, **kwargs_)
12457
        if NoiseRegionType.subclass:
12458
            return NoiseRegionType.subclass(*args_, **kwargs_)
12459
        else:
12460
            return NoiseRegionType(*args_, **kwargs_)
12461
    factory = staticmethod(factory)
12462
    def get_ns_prefix_(self):
12463
        return self.ns_prefix_
12464
    def set_ns_prefix_(self, ns_prefix):
12465
        self.ns_prefix_ = ns_prefix
12466
    def has__content(self):
12467
        if (
12468
            super(NoiseRegionType, self).has__content()
12469
        ):
12470
            return True
12471
        else:
12472
            return False
12473
    def export(self, outfile, level, namespaceprefix_='', namespacedef_='xmlns:pc="http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15"', name_='NoiseRegionType', pretty_print=True):
12474
        imported_ns_def_ = GenerateDSNamespaceDefs_.get('NoiseRegionType')
12475
        if imported_ns_def_ is not None:
12476
            namespacedef_ = imported_ns_def_
12477
        if pretty_print:
12478
            eol_ = '\n'
12479
        else:
12480
            eol_ = ''
12481
        if self.original_tagname_ is not None and name_ == 'NoiseRegionType':
12482
            name_ = self.original_tagname_
12483
        if UseCapturedNS_ and self.ns_prefix_:
12484
            namespaceprefix_ = self.ns_prefix_ + ':'
12485
        showIndent(outfile, level, pretty_print)
12486
        outfile.write('<%s%s%s' % (namespaceprefix_, name_, namespacedef_ and ' ' + namespacedef_ or '', ))
12487
        already_processed = set()
12488
        self._exportAttributes(outfile, level, already_processed, namespaceprefix_, name_='NoiseRegionType')
12489
        if self.has__content():
12490
            outfile.write('>%s' % (eol_, ))
12491
            self._exportChildren(outfile, level + 1, namespaceprefix_, namespacedef_, name_='NoiseRegionType', pretty_print=pretty_print)
12492
            showIndent(outfile, level, pretty_print)
12493
            outfile.write('</%s%s>%s' % (namespaceprefix_, name_, eol_))
12494
        else:
12495
            outfile.write('/>%s' % (eol_, ))
12496
    def _exportAttributes(self, outfile, level, already_processed, namespaceprefix_='', name_='NoiseRegionType'):
12497
        super(NoiseRegionType, self)._exportAttributes(outfile, level, already_processed, namespaceprefix_, name_='NoiseRegionType')
12498
    def _exportChildren(self, outfile, level, namespaceprefix_='', namespacedef_='xmlns:pc="http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15"', name_='NoiseRegionType', fromsubclass_=False, pretty_print=True):
12499
        super(NoiseRegionType, self)._exportChildren(outfile, level, namespaceprefix_, namespacedef_, name_, True, pretty_print=pretty_print)
12500
    def to_etree(self, parent_element=None, name_='NoiseRegionType', mapping_=None, reverse_mapping_=None, nsmap_=None):
12501
        element = super(NoiseRegionType, self).to_etree(parent_element, name_, mapping_, reverse_mapping_, nsmap_)
12502
        if mapping_ is not None:
12503
            mapping_[id(self)] = element
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable id does not seem to be defined.
Loading history...
12504
        if reverse_mapping_ is not None:
12505
            reverse_mapping_[element] = self
12506
        return element
12507
    def build(self, node, gds_collector_=None):
12508
        self.gds_collector_ = gds_collector_
12509
        if SaveElementTreeNode:
12510
            self.gds_elementtree_node_ = node
12511
        already_processed = set()
12512
        self.ns_prefix_ = node.prefix
12513
        self._buildAttributes(node, node.attrib, already_processed)
12514
        for child in node:
12515
            nodeName_ = Tag_pattern_.match(child.tag).groups()[-1]
12516
            self._buildChildren(child, node, nodeName_, gds_collector_=gds_collector_)
12517
        return self
12518
    def _buildAttributes(self, node, attrs, already_processed):
12519
        super(NoiseRegionType, self)._buildAttributes(node, attrs, already_processed)
12520
    def _buildChildren(self, child_, node, nodeName_, fromsubclass_=False, gds_collector_=None):
12521
        super(NoiseRegionType, self)._buildChildren(child_, node, nodeName_, True)
12522
        pass
12523
    def __hash__(self):
12524
        return hash(self.id)
12525
# end class NoiseRegionType
12526
12527
12528 View Code Duplication
class AdvertRegionType(RegionType):
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
12529
    """AdvertRegionType --
12530
    Regions containing advertisements.
12531
      
12532
    * orientation --
12533
      The angle the rectangle encapsulating a region
12534
      has to be rotated in clockwise direction
12535
      in order to correct the present skew
12536
      (negative values indicate anti-clockwise rotation).
12537
      Range: -179.999,180
12538
      
12539
    * bgColour --
12540
      The background colour of the region
12541
    
12542
    """
12543
    __hash__ = GeneratedsSuper.__hash__
12544
    member_data_items_ = [
12545
        MemberSpec_('orientation', 'float', 0, 1, {'use': 'optional', 'name': 'orientation'}),
12546
        MemberSpec_('bgColour', 'pc:ColourSimpleType', 0, 1, {'use': 'optional', 'name': 'bgColour'}),
12547
    ]
12548
    subclass = None
12549
    superclass = RegionType
12550
    def __init__(self, id=None, custom=None, comments=None, continuation=None, AlternativeImage=None, Coords=None, UserDefined=None, Labels=None, Roles=None, TextRegion=None, ImageRegion=None, LineDrawingRegion=None, GraphicRegion=None, TableRegion=None, ChartRegion=None, SeparatorRegion=None, MathsRegion=None, ChemRegion=None, MusicRegion=None, AdvertRegion=None, NoiseRegion=None, UnknownRegion=None, CustomRegion=None, orientation=None, bgColour=None, gds_collector_=None, **kwargs_):
12551
        self.gds_collector_ = gds_collector_
12552
        self.gds_elementtree_node_ = None
12553
        self.original_tagname_ = None
12554
        self.parent_object_ = kwargs_.get('parent_object_')
12555
        self.ns_prefix_ = "pc"
12556
        super(globals().get("AdvertRegionType"), self).__init__(id, custom, comments, continuation, AlternativeImage, Coords, UserDefined, Labels, Roles, TextRegion, ImageRegion, LineDrawingRegion, GraphicRegion, TableRegion, ChartRegion, SeparatorRegion, MathsRegion, ChemRegion, MusicRegion, AdvertRegion, NoiseRegion, UnknownRegion, CustomRegion,  **kwargs_)
12557
        self.orientation = _cast(float, orientation)
12558
        self.orientation_nsprefix_ = "pc"
12559
        self.bgColour = _cast(None, bgColour)
12560
        self.bgColour_nsprefix_ = "pc"
12561
    def factory(*args_, **kwargs_):
12562
        if CurrentSubclassModule_ is not None:
12563
            subclass = getSubclassFromModule_(
12564
                CurrentSubclassModule_, AdvertRegionType)
12565
            if subclass is not None:
12566
                return subclass(*args_, **kwargs_)
12567
        if AdvertRegionType.subclass:
12568
            return AdvertRegionType.subclass(*args_, **kwargs_)
12569
        else:
12570
            return AdvertRegionType(*args_, **kwargs_)
12571
    factory = staticmethod(factory)
12572
    def get_ns_prefix_(self):
12573
        return self.ns_prefix_
12574
    def set_ns_prefix_(self, ns_prefix):
12575
        self.ns_prefix_ = ns_prefix
12576
    def get_orientation(self):
12577
        return self.orientation
12578
    def set_orientation(self, orientation):
12579
        self.orientation = orientation
12580
    def get_bgColour(self):
12581
        return self.bgColour
12582
    def set_bgColour(self, bgColour):
12583
        self.bgColour = bgColour
12584
    def validate_ColourSimpleType(self, value):
12585
        # Validate type pc:ColourSimpleType, a restriction on string.
12586
        if value is not None and Validate_simpletypes_ and self.gds_collector_ is not None:
12587
            if not isinstance(value, str):
12588
                lineno = self.gds_get_node_lineno_()
12589
                self.gds_collector_.add_message('Value "%(value)s"%(lineno)s is not of the correct base simple type (str)' % {"value": value, "lineno": lineno, })
12590
                return False
12591
            value = value
12592
            enumerations = ['black', 'blue', 'brown', 'cyan', 'green', 'grey', 'indigo', 'magenta', 'orange', 'pink', 'red', 'turquoise', 'violet', 'white', 'yellow', 'other']
12593
            if value not in enumerations:
12594
                lineno = self.gds_get_node_lineno_()
12595
                self.gds_collector_.add_message('Value "%(value)s"%(lineno)s does not match xsd enumeration restriction on ColourSimpleType' % {"value" : encode_str_2_3(value), "lineno": lineno} )
12596
                result = False
12597
    def has__content(self):
12598
        if (
12599
            super(AdvertRegionType, self).has__content()
12600
        ):
12601
            return True
12602
        else:
12603
            return False
12604
    def export(self, outfile, level, namespaceprefix_='', namespacedef_='xmlns:pc="http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15"', name_='AdvertRegionType', pretty_print=True):
12605
        imported_ns_def_ = GenerateDSNamespaceDefs_.get('AdvertRegionType')
12606
        if imported_ns_def_ is not None:
12607
            namespacedef_ = imported_ns_def_
12608
        if pretty_print:
12609
            eol_ = '\n'
12610
        else:
12611
            eol_ = ''
12612
        if self.original_tagname_ is not None and name_ == 'AdvertRegionType':
12613
            name_ = self.original_tagname_
12614
        if UseCapturedNS_ and self.ns_prefix_:
12615
            namespaceprefix_ = self.ns_prefix_ + ':'
12616
        showIndent(outfile, level, pretty_print)
12617
        outfile.write('<%s%s%s' % (namespaceprefix_, name_, namespacedef_ and ' ' + namespacedef_ or '', ))
12618
        already_processed = set()
12619
        self._exportAttributes(outfile, level, already_processed, namespaceprefix_, name_='AdvertRegionType')
12620
        if self.has__content():
12621
            outfile.write('>%s' % (eol_, ))
12622
            self._exportChildren(outfile, level + 1, namespaceprefix_, namespacedef_, name_='AdvertRegionType', pretty_print=pretty_print)
12623
            showIndent(outfile, level, pretty_print)
12624
            outfile.write('</%s%s>%s' % (namespaceprefix_, name_, eol_))
12625
        else:
12626
            outfile.write('/>%s' % (eol_, ))
12627
    def _exportAttributes(self, outfile, level, already_processed, namespaceprefix_='', name_='AdvertRegionType'):
12628
        super(AdvertRegionType, self)._exportAttributes(outfile, level, already_processed, namespaceprefix_, name_='AdvertRegionType')
12629
        if self.orientation is not None and 'orientation' not in already_processed:
12630
            already_processed.add('orientation')
12631
            outfile.write(' orientation="%s"' % self.gds_format_float(self.orientation, input_name='orientation'))
12632
        if self.bgColour is not None and 'bgColour' not in already_processed:
12633
            already_processed.add('bgColour')
12634
            outfile.write(' bgColour=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.bgColour), input_name='bgColour')), ))
12635
    def _exportChildren(self, outfile, level, namespaceprefix_='', namespacedef_='xmlns:pc="http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15"', name_='AdvertRegionType', fromsubclass_=False, pretty_print=True):
12636
        super(AdvertRegionType, self)._exportChildren(outfile, level, namespaceprefix_, namespacedef_, name_, True, pretty_print=pretty_print)
12637
    def to_etree(self, parent_element=None, name_='AdvertRegionType', mapping_=None, reverse_mapping_=None, nsmap_=None):
12638
        element = super(AdvertRegionType, self).to_etree(parent_element, name_, mapping_, reverse_mapping_, nsmap_)
12639
        if self.orientation is not None:
12640
            element.set('orientation', self.gds_format_float(self.orientation))
12641
        if self.bgColour is not None:
12642
            element.set('bgColour', self.gds_format_string(self.bgColour))
12643
        if mapping_ is not None:
12644
            mapping_[id(self)] = element
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable id does not seem to be defined.
Loading history...
12645
        if reverse_mapping_ is not None:
12646
            reverse_mapping_[element] = self
12647
        return element
12648
    def build(self, node, gds_collector_=None):
12649
        self.gds_collector_ = gds_collector_
12650
        if SaveElementTreeNode:
12651
            self.gds_elementtree_node_ = node
12652
        already_processed = set()
12653
        self.ns_prefix_ = node.prefix
12654
        self._buildAttributes(node, node.attrib, already_processed)
12655
        for child in node:
12656
            nodeName_ = Tag_pattern_.match(child.tag).groups()[-1]
12657
            self._buildChildren(child, node, nodeName_, gds_collector_=gds_collector_)
12658
        return self
12659
    def _buildAttributes(self, node, attrs, already_processed):
12660
        value = find_attr_value_('orientation', node)
12661
        if value is not None and 'orientation' not in already_processed:
12662
            already_processed.add('orientation')
12663
            value = self.gds_parse_float(value, node, 'orientation')
12664
            self.orientation = value
12665
        value = find_attr_value_('bgColour', node)
12666
        if value is not None and 'bgColour' not in already_processed:
12667
            already_processed.add('bgColour')
12668
            self.bgColour = value
12669
            self.validate_ColourSimpleType(self.bgColour)    # validate type ColourSimpleType
12670
        super(AdvertRegionType, self)._buildAttributes(node, attrs, already_processed)
12671
    def _buildChildren(self, child_, node, nodeName_, fromsubclass_=False, gds_collector_=None):
12672
        super(AdvertRegionType, self)._buildChildren(child_, node, nodeName_, True)
12673
        pass
12674
    def __hash__(self):
12675
        return hash(self.id)
12676
    def set_orientation(self, orientation):
12677
        """
12678
        Set deskewing angle to given `orientation` number.
12679
        Moreover, invalidate self's ``pc:AlternativeImage``s
12680
        (because they will have been rotated and enlarged
12681
        with the angle of the previous value).
12682
        """
12683
        if hasattr(self, 'invalidate_AlternativeImage'):
12684
            # PageType, RegionType:
12685
            self.invalidate_AlternativeImage(feature_selector='deskewed')
12686
        self.orientation = orientation
12687
# end class AdvertRegionType
12688
12689
12690 View Code Duplication
class MusicRegionType(RegionType):
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
12691
    """MusicRegionType --
12692
    Regions containing musical notations.
12693
      
12694
    * orientation --
12695
      The angle the rectangle encapsulating a region
12696
      has to be rotated in clockwise direction
12697
      in order to correct the present skew
12698
      (negative values indicate anti-clockwise rotation).
12699
      Range: -179.999,180
12700
      
12701
    * bgColour --
12702
      The background colour of the region
12703
    
12704
    """
12705
    __hash__ = GeneratedsSuper.__hash__
12706
    member_data_items_ = [
12707
        MemberSpec_('orientation', 'float', 0, 1, {'use': 'optional', 'name': 'orientation'}),
12708
        MemberSpec_('bgColour', 'pc:ColourSimpleType', 0, 1, {'use': 'optional', 'name': 'bgColour'}),
12709
    ]
12710
    subclass = None
12711
    superclass = RegionType
12712
    def __init__(self, id=None, custom=None, comments=None, continuation=None, AlternativeImage=None, Coords=None, UserDefined=None, Labels=None, Roles=None, TextRegion=None, ImageRegion=None, LineDrawingRegion=None, GraphicRegion=None, TableRegion=None, ChartRegion=None, SeparatorRegion=None, MathsRegion=None, ChemRegion=None, MusicRegion=None, AdvertRegion=None, NoiseRegion=None, UnknownRegion=None, CustomRegion=None, orientation=None, bgColour=None, gds_collector_=None, **kwargs_):
12713
        self.gds_collector_ = gds_collector_
12714
        self.gds_elementtree_node_ = None
12715
        self.original_tagname_ = None
12716
        self.parent_object_ = kwargs_.get('parent_object_')
12717
        self.ns_prefix_ = "pc"
12718
        super(globals().get("MusicRegionType"), self).__init__(id, custom, comments, continuation, AlternativeImage, Coords, UserDefined, Labels, Roles, TextRegion, ImageRegion, LineDrawingRegion, GraphicRegion, TableRegion, ChartRegion, SeparatorRegion, MathsRegion, ChemRegion, MusicRegion, AdvertRegion, NoiseRegion, UnknownRegion, CustomRegion,  **kwargs_)
12719
        self.orientation = _cast(float, orientation)
12720
        self.orientation_nsprefix_ = "pc"
12721
        self.bgColour = _cast(None, bgColour)
12722
        self.bgColour_nsprefix_ = "pc"
12723
    def factory(*args_, **kwargs_):
12724
        if CurrentSubclassModule_ is not None:
12725
            subclass = getSubclassFromModule_(
12726
                CurrentSubclassModule_, MusicRegionType)
12727
            if subclass is not None:
12728
                return subclass(*args_, **kwargs_)
12729
        if MusicRegionType.subclass:
12730
            return MusicRegionType.subclass(*args_, **kwargs_)
12731
        else:
12732
            return MusicRegionType(*args_, **kwargs_)
12733
    factory = staticmethod(factory)
12734
    def get_ns_prefix_(self):
12735
        return self.ns_prefix_
12736
    def set_ns_prefix_(self, ns_prefix):
12737
        self.ns_prefix_ = ns_prefix
12738
    def get_orientation(self):
12739
        return self.orientation
12740
    def set_orientation(self, orientation):
12741
        self.orientation = orientation
12742
    def get_bgColour(self):
12743
        return self.bgColour
12744
    def set_bgColour(self, bgColour):
12745
        self.bgColour = bgColour
12746
    def validate_ColourSimpleType(self, value):
12747
        # Validate type pc:ColourSimpleType, a restriction on string.
12748
        if value is not None and Validate_simpletypes_ and self.gds_collector_ is not None:
12749
            if not isinstance(value, str):
12750
                lineno = self.gds_get_node_lineno_()
12751
                self.gds_collector_.add_message('Value "%(value)s"%(lineno)s is not of the correct base simple type (str)' % {"value": value, "lineno": lineno, })
12752
                return False
12753
            value = value
12754
            enumerations = ['black', 'blue', 'brown', 'cyan', 'green', 'grey', 'indigo', 'magenta', 'orange', 'pink', 'red', 'turquoise', 'violet', 'white', 'yellow', 'other']
12755
            if value not in enumerations:
12756
                lineno = self.gds_get_node_lineno_()
12757
                self.gds_collector_.add_message('Value "%(value)s"%(lineno)s does not match xsd enumeration restriction on ColourSimpleType' % {"value" : encode_str_2_3(value), "lineno": lineno} )
12758
                result = False
12759
    def has__content(self):
12760
        if (
12761
            super(MusicRegionType, self).has__content()
12762
        ):
12763
            return True
12764
        else:
12765
            return False
12766
    def export(self, outfile, level, namespaceprefix_='', namespacedef_='xmlns:pc="http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15"', name_='MusicRegionType', pretty_print=True):
12767
        imported_ns_def_ = GenerateDSNamespaceDefs_.get('MusicRegionType')
12768
        if imported_ns_def_ is not None:
12769
            namespacedef_ = imported_ns_def_
12770
        if pretty_print:
12771
            eol_ = '\n'
12772
        else:
12773
            eol_ = ''
12774
        if self.original_tagname_ is not None and name_ == 'MusicRegionType':
12775
            name_ = self.original_tagname_
12776
        if UseCapturedNS_ and self.ns_prefix_:
12777
            namespaceprefix_ = self.ns_prefix_ + ':'
12778
        showIndent(outfile, level, pretty_print)
12779
        outfile.write('<%s%s%s' % (namespaceprefix_, name_, namespacedef_ and ' ' + namespacedef_ or '', ))
12780
        already_processed = set()
12781
        self._exportAttributes(outfile, level, already_processed, namespaceprefix_, name_='MusicRegionType')
12782
        if self.has__content():
12783
            outfile.write('>%s' % (eol_, ))
12784
            self._exportChildren(outfile, level + 1, namespaceprefix_, namespacedef_, name_='MusicRegionType', pretty_print=pretty_print)
12785
            showIndent(outfile, level, pretty_print)
12786
            outfile.write('</%s%s>%s' % (namespaceprefix_, name_, eol_))
12787
        else:
12788
            outfile.write('/>%s' % (eol_, ))
12789
    def _exportAttributes(self, outfile, level, already_processed, namespaceprefix_='', name_='MusicRegionType'):
12790
        super(MusicRegionType, self)._exportAttributes(outfile, level, already_processed, namespaceprefix_, name_='MusicRegionType')
12791
        if self.orientation is not None and 'orientation' not in already_processed:
12792
            already_processed.add('orientation')
12793
            outfile.write(' orientation="%s"' % self.gds_format_float(self.orientation, input_name='orientation'))
12794
        if self.bgColour is not None and 'bgColour' not in already_processed:
12795
            already_processed.add('bgColour')
12796
            outfile.write(' bgColour=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.bgColour), input_name='bgColour')), ))
12797
    def _exportChildren(self, outfile, level, namespaceprefix_='', namespacedef_='xmlns:pc="http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15"', name_='MusicRegionType', fromsubclass_=False, pretty_print=True):
12798
        super(MusicRegionType, self)._exportChildren(outfile, level, namespaceprefix_, namespacedef_, name_, True, pretty_print=pretty_print)
12799
    def to_etree(self, parent_element=None, name_='MusicRegionType', mapping_=None, reverse_mapping_=None, nsmap_=None):
12800
        element = super(MusicRegionType, self).to_etree(parent_element, name_, mapping_, reverse_mapping_, nsmap_)
12801
        if self.orientation is not None:
12802
            element.set('orientation', self.gds_format_float(self.orientation))
12803
        if self.bgColour is not None:
12804
            element.set('bgColour', self.gds_format_string(self.bgColour))
12805
        if mapping_ is not None:
12806
            mapping_[id(self)] = element
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable id does not seem to be defined.
Loading history...
12807
        if reverse_mapping_ is not None:
12808
            reverse_mapping_[element] = self
12809
        return element
12810
    def build(self, node, gds_collector_=None):
12811
        self.gds_collector_ = gds_collector_
12812
        if SaveElementTreeNode:
12813
            self.gds_elementtree_node_ = node
12814
        already_processed = set()
12815
        self.ns_prefix_ = node.prefix
12816
        self._buildAttributes(node, node.attrib, already_processed)
12817
        for child in node:
12818
            nodeName_ = Tag_pattern_.match(child.tag).groups()[-1]
12819
            self._buildChildren(child, node, nodeName_, gds_collector_=gds_collector_)
12820
        return self
12821
    def _buildAttributes(self, node, attrs, already_processed):
12822
        value = find_attr_value_('orientation', node)
12823
        if value is not None and 'orientation' not in already_processed:
12824
            already_processed.add('orientation')
12825
            value = self.gds_parse_float(value, node, 'orientation')
12826
            self.orientation = value
12827
        value = find_attr_value_('bgColour', node)
12828
        if value is not None and 'bgColour' not in already_processed:
12829
            already_processed.add('bgColour')
12830
            self.bgColour = value
12831
            self.validate_ColourSimpleType(self.bgColour)    # validate type ColourSimpleType
12832
        super(MusicRegionType, self)._buildAttributes(node, attrs, already_processed)
12833
    def _buildChildren(self, child_, node, nodeName_, fromsubclass_=False, gds_collector_=None):
12834
        super(MusicRegionType, self)._buildChildren(child_, node, nodeName_, True)
12835
        pass
12836
    def __hash__(self):
12837
        return hash(self.id)
12838
    def set_orientation(self, orientation):
12839
        """
12840
        Set deskewing angle to given `orientation` number.
12841
        Moreover, invalidate self's ``pc:AlternativeImage``s
12842
        (because they will have been rotated and enlarged
12843
        with the angle of the previous value).
12844
        """
12845
        if hasattr(self, 'invalidate_AlternativeImage'):
12846
            # PageType, RegionType:
12847
            self.invalidate_AlternativeImage(feature_selector='deskewed')
12848
        self.orientation = orientation
12849
# end class MusicRegionType
12850
12851
12852
class MapRegionType(RegionType):
12853
    """MapRegionType --
12854
    Regions containing maps.
12855
      
12856
    * orientation --
12857
      The angle the rectangle encapsulating a
12858
      region has to be rotated in clockwise
12859
      direction in order to correct the present
12860
      skew (negative values indicate
12861
      anti-clockwise rotation). Range:
12862
      -179.999,180
12863
    
12864
    """
12865
    __hash__ = GeneratedsSuper.__hash__
12866
    member_data_items_ = [
12867
        MemberSpec_('orientation', 'float', 0, 1, {'use': 'optional', 'name': 'orientation'}),
12868
    ]
12869
    subclass = None
12870
    superclass = RegionType
12871
    def __init__(self, id=None, custom=None, comments=None, continuation=None, AlternativeImage=None, Coords=None, UserDefined=None, Labels=None, Roles=None, TextRegion=None, ImageRegion=None, LineDrawingRegion=None, GraphicRegion=None, TableRegion=None, ChartRegion=None, SeparatorRegion=None, MathsRegion=None, ChemRegion=None, MusicRegion=None, AdvertRegion=None, NoiseRegion=None, UnknownRegion=None, CustomRegion=None, orientation=None, gds_collector_=None, **kwargs_):
12872
        self.gds_collector_ = gds_collector_
12873
        self.gds_elementtree_node_ = None
12874
        self.original_tagname_ = None
12875
        self.parent_object_ = kwargs_.get('parent_object_')
12876
        self.ns_prefix_ = "pc"
12877
        super(globals().get("MapRegionType"), self).__init__(id, custom, comments, continuation, AlternativeImage, Coords, UserDefined, Labels, Roles, TextRegion, ImageRegion, LineDrawingRegion, GraphicRegion, TableRegion, ChartRegion, SeparatorRegion, MathsRegion, ChemRegion, MusicRegion, AdvertRegion, NoiseRegion, UnknownRegion, CustomRegion,  **kwargs_)
12878
        self.orientation = _cast(float, orientation)
12879
        self.orientation_nsprefix_ = "pc"
12880
    def factory(*args_, **kwargs_):
12881
        if CurrentSubclassModule_ is not None:
12882
            subclass = getSubclassFromModule_(
12883
                CurrentSubclassModule_, MapRegionType)
12884
            if subclass is not None:
12885
                return subclass(*args_, **kwargs_)
12886
        if MapRegionType.subclass:
12887
            return MapRegionType.subclass(*args_, **kwargs_)
12888
        else:
12889
            return MapRegionType(*args_, **kwargs_)
12890
    factory = staticmethod(factory)
12891
    def get_ns_prefix_(self):
12892
        return self.ns_prefix_
12893
    def set_ns_prefix_(self, ns_prefix):
12894
        self.ns_prefix_ = ns_prefix
12895
    def get_orientation(self):
12896
        return self.orientation
12897
    def set_orientation(self, orientation):
12898
        self.orientation = orientation
12899
    def has__content(self):
12900
        if (
12901
            super(MapRegionType, self).has__content()
12902
        ):
12903
            return True
12904
        else:
12905
            return False
12906
    def export(self, outfile, level, namespaceprefix_='', namespacedef_='xmlns:pc="http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15"', name_='MapRegionType', pretty_print=True):
12907
        imported_ns_def_ = GenerateDSNamespaceDefs_.get('MapRegionType')
12908
        if imported_ns_def_ is not None:
12909
            namespacedef_ = imported_ns_def_
12910
        if pretty_print:
12911
            eol_ = '\n'
12912
        else:
12913
            eol_ = ''
12914
        if self.original_tagname_ is not None and name_ == 'MapRegionType':
12915
            name_ = self.original_tagname_
12916
        if UseCapturedNS_ and self.ns_prefix_:
12917
            namespaceprefix_ = self.ns_prefix_ + ':'
12918
        showIndent(outfile, level, pretty_print)
12919
        outfile.write('<%s%s%s' % (namespaceprefix_, name_, namespacedef_ and ' ' + namespacedef_ or '', ))
12920
        already_processed = set()
12921
        self._exportAttributes(outfile, level, already_processed, namespaceprefix_, name_='MapRegionType')
12922
        if self.has__content():
12923
            outfile.write('>%s' % (eol_, ))
12924
            self._exportChildren(outfile, level + 1, namespaceprefix_, namespacedef_, name_='MapRegionType', pretty_print=pretty_print)
12925
            showIndent(outfile, level, pretty_print)
12926
            outfile.write('</%s%s>%s' % (namespaceprefix_, name_, eol_))
12927
        else:
12928
            outfile.write('/>%s' % (eol_, ))
12929
    def _exportAttributes(self, outfile, level, already_processed, namespaceprefix_='', name_='MapRegionType'):
12930
        super(MapRegionType, self)._exportAttributes(outfile, level, already_processed, namespaceprefix_, name_='MapRegionType')
12931
        if self.orientation is not None and 'orientation' not in already_processed:
12932
            already_processed.add('orientation')
12933
            outfile.write(' orientation="%s"' % self.gds_format_float(self.orientation, input_name='orientation'))
12934
    def _exportChildren(self, outfile, level, namespaceprefix_='', namespacedef_='xmlns:pc="http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15"', name_='MapRegionType', fromsubclass_=False, pretty_print=True):
12935
        super(MapRegionType, self)._exportChildren(outfile, level, namespaceprefix_, namespacedef_, name_, True, pretty_print=pretty_print)
12936
    def to_etree(self, parent_element=None, name_='MapRegionType', mapping_=None, reverse_mapping_=None, nsmap_=None):
12937
        element = super(MapRegionType, self).to_etree(parent_element, name_, mapping_, reverse_mapping_, nsmap_)
12938
        if self.orientation is not None:
12939
            element.set('orientation', self.gds_format_float(self.orientation))
12940
        if mapping_ is not None:
12941
            mapping_[id(self)] = element
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable id does not seem to be defined.
Loading history...
12942
        if reverse_mapping_ is not None:
12943
            reverse_mapping_[element] = self
12944
        return element
12945
    def build(self, node, gds_collector_=None):
12946
        self.gds_collector_ = gds_collector_
12947
        if SaveElementTreeNode:
12948
            self.gds_elementtree_node_ = node
12949
        already_processed = set()
12950
        self.ns_prefix_ = node.prefix
12951
        self._buildAttributes(node, node.attrib, already_processed)
12952
        for child in node:
12953
            nodeName_ = Tag_pattern_.match(child.tag).groups()[-1]
12954
            self._buildChildren(child, node, nodeName_, gds_collector_=gds_collector_)
12955
        return self
12956
    def _buildAttributes(self, node, attrs, already_processed):
12957
        value = find_attr_value_('orientation', node)
12958
        if value is not None and 'orientation' not in already_processed:
12959
            already_processed.add('orientation')
12960
            value = self.gds_parse_float(value, node, 'orientation')
12961
            self.orientation = value
12962
        super(MapRegionType, self)._buildAttributes(node, attrs, already_processed)
12963
    def _buildChildren(self, child_, node, nodeName_, fromsubclass_=False, gds_collector_=None):
12964
        super(MapRegionType, self)._buildChildren(child_, node, nodeName_, True)
12965
        pass
12966
    def __hash__(self):
12967
        return hash(self.id)
12968
    def set_orientation(self, orientation):
12969
        """
12970
        Set deskewing angle to given `orientation` number.
12971
        Moreover, invalidate self's ``pc:AlternativeImage``s
12972
        (because they will have been rotated and enlarged
12973
        with the angle of the previous value).
12974
        """
12975
        if hasattr(self, 'invalidate_AlternativeImage'):
12976
            # PageType, RegionType:
12977
            self.invalidate_AlternativeImage(feature_selector='deskewed')
12978
        self.orientation = orientation
12979
# end class MapRegionType
12980
12981
12982 View Code Duplication
class ChemRegionType(RegionType):
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
12983
    """ChemRegionType --
12984
    Regions containing chemical formulas.
12985
      
12986
    * orientation --
12987
      The angle the rectangle encapsulating a
12988
      region has to be rotated in clockwise
12989
      direction in order to correct the present
12990
      skew (negative values indicate
12991
      anti-clockwise rotation). Range:
12992
      -179.999,180
12993
      
12994
    * bgColour --
12995
      The background colour of the region
12996
    
12997
    """
12998
    __hash__ = GeneratedsSuper.__hash__
12999
    member_data_items_ = [
13000
        MemberSpec_('orientation', 'float', 0, 1, {'use': 'optional', 'name': 'orientation'}),
13001
        MemberSpec_('bgColour', 'pc:ColourSimpleType', 0, 1, {'use': 'optional', 'name': 'bgColour'}),
13002
    ]
13003
    subclass = None
13004
    superclass = RegionType
13005
    def __init__(self, id=None, custom=None, comments=None, continuation=None, AlternativeImage=None, Coords=None, UserDefined=None, Labels=None, Roles=None, TextRegion=None, ImageRegion=None, LineDrawingRegion=None, GraphicRegion=None, TableRegion=None, ChartRegion=None, SeparatorRegion=None, MathsRegion=None, ChemRegion=None, MusicRegion=None, AdvertRegion=None, NoiseRegion=None, UnknownRegion=None, CustomRegion=None, orientation=None, bgColour=None, gds_collector_=None, **kwargs_):
13006
        self.gds_collector_ = gds_collector_
13007
        self.gds_elementtree_node_ = None
13008
        self.original_tagname_ = None
13009
        self.parent_object_ = kwargs_.get('parent_object_')
13010
        self.ns_prefix_ = "pc"
13011
        super(globals().get("ChemRegionType"), self).__init__(id, custom, comments, continuation, AlternativeImage, Coords, UserDefined, Labels, Roles, TextRegion, ImageRegion, LineDrawingRegion, GraphicRegion, TableRegion, ChartRegion, SeparatorRegion, MathsRegion, ChemRegion, MusicRegion, AdvertRegion, NoiseRegion, UnknownRegion, CustomRegion,  **kwargs_)
13012
        self.orientation = _cast(float, orientation)
13013
        self.orientation_nsprefix_ = "pc"
13014
        self.bgColour = _cast(None, bgColour)
13015
        self.bgColour_nsprefix_ = "pc"
13016
    def factory(*args_, **kwargs_):
13017
        if CurrentSubclassModule_ is not None:
13018
            subclass = getSubclassFromModule_(
13019
                CurrentSubclassModule_, ChemRegionType)
13020
            if subclass is not None:
13021
                return subclass(*args_, **kwargs_)
13022
        if ChemRegionType.subclass:
13023
            return ChemRegionType.subclass(*args_, **kwargs_)
13024
        else:
13025
            return ChemRegionType(*args_, **kwargs_)
13026
    factory = staticmethod(factory)
13027
    def get_ns_prefix_(self):
13028
        return self.ns_prefix_
13029
    def set_ns_prefix_(self, ns_prefix):
13030
        self.ns_prefix_ = ns_prefix
13031
    def get_orientation(self):
13032
        return self.orientation
13033
    def set_orientation(self, orientation):
13034
        self.orientation = orientation
13035
    def get_bgColour(self):
13036
        return self.bgColour
13037
    def set_bgColour(self, bgColour):
13038
        self.bgColour = bgColour
13039
    def validate_ColourSimpleType(self, value):
13040
        # Validate type pc:ColourSimpleType, a restriction on string.
13041
        if value is not None and Validate_simpletypes_ and self.gds_collector_ is not None:
13042
            if not isinstance(value, str):
13043
                lineno = self.gds_get_node_lineno_()
13044
                self.gds_collector_.add_message('Value "%(value)s"%(lineno)s is not of the correct base simple type (str)' % {"value": value, "lineno": lineno, })
13045
                return False
13046
            value = value
13047
            enumerations = ['black', 'blue', 'brown', 'cyan', 'green', 'grey', 'indigo', 'magenta', 'orange', 'pink', 'red', 'turquoise', 'violet', 'white', 'yellow', 'other']
13048
            if value not in enumerations:
13049
                lineno = self.gds_get_node_lineno_()
13050
                self.gds_collector_.add_message('Value "%(value)s"%(lineno)s does not match xsd enumeration restriction on ColourSimpleType' % {"value" : encode_str_2_3(value), "lineno": lineno} )
13051
                result = False
13052
    def has__content(self):
13053
        if (
13054
            super(ChemRegionType, self).has__content()
13055
        ):
13056
            return True
13057
        else:
13058
            return False
13059
    def export(self, outfile, level, namespaceprefix_='', namespacedef_='xmlns:pc="http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15"', name_='ChemRegionType', pretty_print=True):
13060
        imported_ns_def_ = GenerateDSNamespaceDefs_.get('ChemRegionType')
13061
        if imported_ns_def_ is not None:
13062
            namespacedef_ = imported_ns_def_
13063
        if pretty_print:
13064
            eol_ = '\n'
13065
        else:
13066
            eol_ = ''
13067
        if self.original_tagname_ is not None and name_ == 'ChemRegionType':
13068
            name_ = self.original_tagname_
13069
        if UseCapturedNS_ and self.ns_prefix_:
13070
            namespaceprefix_ = self.ns_prefix_ + ':'
13071
        showIndent(outfile, level, pretty_print)
13072
        outfile.write('<%s%s%s' % (namespaceprefix_, name_, namespacedef_ and ' ' + namespacedef_ or '', ))
13073
        already_processed = set()
13074
        self._exportAttributes(outfile, level, already_processed, namespaceprefix_, name_='ChemRegionType')
13075
        if self.has__content():
13076
            outfile.write('>%s' % (eol_, ))
13077
            self._exportChildren(outfile, level + 1, namespaceprefix_, namespacedef_, name_='ChemRegionType', pretty_print=pretty_print)
13078
            showIndent(outfile, level, pretty_print)
13079
            outfile.write('</%s%s>%s' % (namespaceprefix_, name_, eol_))
13080
        else:
13081
            outfile.write('/>%s' % (eol_, ))
13082
    def _exportAttributes(self, outfile, level, already_processed, namespaceprefix_='', name_='ChemRegionType'):
13083
        super(ChemRegionType, self)._exportAttributes(outfile, level, already_processed, namespaceprefix_, name_='ChemRegionType')
13084
        if self.orientation is not None and 'orientation' not in already_processed:
13085
            already_processed.add('orientation')
13086
            outfile.write(' orientation="%s"' % self.gds_format_float(self.orientation, input_name='orientation'))
13087
        if self.bgColour is not None and 'bgColour' not in already_processed:
13088
            already_processed.add('bgColour')
13089
            outfile.write(' bgColour=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.bgColour), input_name='bgColour')), ))
13090
    def _exportChildren(self, outfile, level, namespaceprefix_='', namespacedef_='xmlns:pc="http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15"', name_='ChemRegionType', fromsubclass_=False, pretty_print=True):
13091
        super(ChemRegionType, self)._exportChildren(outfile, level, namespaceprefix_, namespacedef_, name_, True, pretty_print=pretty_print)
13092
    def to_etree(self, parent_element=None, name_='ChemRegionType', mapping_=None, reverse_mapping_=None, nsmap_=None):
13093
        element = super(ChemRegionType, self).to_etree(parent_element, name_, mapping_, reverse_mapping_, nsmap_)
13094
        if self.orientation is not None:
13095
            element.set('orientation', self.gds_format_float(self.orientation))
13096
        if self.bgColour is not None:
13097
            element.set('bgColour', self.gds_format_string(self.bgColour))
13098
        if mapping_ is not None:
13099
            mapping_[id(self)] = element
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable id does not seem to be defined.
Loading history...
13100
        if reverse_mapping_ is not None:
13101
            reverse_mapping_[element] = self
13102
        return element
13103
    def build(self, node, gds_collector_=None):
13104
        self.gds_collector_ = gds_collector_
13105
        if SaveElementTreeNode:
13106
            self.gds_elementtree_node_ = node
13107
        already_processed = set()
13108
        self.ns_prefix_ = node.prefix
13109
        self._buildAttributes(node, node.attrib, already_processed)
13110
        for child in node:
13111
            nodeName_ = Tag_pattern_.match(child.tag).groups()[-1]
13112
            self._buildChildren(child, node, nodeName_, gds_collector_=gds_collector_)
13113
        return self
13114
    def _buildAttributes(self, node, attrs, already_processed):
13115
        value = find_attr_value_('orientation', node)
13116
        if value is not None and 'orientation' not in already_processed:
13117
            already_processed.add('orientation')
13118
            value = self.gds_parse_float(value, node, 'orientation')
13119
            self.orientation = value
13120
        value = find_attr_value_('bgColour', node)
13121
        if value is not None and 'bgColour' not in already_processed:
13122
            already_processed.add('bgColour')
13123
            self.bgColour = value
13124
            self.validate_ColourSimpleType(self.bgColour)    # validate type ColourSimpleType
13125
        super(ChemRegionType, self)._buildAttributes(node, attrs, already_processed)
13126
    def _buildChildren(self, child_, node, nodeName_, fromsubclass_=False, gds_collector_=None):
13127
        super(ChemRegionType, self)._buildChildren(child_, node, nodeName_, True)
13128
        pass
13129
    def __hash__(self):
13130
        return hash(self.id)
13131
    def set_orientation(self, orientation):
13132
        """
13133
        Set deskewing angle to given `orientation` number.
13134
        Moreover, invalidate self's ``pc:AlternativeImage``s
13135
        (because they will have been rotated and enlarged
13136
        with the angle of the previous value).
13137
        """
13138
        if hasattr(self, 'invalidate_AlternativeImage'):
13139
            # PageType, RegionType:
13140
            self.invalidate_AlternativeImage(feature_selector='deskewed')
13141
        self.orientation = orientation
13142
# end class ChemRegionType
13143
13144
13145 View Code Duplication
class MathsRegionType(RegionType):
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
13146
    """MathsRegionType --
13147
    Regions containing equations and mathematical symbols
13148
    should be marked as maths regions.
13149
      
13150
    * orientation --
13151
      The angle the rectangle encapsulating a region
13152
      has to be rotated in clockwise direction
13153
      in order to correct the present skew
13154
      (negative values indicate anti-clockwise rotation).
13155
      Range: -179.999,180
13156
      
13157
    * bgColour --
13158
      The background colour of the region
13159
    
13160
    """
13161
    __hash__ = GeneratedsSuper.__hash__
13162
    member_data_items_ = [
13163
        MemberSpec_('orientation', 'float', 0, 1, {'use': 'optional', 'name': 'orientation'}),
13164
        MemberSpec_('bgColour', 'pc:ColourSimpleType', 0, 1, {'use': 'optional', 'name': 'bgColour'}),
13165
    ]
13166
    subclass = None
13167
    superclass = RegionType
13168
    def __init__(self, id=None, custom=None, comments=None, continuation=None, AlternativeImage=None, Coords=None, UserDefined=None, Labels=None, Roles=None, TextRegion=None, ImageRegion=None, LineDrawingRegion=None, GraphicRegion=None, TableRegion=None, ChartRegion=None, SeparatorRegion=None, MathsRegion=None, ChemRegion=None, MusicRegion=None, AdvertRegion=None, NoiseRegion=None, UnknownRegion=None, CustomRegion=None, orientation=None, bgColour=None, gds_collector_=None, **kwargs_):
13169
        self.gds_collector_ = gds_collector_
13170
        self.gds_elementtree_node_ = None
13171
        self.original_tagname_ = None
13172
        self.parent_object_ = kwargs_.get('parent_object_')
13173
        self.ns_prefix_ = "pc"
13174
        super(globals().get("MathsRegionType"), self).__init__(id, custom, comments, continuation, AlternativeImage, Coords, UserDefined, Labels, Roles, TextRegion, ImageRegion, LineDrawingRegion, GraphicRegion, TableRegion, ChartRegion, SeparatorRegion, MathsRegion, ChemRegion, MusicRegion, AdvertRegion, NoiseRegion, UnknownRegion, CustomRegion,  **kwargs_)
13175
        self.orientation = _cast(float, orientation)
13176
        self.orientation_nsprefix_ = "pc"
13177
        self.bgColour = _cast(None, bgColour)
13178
        self.bgColour_nsprefix_ = "pc"
13179
    def factory(*args_, **kwargs_):
13180
        if CurrentSubclassModule_ is not None:
13181
            subclass = getSubclassFromModule_(
13182
                CurrentSubclassModule_, MathsRegionType)
13183
            if subclass is not None:
13184
                return subclass(*args_, **kwargs_)
13185
        if MathsRegionType.subclass:
13186
            return MathsRegionType.subclass(*args_, **kwargs_)
13187
        else:
13188
            return MathsRegionType(*args_, **kwargs_)
13189
    factory = staticmethod(factory)
13190
    def get_ns_prefix_(self):
13191
        return self.ns_prefix_
13192
    def set_ns_prefix_(self, ns_prefix):
13193
        self.ns_prefix_ = ns_prefix
13194
    def get_orientation(self):
13195
        return self.orientation
13196
    def set_orientation(self, orientation):
13197
        self.orientation = orientation
13198
    def get_bgColour(self):
13199
        return self.bgColour
13200
    def set_bgColour(self, bgColour):
13201
        self.bgColour = bgColour
13202
    def validate_ColourSimpleType(self, value):
13203
        # Validate type pc:ColourSimpleType, a restriction on string.
13204
        if value is not None and Validate_simpletypes_ and self.gds_collector_ is not None:
13205
            if not isinstance(value, str):
13206
                lineno = self.gds_get_node_lineno_()
13207
                self.gds_collector_.add_message('Value "%(value)s"%(lineno)s is not of the correct base simple type (str)' % {"value": value, "lineno": lineno, })
13208
                return False
13209
            value = value
13210
            enumerations = ['black', 'blue', 'brown', 'cyan', 'green', 'grey', 'indigo', 'magenta', 'orange', 'pink', 'red', 'turquoise', 'violet', 'white', 'yellow', 'other']
13211
            if value not in enumerations:
13212
                lineno = self.gds_get_node_lineno_()
13213
                self.gds_collector_.add_message('Value "%(value)s"%(lineno)s does not match xsd enumeration restriction on ColourSimpleType' % {"value" : encode_str_2_3(value), "lineno": lineno} )
13214
                result = False
13215
    def has__content(self):
13216
        if (
13217
            super(MathsRegionType, self).has__content()
13218
        ):
13219
            return True
13220
        else:
13221
            return False
13222
    def export(self, outfile, level, namespaceprefix_='', namespacedef_='xmlns:pc="http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15"', name_='MathsRegionType', pretty_print=True):
13223
        imported_ns_def_ = GenerateDSNamespaceDefs_.get('MathsRegionType')
13224
        if imported_ns_def_ is not None:
13225
            namespacedef_ = imported_ns_def_
13226
        if pretty_print:
13227
            eol_ = '\n'
13228
        else:
13229
            eol_ = ''
13230
        if self.original_tagname_ is not None and name_ == 'MathsRegionType':
13231
            name_ = self.original_tagname_
13232
        if UseCapturedNS_ and self.ns_prefix_:
13233
            namespaceprefix_ = self.ns_prefix_ + ':'
13234
        showIndent(outfile, level, pretty_print)
13235
        outfile.write('<%s%s%s' % (namespaceprefix_, name_, namespacedef_ and ' ' + namespacedef_ or '', ))
13236
        already_processed = set()
13237
        self._exportAttributes(outfile, level, already_processed, namespaceprefix_, name_='MathsRegionType')
13238
        if self.has__content():
13239
            outfile.write('>%s' % (eol_, ))
13240
            self._exportChildren(outfile, level + 1, namespaceprefix_, namespacedef_, name_='MathsRegionType', pretty_print=pretty_print)
13241
            showIndent(outfile, level, pretty_print)
13242
            outfile.write('</%s%s>%s' % (namespaceprefix_, name_, eol_))
13243
        else:
13244
            outfile.write('/>%s' % (eol_, ))
13245
    def _exportAttributes(self, outfile, level, already_processed, namespaceprefix_='', name_='MathsRegionType'):
13246
        super(MathsRegionType, self)._exportAttributes(outfile, level, already_processed, namespaceprefix_, name_='MathsRegionType')
13247
        if self.orientation is not None and 'orientation' not in already_processed:
13248
            already_processed.add('orientation')
13249
            outfile.write(' orientation="%s"' % self.gds_format_float(self.orientation, input_name='orientation'))
13250
        if self.bgColour is not None and 'bgColour' not in already_processed:
13251
            already_processed.add('bgColour')
13252
            outfile.write(' bgColour=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.bgColour), input_name='bgColour')), ))
13253
    def _exportChildren(self, outfile, level, namespaceprefix_='', namespacedef_='xmlns:pc="http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15"', name_='MathsRegionType', fromsubclass_=False, pretty_print=True):
13254
        super(MathsRegionType, self)._exportChildren(outfile, level, namespaceprefix_, namespacedef_, name_, True, pretty_print=pretty_print)
13255
    def to_etree(self, parent_element=None, name_='MathsRegionType', mapping_=None, reverse_mapping_=None, nsmap_=None):
13256
        element = super(MathsRegionType, self).to_etree(parent_element, name_, mapping_, reverse_mapping_, nsmap_)
13257
        if self.orientation is not None:
13258
            element.set('orientation', self.gds_format_float(self.orientation))
13259
        if self.bgColour is not None:
13260
            element.set('bgColour', self.gds_format_string(self.bgColour))
13261
        if mapping_ is not None:
13262
            mapping_[id(self)] = element
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable id does not seem to be defined.
Loading history...
13263
        if reverse_mapping_ is not None:
13264
            reverse_mapping_[element] = self
13265
        return element
13266
    def build(self, node, gds_collector_=None):
13267
        self.gds_collector_ = gds_collector_
13268
        if SaveElementTreeNode:
13269
            self.gds_elementtree_node_ = node
13270
        already_processed = set()
13271
        self.ns_prefix_ = node.prefix
13272
        self._buildAttributes(node, node.attrib, already_processed)
13273
        for child in node:
13274
            nodeName_ = Tag_pattern_.match(child.tag).groups()[-1]
13275
            self._buildChildren(child, node, nodeName_, gds_collector_=gds_collector_)
13276
        return self
13277
    def _buildAttributes(self, node, attrs, already_processed):
13278
        value = find_attr_value_('orientation', node)
13279
        if value is not None and 'orientation' not in already_processed:
13280
            already_processed.add('orientation')
13281
            value = self.gds_parse_float(value, node, 'orientation')
13282
            self.orientation = value
13283
        value = find_attr_value_('bgColour', node)
13284
        if value is not None and 'bgColour' not in already_processed:
13285
            already_processed.add('bgColour')
13286
            self.bgColour = value
13287
            self.validate_ColourSimpleType(self.bgColour)    # validate type ColourSimpleType
13288
        super(MathsRegionType, self)._buildAttributes(node, attrs, already_processed)
13289
    def _buildChildren(self, child_, node, nodeName_, fromsubclass_=False, gds_collector_=None):
13290
        super(MathsRegionType, self)._buildChildren(child_, node, nodeName_, True)
13291
        pass
13292
    def __hash__(self):
13293
        return hash(self.id)
13294
    def set_orientation(self, orientation):
13295
        """
13296
        Set deskewing angle to given `orientation` number.
13297
        Moreover, invalidate self's ``pc:AlternativeImage``s
13298
        (because they will have been rotated and enlarged
13299
        with the angle of the previous value).
13300
        """
13301
        if hasattr(self, 'invalidate_AlternativeImage'):
13302
            # PageType, RegionType:
13303
            self.invalidate_AlternativeImage(feature_selector='deskewed')
13304
        self.orientation = orientation
13305
# end class MathsRegionType
13306
13307
13308 View Code Duplication
class SeparatorRegionType(RegionType):
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
13309
    """SeparatorRegionType --
13310
    Separators are lines that lie between columns and
13311
    paragraphs and can be used to logically separate
13312
    different articles from each other.
13313
      
13314
    * orientation --
13315
      The angle the rectangle encapsulating a region
13316
      has to be rotated in clockwise direction
13317
      in order to correct the present skew
13318
      (negative values indicate anti-clockwise rotation).
13319
      Range: -179.999,180
13320
      
13321
    * colour --
13322
      The colour of the separator
13323
    
13324
    """
13325
    __hash__ = GeneratedsSuper.__hash__
13326
    member_data_items_ = [
13327
        MemberSpec_('orientation', 'float', 0, 1, {'use': 'optional', 'name': 'orientation'}),
13328
        MemberSpec_('colour', 'pc:ColourSimpleType', 0, 1, {'use': 'optional', 'name': 'colour'}),
13329
    ]
13330
    subclass = None
13331
    superclass = RegionType
13332
    def __init__(self, id=None, custom=None, comments=None, continuation=None, AlternativeImage=None, Coords=None, UserDefined=None, Labels=None, Roles=None, TextRegion=None, ImageRegion=None, LineDrawingRegion=None, GraphicRegion=None, TableRegion=None, ChartRegion=None, SeparatorRegion=None, MathsRegion=None, ChemRegion=None, MusicRegion=None, AdvertRegion=None, NoiseRegion=None, UnknownRegion=None, CustomRegion=None, orientation=None, colour=None, gds_collector_=None, **kwargs_):
13333
        self.gds_collector_ = gds_collector_
13334
        self.gds_elementtree_node_ = None
13335
        self.original_tagname_ = None
13336
        self.parent_object_ = kwargs_.get('parent_object_')
13337
        self.ns_prefix_ = "pc"
13338
        super(globals().get("SeparatorRegionType"), self).__init__(id, custom, comments, continuation, AlternativeImage, Coords, UserDefined, Labels, Roles, TextRegion, ImageRegion, LineDrawingRegion, GraphicRegion, TableRegion, ChartRegion, SeparatorRegion, MathsRegion, ChemRegion, MusicRegion, AdvertRegion, NoiseRegion, UnknownRegion, CustomRegion,  **kwargs_)
13339
        self.orientation = _cast(float, orientation)
13340
        self.orientation_nsprefix_ = "pc"
13341
        self.colour = _cast(None, colour)
13342
        self.colour_nsprefix_ = "pc"
13343
    def factory(*args_, **kwargs_):
13344
        if CurrentSubclassModule_ is not None:
13345
            subclass = getSubclassFromModule_(
13346
                CurrentSubclassModule_, SeparatorRegionType)
13347
            if subclass is not None:
13348
                return subclass(*args_, **kwargs_)
13349
        if SeparatorRegionType.subclass:
13350
            return SeparatorRegionType.subclass(*args_, **kwargs_)
13351
        else:
13352
            return SeparatorRegionType(*args_, **kwargs_)
13353
    factory = staticmethod(factory)
13354
    def get_ns_prefix_(self):
13355
        return self.ns_prefix_
13356
    def set_ns_prefix_(self, ns_prefix):
13357
        self.ns_prefix_ = ns_prefix
13358
    def get_orientation(self):
13359
        return self.orientation
13360
    def set_orientation(self, orientation):
13361
        self.orientation = orientation
13362
    def get_colour(self):
13363
        return self.colour
13364
    def set_colour(self, colour):
13365
        self.colour = colour
13366
    def validate_ColourSimpleType(self, value):
13367
        # Validate type pc:ColourSimpleType, a restriction on string.
13368
        if value is not None and Validate_simpletypes_ and self.gds_collector_ is not None:
13369
            if not isinstance(value, str):
13370
                lineno = self.gds_get_node_lineno_()
13371
                self.gds_collector_.add_message('Value "%(value)s"%(lineno)s is not of the correct base simple type (str)' % {"value": value, "lineno": lineno, })
13372
                return False
13373
            value = value
13374
            enumerations = ['black', 'blue', 'brown', 'cyan', 'green', 'grey', 'indigo', 'magenta', 'orange', 'pink', 'red', 'turquoise', 'violet', 'white', 'yellow', 'other']
13375
            if value not in enumerations:
13376
                lineno = self.gds_get_node_lineno_()
13377
                self.gds_collector_.add_message('Value "%(value)s"%(lineno)s does not match xsd enumeration restriction on ColourSimpleType' % {"value" : encode_str_2_3(value), "lineno": lineno} )
13378
                result = False
13379
    def has__content(self):
13380
        if (
13381
            super(SeparatorRegionType, self).has__content()
13382
        ):
13383
            return True
13384
        else:
13385
            return False
13386
    def export(self, outfile, level, namespaceprefix_='', namespacedef_='xmlns:pc="http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15"', name_='SeparatorRegionType', pretty_print=True):
13387
        imported_ns_def_ = GenerateDSNamespaceDefs_.get('SeparatorRegionType')
13388
        if imported_ns_def_ is not None:
13389
            namespacedef_ = imported_ns_def_
13390
        if pretty_print:
13391
            eol_ = '\n'
13392
        else:
13393
            eol_ = ''
13394
        if self.original_tagname_ is not None and name_ == 'SeparatorRegionType':
13395
            name_ = self.original_tagname_
13396
        if UseCapturedNS_ and self.ns_prefix_:
13397
            namespaceprefix_ = self.ns_prefix_ + ':'
13398
        showIndent(outfile, level, pretty_print)
13399
        outfile.write('<%s%s%s' % (namespaceprefix_, name_, namespacedef_ and ' ' + namespacedef_ or '', ))
13400
        already_processed = set()
13401
        self._exportAttributes(outfile, level, already_processed, namespaceprefix_, name_='SeparatorRegionType')
13402
        if self.has__content():
13403
            outfile.write('>%s' % (eol_, ))
13404
            self._exportChildren(outfile, level + 1, namespaceprefix_, namespacedef_, name_='SeparatorRegionType', pretty_print=pretty_print)
13405
            showIndent(outfile, level, pretty_print)
13406
            outfile.write('</%s%s>%s' % (namespaceprefix_, name_, eol_))
13407
        else:
13408
            outfile.write('/>%s' % (eol_, ))
13409
    def _exportAttributes(self, outfile, level, already_processed, namespaceprefix_='', name_='SeparatorRegionType'):
13410
        super(SeparatorRegionType, self)._exportAttributes(outfile, level, already_processed, namespaceprefix_, name_='SeparatorRegionType')
13411
        if self.orientation is not None and 'orientation' not in already_processed:
13412
            already_processed.add('orientation')
13413
            outfile.write(' orientation="%s"' % self.gds_format_float(self.orientation, input_name='orientation'))
13414
        if self.colour is not None and 'colour' not in already_processed:
13415
            already_processed.add('colour')
13416
            outfile.write(' colour=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.colour), input_name='colour')), ))
13417
    def _exportChildren(self, outfile, level, namespaceprefix_='', namespacedef_='xmlns:pc="http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15"', name_='SeparatorRegionType', fromsubclass_=False, pretty_print=True):
13418
        super(SeparatorRegionType, self)._exportChildren(outfile, level, namespaceprefix_, namespacedef_, name_, True, pretty_print=pretty_print)
13419
    def to_etree(self, parent_element=None, name_='SeparatorRegionType', mapping_=None, reverse_mapping_=None, nsmap_=None):
13420
        element = super(SeparatorRegionType, self).to_etree(parent_element, name_, mapping_, reverse_mapping_, nsmap_)
13421
        if self.orientation is not None:
13422
            element.set('orientation', self.gds_format_float(self.orientation))
13423
        if self.colour is not None:
13424
            element.set('colour', self.gds_format_string(self.colour))
13425
        if mapping_ is not None:
13426
            mapping_[id(self)] = element
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable id does not seem to be defined.
Loading history...
13427
        if reverse_mapping_ is not None:
13428
            reverse_mapping_[element] = self
13429
        return element
13430
    def build(self, node, gds_collector_=None):
13431
        self.gds_collector_ = gds_collector_
13432
        if SaveElementTreeNode:
13433
            self.gds_elementtree_node_ = node
13434
        already_processed = set()
13435
        self.ns_prefix_ = node.prefix
13436
        self._buildAttributes(node, node.attrib, already_processed)
13437
        for child in node:
13438
            nodeName_ = Tag_pattern_.match(child.tag).groups()[-1]
13439
            self._buildChildren(child, node, nodeName_, gds_collector_=gds_collector_)
13440
        return self
13441
    def _buildAttributes(self, node, attrs, already_processed):
13442
        value = find_attr_value_('orientation', node)
13443
        if value is not None and 'orientation' not in already_processed:
13444
            already_processed.add('orientation')
13445
            value = self.gds_parse_float(value, node, 'orientation')
13446
            self.orientation = value
13447
        value = find_attr_value_('colour', node)
13448
        if value is not None and 'colour' not in already_processed:
13449
            already_processed.add('colour')
13450
            self.colour = value
13451
            self.validate_ColourSimpleType(self.colour)    # validate type ColourSimpleType
13452
        super(SeparatorRegionType, self)._buildAttributes(node, attrs, already_processed)
13453
    def _buildChildren(self, child_, node, nodeName_, fromsubclass_=False, gds_collector_=None):
13454
        super(SeparatorRegionType, self)._buildChildren(child_, node, nodeName_, True)
13455
        pass
13456
    def __hash__(self):
13457
        return hash(self.id)
13458
    def set_orientation(self, orientation):
13459
        """
13460
        Set deskewing angle to given `orientation` number.
13461
        Moreover, invalidate self's ``pc:AlternativeImage``s
13462
        (because they will have been rotated and enlarged
13463
        with the angle of the previous value).
13464
        """
13465
        if hasattr(self, 'invalidate_AlternativeImage'):
13466
            # PageType, RegionType:
13467
            self.invalidate_AlternativeImage(feature_selector='deskewed')
13468
        self.orientation = orientation
13469
# end class SeparatorRegionType
13470
13471
13472
class ChartRegionType(RegionType):
13473
    """ChartRegionType --
13474
    Regions containing charts or graphs of any type, should
13475
    be marked as chart regions.
13476
      
13477
    * orientation --
13478
      The angle the rectangle encapsulating a region
13479
      has to be rotated in clockwise direction
13480
      in order to correct the present skew
13481
      (negative values indicate anti-clockwise rotation).
13482
      Range: -179.999,180
13483
      
13484
    * type --
13485
      The type of chart in the region
13486
      
13487
    * numColours --
13488
      An approximation of the number of colours
13489
      used in the region
13490
      
13491
    * bgColour --
13492
      The background colour of the region
13493
      
13494
    * embText --
13495
      Specifies whether the region also contains
13496
      text
13497
    
13498
    """
13499
    __hash__ = GeneratedsSuper.__hash__
13500
    member_data_items_ = [
13501
        MemberSpec_('orientation', 'float', 0, 1, {'use': 'optional', 'name': 'orientation'}),
13502
        MemberSpec_('type_', 'pc:ChartTypeSimpleType', 0, 1, {'use': 'optional', 'name': 'type_'}),
13503
        MemberSpec_('numColours', 'int', 0, 1, {'use': 'optional', 'name': 'numColours'}),
13504
        MemberSpec_('bgColour', 'pc:ColourSimpleType', 0, 1, {'use': 'optional', 'name': 'bgColour'}),
13505
        MemberSpec_('embText', 'boolean', 0, 1, {'use': 'optional', 'name': 'embText'}),
13506
    ]
13507
    subclass = None
13508
    superclass = RegionType
13509
    def __init__(self, id=None, custom=None, comments=None, continuation=None, AlternativeImage=None, Coords=None, UserDefined=None, Labels=None, Roles=None, TextRegion=None, ImageRegion=None, LineDrawingRegion=None, GraphicRegion=None, TableRegion=None, ChartRegion=None, SeparatorRegion=None, MathsRegion=None, ChemRegion=None, MusicRegion=None, AdvertRegion=None, NoiseRegion=None, UnknownRegion=None, CustomRegion=None, orientation=None, type_=None, numColours=None, bgColour=None, embText=None, gds_collector_=None, **kwargs_):
13510
        self.gds_collector_ = gds_collector_
13511
        self.gds_elementtree_node_ = None
13512
        self.original_tagname_ = None
13513
        self.parent_object_ = kwargs_.get('parent_object_')
13514
        self.ns_prefix_ = "pc"
13515
        super(globals().get("ChartRegionType"), self).__init__(id, custom, comments, continuation, AlternativeImage, Coords, UserDefined, Labels, Roles, TextRegion, ImageRegion, LineDrawingRegion, GraphicRegion, TableRegion, ChartRegion, SeparatorRegion, MathsRegion, ChemRegion, MusicRegion, AdvertRegion, NoiseRegion, UnknownRegion, CustomRegion,  **kwargs_)
13516
        self.orientation = _cast(float, orientation)
13517
        self.orientation_nsprefix_ = "pc"
13518
        self.type_ = _cast(None, type_)
13519
        self.type__nsprefix_ = "pc"
13520
        self.numColours = _cast(int, numColours)
13521
        self.numColours_nsprefix_ = "pc"
13522
        self.bgColour = _cast(None, bgColour)
13523
        self.bgColour_nsprefix_ = "pc"
13524
        self.embText = _cast(bool, embText)
13525
        self.embText_nsprefix_ = "pc"
13526
    def factory(*args_, **kwargs_):
13527
        if CurrentSubclassModule_ is not None:
13528
            subclass = getSubclassFromModule_(
13529
                CurrentSubclassModule_, ChartRegionType)
13530
            if subclass is not None:
13531
                return subclass(*args_, **kwargs_)
13532
        if ChartRegionType.subclass:
13533
            return ChartRegionType.subclass(*args_, **kwargs_)
13534
        else:
13535
            return ChartRegionType(*args_, **kwargs_)
13536
    factory = staticmethod(factory)
13537
    def get_ns_prefix_(self):
13538
        return self.ns_prefix_
13539
    def set_ns_prefix_(self, ns_prefix):
13540
        self.ns_prefix_ = ns_prefix
13541
    def get_orientation(self):
13542
        return self.orientation
13543
    def set_orientation(self, orientation):
13544
        self.orientation = orientation
13545
    def get_type(self):
13546
        return self.type_
13547
    def set_type(self, type_):
13548
        self.type_ = type_
13549
    def get_numColours(self):
13550
        return self.numColours
13551
    def set_numColours(self, numColours):
13552
        self.numColours = numColours
13553
    def get_bgColour(self):
13554
        return self.bgColour
13555
    def set_bgColour(self, bgColour):
13556
        self.bgColour = bgColour
13557
    def get_embText(self):
13558
        return self.embText
13559
    def set_embText(self, embText):
13560
        self.embText = embText
13561
    def validate_ChartTypeSimpleType(self, value):
13562
        # Validate type pc:ChartTypeSimpleType, a restriction on string.
13563
        if value is not None and Validate_simpletypes_ and self.gds_collector_ is not None:
13564
            if not isinstance(value, str):
13565
                lineno = self.gds_get_node_lineno_()
13566
                self.gds_collector_.add_message('Value "%(value)s"%(lineno)s is not of the correct base simple type (str)' % {"value": value, "lineno": lineno, })
13567
                return False
13568
            value = value
13569
            enumerations = ['bar', 'line', 'pie', 'scatter', 'surface', 'other']
13570
            if value not in enumerations:
13571
                lineno = self.gds_get_node_lineno_()
13572
                self.gds_collector_.add_message('Value "%(value)s"%(lineno)s does not match xsd enumeration restriction on ChartTypeSimpleType' % {"value" : encode_str_2_3(value), "lineno": lineno} )
13573
                result = False
13574
    def validate_ColourSimpleType(self, value):
13575
        # Validate type pc:ColourSimpleType, a restriction on string.
13576
        if value is not None and Validate_simpletypes_ and self.gds_collector_ is not None:
13577
            if not isinstance(value, str):
13578
                lineno = self.gds_get_node_lineno_()
13579
                self.gds_collector_.add_message('Value "%(value)s"%(lineno)s is not of the correct base simple type (str)' % {"value": value, "lineno": lineno, })
13580
                return False
13581
            value = value
13582
            enumerations = ['black', 'blue', 'brown', 'cyan', 'green', 'grey', 'indigo', 'magenta', 'orange', 'pink', 'red', 'turquoise', 'violet', 'white', 'yellow', 'other']
13583
            if value not in enumerations:
13584
                lineno = self.gds_get_node_lineno_()
13585
                self.gds_collector_.add_message('Value "%(value)s"%(lineno)s does not match xsd enumeration restriction on ColourSimpleType' % {"value" : encode_str_2_3(value), "lineno": lineno} )
13586
                result = False
13587
    def has__content(self):
13588
        if (
13589
            super(ChartRegionType, self).has__content()
13590
        ):
13591
            return True
13592
        else:
13593
            return False
13594
    def export(self, outfile, level, namespaceprefix_='', namespacedef_='xmlns:pc="http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15"', name_='ChartRegionType', pretty_print=True):
13595
        imported_ns_def_ = GenerateDSNamespaceDefs_.get('ChartRegionType')
13596
        if imported_ns_def_ is not None:
13597
            namespacedef_ = imported_ns_def_
13598
        if pretty_print:
13599
            eol_ = '\n'
13600
        else:
13601
            eol_ = ''
13602
        if self.original_tagname_ is not None and name_ == 'ChartRegionType':
13603
            name_ = self.original_tagname_
13604
        if UseCapturedNS_ and self.ns_prefix_:
13605
            namespaceprefix_ = self.ns_prefix_ + ':'
13606
        showIndent(outfile, level, pretty_print)
13607
        outfile.write('<%s%s%s' % (namespaceprefix_, name_, namespacedef_ and ' ' + namespacedef_ or '', ))
13608
        already_processed = set()
13609
        self._exportAttributes(outfile, level, already_processed, namespaceprefix_, name_='ChartRegionType')
13610
        if self.has__content():
13611
            outfile.write('>%s' % (eol_, ))
13612
            self._exportChildren(outfile, level + 1, namespaceprefix_, namespacedef_, name_='ChartRegionType', pretty_print=pretty_print)
13613
            showIndent(outfile, level, pretty_print)
13614
            outfile.write('</%s%s>%s' % (namespaceprefix_, name_, eol_))
13615
        else:
13616
            outfile.write('/>%s' % (eol_, ))
13617
    def _exportAttributes(self, outfile, level, already_processed, namespaceprefix_='', name_='ChartRegionType'):
13618
        super(ChartRegionType, self)._exportAttributes(outfile, level, already_processed, namespaceprefix_, name_='ChartRegionType')
13619
        if self.orientation is not None and 'orientation' not in already_processed:
13620
            already_processed.add('orientation')
13621
            outfile.write(' orientation="%s"' % self.gds_format_float(self.orientation, input_name='orientation'))
13622
        if self.type_ is not None and 'type_' not in already_processed:
13623
            already_processed.add('type_')
13624
            outfile.write(' type=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.type_), input_name='type')), ))
13625
        if self.numColours is not None and 'numColours' not in already_processed:
13626
            already_processed.add('numColours')
13627
            outfile.write(' numColours="%s"' % self.gds_format_integer(self.numColours, input_name='numColours'))
13628
        if self.bgColour is not None and 'bgColour' not in already_processed:
13629
            already_processed.add('bgColour')
13630
            outfile.write(' bgColour=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.bgColour), input_name='bgColour')), ))
13631
        if self.embText is not None and 'embText' not in already_processed:
13632
            already_processed.add('embText')
13633
            outfile.write(' embText="%s"' % self.gds_format_boolean(self.embText, input_name='embText'))
13634
    def _exportChildren(self, outfile, level, namespaceprefix_='', namespacedef_='xmlns:pc="http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15"', name_='ChartRegionType', fromsubclass_=False, pretty_print=True):
13635
        super(ChartRegionType, self)._exportChildren(outfile, level, namespaceprefix_, namespacedef_, name_, True, pretty_print=pretty_print)
13636
    def to_etree(self, parent_element=None, name_='ChartRegionType', mapping_=None, reverse_mapping_=None, nsmap_=None):
13637
        element = super(ChartRegionType, self).to_etree(parent_element, name_, mapping_, reverse_mapping_, nsmap_)
13638
        if self.orientation is not None:
13639
            element.set('orientation', self.gds_format_float(self.orientation))
13640
        if self.type_ is not None:
13641
            element.set('type', self.gds_format_string(self.type_))
13642
        if self.numColours is not None:
13643
            element.set('numColours', self.gds_format_integer(self.numColours))
13644
        if self.bgColour is not None:
13645
            element.set('bgColour', self.gds_format_string(self.bgColour))
13646
        if self.embText is not None:
13647
            element.set('embText', self.gds_format_boolean(self.embText))
13648
        if mapping_ is not None:
13649
            mapping_[id(self)] = element
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable id does not seem to be defined.
Loading history...
13650
        if reverse_mapping_ is not None:
13651
            reverse_mapping_[element] = self
13652
        return element
13653
    def build(self, node, gds_collector_=None):
13654
        self.gds_collector_ = gds_collector_
13655
        if SaveElementTreeNode:
13656
            self.gds_elementtree_node_ = node
13657
        already_processed = set()
13658
        self.ns_prefix_ = node.prefix
13659
        self._buildAttributes(node, node.attrib, already_processed)
13660
        for child in node:
13661
            nodeName_ = Tag_pattern_.match(child.tag).groups()[-1]
13662
            self._buildChildren(child, node, nodeName_, gds_collector_=gds_collector_)
13663
        return self
13664
    def _buildAttributes(self, node, attrs, already_processed):
13665
        value = find_attr_value_('orientation', node)
13666
        if value is not None and 'orientation' not in already_processed:
13667
            already_processed.add('orientation')
13668
            value = self.gds_parse_float(value, node, 'orientation')
13669
            self.orientation = value
13670
        value = find_attr_value_('type', node)
13671
        if value is not None and 'type' not in already_processed:
13672
            already_processed.add('type')
13673
            self.type_ = value
13674
            self.validate_ChartTypeSimpleType(self.type_)    # validate type ChartTypeSimpleType
13675
        value = find_attr_value_('numColours', node)
13676
        if value is not None and 'numColours' not in already_processed:
13677
            already_processed.add('numColours')
13678
            self.numColours = self.gds_parse_integer(value, node, 'numColours')
13679
        value = find_attr_value_('bgColour', node)
13680
        if value is not None and 'bgColour' not in already_processed:
13681
            already_processed.add('bgColour')
13682
            self.bgColour = value
13683
            self.validate_ColourSimpleType(self.bgColour)    # validate type ColourSimpleType
13684
        value = find_attr_value_('embText', node)
13685
        if value is not None and 'embText' not in already_processed:
13686
            already_processed.add('embText')
13687
            if value in ('true', '1'):
13688
                self.embText = True
13689
            elif value in ('false', '0'):
13690
                self.embText = False
13691
            else:
13692
                raise_parse_error(node, 'Bad boolean attribute')
13693
        super(ChartRegionType, self)._buildAttributes(node, attrs, already_processed)
13694
    def _buildChildren(self, child_, node, nodeName_, fromsubclass_=False, gds_collector_=None):
13695
        super(ChartRegionType, self)._buildChildren(child_, node, nodeName_, True)
13696
        pass
13697
    def __hash__(self):
13698
        return hash(self.id)
13699
    def set_orientation(self, orientation):
13700
        """
13701
        Set deskewing angle to given `orientation` number.
13702
        Moreover, invalidate self's ``pc:AlternativeImage``s
13703
        (because they will have been rotated and enlarged
13704
        with the angle of the previous value).
13705
        """
13706
        if hasattr(self, 'invalidate_AlternativeImage'):
13707
            # PageType, RegionType:
13708
            self.invalidate_AlternativeImage(feature_selector='deskewed')
13709
        self.orientation = orientation
13710
# end class ChartRegionType
13711
13712
13713
class TableRegionType(RegionType):
13714
    """TableRegionType --
13715
    Tabular data in any form is represented with a table
13716
    region. Rows and columns may or may not have separator
13717
    lines; these lines are not separator regions.
13718
      
13719
    * orientation --
13720
      The angle the rectangle encapsulating a	region
13721
      has to be rotated in clockwise direction
13722
      in order to correct the present	skew
13723
      (negative values indicate anti-clockwise rotation).
13724
      Range: -179.999,180
13725
      
13726
    * rows --
13727
      The number of rows present in the table
13728
      
13729
    * columns --
13730
      The number of columns present in the table
13731
      
13732
    * lineColour --
13733
      The colour of the lines used in the region
13734
      
13735
    * bgColour --
13736
      The background colour of the region
13737
      
13738
    * lineSeparators --
13739
      Specifies the presence of line separators
13740
      
13741
    * embText --
13742
      Specifies whether the region also contains
13743
      text
13744
      
13745
    * Grid -- Table grid (visible or virtual grid lines)
13746
    
13747
    """
13748
    __hash__ = GeneratedsSuper.__hash__
13749
    member_data_items_ = [
13750
        MemberSpec_('orientation', 'float', 0, 1, {'use': 'optional', 'name': 'orientation'}),
13751
        MemberSpec_('rows', 'int', 0, 1, {'use': 'optional', 'name': 'rows'}),
13752
        MemberSpec_('columns', 'int', 0, 1, {'use': 'optional', 'name': 'columns'}),
13753
        MemberSpec_('lineColour', 'pc:ColourSimpleType', 0, 1, {'use': 'optional', 'name': 'lineColour'}),
13754
        MemberSpec_('bgColour', 'pc:ColourSimpleType', 0, 1, {'use': 'optional', 'name': 'bgColour'}),
13755
        MemberSpec_('lineSeparators', 'boolean', 0, 1, {'use': 'optional', 'name': 'lineSeparators'}),
13756
        MemberSpec_('embText', 'boolean', 0, 1, {'use': 'optional', 'name': 'embText'}),
13757
        MemberSpec_('Grid', 'GridType', 0, 1, {'maxOccurs': '1', 'minOccurs': '0', 'name': 'Grid', 'type': 'GridType'}, None),
13758
    ]
13759
    subclass = None
13760
    superclass = RegionType
13761
    def __init__(self, id=None, custom=None, comments=None, continuation=None, AlternativeImage=None, Coords=None, UserDefined=None, Labels=None, Roles=None, TextRegion=None, ImageRegion=None, LineDrawingRegion=None, GraphicRegion=None, TableRegion=None, ChartRegion=None, SeparatorRegion=None, MathsRegion=None, ChemRegion=None, MusicRegion=None, AdvertRegion=None, NoiseRegion=None, UnknownRegion=None, CustomRegion=None, orientation=None, rows=None, columns=None, lineColour=None, bgColour=None, lineSeparators=None, embText=None, Grid=None, gds_collector_=None, **kwargs_):
13762
        self.gds_collector_ = gds_collector_
13763
        self.gds_elementtree_node_ = None
13764
        self.original_tagname_ = None
13765
        self.parent_object_ = kwargs_.get('parent_object_')
13766
        self.ns_prefix_ = "pc"
13767
        super(globals().get("TableRegionType"), self).__init__(id, custom, comments, continuation, AlternativeImage, Coords, UserDefined, Labels, Roles, TextRegion, ImageRegion, LineDrawingRegion, GraphicRegion, TableRegion, ChartRegion, SeparatorRegion, MathsRegion, ChemRegion, MusicRegion, AdvertRegion, NoiseRegion, UnknownRegion, CustomRegion,  **kwargs_)
13768
        self.orientation = _cast(float, orientation)
13769
        self.orientation_nsprefix_ = "pc"
13770
        self.rows = _cast(int, rows)
13771
        self.rows_nsprefix_ = "pc"
13772
        self.columns = _cast(int, columns)
13773
        self.columns_nsprefix_ = "pc"
13774
        self.lineColour = _cast(None, lineColour)
13775
        self.lineColour_nsprefix_ = "pc"
13776
        self.bgColour = _cast(None, bgColour)
13777
        self.bgColour_nsprefix_ = "pc"
13778
        self.lineSeparators = _cast(bool, lineSeparators)
13779
        self.lineSeparators_nsprefix_ = "pc"
13780
        self.embText = _cast(bool, embText)
13781
        self.embText_nsprefix_ = "pc"
13782
        self.Grid = Grid
13783
        self.Grid_nsprefix_ = "pc"
13784
    def factory(*args_, **kwargs_):
13785
        if CurrentSubclassModule_ is not None:
13786
            subclass = getSubclassFromModule_(
13787
                CurrentSubclassModule_, TableRegionType)
13788
            if subclass is not None:
13789
                return subclass(*args_, **kwargs_)
13790
        if TableRegionType.subclass:
13791
            return TableRegionType.subclass(*args_, **kwargs_)
13792
        else:
13793
            return TableRegionType(*args_, **kwargs_)
13794
    factory = staticmethod(factory)
13795
    def get_ns_prefix_(self):
13796
        return self.ns_prefix_
13797
    def set_ns_prefix_(self, ns_prefix):
13798
        self.ns_prefix_ = ns_prefix
13799
    def get_Grid(self):
13800
        return self.Grid
13801
    def set_Grid(self, Grid):
13802
        self.Grid = Grid
13803
    def get_orientation(self):
13804
        return self.orientation
13805
    def set_orientation(self, orientation):
13806
        self.orientation = orientation
13807
    def get_rows(self):
13808
        return self.rows
13809
    def set_rows(self, rows):
13810
        self.rows = rows
13811
    def get_columns(self):
13812
        return self.columns
13813
    def set_columns(self, columns):
13814
        self.columns = columns
13815
    def get_lineColour(self):
13816
        return self.lineColour
13817
    def set_lineColour(self, lineColour):
13818
        self.lineColour = lineColour
13819
    def get_bgColour(self):
13820
        return self.bgColour
13821
    def set_bgColour(self, bgColour):
13822
        self.bgColour = bgColour
13823
    def get_lineSeparators(self):
13824
        return self.lineSeparators
13825
    def set_lineSeparators(self, lineSeparators):
13826
        self.lineSeparators = lineSeparators
13827
    def get_embText(self):
13828
        return self.embText
13829
    def set_embText(self, embText):
13830
        self.embText = embText
13831
    def validate_ColourSimpleType(self, value):
13832
        # Validate type pc:ColourSimpleType, a restriction on string.
13833
        if value is not None and Validate_simpletypes_ and self.gds_collector_ is not None:
13834
            if not isinstance(value, str):
13835
                lineno = self.gds_get_node_lineno_()
13836
                self.gds_collector_.add_message('Value "%(value)s"%(lineno)s is not of the correct base simple type (str)' % {"value": value, "lineno": lineno, })
13837
                return False
13838
            value = value
13839
            enumerations = ['black', 'blue', 'brown', 'cyan', 'green', 'grey', 'indigo', 'magenta', 'orange', 'pink', 'red', 'turquoise', 'violet', 'white', 'yellow', 'other']
13840
            if value not in enumerations:
13841
                lineno = self.gds_get_node_lineno_()
13842
                self.gds_collector_.add_message('Value "%(value)s"%(lineno)s does not match xsd enumeration restriction on ColourSimpleType' % {"value" : encode_str_2_3(value), "lineno": lineno} )
13843
                result = False
13844
    def has__content(self):
13845
        if (
13846
            self.Grid is not None or
13847
            super(TableRegionType, self).has__content()
13848
        ):
13849
            return True
13850
        else:
13851
            return False
13852
    def export(self, outfile, level, namespaceprefix_='', namespacedef_='xmlns:pc="http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15"', name_='TableRegionType', pretty_print=True):
13853
        imported_ns_def_ = GenerateDSNamespaceDefs_.get('TableRegionType')
13854
        if imported_ns_def_ is not None:
13855
            namespacedef_ = imported_ns_def_
13856
        if pretty_print:
13857
            eol_ = '\n'
13858
        else:
13859
            eol_ = ''
13860
        if self.original_tagname_ is not None and name_ == 'TableRegionType':
13861
            name_ = self.original_tagname_
13862
        if UseCapturedNS_ and self.ns_prefix_:
13863
            namespaceprefix_ = self.ns_prefix_ + ':'
13864
        showIndent(outfile, level, pretty_print)
13865
        outfile.write('<%s%s%s' % (namespaceprefix_, name_, namespacedef_ and ' ' + namespacedef_ or '', ))
13866
        already_processed = set()
13867
        self._exportAttributes(outfile, level, already_processed, namespaceprefix_, name_='TableRegionType')
13868
        if self.has__content():
13869
            outfile.write('>%s' % (eol_, ))
13870
            self._exportChildren(outfile, level + 1, namespaceprefix_, namespacedef_, name_='TableRegionType', pretty_print=pretty_print)
13871
            showIndent(outfile, level, pretty_print)
13872
            outfile.write('</%s%s>%s' % (namespaceprefix_, name_, eol_))
13873
        else:
13874
            outfile.write('/>%s' % (eol_, ))
13875
    def _exportAttributes(self, outfile, level, already_processed, namespaceprefix_='', name_='TableRegionType'):
13876
        super(TableRegionType, self)._exportAttributes(outfile, level, already_processed, namespaceprefix_, name_='TableRegionType')
13877
        if self.orientation is not None and 'orientation' not in already_processed:
13878
            already_processed.add('orientation')
13879
            outfile.write(' orientation="%s"' % self.gds_format_float(self.orientation, input_name='orientation'))
13880
        if self.rows is not None and 'rows' not in already_processed:
13881
            already_processed.add('rows')
13882
            outfile.write(' rows="%s"' % self.gds_format_integer(self.rows, input_name='rows'))
13883
        if self.columns is not None and 'columns' not in already_processed:
13884
            already_processed.add('columns')
13885
            outfile.write(' columns="%s"' % self.gds_format_integer(self.columns, input_name='columns'))
13886
        if self.lineColour is not None and 'lineColour' not in already_processed:
13887
            already_processed.add('lineColour')
13888
            outfile.write(' lineColour=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.lineColour), input_name='lineColour')), ))
13889
        if self.bgColour is not None and 'bgColour' not in already_processed:
13890
            already_processed.add('bgColour')
13891
            outfile.write(' bgColour=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.bgColour), input_name='bgColour')), ))
13892
        if self.lineSeparators is not None and 'lineSeparators' not in already_processed:
13893
            already_processed.add('lineSeparators')
13894
            outfile.write(' lineSeparators="%s"' % self.gds_format_boolean(self.lineSeparators, input_name='lineSeparators'))
13895
        if self.embText is not None and 'embText' not in already_processed:
13896
            already_processed.add('embText')
13897
            outfile.write(' embText="%s"' % self.gds_format_boolean(self.embText, input_name='embText'))
13898
    def _exportChildren(self, outfile, level, namespaceprefix_='', namespacedef_='xmlns:pc="http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15"', name_='TableRegionType', fromsubclass_=False, pretty_print=True):
13899
        super(TableRegionType, self)._exportChildren(outfile, level, namespaceprefix_, namespacedef_, name_, True, pretty_print=pretty_print)
13900
        if pretty_print:
13901
            eol_ = '\n'
13902
        else:
13903
            eol_ = ''
13904
        if self.Grid is not None:
13905
            namespaceprefix_ = self.Grid_nsprefix_ + ':' if (UseCapturedNS_ and self.Grid_nsprefix_) else ''
13906
            self.Grid.export(outfile, level, namespaceprefix_, namespacedef_='', name_='Grid', pretty_print=pretty_print)
13907
    def to_etree(self, parent_element=None, name_='TableRegionType', mapping_=None, reverse_mapping_=None, nsmap_=None):
13908
        element = super(TableRegionType, self).to_etree(parent_element, name_, mapping_, reverse_mapping_, nsmap_)
13909
        if self.orientation is not None:
13910
            element.set('orientation', self.gds_format_float(self.orientation))
13911
        if self.rows is not None:
13912
            element.set('rows', self.gds_format_integer(self.rows))
13913
        if self.columns is not None:
13914
            element.set('columns', self.gds_format_integer(self.columns))
13915
        if self.lineColour is not None:
13916
            element.set('lineColour', self.gds_format_string(self.lineColour))
13917
        if self.bgColour is not None:
13918
            element.set('bgColour', self.gds_format_string(self.bgColour))
13919
        if self.lineSeparators is not None:
13920
            element.set('lineSeparators', self.gds_format_boolean(self.lineSeparators))
13921
        if self.embText is not None:
13922
            element.set('embText', self.gds_format_boolean(self.embText))
13923
        if self.Grid is not None:
13924
            Grid_ = self.Grid
13925
            Grid_.to_etree(element, name_='Grid', mapping_=mapping_, reverse_mapping_=reverse_mapping_, nsmap_=nsmap_)
13926
        if mapping_ is not None:
13927
            mapping_[id(self)] = element
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable id does not seem to be defined.
Loading history...
13928
        if reverse_mapping_ is not None:
13929
            reverse_mapping_[element] = self
13930
        return element
13931
    def build(self, node, gds_collector_=None):
13932
        self.gds_collector_ = gds_collector_
13933
        if SaveElementTreeNode:
13934
            self.gds_elementtree_node_ = node
13935
        already_processed = set()
13936
        self.ns_prefix_ = node.prefix
13937
        self._buildAttributes(node, node.attrib, already_processed)
13938
        for child in node:
13939
            nodeName_ = Tag_pattern_.match(child.tag).groups()[-1]
13940
            self._buildChildren(child, node, nodeName_, gds_collector_=gds_collector_)
13941
        return self
13942
    def _buildAttributes(self, node, attrs, already_processed):
13943
        value = find_attr_value_('orientation', node)
13944
        if value is not None and 'orientation' not in already_processed:
13945
            already_processed.add('orientation')
13946
            value = self.gds_parse_float(value, node, 'orientation')
13947
            self.orientation = value
13948
        value = find_attr_value_('rows', node)
13949
        if value is not None and 'rows' not in already_processed:
13950
            already_processed.add('rows')
13951
            self.rows = self.gds_parse_integer(value, node, 'rows')
13952
        value = find_attr_value_('columns', node)
13953
        if value is not None and 'columns' not in already_processed:
13954
            already_processed.add('columns')
13955
            self.columns = self.gds_parse_integer(value, node, 'columns')
13956
        value = find_attr_value_('lineColour', node)
13957
        if value is not None and 'lineColour' not in already_processed:
13958
            already_processed.add('lineColour')
13959
            self.lineColour = value
13960
            self.validate_ColourSimpleType(self.lineColour)    # validate type ColourSimpleType
13961
        value = find_attr_value_('bgColour', node)
13962
        if value is not None and 'bgColour' not in already_processed:
13963
            already_processed.add('bgColour')
13964
            self.bgColour = value
13965
            self.validate_ColourSimpleType(self.bgColour)    # validate type ColourSimpleType
13966
        value = find_attr_value_('lineSeparators', node)
13967
        if value is not None and 'lineSeparators' not in already_processed:
13968
            already_processed.add('lineSeparators')
13969
            if value in ('true', '1'):
13970
                self.lineSeparators = True
13971
            elif value in ('false', '0'):
13972
                self.lineSeparators = False
13973
            else:
13974
                raise_parse_error(node, 'Bad boolean attribute')
13975
        value = find_attr_value_('embText', node)
13976
        if value is not None and 'embText' not in already_processed:
13977
            already_processed.add('embText')
13978
            if value in ('true', '1'):
13979
                self.embText = True
13980
            elif value in ('false', '0'):
13981
                self.embText = False
13982
            else:
13983
                raise_parse_error(node, 'Bad boolean attribute')
13984
        super(TableRegionType, self)._buildAttributes(node, attrs, already_processed)
13985
    def _buildChildren(self, child_, node, nodeName_, fromsubclass_=False, gds_collector_=None):
13986
        if nodeName_ == 'Grid':
13987
            obj_ = GridType.factory(parent_object_=self)
13988
            obj_.build(child_, gds_collector_=gds_collector_)
13989
            self.Grid = obj_
13990
            obj_.original_tagname_ = 'Grid'
13991
        super(TableRegionType, self)._buildChildren(child_, node, nodeName_, True)
13992
    def __hash__(self):
13993
        return hash(self.id)
13994
    def set_orientation(self, orientation):
13995
        """
13996
        Set deskewing angle to given `orientation` number.
13997
        Moreover, invalidate self's ``pc:AlternativeImage``s
13998
        (because they will have been rotated and enlarged
13999
        with the angle of the previous value).
14000
        """
14001
        if hasattr(self, 'invalidate_AlternativeImage'):
14002
            # PageType, RegionType:
14003
            self.invalidate_AlternativeImage(feature_selector='deskewed')
14004
        self.orientation = orientation
14005
# end class TableRegionType
14006
14007
14008 View Code Duplication
class GraphicRegionType(RegionType):
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
14009
    """GraphicRegionType --
14010
    Regions containing simple graphics, such as a company
14011
    logo, should be marked as graphic regions.
14012
      
14013
    * orientation --
14014
      The angle the rectangle encapsulating a region
14015
      has to be rotated in clockwise direction
14016
      in order to correct the present skew
14017
      (negative values indicate anti-clockwise rotation).
14018
      Range: -179.999,180
14019
      
14020
    * type --
14021
      The type of graphic in the region
14022
      
14023
    * numColours --
14024
      An approximation of the number of colours
14025
      used in the region
14026
      
14027
    * embText --
14028
      Specifies whether the region also contains
14029
      text.
14030
    
14031
    """
14032
    __hash__ = GeneratedsSuper.__hash__
14033
    member_data_items_ = [
14034
        MemberSpec_('orientation', 'float', 0, 1, {'use': 'optional', 'name': 'orientation'}),
14035
        MemberSpec_('type_', 'pc:GraphicsTypeSimpleType', 0, 1, {'use': 'optional', 'name': 'type_'}),
14036
        MemberSpec_('numColours', 'int', 0, 1, {'use': 'optional', 'name': 'numColours'}),
14037
        MemberSpec_('embText', 'boolean', 0, 1, {'use': 'optional', 'name': 'embText'}),
14038
    ]
14039
    subclass = None
14040
    superclass = RegionType
14041
    def __init__(self, id=None, custom=None, comments=None, continuation=None, AlternativeImage=None, Coords=None, UserDefined=None, Labels=None, Roles=None, TextRegion=None, ImageRegion=None, LineDrawingRegion=None, GraphicRegion=None, TableRegion=None, ChartRegion=None, SeparatorRegion=None, MathsRegion=None, ChemRegion=None, MusicRegion=None, AdvertRegion=None, NoiseRegion=None, UnknownRegion=None, CustomRegion=None, orientation=None, type_=None, numColours=None, embText=None, gds_collector_=None, **kwargs_):
14042
        self.gds_collector_ = gds_collector_
14043
        self.gds_elementtree_node_ = None
14044
        self.original_tagname_ = None
14045
        self.parent_object_ = kwargs_.get('parent_object_')
14046
        self.ns_prefix_ = "pc"
14047
        super(globals().get("GraphicRegionType"), self).__init__(id, custom, comments, continuation, AlternativeImage, Coords, UserDefined, Labels, Roles, TextRegion, ImageRegion, LineDrawingRegion, GraphicRegion, TableRegion, ChartRegion, SeparatorRegion, MathsRegion, ChemRegion, MusicRegion, AdvertRegion, NoiseRegion, UnknownRegion, CustomRegion,  **kwargs_)
14048
        self.orientation = _cast(float, orientation)
14049
        self.orientation_nsprefix_ = "pc"
14050
        self.type_ = _cast(None, type_)
14051
        self.type__nsprefix_ = "pc"
14052
        self.numColours = _cast(int, numColours)
14053
        self.numColours_nsprefix_ = "pc"
14054
        self.embText = _cast(bool, embText)
14055
        self.embText_nsprefix_ = "pc"
14056
    def factory(*args_, **kwargs_):
14057
        if CurrentSubclassModule_ is not None:
14058
            subclass = getSubclassFromModule_(
14059
                CurrentSubclassModule_, GraphicRegionType)
14060
            if subclass is not None:
14061
                return subclass(*args_, **kwargs_)
14062
        if GraphicRegionType.subclass:
14063
            return GraphicRegionType.subclass(*args_, **kwargs_)
14064
        else:
14065
            return GraphicRegionType(*args_, **kwargs_)
14066
    factory = staticmethod(factory)
14067
    def get_ns_prefix_(self):
14068
        return self.ns_prefix_
14069
    def set_ns_prefix_(self, ns_prefix):
14070
        self.ns_prefix_ = ns_prefix
14071
    def get_orientation(self):
14072
        return self.orientation
14073
    def set_orientation(self, orientation):
14074
        self.orientation = orientation
14075
    def get_type(self):
14076
        return self.type_
14077
    def set_type(self, type_):
14078
        self.type_ = type_
14079
    def get_numColours(self):
14080
        return self.numColours
14081
    def set_numColours(self, numColours):
14082
        self.numColours = numColours
14083
    def get_embText(self):
14084
        return self.embText
14085
    def set_embText(self, embText):
14086
        self.embText = embText
14087
    def validate_GraphicsTypeSimpleType(self, value):
14088
        # Validate type pc:GraphicsTypeSimpleType, a restriction on string.
14089
        if value is not None and Validate_simpletypes_ and self.gds_collector_ is not None:
14090
            if not isinstance(value, str):
14091
                lineno = self.gds_get_node_lineno_()
14092
                self.gds_collector_.add_message('Value "%(value)s"%(lineno)s is not of the correct base simple type (str)' % {"value": value, "lineno": lineno, })
14093
                return False
14094
            value = value
14095
            enumerations = ['logo', 'letterhead', 'decoration', 'frame', 'handwritten-annotation', 'stamp', 'signature', 'barcode', 'paper-grow', 'punch-hole', 'other']
14096
            if value not in enumerations:
14097
                lineno = self.gds_get_node_lineno_()
14098
                self.gds_collector_.add_message('Value "%(value)s"%(lineno)s does not match xsd enumeration restriction on GraphicsTypeSimpleType' % {"value" : encode_str_2_3(value), "lineno": lineno} )
14099
                result = False
14100
    def has__content(self):
14101
        if (
14102
            super(GraphicRegionType, self).has__content()
14103
        ):
14104
            return True
14105
        else:
14106
            return False
14107
    def export(self, outfile, level, namespaceprefix_='', namespacedef_='xmlns:pc="http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15"', name_='GraphicRegionType', pretty_print=True):
14108
        imported_ns_def_ = GenerateDSNamespaceDefs_.get('GraphicRegionType')
14109
        if imported_ns_def_ is not None:
14110
            namespacedef_ = imported_ns_def_
14111
        if pretty_print:
14112
            eol_ = '\n'
14113
        else:
14114
            eol_ = ''
14115
        if self.original_tagname_ is not None and name_ == 'GraphicRegionType':
14116
            name_ = self.original_tagname_
14117
        if UseCapturedNS_ and self.ns_prefix_:
14118
            namespaceprefix_ = self.ns_prefix_ + ':'
14119
        showIndent(outfile, level, pretty_print)
14120
        outfile.write('<%s%s%s' % (namespaceprefix_, name_, namespacedef_ and ' ' + namespacedef_ or '', ))
14121
        already_processed = set()
14122
        self._exportAttributes(outfile, level, already_processed, namespaceprefix_, name_='GraphicRegionType')
14123
        if self.has__content():
14124
            outfile.write('>%s' % (eol_, ))
14125
            self._exportChildren(outfile, level + 1, namespaceprefix_, namespacedef_, name_='GraphicRegionType', pretty_print=pretty_print)
14126
            showIndent(outfile, level, pretty_print)
14127
            outfile.write('</%s%s>%s' % (namespaceprefix_, name_, eol_))
14128
        else:
14129
            outfile.write('/>%s' % (eol_, ))
14130
    def _exportAttributes(self, outfile, level, already_processed, namespaceprefix_='', name_='GraphicRegionType'):
14131
        super(GraphicRegionType, self)._exportAttributes(outfile, level, already_processed, namespaceprefix_, name_='GraphicRegionType')
14132
        if self.orientation is not None and 'orientation' not in already_processed:
14133
            already_processed.add('orientation')
14134
            outfile.write(' orientation="%s"' % self.gds_format_float(self.orientation, input_name='orientation'))
14135
        if self.type_ is not None and 'type_' not in already_processed:
14136
            already_processed.add('type_')
14137
            outfile.write(' type=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.type_), input_name='type')), ))
14138
        if self.numColours is not None and 'numColours' not in already_processed:
14139
            already_processed.add('numColours')
14140
            outfile.write(' numColours="%s"' % self.gds_format_integer(self.numColours, input_name='numColours'))
14141
        if self.embText is not None and 'embText' not in already_processed:
14142
            already_processed.add('embText')
14143
            outfile.write(' embText="%s"' % self.gds_format_boolean(self.embText, input_name='embText'))
14144
    def _exportChildren(self, outfile, level, namespaceprefix_='', namespacedef_='xmlns:pc="http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15"', name_='GraphicRegionType', fromsubclass_=False, pretty_print=True):
14145
        super(GraphicRegionType, self)._exportChildren(outfile, level, namespaceprefix_, namespacedef_, name_, True, pretty_print=pretty_print)
14146
    def to_etree(self, parent_element=None, name_='GraphicRegionType', mapping_=None, reverse_mapping_=None, nsmap_=None):
14147
        element = super(GraphicRegionType, self).to_etree(parent_element, name_, mapping_, reverse_mapping_, nsmap_)
14148
        if self.orientation is not None:
14149
            element.set('orientation', self.gds_format_float(self.orientation))
14150
        if self.type_ is not None:
14151
            element.set('type', self.gds_format_string(self.type_))
14152
        if self.numColours is not None:
14153
            element.set('numColours', self.gds_format_integer(self.numColours))
14154
        if self.embText is not None:
14155
            element.set('embText', self.gds_format_boolean(self.embText))
14156
        if mapping_ is not None:
14157
            mapping_[id(self)] = element
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable id does not seem to be defined.
Loading history...
14158
        if reverse_mapping_ is not None:
14159
            reverse_mapping_[element] = self
14160
        return element
14161
    def build(self, node, gds_collector_=None):
14162
        self.gds_collector_ = gds_collector_
14163
        if SaveElementTreeNode:
14164
            self.gds_elementtree_node_ = node
14165
        already_processed = set()
14166
        self.ns_prefix_ = node.prefix
14167
        self._buildAttributes(node, node.attrib, already_processed)
14168
        for child in node:
14169
            nodeName_ = Tag_pattern_.match(child.tag).groups()[-1]
14170
            self._buildChildren(child, node, nodeName_, gds_collector_=gds_collector_)
14171
        return self
14172
    def _buildAttributes(self, node, attrs, already_processed):
14173
        value = find_attr_value_('orientation', node)
14174
        if value is not None and 'orientation' not in already_processed:
14175
            already_processed.add('orientation')
14176
            value = self.gds_parse_float(value, node, 'orientation')
14177
            self.orientation = value
14178
        value = find_attr_value_('type', node)
14179
        if value is not None and 'type' not in already_processed:
14180
            already_processed.add('type')
14181
            self.type_ = value
14182
            self.validate_GraphicsTypeSimpleType(self.type_)    # validate type GraphicsTypeSimpleType
14183
        value = find_attr_value_('numColours', node)
14184
        if value is not None and 'numColours' not in already_processed:
14185
            already_processed.add('numColours')
14186
            self.numColours = self.gds_parse_integer(value, node, 'numColours')
14187
        value = find_attr_value_('embText', node)
14188
        if value is not None and 'embText' not in already_processed:
14189
            already_processed.add('embText')
14190
            if value in ('true', '1'):
14191
                self.embText = True
14192
            elif value in ('false', '0'):
14193
                self.embText = False
14194
            else:
14195
                raise_parse_error(node, 'Bad boolean attribute')
14196
        super(GraphicRegionType, self)._buildAttributes(node, attrs, already_processed)
14197
    def _buildChildren(self, child_, node, nodeName_, fromsubclass_=False, gds_collector_=None):
14198
        super(GraphicRegionType, self)._buildChildren(child_, node, nodeName_, True)
14199
        pass
14200
    def __hash__(self):
14201
        return hash(self.id)
14202
    def set_orientation(self, orientation):
14203
        """
14204
        Set deskewing angle to given `orientation` number.
14205
        Moreover, invalidate self's ``pc:AlternativeImage``s
14206
        (because they will have been rotated and enlarged
14207
        with the angle of the previous value).
14208
        """
14209
        if hasattr(self, 'invalidate_AlternativeImage'):
14210
            # PageType, RegionType:
14211
            self.invalidate_AlternativeImage(feature_selector='deskewed')
14212
        self.orientation = orientation
14213
# end class GraphicRegionType
14214
14215
14216 View Code Duplication
class LineDrawingRegionType(RegionType):
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
14217
    """LineDrawingRegionType --
14218
    A line drawing is a single colour illustration without
14219
    solid areas.
14220
      
14221
    * orientation --
14222
      The angle the rectangle encapsulating a region
14223
      has to be rotated in clockwise direction
14224
      in order to correct the present skew
14225
      (negative values indicate anti-clockwise rotation).
14226
      Range: -179.999,180
14227
      
14228
    * penColour --
14229
      The pen (foreground) colour of the region
14230
      
14231
    * bgColour --
14232
      The background colour of the region
14233
      
14234
    * embText --
14235
      Specifies whether the region also contains
14236
      text
14237
    
14238
    """
14239
    __hash__ = GeneratedsSuper.__hash__
14240
    member_data_items_ = [
14241
        MemberSpec_('orientation', 'float', 0, 1, {'use': 'optional', 'name': 'orientation'}),
14242
        MemberSpec_('penColour', 'pc:ColourSimpleType', 0, 1, {'use': 'optional', 'name': 'penColour'}),
14243
        MemberSpec_('bgColour', 'pc:ColourSimpleType', 0, 1, {'use': 'optional', 'name': 'bgColour'}),
14244
        MemberSpec_('embText', 'boolean', 0, 1, {'use': 'optional', 'name': 'embText'}),
14245
    ]
14246
    subclass = None
14247
    superclass = RegionType
14248
    def __init__(self, id=None, custom=None, comments=None, continuation=None, AlternativeImage=None, Coords=None, UserDefined=None, Labels=None, Roles=None, TextRegion=None, ImageRegion=None, LineDrawingRegion=None, GraphicRegion=None, TableRegion=None, ChartRegion=None, SeparatorRegion=None, MathsRegion=None, ChemRegion=None, MusicRegion=None, AdvertRegion=None, NoiseRegion=None, UnknownRegion=None, CustomRegion=None, orientation=None, penColour=None, bgColour=None, embText=None, gds_collector_=None, **kwargs_):
14249
        self.gds_collector_ = gds_collector_
14250
        self.gds_elementtree_node_ = None
14251
        self.original_tagname_ = None
14252
        self.parent_object_ = kwargs_.get('parent_object_')
14253
        self.ns_prefix_ = "pc"
14254
        super(globals().get("LineDrawingRegionType"), self).__init__(id, custom, comments, continuation, AlternativeImage, Coords, UserDefined, Labels, Roles, TextRegion, ImageRegion, LineDrawingRegion, GraphicRegion, TableRegion, ChartRegion, SeparatorRegion, MathsRegion, ChemRegion, MusicRegion, AdvertRegion, NoiseRegion, UnknownRegion, CustomRegion,  **kwargs_)
14255
        self.orientation = _cast(float, orientation)
14256
        self.orientation_nsprefix_ = "pc"
14257
        self.penColour = _cast(None, penColour)
14258
        self.penColour_nsprefix_ = "pc"
14259
        self.bgColour = _cast(None, bgColour)
14260
        self.bgColour_nsprefix_ = "pc"
14261
        self.embText = _cast(bool, embText)
14262
        self.embText_nsprefix_ = "pc"
14263
    def factory(*args_, **kwargs_):
14264
        if CurrentSubclassModule_ is not None:
14265
            subclass = getSubclassFromModule_(
14266
                CurrentSubclassModule_, LineDrawingRegionType)
14267
            if subclass is not None:
14268
                return subclass(*args_, **kwargs_)
14269
        if LineDrawingRegionType.subclass:
14270
            return LineDrawingRegionType.subclass(*args_, **kwargs_)
14271
        else:
14272
            return LineDrawingRegionType(*args_, **kwargs_)
14273
    factory = staticmethod(factory)
14274
    def get_ns_prefix_(self):
14275
        return self.ns_prefix_
14276
    def set_ns_prefix_(self, ns_prefix):
14277
        self.ns_prefix_ = ns_prefix
14278
    def get_orientation(self):
14279
        return self.orientation
14280
    def set_orientation(self, orientation):
14281
        self.orientation = orientation
14282
    def get_penColour(self):
14283
        return self.penColour
14284
    def set_penColour(self, penColour):
14285
        self.penColour = penColour
14286
    def get_bgColour(self):
14287
        return self.bgColour
14288
    def set_bgColour(self, bgColour):
14289
        self.bgColour = bgColour
14290
    def get_embText(self):
14291
        return self.embText
14292
    def set_embText(self, embText):
14293
        self.embText = embText
14294
    def validate_ColourSimpleType(self, value):
14295
        # Validate type pc:ColourSimpleType, a restriction on string.
14296
        if value is not None and Validate_simpletypes_ and self.gds_collector_ is not None:
14297
            if not isinstance(value, str):
14298
                lineno = self.gds_get_node_lineno_()
14299
                self.gds_collector_.add_message('Value "%(value)s"%(lineno)s is not of the correct base simple type (str)' % {"value": value, "lineno": lineno, })
14300
                return False
14301
            value = value
14302
            enumerations = ['black', 'blue', 'brown', 'cyan', 'green', 'grey', 'indigo', 'magenta', 'orange', 'pink', 'red', 'turquoise', 'violet', 'white', 'yellow', 'other']
14303
            if value not in enumerations:
14304
                lineno = self.gds_get_node_lineno_()
14305
                self.gds_collector_.add_message('Value "%(value)s"%(lineno)s does not match xsd enumeration restriction on ColourSimpleType' % {"value" : encode_str_2_3(value), "lineno": lineno} )
14306
                result = False
14307
    def has__content(self):
14308
        if (
14309
            super(LineDrawingRegionType, self).has__content()
14310
        ):
14311
            return True
14312
        else:
14313
            return False
14314
    def export(self, outfile, level, namespaceprefix_='', namespacedef_='xmlns:pc="http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15"', name_='LineDrawingRegionType', pretty_print=True):
14315
        imported_ns_def_ = GenerateDSNamespaceDefs_.get('LineDrawingRegionType')
14316
        if imported_ns_def_ is not None:
14317
            namespacedef_ = imported_ns_def_
14318
        if pretty_print:
14319
            eol_ = '\n'
14320
        else:
14321
            eol_ = ''
14322
        if self.original_tagname_ is not None and name_ == 'LineDrawingRegionType':
14323
            name_ = self.original_tagname_
14324
        if UseCapturedNS_ and self.ns_prefix_:
14325
            namespaceprefix_ = self.ns_prefix_ + ':'
14326
        showIndent(outfile, level, pretty_print)
14327
        outfile.write('<%s%s%s' % (namespaceprefix_, name_, namespacedef_ and ' ' + namespacedef_ or '', ))
14328
        already_processed = set()
14329
        self._exportAttributes(outfile, level, already_processed, namespaceprefix_, name_='LineDrawingRegionType')
14330
        if self.has__content():
14331
            outfile.write('>%s' % (eol_, ))
14332
            self._exportChildren(outfile, level + 1, namespaceprefix_, namespacedef_, name_='LineDrawingRegionType', pretty_print=pretty_print)
14333
            showIndent(outfile, level, pretty_print)
14334
            outfile.write('</%s%s>%s' % (namespaceprefix_, name_, eol_))
14335
        else:
14336
            outfile.write('/>%s' % (eol_, ))
14337
    def _exportAttributes(self, outfile, level, already_processed, namespaceprefix_='', name_='LineDrawingRegionType'):
14338
        super(LineDrawingRegionType, self)._exportAttributes(outfile, level, already_processed, namespaceprefix_, name_='LineDrawingRegionType')
14339
        if self.orientation is not None and 'orientation' not in already_processed:
14340
            already_processed.add('orientation')
14341
            outfile.write(' orientation="%s"' % self.gds_format_float(self.orientation, input_name='orientation'))
14342
        if self.penColour is not None and 'penColour' not in already_processed:
14343
            already_processed.add('penColour')
14344
            outfile.write(' penColour=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.penColour), input_name='penColour')), ))
14345
        if self.bgColour is not None and 'bgColour' not in already_processed:
14346
            already_processed.add('bgColour')
14347
            outfile.write(' bgColour=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.bgColour), input_name='bgColour')), ))
14348
        if self.embText is not None and 'embText' not in already_processed:
14349
            already_processed.add('embText')
14350
            outfile.write(' embText="%s"' % self.gds_format_boolean(self.embText, input_name='embText'))
14351
    def _exportChildren(self, outfile, level, namespaceprefix_='', namespacedef_='xmlns:pc="http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15"', name_='LineDrawingRegionType', fromsubclass_=False, pretty_print=True):
14352
        super(LineDrawingRegionType, self)._exportChildren(outfile, level, namespaceprefix_, namespacedef_, name_, True, pretty_print=pretty_print)
14353
    def to_etree(self, parent_element=None, name_='LineDrawingRegionType', mapping_=None, reverse_mapping_=None, nsmap_=None):
14354
        element = super(LineDrawingRegionType, self).to_etree(parent_element, name_, mapping_, reverse_mapping_, nsmap_)
14355
        if self.orientation is not None:
14356
            element.set('orientation', self.gds_format_float(self.orientation))
14357
        if self.penColour is not None:
14358
            element.set('penColour', self.gds_format_string(self.penColour))
14359
        if self.bgColour is not None:
14360
            element.set('bgColour', self.gds_format_string(self.bgColour))
14361
        if self.embText is not None:
14362
            element.set('embText', self.gds_format_boolean(self.embText))
14363
        if mapping_ is not None:
14364
            mapping_[id(self)] = element
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable id does not seem to be defined.
Loading history...
14365
        if reverse_mapping_ is not None:
14366
            reverse_mapping_[element] = self
14367
        return element
14368
    def build(self, node, gds_collector_=None):
14369
        self.gds_collector_ = gds_collector_
14370
        if SaveElementTreeNode:
14371
            self.gds_elementtree_node_ = node
14372
        already_processed = set()
14373
        self.ns_prefix_ = node.prefix
14374
        self._buildAttributes(node, node.attrib, already_processed)
14375
        for child in node:
14376
            nodeName_ = Tag_pattern_.match(child.tag).groups()[-1]
14377
            self._buildChildren(child, node, nodeName_, gds_collector_=gds_collector_)
14378
        return self
14379
    def _buildAttributes(self, node, attrs, already_processed):
14380
        value = find_attr_value_('orientation', node)
14381
        if value is not None and 'orientation' not in already_processed:
14382
            already_processed.add('orientation')
14383
            value = self.gds_parse_float(value, node, 'orientation')
14384
            self.orientation = value
14385
        value = find_attr_value_('penColour', node)
14386
        if value is not None and 'penColour' not in already_processed:
14387
            already_processed.add('penColour')
14388
            self.penColour = value
14389
            self.validate_ColourSimpleType(self.penColour)    # validate type ColourSimpleType
14390
        value = find_attr_value_('bgColour', node)
14391
        if value is not None and 'bgColour' not in already_processed:
14392
            already_processed.add('bgColour')
14393
            self.bgColour = value
14394
            self.validate_ColourSimpleType(self.bgColour)    # validate type ColourSimpleType
14395
        value = find_attr_value_('embText', node)
14396
        if value is not None and 'embText' not in already_processed:
14397
            already_processed.add('embText')
14398
            if value in ('true', '1'):
14399
                self.embText = True
14400
            elif value in ('false', '0'):
14401
                self.embText = False
14402
            else:
14403
                raise_parse_error(node, 'Bad boolean attribute')
14404
        super(LineDrawingRegionType, self)._buildAttributes(node, attrs, already_processed)
14405
    def _buildChildren(self, child_, node, nodeName_, fromsubclass_=False, gds_collector_=None):
14406
        super(LineDrawingRegionType, self)._buildChildren(child_, node, nodeName_, True)
14407
        pass
14408
    def __hash__(self):
14409
        return hash(self.id)
14410
    def set_orientation(self, orientation):
14411
        """
14412
        Set deskewing angle to given `orientation` number.
14413
        Moreover, invalidate self's ``pc:AlternativeImage``s
14414
        (because they will have been rotated and enlarged
14415
        with the angle of the previous value).
14416
        """
14417
        if hasattr(self, 'invalidate_AlternativeImage'):
14418
            # PageType, RegionType:
14419
            self.invalidate_AlternativeImage(feature_selector='deskewed')
14420
        self.orientation = orientation
14421
# end class LineDrawingRegionType
14422
14423
14424
class ImageRegionType(RegionType):
14425
    """ImageRegionType --
14426
    An image is considered to be more intricate and complex
14427
    than a graphic. These can be photos or drawings.
14428
      
14429
    * orientation --
14430
      The angle the rectangle encapsulating a region
14431
      has to be rotated in clockwise direction
14432
      in order to correct the present skew
14433
      (negative values indicate anti-clockwise rotation).
14434
      Range: -179.999,180
14435
      
14436
    * colourDepth --
14437
      The colour bit depth required for the region
14438
      
14439
    * bgColour --
14440
      The background colour of the region
14441
      
14442
    * embText --
14443
      Specifies whether the region also contains
14444
      text
14445
    
14446
    """
14447
    __hash__ = GeneratedsSuper.__hash__
14448
    member_data_items_ = [
14449
        MemberSpec_('orientation', 'float', 0, 1, {'use': 'optional', 'name': 'orientation'}),
14450
        MemberSpec_('colourDepth', 'pc:ColourDepthSimpleType', 0, 1, {'use': 'optional', 'name': 'colourDepth'}),
14451
        MemberSpec_('bgColour', 'pc:ColourSimpleType', 0, 1, {'use': 'optional', 'name': 'bgColour'}),
14452
        MemberSpec_('embText', 'boolean', 0, 1, {'use': 'optional', 'name': 'embText'}),
14453
    ]
14454
    subclass = None
14455
    superclass = RegionType
14456
    def __init__(self, id=None, custom=None, comments=None, continuation=None, AlternativeImage=None, Coords=None, UserDefined=None, Labels=None, Roles=None, TextRegion=None, ImageRegion=None, LineDrawingRegion=None, GraphicRegion=None, TableRegion=None, ChartRegion=None, SeparatorRegion=None, MathsRegion=None, ChemRegion=None, MusicRegion=None, AdvertRegion=None, NoiseRegion=None, UnknownRegion=None, CustomRegion=None, orientation=None, colourDepth=None, bgColour=None, embText=None, gds_collector_=None, **kwargs_):
14457
        self.gds_collector_ = gds_collector_
14458
        self.gds_elementtree_node_ = None
14459
        self.original_tagname_ = None
14460
        self.parent_object_ = kwargs_.get('parent_object_')
14461
        self.ns_prefix_ = "pc"
14462
        super(globals().get("ImageRegionType"), self).__init__(id, custom, comments, continuation, AlternativeImage, Coords, UserDefined, Labels, Roles, TextRegion, ImageRegion, LineDrawingRegion, GraphicRegion, TableRegion, ChartRegion, SeparatorRegion, MathsRegion, ChemRegion, MusicRegion, AdvertRegion, NoiseRegion, UnknownRegion, CustomRegion,  **kwargs_)
14463
        self.orientation = _cast(float, orientation)
14464
        self.orientation_nsprefix_ = "pc"
14465
        self.colourDepth = _cast(None, colourDepth)
14466
        self.colourDepth_nsprefix_ = "pc"
14467
        self.bgColour = _cast(None, bgColour)
14468
        self.bgColour_nsprefix_ = "pc"
14469
        self.embText = _cast(bool, embText)
14470
        self.embText_nsprefix_ = "pc"
14471
    def factory(*args_, **kwargs_):
14472
        if CurrentSubclassModule_ is not None:
14473
            subclass = getSubclassFromModule_(
14474
                CurrentSubclassModule_, ImageRegionType)
14475
            if subclass is not None:
14476
                return subclass(*args_, **kwargs_)
14477
        if ImageRegionType.subclass:
14478
            return ImageRegionType.subclass(*args_, **kwargs_)
14479
        else:
14480
            return ImageRegionType(*args_, **kwargs_)
14481
    factory = staticmethod(factory)
14482
    def get_ns_prefix_(self):
14483
        return self.ns_prefix_
14484
    def set_ns_prefix_(self, ns_prefix):
14485
        self.ns_prefix_ = ns_prefix
14486
    def get_orientation(self):
14487
        return self.orientation
14488
    def set_orientation(self, orientation):
14489
        self.orientation = orientation
14490
    def get_colourDepth(self):
14491
        return self.colourDepth
14492
    def set_colourDepth(self, colourDepth):
14493
        self.colourDepth = colourDepth
14494
    def get_bgColour(self):
14495
        return self.bgColour
14496
    def set_bgColour(self, bgColour):
14497
        self.bgColour = bgColour
14498
    def get_embText(self):
14499
        return self.embText
14500
    def set_embText(self, embText):
14501
        self.embText = embText
14502
    def validate_ColourDepthSimpleType(self, value):
14503
        # Validate type pc:ColourDepthSimpleType, a restriction on string.
14504
        if value is not None and Validate_simpletypes_ and self.gds_collector_ is not None:
14505
            if not isinstance(value, str):
14506
                lineno = self.gds_get_node_lineno_()
14507
                self.gds_collector_.add_message('Value "%(value)s"%(lineno)s is not of the correct base simple type (str)' % {"value": value, "lineno": lineno, })
14508
                return False
14509
            value = value
14510
            enumerations = ['bilevel', 'greyscale', 'colour', 'other']
14511
            if value not in enumerations:
14512
                lineno = self.gds_get_node_lineno_()
14513
                self.gds_collector_.add_message('Value "%(value)s"%(lineno)s does not match xsd enumeration restriction on ColourDepthSimpleType' % {"value" : encode_str_2_3(value), "lineno": lineno} )
14514
                result = False
14515
    def validate_ColourSimpleType(self, value):
14516
        # Validate type pc:ColourSimpleType, a restriction on string.
14517
        if value is not None and Validate_simpletypes_ and self.gds_collector_ is not None:
14518
            if not isinstance(value, str):
14519
                lineno = self.gds_get_node_lineno_()
14520
                self.gds_collector_.add_message('Value "%(value)s"%(lineno)s is not of the correct base simple type (str)' % {"value": value, "lineno": lineno, })
14521
                return False
14522
            value = value
14523
            enumerations = ['black', 'blue', 'brown', 'cyan', 'green', 'grey', 'indigo', 'magenta', 'orange', 'pink', 'red', 'turquoise', 'violet', 'white', 'yellow', 'other']
14524
            if value not in enumerations:
14525
                lineno = self.gds_get_node_lineno_()
14526
                self.gds_collector_.add_message('Value "%(value)s"%(lineno)s does not match xsd enumeration restriction on ColourSimpleType' % {"value" : encode_str_2_3(value), "lineno": lineno} )
14527
                result = False
14528
    def has__content(self):
14529
        if (
14530
            super(ImageRegionType, self).has__content()
14531
        ):
14532
            return True
14533
        else:
14534
            return False
14535
    def export(self, outfile, level, namespaceprefix_='', namespacedef_='xmlns:pc="http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15"', name_='ImageRegionType', pretty_print=True):
14536
        imported_ns_def_ = GenerateDSNamespaceDefs_.get('ImageRegionType')
14537
        if imported_ns_def_ is not None:
14538
            namespacedef_ = imported_ns_def_
14539
        if pretty_print:
14540
            eol_ = '\n'
14541
        else:
14542
            eol_ = ''
14543
        if self.original_tagname_ is not None and name_ == 'ImageRegionType':
14544
            name_ = self.original_tagname_
14545
        if UseCapturedNS_ and self.ns_prefix_:
14546
            namespaceprefix_ = self.ns_prefix_ + ':'
14547
        showIndent(outfile, level, pretty_print)
14548
        outfile.write('<%s%s%s' % (namespaceprefix_, name_, namespacedef_ and ' ' + namespacedef_ or '', ))
14549
        already_processed = set()
14550
        self._exportAttributes(outfile, level, already_processed, namespaceprefix_, name_='ImageRegionType')
14551
        if self.has__content():
14552
            outfile.write('>%s' % (eol_, ))
14553
            self._exportChildren(outfile, level + 1, namespaceprefix_, namespacedef_, name_='ImageRegionType', pretty_print=pretty_print)
14554
            showIndent(outfile, level, pretty_print)
14555
            outfile.write('</%s%s>%s' % (namespaceprefix_, name_, eol_))
14556
        else:
14557
            outfile.write('/>%s' % (eol_, ))
14558
    def _exportAttributes(self, outfile, level, already_processed, namespaceprefix_='', name_='ImageRegionType'):
14559
        super(ImageRegionType, self)._exportAttributes(outfile, level, already_processed, namespaceprefix_, name_='ImageRegionType')
14560
        if self.orientation is not None and 'orientation' not in already_processed:
14561
            already_processed.add('orientation')
14562
            outfile.write(' orientation="%s"' % self.gds_format_float(self.orientation, input_name='orientation'))
14563
        if self.colourDepth is not None and 'colourDepth' not in already_processed:
14564
            already_processed.add('colourDepth')
14565
            outfile.write(' colourDepth=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.colourDepth), input_name='colourDepth')), ))
14566
        if self.bgColour is not None and 'bgColour' not in already_processed:
14567
            already_processed.add('bgColour')
14568
            outfile.write(' bgColour=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.bgColour), input_name='bgColour')), ))
14569
        if self.embText is not None and 'embText' not in already_processed:
14570
            already_processed.add('embText')
14571
            outfile.write(' embText="%s"' % self.gds_format_boolean(self.embText, input_name='embText'))
14572
    def _exportChildren(self, outfile, level, namespaceprefix_='', namespacedef_='xmlns:pc="http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15"', name_='ImageRegionType', fromsubclass_=False, pretty_print=True):
14573
        super(ImageRegionType, self)._exportChildren(outfile, level, namespaceprefix_, namespacedef_, name_, True, pretty_print=pretty_print)
14574
    def to_etree(self, parent_element=None, name_='ImageRegionType', mapping_=None, reverse_mapping_=None, nsmap_=None):
14575
        element = super(ImageRegionType, self).to_etree(parent_element, name_, mapping_, reverse_mapping_, nsmap_)
14576
        if self.orientation is not None:
14577
            element.set('orientation', self.gds_format_float(self.orientation))
14578
        if self.colourDepth is not None:
14579
            element.set('colourDepth', self.gds_format_string(self.colourDepth))
14580
        if self.bgColour is not None:
14581
            element.set('bgColour', self.gds_format_string(self.bgColour))
14582
        if self.embText is not None:
14583
            element.set('embText', self.gds_format_boolean(self.embText))
14584
        if mapping_ is not None:
14585
            mapping_[id(self)] = element
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable id does not seem to be defined.
Loading history...
14586
        if reverse_mapping_ is not None:
14587
            reverse_mapping_[element] = self
14588
        return element
14589
    def build(self, node, gds_collector_=None):
14590
        self.gds_collector_ = gds_collector_
14591
        if SaveElementTreeNode:
14592
            self.gds_elementtree_node_ = node
14593
        already_processed = set()
14594
        self.ns_prefix_ = node.prefix
14595
        self._buildAttributes(node, node.attrib, already_processed)
14596
        for child in node:
14597
            nodeName_ = Tag_pattern_.match(child.tag).groups()[-1]
14598
            self._buildChildren(child, node, nodeName_, gds_collector_=gds_collector_)
14599
        return self
14600
    def _buildAttributes(self, node, attrs, already_processed):
14601
        value = find_attr_value_('orientation', node)
14602
        if value is not None and 'orientation' not in already_processed:
14603
            already_processed.add('orientation')
14604
            value = self.gds_parse_float(value, node, 'orientation')
14605
            self.orientation = value
14606
        value = find_attr_value_('colourDepth', node)
14607
        if value is not None and 'colourDepth' not in already_processed:
14608
            already_processed.add('colourDepth')
14609
            self.colourDepth = value
14610
            self.validate_ColourDepthSimpleType(self.colourDepth)    # validate type ColourDepthSimpleType
14611
        value = find_attr_value_('bgColour', node)
14612
        if value is not None and 'bgColour' not in already_processed:
14613
            already_processed.add('bgColour')
14614
            self.bgColour = value
14615
            self.validate_ColourSimpleType(self.bgColour)    # validate type ColourSimpleType
14616
        value = find_attr_value_('embText', node)
14617
        if value is not None and 'embText' not in already_processed:
14618
            already_processed.add('embText')
14619
            if value in ('true', '1'):
14620
                self.embText = True
14621
            elif value in ('false', '0'):
14622
                self.embText = False
14623
            else:
14624
                raise_parse_error(node, 'Bad boolean attribute')
14625
        super(ImageRegionType, self)._buildAttributes(node, attrs, already_processed)
14626
    def _buildChildren(self, child_, node, nodeName_, fromsubclass_=False, gds_collector_=None):
14627
        super(ImageRegionType, self)._buildChildren(child_, node, nodeName_, True)
14628
        pass
14629
    def __hash__(self):
14630
        return hash(self.id)
14631
    def set_orientation(self, orientation):
14632
        """
14633
        Set deskewing angle to given `orientation` number.
14634
        Moreover, invalidate self's ``pc:AlternativeImage``s
14635
        (because they will have been rotated and enlarged
14636
        with the angle of the previous value).
14637
        """
14638
        if hasattr(self, 'invalidate_AlternativeImage'):
14639
            # PageType, RegionType:
14640
            self.invalidate_AlternativeImage(feature_selector='deskewed')
14641
        self.orientation = orientation
14642
# end class ImageRegionType
14643
14644
14645
class TextRegionType(RegionType):
14646
    """TextRegionType --
14647
    Pure text is represented as a text region. This includes
14648
    drop capitals, but practically ornate text may be
14649
    considered as a graphic.
14650
      
14651
    * orientation --
14652
      The angle the rectangle encapsulating the region
14653
      has to be rotated in clockwise direction
14654
      in order to correct the present skew
14655
      (negative values indicate anti-clockwise rotation).
14656
      (The rotated image can be further referenced
14657
      via
14658
14659
      AlternativeImage
14660
14661
      .)
14662
      Range: -179.999,180
14663
      
14664
    * type --
14665
      The nature of the text in the region
14666
      
14667
    * leading --
14668
      The degree of space in points between the lines of
14669
      text (line spacing)
14670
      
14671
    * readingDirection --
14672
      The direction in which text within lines
14673
      should be read (order of words and characters),
14674
      in addition to
14675
14676
      textLineOrder
14677
14678
      .
14679
      
14680
    * textLineOrder --
14681
      The order of text lines within the block,
14682
      in addition to
14683
14684
      readingDirection
14685
14686
      .
14687
      
14688
    * readingOrientation --
14689
      The angle the baseline of text within the region
14690
      has to be rotated (relative to the rectangle
14691
      encapsulating the region) in clockwise direction
14692
      in order to correct the present skew,
14693
      in addition to
14694
14695
      orientation
14696
14697
      (negative values indicate anti-clockwise rotation).
14698
      Range: -179.999,180
14699
      
14700
    * indented --
14701
      Defines whether a region of text is indented or not
14702
      
14703
    * align -- Text align
14704
    * primaryLanguage --
14705
      The primary language used in the region
14706
      
14707
    * secondaryLanguage --
14708
      The secondary language used in the region
14709
      
14710
    * primaryScript --
14711
      The primary script used in the region
14712
      
14713
    * secondaryScript --
14714
      The secondary script used in the region
14715
    
14716
    """
14717
    __hash__ = GeneratedsSuper.__hash__
14718
    member_data_items_ = [
14719
        MemberSpec_('orientation', 'float', 0, 1, {'use': 'optional', 'name': 'orientation'}),
14720
        MemberSpec_('type_', 'pc:TextTypeSimpleType', 0, 1, {'use': 'optional', 'name': 'type_'}),
14721
        MemberSpec_('leading', 'int', 0, 1, {'use': 'optional', 'name': 'leading'}),
14722
        MemberSpec_('readingDirection', 'pc:ReadingDirectionSimpleType', 0, 1, {'use': 'optional', 'name': 'readingDirection'}),
14723
        MemberSpec_('textLineOrder', 'pc:TextLineOrderSimpleType', 0, 1, {'use': 'optional', 'name': 'textLineOrder'}),
14724
        MemberSpec_('readingOrientation', 'float', 0, 1, {'use': 'optional', 'name': 'readingOrientation'}),
14725
        MemberSpec_('indented', 'boolean', 0, 1, {'use': 'optional', 'name': 'indented'}),
14726
        MemberSpec_('align', 'pc:AlignSimpleType', 0, 1, {'use': 'optional', 'name': 'align'}),
14727
        MemberSpec_('primaryLanguage', 'pc:LanguageSimpleType', 0, 1, {'use': 'optional', 'name': 'primaryLanguage'}),
14728
        MemberSpec_('secondaryLanguage', 'pc:LanguageSimpleType', 0, 1, {'use': 'optional', 'name': 'secondaryLanguage'}),
14729
        MemberSpec_('primaryScript', 'pc:ScriptSimpleType', 0, 1, {'use': 'optional', 'name': 'primaryScript'}),
14730
        MemberSpec_('secondaryScript', 'pc:ScriptSimpleType', 0, 1, {'use': 'optional', 'name': 'secondaryScript'}),
14731
        MemberSpec_('production', 'pc:ProductionSimpleType', 0, 1, {'use': 'optional', 'name': 'production'}),
14732
        MemberSpec_('TextLine', 'TextLineType', 1, 1, {'maxOccurs': 'unbounded', 'minOccurs': '0', 'name': 'TextLine', 'type': 'TextLineType'}, None),
14733
        MemberSpec_('TextEquiv', 'TextEquivType', 1, 1, {'maxOccurs': 'unbounded', 'minOccurs': '0', 'name': 'TextEquiv', 'type': 'TextEquivType'}, None),
14734
        MemberSpec_('TextStyle', 'TextStyleType', 0, 1, {'maxOccurs': '1', 'minOccurs': '0', 'name': 'TextStyle', 'type': 'TextStyleType'}, None),
14735
    ]
14736
    subclass = None
14737
    superclass = RegionType
14738
    def __init__(self, id=None, custom=None, comments=None, continuation=None, AlternativeImage=None, Coords=None, UserDefined=None, Labels=None, Roles=None, TextRegion=None, ImageRegion=None, LineDrawingRegion=None, GraphicRegion=None, TableRegion=None, ChartRegion=None, SeparatorRegion=None, MathsRegion=None, ChemRegion=None, MusicRegion=None, AdvertRegion=None, NoiseRegion=None, UnknownRegion=None, CustomRegion=None, orientation=None, type_=None, leading=None, readingDirection=None, textLineOrder=None, readingOrientation=None, indented=None, align=None, primaryLanguage=None, secondaryLanguage=None, primaryScript=None, secondaryScript=None, production=None, TextLine=None, TextEquiv=None, TextStyle=None, gds_collector_=None, **kwargs_):
14739
        self.gds_collector_ = gds_collector_
14740
        self.gds_elementtree_node_ = None
14741
        self.original_tagname_ = None
14742
        self.parent_object_ = kwargs_.get('parent_object_')
14743
        self.ns_prefix_ = "pc"
14744
        super(globals().get("TextRegionType"), self).__init__(id, custom, comments, continuation, AlternativeImage, Coords, UserDefined, Labels, Roles, TextRegion, ImageRegion, LineDrawingRegion, GraphicRegion, TableRegion, ChartRegion, SeparatorRegion, MathsRegion, ChemRegion, MusicRegion, AdvertRegion, NoiseRegion, UnknownRegion, CustomRegion,  **kwargs_)
14745
        self.orientation = _cast(float, orientation)
14746
        self.orientation_nsprefix_ = "pc"
14747
        self.type_ = _cast(None, type_)
14748
        self.type__nsprefix_ = "pc"
14749
        self.leading = _cast(int, leading)
14750
        self.leading_nsprefix_ = "pc"
14751
        self.readingDirection = _cast(None, readingDirection)
14752
        self.readingDirection_nsprefix_ = "pc"
14753
        self.textLineOrder = _cast(None, textLineOrder)
14754
        self.textLineOrder_nsprefix_ = "pc"
14755
        self.readingOrientation = _cast(float, readingOrientation)
14756
        self.readingOrientation_nsprefix_ = "pc"
14757
        self.indented = _cast(bool, indented)
14758
        self.indented_nsprefix_ = "pc"
14759
        self.align = _cast(None, align)
14760
        self.align_nsprefix_ = "pc"
14761
        self.primaryLanguage = _cast(None, primaryLanguage)
14762
        self.primaryLanguage_nsprefix_ = "pc"
14763
        self.secondaryLanguage = _cast(None, secondaryLanguage)
14764
        self.secondaryLanguage_nsprefix_ = "pc"
14765
        self.primaryScript = _cast(None, primaryScript)
14766
        self.primaryScript_nsprefix_ = "pc"
14767
        self.secondaryScript = _cast(None, secondaryScript)
14768
        self.secondaryScript_nsprefix_ = "pc"
14769
        self.production = _cast(None, production)
14770
        self.production_nsprefix_ = "pc"
14771
        if TextLine is None:
14772
            self.TextLine = []
14773
        else:
14774
            self.TextLine = TextLine
14775
        self.TextLine_nsprefix_ = "pc"
14776
        if TextEquiv is None:
14777
            self.TextEquiv = []
14778
        else:
14779
            self.TextEquiv = TextEquiv
14780
        self.TextEquiv_nsprefix_ = "pc"
14781
        self.TextStyle = TextStyle
14782
        self.TextStyle_nsprefix_ = "pc"
14783
    def factory(*args_, **kwargs_):
14784
        if CurrentSubclassModule_ is not None:
14785
            subclass = getSubclassFromModule_(
14786
                CurrentSubclassModule_, TextRegionType)
14787
            if subclass is not None:
14788
                return subclass(*args_, **kwargs_)
14789
        if TextRegionType.subclass:
14790
            return TextRegionType.subclass(*args_, **kwargs_)
14791
        else:
14792
            return TextRegionType(*args_, **kwargs_)
14793
    factory = staticmethod(factory)
14794
    def get_ns_prefix_(self):
14795
        return self.ns_prefix_
14796
    def set_ns_prefix_(self, ns_prefix):
14797
        self.ns_prefix_ = ns_prefix
14798
    def get_TextLine(self):
14799
        return self.TextLine
14800
    def set_TextLine(self, TextLine):
14801
        self.TextLine = TextLine
14802
    def add_TextLine(self, value):
14803
        self.TextLine.append(value)
14804
    def insert_TextLine_at(self, index, value):
14805
        self.TextLine.insert(index, value)
14806
    def replace_TextLine_at(self, index, value):
14807
        self.TextLine[index] = value
14808
    def get_TextEquiv(self):
14809
        return self.TextEquiv
14810
    def set_TextEquiv(self, TextEquiv):
14811
        self.TextEquiv = TextEquiv
14812
    def add_TextEquiv(self, value):
14813
        self.TextEquiv.append(value)
14814
    def insert_TextEquiv_at(self, index, value):
14815
        self.TextEquiv.insert(index, value)
14816
    def replace_TextEquiv_at(self, index, value):
14817
        self.TextEquiv[index] = value
14818
    def get_TextStyle(self):
14819
        return self.TextStyle
14820
    def set_TextStyle(self, TextStyle):
14821
        self.TextStyle = TextStyle
14822
    def get_orientation(self):
14823
        return self.orientation
14824
    def set_orientation(self, orientation):
14825
        self.orientation = orientation
14826
    def get_type(self):
14827
        return self.type_
14828
    def set_type(self, type_):
14829
        self.type_ = type_
14830
    def get_leading(self):
14831
        return self.leading
14832
    def set_leading(self, leading):
14833
        self.leading = leading
14834
    def get_readingDirection(self):
14835
        return self.readingDirection
14836
    def set_readingDirection(self, readingDirection):
14837
        self.readingDirection = readingDirection
14838
    def get_textLineOrder(self):
14839
        return self.textLineOrder
14840
    def set_textLineOrder(self, textLineOrder):
14841
        self.textLineOrder = textLineOrder
14842
    def get_readingOrientation(self):
14843
        return self.readingOrientation
14844
    def set_readingOrientation(self, readingOrientation):
14845
        self.readingOrientation = readingOrientation
14846
    def get_indented(self):
14847
        return self.indented
14848
    def set_indented(self, indented):
14849
        self.indented = indented
14850
    def get_align(self):
14851
        return self.align
14852
    def set_align(self, align):
14853
        self.align = align
14854
    def get_primaryLanguage(self):
14855
        return self.primaryLanguage
14856
    def set_primaryLanguage(self, primaryLanguage):
14857
        self.primaryLanguage = primaryLanguage
14858
    def get_secondaryLanguage(self):
14859
        return self.secondaryLanguage
14860
    def set_secondaryLanguage(self, secondaryLanguage):
14861
        self.secondaryLanguage = secondaryLanguage
14862
    def get_primaryScript(self):
14863
        return self.primaryScript
14864
    def set_primaryScript(self, primaryScript):
14865
        self.primaryScript = primaryScript
14866
    def get_secondaryScript(self):
14867
        return self.secondaryScript
14868
    def set_secondaryScript(self, secondaryScript):
14869
        self.secondaryScript = secondaryScript
14870
    def get_production(self):
14871
        return self.production
14872
    def set_production(self, production):
14873
        self.production = production
14874
    def validate_TextTypeSimpleType(self, value):
14875
        # Validate type pc:TextTypeSimpleType, a restriction on string.
14876
        if value is not None and Validate_simpletypes_ and self.gds_collector_ is not None:
14877
            if not isinstance(value, str):
14878
                lineno = self.gds_get_node_lineno_()
14879
                self.gds_collector_.add_message('Value "%(value)s"%(lineno)s is not of the correct base simple type (str)' % {"value": value, "lineno": lineno, })
14880
                return False
14881
            value = value
14882
            enumerations = ['paragraph', 'heading', 'caption', 'header', 'footer', 'page-number', 'drop-capital', 'credit', 'floating', 'signature-mark', 'catch-word', 'marginalia', 'footnote', 'footnote-continued', 'endnote', 'TOC-entry', 'list-label', 'other']
14883
            if value not in enumerations:
14884
                lineno = self.gds_get_node_lineno_()
14885
                self.gds_collector_.add_message('Value "%(value)s"%(lineno)s does not match xsd enumeration restriction on TextTypeSimpleType' % {"value" : encode_str_2_3(value), "lineno": lineno} )
14886
                result = False
14887
    def validate_ReadingDirectionSimpleType(self, value):
14888
        # Validate type pc:ReadingDirectionSimpleType, a restriction on string.
14889
        if value is not None and Validate_simpletypes_ and self.gds_collector_ is not None:
14890
            if not isinstance(value, str):
14891
                lineno = self.gds_get_node_lineno_()
14892
                self.gds_collector_.add_message('Value "%(value)s"%(lineno)s is not of the correct base simple type (str)' % {"value": value, "lineno": lineno, })
14893
                return False
14894
            value = value
14895
            enumerations = ['left-to-right', 'right-to-left', 'top-to-bottom', 'bottom-to-top']
14896
            if value not in enumerations:
14897
                lineno = self.gds_get_node_lineno_()
14898
                self.gds_collector_.add_message('Value "%(value)s"%(lineno)s does not match xsd enumeration restriction on ReadingDirectionSimpleType' % {"value" : encode_str_2_3(value), "lineno": lineno} )
14899
                result = False
14900
    def validate_TextLineOrderSimpleType(self, value):
14901
        # Validate type pc:TextLineOrderSimpleType, a restriction on string.
14902
        if value is not None and Validate_simpletypes_ and self.gds_collector_ is not None:
14903
            if not isinstance(value, str):
14904
                lineno = self.gds_get_node_lineno_()
14905
                self.gds_collector_.add_message('Value "%(value)s"%(lineno)s is not of the correct base simple type (str)' % {"value": value, "lineno": lineno, })
14906
                return False
14907
            value = value
14908
            enumerations = ['top-to-bottom', 'bottom-to-top', 'left-to-right', 'right-to-left']
14909
            if value not in enumerations:
14910
                lineno = self.gds_get_node_lineno_()
14911
                self.gds_collector_.add_message('Value "%(value)s"%(lineno)s does not match xsd enumeration restriction on TextLineOrderSimpleType' % {"value" : encode_str_2_3(value), "lineno": lineno} )
14912
                result = False
14913
    def validate_AlignSimpleType(self, value):
14914
        # Validate type pc:AlignSimpleType, a restriction on string.
14915
        if value is not None and Validate_simpletypes_ and self.gds_collector_ is not None:
14916
            if not isinstance(value, str):
14917
                lineno = self.gds_get_node_lineno_()
14918
                self.gds_collector_.add_message('Value "%(value)s"%(lineno)s is not of the correct base simple type (str)' % {"value": value, "lineno": lineno, })
14919
                return False
14920
            value = value
14921
            enumerations = ['left', 'centre', 'right', 'justify']
14922
            if value not in enumerations:
14923
                lineno = self.gds_get_node_lineno_()
14924
                self.gds_collector_.add_message('Value "%(value)s"%(lineno)s does not match xsd enumeration restriction on AlignSimpleType' % {"value" : encode_str_2_3(value), "lineno": lineno} )
14925
                result = False
14926
    def validate_LanguageSimpleType(self, value):
14927
        # Validate type pc:LanguageSimpleType, a restriction on string.
14928
        if value is not None and Validate_simpletypes_ and self.gds_collector_ is not None:
14929
            if not isinstance(value, str):
14930
                lineno = self.gds_get_node_lineno_()
14931
                self.gds_collector_.add_message('Value "%(value)s"%(lineno)s is not of the correct base simple type (str)' % {"value": value, "lineno": lineno, })
14932
                return False
14933
            value = value
14934
            enumerations = ['Abkhaz', 'Afar', 'Afrikaans', 'Akan', 'Albanian', 'Amharic', 'Arabic', 'Aragonese', 'Armenian', 'Assamese', 'Avaric', 'Avestan', 'Aymara', 'Azerbaijani', 'Bambara', 'Bashkir', 'Basque', 'Belarusian', 'Bengali', 'Bihari', 'Bislama', 'Bosnian', 'Breton', 'Bulgarian', 'Burmese', 'Cambodian', 'Cantonese', 'Catalan', 'Chamorro', 'Chechen', 'Chichewa', 'Chinese', 'Chuvash', 'Cornish', 'Corsican', 'Cree', 'Croatian', 'Czech', 'Danish', 'Divehi', 'Dutch', 'Dzongkha', 'English', 'Esperanto', 'Estonian', 'Ewe', 'Faroese', 'Fijian', 'Finnish', 'French', 'Fula', 'Gaelic', 'Galician', 'Ganda', 'Georgian', 'German', 'Greek', 'Guaraní', 'Gujarati', 'Haitian', 'Hausa', 'Hebrew', 'Herero', 'Hindi', 'Hiri Motu', 'Hungarian', 'Icelandic', 'Ido', 'Igbo', 'Indonesian', 'Interlingua', 'Interlingue', 'Inuktitut', 'Inupiaq', 'Irish', 'Italian', 'Japanese', 'Javanese', 'Kalaallisut', 'Kannada', 'Kanuri', 'Kashmiri', 'Kazakh', 'Khmer', 'Kikuyu', 'Kinyarwanda', 'Kirundi', 'Komi', 'Kongo', 'Korean', 'Kurdish', 'Kwanyama', 'Kyrgyz', 'Lao', 'Latin', 'Latvian', 'Limburgish', 'Lingala', 'Lithuanian', 'Luba-Katanga', 'Luxembourgish', 'Macedonian', 'Malagasy', 'Malay', 'Malayalam', 'Maltese', 'Manx', 'Māori', 'Marathi', 'Marshallese', 'Mongolian', 'Nauru', 'Navajo', 'Ndonga', 'Nepali', 'North Ndebele', 'Northern Sami', 'Norwegian', 'Norwegian Bokmål', 'Norwegian Nynorsk', 'Nuosu', 'Occitan', 'Ojibwe', 'Old Church Slavonic', 'Oriya', 'Oromo', 'Ossetian', 'Pāli', 'Panjabi', 'Pashto', 'Persian', 'Polish', 'Portuguese', 'Punjabi', 'Quechua', 'Romanian', 'Romansh', 'Russian', 'Samoan', 'Sango', 'Sanskrit', 'Sardinian', 'Serbian', 'Shona', 'Sindhi', 'Sinhala', 'Slovak', 'Slovene', 'Somali', 'South Ndebele', 'Southern Sotho', 'Spanish', 'Sundanese', 'Swahili', 'Swati', 'Swedish', 'Tagalog', 'Tahitian', 'Tajik', 'Tamil', 'Tatar', 'Telugu', 'Thai', 'Tibetan', 'Tigrinya', 'Tonga', 'Tsonga', 'Tswana', 'Turkish', 'Turkmen', 'Twi', 'Uighur', 'Ukrainian', 'Urdu', 'Uzbek', 'Venda', 'Vietnamese', 'Volapük', 'Walloon', 'Welsh', 'Western Frisian', 'Wolof', 'Xhosa', 'Yiddish', 'Yoruba', 'Zhuang', 'Zulu', 'other']
14935
            if value not in enumerations:
14936
                lineno = self.gds_get_node_lineno_()
14937
                self.gds_collector_.add_message('Value "%(value)s"%(lineno)s does not match xsd enumeration restriction on LanguageSimpleType' % {"value" : encode_str_2_3(value), "lineno": lineno} )
14938
                result = False
14939
    def validate_ScriptSimpleType(self, value):
14940
        # Validate type pc:ScriptSimpleType, a restriction on string.
14941
        if value is not None and Validate_simpletypes_ and self.gds_collector_ is not None:
14942
            if not isinstance(value, str):
14943
                lineno = self.gds_get_node_lineno_()
14944
                self.gds_collector_.add_message('Value "%(value)s"%(lineno)s is not of the correct base simple type (str)' % {"value": value, "lineno": lineno, })
14945
                return False
14946
            value = value
14947
            enumerations = ['Adlm - Adlam', 'Afak - Afaka', 'Aghb - Caucasian Albanian', 'Ahom - Ahom, Tai Ahom', 'Arab - Arabic', 'Aran - Arabic (Nastaliq variant)', 'Armi - Imperial Aramaic', 'Armn - Armenian', 'Avst - Avestan', 'Bali - Balinese', 'Bamu - Bamum', 'Bass - Bassa Vah', 'Batk - Batak', 'Beng - Bengali', 'Bhks - Bhaiksuki', 'Blis - Blissymbols', 'Bopo - Bopomofo', 'Brah - Brahmi', 'Brai - Braille', 'Bugi - Buginese', 'Buhd - Buhid', 'Cakm - Chakma', 'Cans - Unified Canadian Aboriginal Syllabics', 'Cari - Carian', 'Cham - Cham', 'Cher - Cherokee', 'Cirt - Cirth', 'Copt - Coptic', 'Cprt - Cypriot', 'Cyrl - Cyrillic', 'Cyrs - Cyrillic (Old Church Slavonic variant)', 'Deva - Devanagari (Nagari)', 'Dsrt - Deseret (Mormon)', 'Dupl - Duployan shorthand, Duployan stenography', 'Egyd - Egyptian demotic', 'Egyh - Egyptian hieratic', 'Egyp - Egyptian hieroglyphs', 'Elba - Elbasan', 'Ethi - Ethiopic', 'Geok - Khutsuri (Asomtavruli and Nuskhuri)', 'Geor - Georgian (Mkhedruli)', 'Glag - Glagolitic', 'Goth - Gothic', 'Gran - Grantha', 'Grek - Greek', 'Gujr - Gujarati', 'Guru - Gurmukhi', 'Hanb - Han with Bopomofo', 'Hang - Hangul', 'Hani - Han (Hanzi, Kanji, Hanja)', 'Hano - Hanunoo (Hanunóo)', 'Hans - Han (Simplified variant)', 'Hant - Han (Traditional variant)', 'Hatr - Hatran', 'Hebr - Hebrew', 'Hira - Hiragana', 'Hluw - Anatolian Hieroglyphs', 'Hmng - Pahawh Hmong', 'Hrkt - Japanese syllabaries', 'Hung - Old Hungarian (Hungarian Runic)', 'Inds - Indus (Harappan)', 'Ital - Old Italic (Etruscan, Oscan etc.)', 'Jamo - Jamo', 'Java - Javanese', 'Jpan - Japanese', 'Jurc - Jurchen', 'Kali - Kayah Li', 'Kana - Katakana', 'Khar - Kharoshthi', 'Khmr - Khmer', 'Khoj - Khojki', 'Kitl - Khitan large script', 'Kits - Khitan small script', 'Knda - Kannada', 'Kore - Korean (alias for Hangul + Han)', 'Kpel - Kpelle', 'Kthi - Kaithi', 'Lana - Tai Tham (Lanna)', 'Laoo - Lao', 'Latf - Latin (Fraktur variant)', 'Latg - Latin (Gaelic variant)', 'Latn - Latin', 'Leke - Leke', 'Lepc - Lepcha (Róng)', 'Limb - Limbu', 'Lina - Linear A', 'Linb - Linear B', 'Lisu - Lisu (Fraser)', 'Loma - Loma', 'Lyci - Lycian', 'Lydi - Lydian', 'Mahj - Mahajani', 'Mand - Mandaic, Mandaean', 'Mani - Manichaean', 'Marc - Marchen', 'Maya - Mayan hieroglyphs', 'Mend - Mende Kikakui', 'Merc - Meroitic Cursive', 'Mero - Meroitic Hieroglyphs', 'Mlym - Malayalam', 'Modi - Modi, Moḍī', 'Mong - Mongolian', 'Moon - Moon (Moon code, Moon script, Moon type)', 'Mroo - Mro, Mru', 'Mtei - Meitei Mayek (Meithei, Meetei)', 'Mult - Multani', 'Mymr - Myanmar (Burmese)', 'Narb - Old North Arabian (Ancient North Arabian)', 'Nbat - Nabataean', 'Newa - Newa, Newar, Newari', 'Nkgb - Nakhi Geba', 'Nkoo - N’Ko', 'Nshu - Nüshu', 'Ogam - Ogham', 'Olck - Ol Chiki (Ol Cemet’, Ol, Santali)', 'Orkh - Old Turkic, Orkhon Runic', 'Orya - Oriya', 'Osge - Osage', 'Osma - Osmanya', 'Palm - Palmyrene', 'Pauc - Pau Cin Hau', 'Perm - Old Permic', 'Phag - Phags-pa', 'Phli - Inscriptional Pahlavi', 'Phlp - Psalter Pahlavi', 'Phlv - Book Pahlavi', 'Phnx - Phoenician', 'Piqd - Klingon (KLI pIqaD)', 'Plrd - Miao (Pollard)', 'Prti - Inscriptional Parthian', 'Rjng - Rejang (Redjang, Kaganga)', 'Roro - Rongorongo', 'Runr - Runic', 'Samr - Samaritan', 'Sara - Sarati', 'Sarb - Old South Arabian', 'Saur - Saurashtra', 'Sgnw - SignWriting', 'Shaw - Shavian (Shaw)', 'Shrd - Sharada, Śāradā', 'Sidd - Siddham', 'Sind - Khudawadi, Sindhi', 'Sinh - Sinhala', 'Sora - Sora Sompeng', 'Sund - Sundanese', 'Sylo - Syloti Nagri', 'Syrc - Syriac', 'Syre - Syriac (Estrangelo variant)', 'Syrj - Syriac (Western variant)', 'Syrn - Syriac (Eastern variant)', 'Tagb - Tagbanwa', 'Takr - Takri', 'Tale - Tai Le', 'Talu - New Tai Lue', 'Taml - Tamil', 'Tang - Tangut', 'Tavt - Tai Viet', 'Telu - Telugu', 'Teng - Tengwar', 'Tfng - Tifinagh (Berber)', 'Tglg - Tagalog (Baybayin, Alibata)', 'Thaa - Thaana', 'Thai - Thai', 'Tibt - Tibetan', 'Tirh - Tirhuta', 'Ugar - Ugaritic', 'Vaii - Vai', 'Visp - Visible Speech', 'Wara - Warang Citi (Varang Kshiti)', 'Wole - Woleai', 'Xpeo - Old Persian', 'Xsux - Cuneiform, Sumero-Akkadian', 'Yiii - Yi', 'Zinh - Code for inherited script', 'Zmth - Mathematical notation', 'Zsye - Symbols (Emoji variant)', 'Zsym - Symbols', 'Zxxx - Code for unwritten documents', 'Zyyy - Code for undetermined script', 'Zzzz - Code for uncoded script', 'other']
14948
            if value not in enumerations:
14949
                lineno = self.gds_get_node_lineno_()
14950
                self.gds_collector_.add_message('Value "%(value)s"%(lineno)s does not match xsd enumeration restriction on ScriptSimpleType' % {"value" : encode_str_2_3(value), "lineno": lineno} )
14951
                result = False
14952
    def validate_ProductionSimpleType(self, value):
14953
        # Validate type pc:ProductionSimpleType, a restriction on string.
14954
        if value is not None and Validate_simpletypes_ and self.gds_collector_ is not None:
14955
            if not isinstance(value, str):
14956
                lineno = self.gds_get_node_lineno_()
14957
                self.gds_collector_.add_message('Value "%(value)s"%(lineno)s is not of the correct base simple type (str)' % {"value": value, "lineno": lineno, })
14958
                return False
14959
            value = value
14960
            enumerations = ['printed', 'typewritten', 'handwritten-cursive', 'handwritten-printscript', 'medieval-manuscript', 'other']
14961
            if value not in enumerations:
14962
                lineno = self.gds_get_node_lineno_()
14963
                self.gds_collector_.add_message('Value "%(value)s"%(lineno)s does not match xsd enumeration restriction on ProductionSimpleType' % {"value" : encode_str_2_3(value), "lineno": lineno} )
14964
                result = False
14965
    def has__content(self):
14966
        if (
14967
            self.TextLine or
14968
            self.TextEquiv or
14969
            self.TextStyle is not None or
14970
            super(TextRegionType, self).has__content()
14971
        ):
14972
            return True
14973
        else:
14974
            return False
14975
    def export(self, outfile, level, namespaceprefix_='', namespacedef_='xmlns:pc="http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15"', name_='TextRegionType', pretty_print=True):
14976
        imported_ns_def_ = GenerateDSNamespaceDefs_.get('TextRegionType')
14977
        if imported_ns_def_ is not None:
14978
            namespacedef_ = imported_ns_def_
14979
        if pretty_print:
14980
            eol_ = '\n'
14981
        else:
14982
            eol_ = ''
14983
        if self.original_tagname_ is not None and name_ == 'TextRegionType':
14984
            name_ = self.original_tagname_
14985
        if UseCapturedNS_ and self.ns_prefix_:
14986
            namespaceprefix_ = self.ns_prefix_ + ':'
14987
        showIndent(outfile, level, pretty_print)
14988
        outfile.write('<%s%s%s' % (namespaceprefix_, name_, namespacedef_ and ' ' + namespacedef_ or '', ))
14989
        already_processed = set()
14990
        self._exportAttributes(outfile, level, already_processed, namespaceprefix_, name_='TextRegionType')
14991
        if self.has__content():
14992
            outfile.write('>%s' % (eol_, ))
14993
            self._exportChildren(outfile, level + 1, namespaceprefix_, namespacedef_, name_='TextRegionType', pretty_print=pretty_print)
14994
            showIndent(outfile, level, pretty_print)
14995
            outfile.write('</%s%s>%s' % (namespaceprefix_, name_, eol_))
14996
        else:
14997
            outfile.write('/>%s' % (eol_, ))
14998
    def _exportAttributes(self, outfile, level, already_processed, namespaceprefix_='', name_='TextRegionType'):
14999
        super(TextRegionType, self)._exportAttributes(outfile, level, already_processed, namespaceprefix_, name_='TextRegionType')
15000
        if self.orientation is not None and 'orientation' not in already_processed:
15001
            already_processed.add('orientation')
15002
            outfile.write(' orientation="%s"' % self.gds_format_float(self.orientation, input_name='orientation'))
15003
        if self.type_ is not None and 'type_' not in already_processed:
15004
            already_processed.add('type_')
15005
            outfile.write(' type=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.type_), input_name='type')), ))
15006
        if self.leading is not None and 'leading' not in already_processed:
15007
            already_processed.add('leading')
15008
            outfile.write(' leading="%s"' % self.gds_format_integer(self.leading, input_name='leading'))
15009
        if self.readingDirection is not None and 'readingDirection' not in already_processed:
15010
            already_processed.add('readingDirection')
15011
            outfile.write(' readingDirection=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.readingDirection), input_name='readingDirection')), ))
15012
        if self.textLineOrder is not None and 'textLineOrder' not in already_processed:
15013
            already_processed.add('textLineOrder')
15014
            outfile.write(' textLineOrder=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.textLineOrder), input_name='textLineOrder')), ))
15015
        if self.readingOrientation is not None and 'readingOrientation' not in already_processed:
15016
            already_processed.add('readingOrientation')
15017
            outfile.write(' readingOrientation="%s"' % self.gds_format_float(self.readingOrientation, input_name='readingOrientation'))
15018
        if self.indented is not None and 'indented' not in already_processed:
15019
            already_processed.add('indented')
15020
            outfile.write(' indented="%s"' % self.gds_format_boolean(self.indented, input_name='indented'))
15021
        if self.align is not None and 'align' not in already_processed:
15022
            already_processed.add('align')
15023
            outfile.write(' align=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.align), input_name='align')), ))
15024
        if self.primaryLanguage is not None and 'primaryLanguage' not in already_processed:
15025
            already_processed.add('primaryLanguage')
15026
            outfile.write(' primaryLanguage=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.primaryLanguage), input_name='primaryLanguage')), ))
15027
        if self.secondaryLanguage is not None and 'secondaryLanguage' not in already_processed:
15028
            already_processed.add('secondaryLanguage')
15029
            outfile.write(' secondaryLanguage=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.secondaryLanguage), input_name='secondaryLanguage')), ))
15030
        if self.primaryScript is not None and 'primaryScript' not in already_processed:
15031
            already_processed.add('primaryScript')
15032
            outfile.write(' primaryScript=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.primaryScript), input_name='primaryScript')), ))
15033
        if self.secondaryScript is not None and 'secondaryScript' not in already_processed:
15034
            already_processed.add('secondaryScript')
15035
            outfile.write(' secondaryScript=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.secondaryScript), input_name='secondaryScript')), ))
15036
        if self.production is not None and 'production' not in already_processed:
15037
            already_processed.add('production')
15038
            outfile.write(' production=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.production), input_name='production')), ))
15039
    def _exportChildren(self, outfile, level, namespaceprefix_='', namespacedef_='xmlns:pc="http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15"', name_='TextRegionType', fromsubclass_=False, pretty_print=True):
15040
        super(TextRegionType, self)._exportChildren(outfile, level, namespaceprefix_, namespacedef_, name_, True, pretty_print=pretty_print)
15041
        if pretty_print:
15042
            eol_ = '\n'
15043
        else:
15044
            eol_ = ''
15045
        for TextLine_ in self.TextLine:
15046
            namespaceprefix_ = self.TextLine_nsprefix_ + ':' if (UseCapturedNS_ and self.TextLine_nsprefix_) else ''
15047
            TextLine_.export(outfile, level, namespaceprefix_, namespacedef_='', name_='TextLine', pretty_print=pretty_print)
15048
        for TextEquiv_ in self.TextEquiv:
15049
            namespaceprefix_ = self.TextEquiv_nsprefix_ + ':' if (UseCapturedNS_ and self.TextEquiv_nsprefix_) else ''
15050
            TextEquiv_.export(outfile, level, namespaceprefix_, namespacedef_='', name_='TextEquiv', pretty_print=pretty_print)
15051
        if self.TextStyle is not None:
15052
            namespaceprefix_ = self.TextStyle_nsprefix_ + ':' if (UseCapturedNS_ and self.TextStyle_nsprefix_) else ''
15053
            self.TextStyle.export(outfile, level, namespaceprefix_, namespacedef_='', name_='TextStyle', pretty_print=pretty_print)
15054
    def to_etree(self, parent_element=None, name_='TextRegionType', mapping_=None, reverse_mapping_=None, nsmap_=None):
15055
        element = super(TextRegionType, self).to_etree(parent_element, name_, mapping_, reverse_mapping_, nsmap_)
15056
        if self.orientation is not None:
15057
            element.set('orientation', self.gds_format_float(self.orientation))
15058
        if self.type_ is not None:
15059
            element.set('type', self.gds_format_string(self.type_))
15060
        if self.leading is not None:
15061
            element.set('leading', self.gds_format_integer(self.leading))
15062
        if self.readingDirection is not None:
15063
            element.set('readingDirection', self.gds_format_string(self.readingDirection))
15064
        if self.textLineOrder is not None:
15065
            element.set('textLineOrder', self.gds_format_string(self.textLineOrder))
15066
        if self.readingOrientation is not None:
15067
            element.set('readingOrientation', self.gds_format_float(self.readingOrientation))
15068
        if self.indented is not None:
15069
            element.set('indented', self.gds_format_boolean(self.indented))
15070
        if self.align is not None:
15071
            element.set('align', self.gds_format_string(self.align))
15072
        if self.primaryLanguage is not None:
15073
            element.set('primaryLanguage', self.gds_format_string(self.primaryLanguage))
15074
        if self.secondaryLanguage is not None:
15075
            element.set('secondaryLanguage', self.gds_format_string(self.secondaryLanguage))
15076
        if self.primaryScript is not None:
15077
            element.set('primaryScript', self.gds_format_string(self.primaryScript))
15078
        if self.secondaryScript is not None:
15079
            element.set('secondaryScript', self.gds_format_string(self.secondaryScript))
15080
        if self.production is not None:
15081
            element.set('production', self.gds_format_string(self.production))
15082
        for TextLine_ in self.TextLine:
15083
            TextLine_.to_etree(element, name_='TextLine', mapping_=mapping_, reverse_mapping_=reverse_mapping_, nsmap_=nsmap_)
15084
        for TextEquiv_ in self.TextEquiv:
15085
            TextEquiv_.to_etree(element, name_='TextEquiv', mapping_=mapping_, reverse_mapping_=reverse_mapping_, nsmap_=nsmap_)
15086
        if self.TextStyle is not None:
15087
            TextStyle_ = self.TextStyle
15088
            TextStyle_.to_etree(element, name_='TextStyle', mapping_=mapping_, reverse_mapping_=reverse_mapping_, nsmap_=nsmap_)
15089
        if mapping_ is not None:
15090
            mapping_[id(self)] = element
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable id does not seem to be defined.
Loading history...
15091
        if reverse_mapping_ is not None:
15092
            reverse_mapping_[element] = self
15093
        return element
15094
    def build(self, node, gds_collector_=None):
15095
        self.gds_collector_ = gds_collector_
15096
        if SaveElementTreeNode:
15097
            self.gds_elementtree_node_ = node
15098
        already_processed = set()
15099
        self.ns_prefix_ = node.prefix
15100
        self._buildAttributes(node, node.attrib, already_processed)
15101
        for child in node:
15102
            nodeName_ = Tag_pattern_.match(child.tag).groups()[-1]
15103
            self._buildChildren(child, node, nodeName_, gds_collector_=gds_collector_)
15104
        return self
15105
    def _buildAttributes(self, node, attrs, already_processed):
15106
        value = find_attr_value_('orientation', node)
15107
        if value is not None and 'orientation' not in already_processed:
15108
            already_processed.add('orientation')
15109
            value = self.gds_parse_float(value, node, 'orientation')
15110
            self.orientation = value
15111
        value = find_attr_value_('type', node)
15112
        if value is not None and 'type' not in already_processed:
15113
            already_processed.add('type')
15114
            self.type_ = value
15115
            self.validate_TextTypeSimpleType(self.type_)    # validate type TextTypeSimpleType
15116
        value = find_attr_value_('leading', node)
15117
        if value is not None and 'leading' not in already_processed:
15118
            already_processed.add('leading')
15119
            self.leading = self.gds_parse_integer(value, node, 'leading')
15120
        value = find_attr_value_('readingDirection', node)
15121
        if value is not None and 'readingDirection' not in already_processed:
15122
            already_processed.add('readingDirection')
15123
            self.readingDirection = value
15124
            self.validate_ReadingDirectionSimpleType(self.readingDirection)    # validate type ReadingDirectionSimpleType
15125
        value = find_attr_value_('textLineOrder', node)
15126
        if value is not None and 'textLineOrder' not in already_processed:
15127
            already_processed.add('textLineOrder')
15128
            self.textLineOrder = value
15129
            self.validate_TextLineOrderSimpleType(self.textLineOrder)    # validate type TextLineOrderSimpleType
15130
        value = find_attr_value_('readingOrientation', node)
15131
        if value is not None and 'readingOrientation' not in already_processed:
15132
            already_processed.add('readingOrientation')
15133
            value = self.gds_parse_float(value, node, 'readingOrientation')
15134
            self.readingOrientation = value
15135
        value = find_attr_value_('indented', node)
15136
        if value is not None and 'indented' not in already_processed:
15137
            already_processed.add('indented')
15138
            if value in ('true', '1'):
15139
                self.indented = True
15140
            elif value in ('false', '0'):
15141
                self.indented = False
15142
            else:
15143
                raise_parse_error(node, 'Bad boolean attribute')
15144
        value = find_attr_value_('align', node)
15145
        if value is not None and 'align' not in already_processed:
15146
            already_processed.add('align')
15147
            self.align = value
15148
            self.validate_AlignSimpleType(self.align)    # validate type AlignSimpleType
15149
        value = find_attr_value_('primaryLanguage', node)
15150
        if value is not None and 'primaryLanguage' not in already_processed:
15151
            already_processed.add('primaryLanguage')
15152
            self.primaryLanguage = value
15153
            self.validate_LanguageSimpleType(self.primaryLanguage)    # validate type LanguageSimpleType
15154
        value = find_attr_value_('secondaryLanguage', node)
15155
        if value is not None and 'secondaryLanguage' not in already_processed:
15156
            already_processed.add('secondaryLanguage')
15157
            self.secondaryLanguage = value
15158
            self.validate_LanguageSimpleType(self.secondaryLanguage)    # validate type LanguageSimpleType
15159
        value = find_attr_value_('primaryScript', node)
15160
        if value is not None and 'primaryScript' not in already_processed:
15161
            already_processed.add('primaryScript')
15162
            self.primaryScript = value
15163
            self.validate_ScriptSimpleType(self.primaryScript)    # validate type ScriptSimpleType
15164
        value = find_attr_value_('secondaryScript', node)
15165
        if value is not None and 'secondaryScript' not in already_processed:
15166
            already_processed.add('secondaryScript')
15167
            self.secondaryScript = value
15168
            self.validate_ScriptSimpleType(self.secondaryScript)    # validate type ScriptSimpleType
15169
        value = find_attr_value_('production', node)
15170
        if value is not None and 'production' not in already_processed:
15171
            already_processed.add('production')
15172
            self.production = value
15173
            self.validate_ProductionSimpleType(self.production)    # validate type ProductionSimpleType
15174
        super(TextRegionType, self)._buildAttributes(node, attrs, already_processed)
15175
    def _buildChildren(self, child_, node, nodeName_, fromsubclass_=False, gds_collector_=None):
15176
        if nodeName_ == 'TextLine':
15177
            obj_ = TextLineType.factory(parent_object_=self)
15178
            obj_.build(child_, gds_collector_=gds_collector_)
15179
            self.TextLine.append(obj_)
15180
            obj_.original_tagname_ = 'TextLine'
15181
        elif nodeName_ == 'TextEquiv':
15182
            obj_ = TextEquivType.factory(parent_object_=self)
15183
            obj_.build(child_, gds_collector_=gds_collector_)
15184
            self.TextEquiv.append(obj_)
15185
            obj_.original_tagname_ = 'TextEquiv'
15186
        elif nodeName_ == 'TextStyle':
15187
            obj_ = TextStyleType.factory(parent_object_=self)
15188
            obj_.build(child_, gds_collector_=gds_collector_)
15189
            self.TextStyle = obj_
15190
            obj_.original_tagname_ = 'TextStyle'
15191
        super(TextRegionType, self)._buildChildren(child_, node, nodeName_, True)
15192
    def __hash__(self):
15193
        return hash(self.id)
15194
    def set_orientation(self, orientation):
15195
        """
15196
        Set deskewing angle to given `orientation` number.
15197
        Moreover, invalidate self's ``pc:AlternativeImage``s
15198
        (because they will have been rotated and enlarged
15199
        with the angle of the previous value).
15200
        """
15201
        if hasattr(self, 'invalidate_AlternativeImage'):
15202
            # PageType, RegionType:
15203
            self.invalidate_AlternativeImage(feature_selector='deskewed')
15204
        self.orientation = orientation
15205
# end class TextRegionType
15206
15207
15208
#
15209
# End data representation classes.
15210
#
15211
15212
15213
GDSClassesMapping = {
15214
    'PcGts': PcGtsType,
15215
}
15216
15217
15218
USAGE_TEXT = """
15219
Usage: python <Parser>.py [ -s ] <in_xml_file>
15220
"""
15221
15222
15223
def usage():
15224
    print(USAGE_TEXT)
15225
    sys.exit(1)
15226
15227
15228
def get_root_tag(node):
15229
    tag = Tag_pattern_.match(node.tag).groups()[-1]
15230
    prefix_tag = TagNamePrefix + tag
15231
    rootClass = GDSClassesMapping.get(prefix_tag)
15232
    if rootClass is None:
15233
        rootClass = globals().get(prefix_tag)
15234
    return tag, rootClass
15235
15236
15237
def get_required_ns_prefix_defs(rootNode):
15238
    '''Get all name space prefix definitions required in this XML doc.
15239
    Return a dictionary of definitions and a char string of definitions.
15240
    '''
15241
    nsmap = {
15242
        prefix: uri
15243
        for node in rootNode.iter()
15244
        for (prefix, uri) in node.nsmap.items()
15245
        if prefix is not None
15246
    }
15247
    namespacedefs = ' '.join([
15248
        'xmlns:{}="{}"'.format(prefix, uri)
15249
        for prefix, uri in nsmap.items()
15250
    ])
15251
    return nsmap, namespacedefs
15252
15253
15254
def parse(inFileName, silence=False, print_warnings=True):
15255
    global CapturedNsmap_
15256
    gds_collector = GdsCollector_()
15257
    parser = None
15258
    doc = parsexml_(inFileName, parser)
15259
    rootNode = doc.getroot()
15260
    rootTag, rootClass = get_root_tag(rootNode)
15261
    if rootClass is None:
15262
        rootTag = 'PcGts'
15263
        rootClass = PcGts
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable PcGts does not seem to be defined.
Loading history...
15264
    rootObj = rootClass.factory()
15265
    rootObj.build(rootNode, gds_collector_=gds_collector)
15266
    CapturedNsmap_, namespacedefs = get_required_ns_prefix_defs(rootNode)
15267
    if not SaveElementTreeNode:
15268
        doc = None
15269
        rootNode = None
15270
##     if not silence:
15271
##         sys.stdout.write('<?xml version="1.0" ?>\n')
15272
##         rootObj.export(
15273
##             sys.stdout, 0, name_=rootTag,
15274
##             namespacedef_=namespacedefs,
15275
##             pretty_print=True)
15276
    if print_warnings and len(gds_collector.get_messages()) > 0:
15277
        separator = ('-' * 50) + '\n'
15278
        sys.stderr.write(separator)
15279
        sys.stderr.write('----- Warnings -- count: {} -----\n'.format(
15280
            len(gds_collector.get_messages()), ))
15281
        gds_collector.write_messages(sys.stderr)
15282
        sys.stderr.write(separator)
15283
    return rootObj
15284
15285
15286
def parseEtree(inFileName, silence=False, print_warnings=True,
15287
               mapping=None, reverse_mapping=None, nsmap=None):
15288
    parser = None
15289
    doc = parsexml_(inFileName, parser)
15290
    gds_collector = GdsCollector_()
15291
    rootNode = doc.getroot()
15292
    rootTag, rootClass = get_root_tag(rootNode)
15293
    if rootClass is None:
15294
        rootTag = 'PcGts'
15295
        rootClass = PcGts
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable PcGts does not seem to be defined.
Loading history...
15296
    rootObj = rootClass.factory()
15297
    rootObj.build(rootNode, gds_collector_=gds_collector)
15298
    if mapping is None:
15299
        mapping = {}
15300
    if reverse_mapping is None:
15301
        reverse_mapping = {}
15302
    rootElement = rootObj.to_etree(
15303
        None, name_=rootTag, mapping_=mapping,
15304
        reverse_mapping_=reverse_mapping, nsmap_=nsmap)
15305
    reverse_node_mapping = rootObj.gds_reverse_node_mapping(mapping)
15306
    # Enable Python to collect the space used by the DOM.
15307
    if not SaveElementTreeNode:
15308
        doc = None
15309
        rootNode = None
15310
##     if not silence:
15311
##         content = etree_.tostring(
15312
##             rootElement, pretty_print=True,
15313
##             xml_declaration=True, encoding="utf-8")
15314
##         sys.stdout.write(str(content))
15315
##         sys.stdout.write('\n')
15316
    if print_warnings and len(gds_collector.get_messages()) > 0:
15317
        separator = ('-' * 50) + '\n'
15318
        sys.stderr.write(separator)
15319
        sys.stderr.write('----- Warnings -- count: {} -----\n'.format(
15320
            len(gds_collector.get_messages()), ))
15321
        gds_collector.write_messages(sys.stderr)
15322
        sys.stderr.write(separator)
15323
    return rootObj, rootElement, mapping, reverse_node_mapping
15324
15325
15326 View Code Duplication
def parseString(inString, silence=False, print_warnings=True):
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
15327
    '''Parse a string, create the object tree, and export it.
15328
15329
    Arguments:
15330
    - inString -- A string.  This XML fragment should not start
15331
      with an XML declaration containing an encoding.
15332
    - silence -- A boolean.  If False, export the object.
15333
    Returns -- The root object in the tree.
15334
    '''
15335
    parser = None
15336
    rootNode= parsexmlstring_(inString, parser)
15337
    gds_collector = GdsCollector_()
15338
    rootTag, rootClass = get_root_tag(rootNode)
15339
    if rootClass is None:
15340
        rootTag = 'PcGts'
15341
        rootClass = PcGts
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable PcGts does not seem to be defined.
Loading history...
15342
    rootObj = rootClass.factory()
15343
    rootObj.build(rootNode, gds_collector_=gds_collector)
15344
    if not SaveElementTreeNode:
15345
        rootNode = None
15346
##     if not silence:
15347
##         sys.stdout.write('<?xml version="1.0" ?>\n')
15348
##         rootObj.export(
15349
##             sys.stdout, 0, name_=rootTag,
15350
##             namespacedef_='xmlns:pc="http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15"')
15351
    if print_warnings and len(gds_collector.get_messages()) > 0:
15352
        separator = ('-' * 50) + '\n'
15353
        sys.stderr.write(separator)
15354
        sys.stderr.write('----- Warnings -- count: {} -----\n'.format(
15355
            len(gds_collector.get_messages()), ))
15356
        gds_collector.write_messages(sys.stderr)
15357
        sys.stderr.write(separator)
15358
    return rootObj
15359
15360
15361 View Code Duplication
def parseLiteral(inFileName, silence=False, print_warnings=True):
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
15362
    parser = None
15363
    doc = parsexml_(inFileName, parser)
15364
    gds_collector = GdsCollector_()
15365
    rootNode = doc.getroot()
15366
    rootTag, rootClass = get_root_tag(rootNode)
15367
    if rootClass is None:
15368
        rootTag = 'PcGts'
15369
        rootClass = PcGts
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable PcGts does not seem to be defined.
Loading history...
15370
    rootObj = rootClass.factory()
15371
    rootObj.build(rootNode, gds_collector_=gds_collector)
15372
    # Enable Python to collect the space used by the DOM.
15373
    if not SaveElementTreeNode:
15374
        doc = None
15375
        rootNode = None
15376
##     if not silence:
15377
##         sys.stdout.write('#from ocrd_page_generateds import *\n\n')
15378
##         sys.stdout.write('import ocrd_page_generateds as model_\n\n')
15379
##         sys.stdout.write('rootObj = model_.rootClass(\n')
15380
##         rootObj.exportLiteral(sys.stdout, 0, name_=rootTag)
15381
##         sys.stdout.write(')\n')
15382
    if print_warnings and len(gds_collector.get_messages()) > 0:
15383
        separator = ('-' * 50) + '\n'
15384
        sys.stderr.write(separator)
15385
        sys.stderr.write('----- Warnings -- count: {} -----\n'.format(
15386
            len(gds_collector.get_messages()), ))
15387
        gds_collector.write_messages(sys.stderr)
15388
        sys.stderr.write(separator)
15389
    return rootObj
15390
15391
15392
def main():
15393
    args = sys.argv[1:]
15394
    if len(args) == 1:
15395
        parse(args[0])
15396
    else:
15397
        usage()
15398
15399
15400
if __name__ == '__main__':
15401
    #import pdb; pdb.set_trace()
15402
    main()
15403
15404
RenameMappings_ = {
15405
}
15406
15407
#
15408
# Mapping of namespaces to types defined in them
15409
# and the file in which each is defined.
15410
# simpleTypes are marked "ST" and complexTypes "CT".
15411
NamespaceToDefMappings_ = {'http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15': [('ColourSimpleType',
15412
                                                                      'src/ocrd_validators/page.xsd',
15413
                                                                      'ST'),
15414
                                                                     ('ReadingDirectionSimpleType',
15415
                                                                      'src/ocrd_validators/page.xsd',
15416
                                                                      'ST'),
15417
                                                                     ('TextLineOrderSimpleType',
15418
                                                                      'src/ocrd_validators/page.xsd',
15419
                                                                      'ST'),
15420
                                                                     ('TextTypeSimpleType',
15421
                                                                      'src/ocrd_validators/page.xsd',
15422
                                                                      'ST'),
15423
                                                                     ('PageTypeSimpleType',
15424
                                                                      'src/ocrd_validators/page.xsd',
15425
                                                                      'ST'),
15426
                                                                     ('ConfSimpleType',
15427
                                                                      'src/ocrd_validators/page.xsd',
15428
                                                                      'ST'),
15429
                                                                     ('LanguageSimpleType',
15430
                                                                      'src/ocrd_validators/page.xsd',
15431
                                                                      'ST'),
15432
                                                                     ('ScriptSimpleType',
15433
                                                                      'src/ocrd_validators/page.xsd',
15434
                                                                      'ST'),
15435
                                                                     ('ColourDepthSimpleType',
15436
                                                                      'src/ocrd_validators/page.xsd',
15437
                                                                      'ST'),
15438
                                                                     ('GraphicsTypeSimpleType',
15439
                                                                      'src/ocrd_validators/page.xsd',
15440
                                                                      'ST'),
15441
                                                                     ('ChartTypeSimpleType',
15442
                                                                      'src/ocrd_validators/page.xsd',
15443
                                                                      'ST'),
15444
                                                                     ('PointsType',
15445
                                                                      'src/ocrd_validators/page.xsd',
15446
                                                                      'ST'),
15447
                                                                     ('ProductionSimpleType',
15448
                                                                      'src/ocrd_validators/page.xsd',
15449
                                                                      'ST'),
15450
                                                                     ('AlignSimpleType',
15451
                                                                      'src/ocrd_validators/page.xsd',
15452
                                                                      'ST'),
15453
                                                                     ('GroupTypeSimpleType',
15454
                                                                      'src/ocrd_validators/page.xsd',
15455
                                                                      'ST'),
15456
                                                                     ('TextDataTypeSimpleType',
15457
                                                                      'src/ocrd_validators/page.xsd',
15458
                                                                      'ST'),
15459
                                                                     ('UnderlineStyleSimpleType',
15460
                                                                      'src/ocrd_validators/page.xsd',
15461
                                                                      'ST'),
15462
                                                                     ('PcGtsType',
15463
                                                                      'src/ocrd_validators/page.xsd',
15464
                                                                      'CT'),
15465
                                                                     ('MetadataType',
15466
                                                                      'src/ocrd_validators/page.xsd',
15467
                                                                      'CT'),
15468
                                                                     ('MetadataItemType',
15469
                                                                      'src/ocrd_validators/page.xsd',
15470
                                                                      'CT'),
15471
                                                                     ('LabelsType',
15472
                                                                      'src/ocrd_validators/page.xsd',
15473
                                                                      'CT'),
15474
                                                                     ('LabelType',
15475
                                                                      'src/ocrd_validators/page.xsd',
15476
                                                                      'CT'),
15477
                                                                     ('PageType',
15478
                                                                      'src/ocrd_validators/page.xsd',
15479
                                                                      'CT'),
15480
                                                                     ('TextRegionType',
15481
                                                                      'src/ocrd_validators/page.xsd',
15482
                                                                      'CT'),
15483
                                                                     ('CoordsType',
15484
                                                                      'src/ocrd_validators/page.xsd',
15485
                                                                      'CT'),
15486
                                                                     ('TextLineType',
15487
                                                                      'src/ocrd_validators/page.xsd',
15488
                                                                      'CT'),
15489
                                                                     ('WordType',
15490
                                                                      'src/ocrd_validators/page.xsd',
15491
                                                                      'CT'),
15492
                                                                     ('GlyphType',
15493
                                                                      'src/ocrd_validators/page.xsd',
15494
                                                                      'CT'),
15495
                                                                     ('TextEquivType',
15496
                                                                      'src/ocrd_validators/page.xsd',
15497
                                                                      'CT'),
15498
                                                                     ('ImageRegionType',
15499
                                                                      'src/ocrd_validators/page.xsd',
15500
                                                                      'CT'),
15501
                                                                     ('LineDrawingRegionType',
15502
                                                                      'src/ocrd_validators/page.xsd',
15503
                                                                      'CT'),
15504
                                                                     ('GraphicRegionType',
15505
                                                                      'src/ocrd_validators/page.xsd',
15506
                                                                      'CT'),
15507
                                                                     ('TableRegionType',
15508
                                                                      'src/ocrd_validators/page.xsd',
15509
                                                                      'CT'),
15510
                                                                     ('GridType',
15511
                                                                      'src/ocrd_validators/page.xsd',
15512
                                                                      'CT'),
15513
                                                                     ('GridPointsType',
15514
                                                                      'src/ocrd_validators/page.xsd',
15515
                                                                      'CT'),
15516
                                                                     ('ChartRegionType',
15517
                                                                      'src/ocrd_validators/page.xsd',
15518
                                                                      'CT'),
15519
                                                                     ('SeparatorRegionType',
15520
                                                                      'src/ocrd_validators/page.xsd',
15521
                                                                      'CT'),
15522
                                                                     ('MathsRegionType',
15523
                                                                      'src/ocrd_validators/page.xsd',
15524
                                                                      'CT'),
15525
                                                                     ('ChemRegionType',
15526
                                                                      'src/ocrd_validators/page.xsd',
15527
                                                                      'CT'),
15528
                                                                     ('MapRegionType',
15529
                                                                      'src/ocrd_validators/page.xsd',
15530
                                                                      'CT'),
15531
                                                                     ('MusicRegionType',
15532
                                                                      'src/ocrd_validators/page.xsd',
15533
                                                                      'CT'),
15534
                                                                     ('AdvertRegionType',
15535
                                                                      'src/ocrd_validators/page.xsd',
15536
                                                                      'CT'),
15537
                                                                     ('NoiseRegionType',
15538
                                                                      'src/ocrd_validators/page.xsd',
15539
                                                                      'CT'),
15540
                                                                     ('UnknownRegionType',
15541
                                                                      'src/ocrd_validators/page.xsd',
15542
                                                                      'CT'),
15543
                                                                     ('CustomRegionType',
15544
                                                                      'src/ocrd_validators/page.xsd',
15545
                                                                      'CT'),
15546
                                                                     ('PrintSpaceType',
15547
                                                                      'src/ocrd_validators/page.xsd',
15548
                                                                      'CT'),
15549
                                                                     ('ReadingOrderType',
15550
                                                                      'src/ocrd_validators/page.xsd',
15551
                                                                      'CT'),
15552
                                                                     ('RegionRefIndexedType',
15553
                                                                      'src/ocrd_validators/page.xsd',
15554
                                                                      'CT'),
15555
                                                                     ('OrderedGroupIndexedType',
15556
                                                                      'src/ocrd_validators/page.xsd',
15557
                                                                      'CT'),
15558
                                                                     ('UnorderedGroupIndexedType',
15559
                                                                      'src/ocrd_validators/page.xsd',
15560
                                                                      'CT'),
15561
                                                                     ('RegionRefType',
15562
                                                                      'src/ocrd_validators/page.xsd',
15563
                                                                      'CT'),
15564
                                                                     ('OrderedGroupType',
15565
                                                                      'src/ocrd_validators/page.xsd',
15566
                                                                      'CT'),
15567
                                                                     ('UnorderedGroupType',
15568
                                                                      'src/ocrd_validators/page.xsd',
15569
                                                                      'CT'),
15570
                                                                     ('BorderType',
15571
                                                                      'src/ocrd_validators/page.xsd',
15572
                                                                      'CT'),
15573
                                                                     ('LayersType',
15574
                                                                      'src/ocrd_validators/page.xsd',
15575
                                                                      'CT'),
15576
                                                                     ('LayerType',
15577
                                                                      'src/ocrd_validators/page.xsd',
15578
                                                                      'CT'),
15579
                                                                     ('BaselineType',
15580
                                                                      'src/ocrd_validators/page.xsd',
15581
                                                                      'CT'),
15582
                                                                     ('RelationsType',
15583
                                                                      'src/ocrd_validators/page.xsd',
15584
                                                                      'CT'),
15585
                                                                     ('RelationType',
15586
                                                                      'src/ocrd_validators/page.xsd',
15587
                                                                      'CT'),
15588
                                                                     ('TextStyleType',
15589
                                                                      'src/ocrd_validators/page.xsd',
15590
                                                                      'CT'),
15591
                                                                     ('RegionType',
15592
                                                                      'src/ocrd_validators/page.xsd',
15593
                                                                      'CT'),
15594
                                                                     ('AlternativeImageType',
15595
                                                                      'src/ocrd_validators/page.xsd',
15596
                                                                      'CT'),
15597
                                                                     ('GraphemesType',
15598
                                                                      'src/ocrd_validators/page.xsd',
15599
                                                                      'CT'),
15600
                                                                     ('GraphemeBaseType',
15601
                                                                      'src/ocrd_validators/page.xsd',
15602
                                                                      'CT'),
15603
                                                                     ('GraphemeType',
15604
                                                                      'src/ocrd_validators/page.xsd',
15605
                                                                      'CT'),
15606
                                                                     ('NonPrintingCharType',
15607
                                                                      'src/ocrd_validators/page.xsd',
15608
                                                                      'CT'),
15609
                                                                     ('GraphemeGroupType',
15610
                                                                      'src/ocrd_validators/page.xsd',
15611
                                                                      'CT'),
15612
                                                                     ('UserDefinedType',
15613
                                                                      'src/ocrd_validators/page.xsd',
15614
                                                                      'CT'),
15615
                                                                     ('UserAttributeType',
15616
                                                                      'src/ocrd_validators/page.xsd',
15617
                                                                      'CT'),
15618
                                                                     ('TableCellRoleType',
15619
                                                                      'src/ocrd_validators/page.xsd',
15620
                                                                      'CT'),
15621
                                                                     ('RolesType',
15622
                                                                      'src/ocrd_validators/page.xsd',
15623
                                                                      'CT')]}
15624
15625
__all__ = [
15626
    "AdvertRegionType",
15627
    "AlternativeImageType",
15628
    "BaselineType",
15629
    "BorderType",
15630
    "ChartRegionType",
15631
    "ChemRegionType",
15632
    "CoordsType",
15633
    "CustomRegionType",
15634
    "GlyphType",
15635
    "GraphemeBaseType",
15636
    "GraphemeGroupType",
15637
    "GraphemeType",
15638
    "GraphemesType",
15639
    "GraphicRegionType",
15640
    "GridPointsType",
15641
    "GridType",
15642
    "ImageRegionType",
15643
    "LabelType",
15644
    "LabelsType",
15645
    "LayerType",
15646
    "LayersType",
15647
    "LineDrawingRegionType",
15648
    "MapRegionType",
15649
    "MathsRegionType",
15650
    "MetadataItemType",
15651
    "MetadataType",
15652
    "MusicRegionType",
15653
    "NoiseRegionType",
15654
    "NonPrintingCharType",
15655
    "OrderedGroupIndexedType",
15656
    "OrderedGroupType",
15657
    "PageType",
15658
    "PcGtsType",
15659
    "PrintSpaceType",
15660
    "ReadingOrderType",
15661
    "RegionRefIndexedType",
15662
    "RegionRefType",
15663
    "RegionType",
15664
    "RelationType",
15665
    "RelationsType",
15666
    "RolesType",
15667
    "SeparatorRegionType",
15668
    "TableCellRoleType",
15669
    "TableRegionType",
15670
    "TextEquivType",
15671
    "TextLineType",
15672
    "TextRegionType",
15673
    "TextStyleType",
15674
    "UnknownRegionType",
15675
    "UnorderedGroupIndexedType",
15676
    "UnorderedGroupType",
15677
    "UserAttributeType",
15678
    "UserDefinedType",
15679
    "WordType"
15680
]
15681