Code Duplication    Length = 18-18 lines in 2 locations

src/ocrd_page_user_methods/prune_ReadingOrder.py 1 location

@@ 1-18 (lines=18) @@
1
def prune_ReadingOrder(self):
2
    """
3
    Remove any empty ReadingOrder elements
4
    """
5
    ro = self.get_Page().get_ReadingOrder()
6
    if ro:
7
        og = ro.get_OrderedGroup()
8
        if og and (not og.get_RegionRefIndexed() and
9
                   not og.get_OrderedGroupIndexed() and
10
                   not og.get_UnorderedGroupIndexed()):
11
            og = None
12
        ug = ro.get_UnorderedGroup()
13
        if ug and (not ug.get_RegionRef() and
14
                   not ug.get_OrderedGroup() and
15
                   not ug.get_UnorderedGroup()):
16
            ug = None
17
        if not og and not ug:
18
            self.get_Page().set_ReadingOrder(None)
19

src/ocrd_models/ocrd_page_generateds.py 1 location

@@ 1771-1788 (lines=18) @@
1768
                ret += doc.xpath('//page:Glyph/page:AlternativeImage/@filename', namespaces=NAMESPACES)
1769
    
1770
        return ret
1771
    def prune_ReadingOrder(self):
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