Code Duplication    Length = 30-30 lines in 2 locations

src/ocrd_models/ocrd_page_generateds.py 1 location

@@ 3218-3247 (lines=30) @@
3215
                else:
3216
                    ret = in_reading_order + [r for r in ret if r not in in_reading_order]
3217
        return ret
3218
    def get_AllAlternativeImages(self, page=True, region=True, line=True, word=True, glyph=True):
3219
        """
3220
        Get all the ``pc:AlternativeImage`` in a document
3221
    
3222
        Arguments:
3223
            page (boolean): Get images on ``pc:Page`` level
3224
            region (boolean): Get images on ``pc:*Region`` level
3225
            line (boolean): Get images on ``pc:TextLine`` level
3226
            word (boolean): Get images on ``pc:Word`` level
3227
            glyph (boolean): Get images on ``pc:Glyph`` level
3228
    
3229
        Returns:
3230
            a list of :py:class:`AlternativeImageType`
3231
        """
3232
        ret = []
3233
        if page:
3234
            ret += self.get_AlternativeImage()
3235
        for this_region in self.get_AllRegions(['Text']):
3236
            if region:
3237
                ret += this_region.get_AlternativeImage()
3238
            for this_line in this_region.get_TextLine():
3239
                if line:
3240
                    ret += this_line.get_AlternativeImage()
3241
                for this_word in this_line.get_Word():
3242
                    if word:
3243
                        ret += this_word.get_AlternativeImage()
3244
                    for this_glyph in this_word.get_Glyph():
3245
                        if glyph:
3246
                            ret += this_glyph.get_AlternativeImage()
3247
        return ret
3248
    
3249
    def invalidate_AlternativeImage(self, feature_selector=None):
3250
        """

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