Code Duplication    Length = 30-30 lines in 2 locations

src/ocrd_page_user_methods/get_AllAlternativeImages.py 1 location

@@ 1-30 (lines=30) @@
1
def get_AllAlternativeImages(self, page=True, region=True, line=True, word=True, glyph=True):
2
    """
3
    Get all the ``pc:AlternativeImage`` in a document
4
5
    Arguments:
6
        page (boolean): Get images on ``pc:Page`` level
7
        region (boolean): Get images on ``pc:*Region`` level
8
        line (boolean): Get images on ``pc:TextLine`` level
9
        word (boolean): Get images on ``pc:Word`` level
10
        glyph (boolean): Get images on ``pc:Glyph`` level
11
12
    Returns:
13
        a list of :py:class:`AlternativeImageType`
14
    """
15
    ret = []
16
    if page:
17
        ret += self.get_AlternativeImage()
18
    for this_region in self.get_AllRegions(['Text']):
19
        if region:
20
            ret += this_region.get_AlternativeImage()
21
        for this_line in this_region.get_TextLine():
22
            if line:
23
                ret += this_line.get_AlternativeImage()
24
            for this_word in this_line.get_Word():
25
                if word:
26
                    ret += this_word.get_AlternativeImage()
27
                for this_glyph in this_word.get_Glyph():
28
                    if glyph:
29
                        ret += this_glyph.get_AlternativeImage()
30
    return ret
31
32

src/ocrd_models/ocrd_page_generateds.py 1 location

@@ 3824-3853 (lines=30) @@
3821
                else:
3822
                    ret = in_reading_order + [r for r in ret if r not in in_reading_order]
3823
        return ret
3824
    def get_AllAlternativeImages(self, page=True, region=True, line=True, word=True, glyph=True):
3825
        """
3826
        Get all the ``pc:AlternativeImage`` in a document
3827
    
3828
        Arguments:
3829
            page (boolean): Get images on ``pc:Page`` level
3830
            region (boolean): Get images on ``pc:*Region`` level
3831
            line (boolean): Get images on ``pc:TextLine`` level
3832
            word (boolean): Get images on ``pc:Word`` level
3833
            glyph (boolean): Get images on ``pc:Glyph`` level
3834
    
3835
        Returns:
3836
            a list of :py:class:`AlternativeImageType`
3837
        """
3838
        ret = []
3839
        if page:
3840
            ret += self.get_AlternativeImage()
3841
        for this_region in self.get_AllRegions(['Text']):
3842
            if region:
3843
                ret += this_region.get_AlternativeImage()
3844
            for this_line in this_region.get_TextLine():
3845
                if line:
3846
                    ret += this_line.get_AlternativeImage()
3847
                for this_word in this_line.get_Word():
3848
                    if word:
3849
                        ret += this_word.get_AlternativeImage()
3850
                    for this_glyph in this_word.get_Glyph():
3851
                        if glyph:
3852
                            ret += this_glyph.get_AlternativeImage()
3853
        return ret
3854
    
3855
    def invalidate_AlternativeImage(self, feature_selector=None):
3856
        """