Code Duplication    Length = 113-118 lines in 2 locations

src/ocrd_models/ocrd_page_generateds.py 2 locations

@@ 6216-6333 (lines=118) @@
6213
# end class GridPointsType
6214
6215
6216
class PrintSpaceType(GeneratedsSuper):
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
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
@@ 12106-12218 (lines=113) @@
12103
# end class TableCellRoleType
12104
12105
12106
class RolesType(GeneratedsSuper):
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
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