Passed
Pull Request — master (#655)
by Konstantin
03:18 queued 25s
created

get_AllAlternativeImages   A

Complexity

Total Complexity 10

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 10
eloc 18
dl 0
loc 28
rs 10
c 0
b 0
f 0

1 Function

Rating   Name   Duplication   Size   Complexity  
C get_AllAlternativeImages() 0 27 10
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
6
    page (boolean): Get pc:Page level images
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
    ret = []
13
    if page:
14
        ret += self.get_AlternativeImage()
15
    for this_region in self.get_AllRegions(['Text']):
16
        if region:
17
            ret += this_region.get_AlternativeImage()
18
        for this_line in this_region.get_TextLine():
19
            if line:
20
                ret += this_line.get_AlternativeImage()
21
            for this_word in this_line.get_Word():
22
                if word:
23
                    ret += this_word.get_AlternativeImage()
24
                for this_glyph in this_word.get_Glyph():
25
                    if glyph:
26
                        ret += this_glyph.get_AlternativeImage()
27
    return ret
28
29