Code Duplication    Length = 28-28 lines in 3 locations

src/ocrd_models/ocrd_page_generateds.py 2 locations

@@ 8051-8078 (lines=28) @@
8048
        return self.get_AllIndexed()
8049
    
8050
    # pylint: disable=line-too-long,invalid-name,missing-module-docstring,missing-function-docstring
8051
    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
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
@@ 7088-7115 (lines=28) @@
7085
        return self.get_AllIndexed()
7086
    
7087
    # pylint: disable=line-too-long,invalid-name,missing-module-docstring,missing-function-docstring
7088
    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
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

src/ocrd_page_user_methods/_exportChildren_GroupType.py 1 location

@@ 2-29 (lines=28) @@
1
# pylint: disable=line-too-long,invalid-name,missing-module-docstring,missing-function-docstring
2
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
3
    if pretty_print:
4
        eol_ = '\n'
5
    else:
6
        eol_ = ''
7
    if self.UserDefined is not None:
8
        namespaceprefix_ = self.UserDefined_nsprefix_ + ':' if (UseCapturedNS_ and self.UserDefined_nsprefix_) else ''
9
        self.UserDefined.export(outfile, level, namespaceprefix_, namespacedef_='', name_='UserDefined', pretty_print=pretty_print)
10
    for Labels_ in self.Labels:
11
        namespaceprefix_ = self.Labels_nsprefix_ + ':' if (UseCapturedNS_ and self.Labels_nsprefix_) else ''
12
        Labels_.export(outfile, level, namespaceprefix_, namespacedef_='', name_='Labels', pretty_print=pretty_print)
13
    cleaned = []
14
    def replaceWithRRI(group):
15
        rri = RegionRefIndexedType.factory(parent_object_=self) # pylint: disable=undefined-variable
16
        rri.index = group.index
17
        rri.regionRef = group.regionRef
18
        cleaned.append(rri)
19
    # remove empty groups and replace with RegionRefIndexedType
20
    for entry in self.get_AllIndexed():
21
        # pylint: disable=undefined-variable
22
        if isinstance(entry, (OrderedGroupIndexedType)) and not entry.get_AllIndexed():
23
            replaceWithRRI(entry)
24
        elif isinstance(entry, UnorderedGroupIndexedType) and not entry.get_UnorderedGroupChildren():
25
            replaceWithRRI(entry)
26
        else:
27
            cleaned.append(entry)
28
    for entry in cleaned:
29
        entry.export(outfile, level, namespaceprefix_, namespacedef_='', name_=entry.__class__.__name__[:-4], pretty_print=pretty_print)
30