| Conditions | 10 |
| Total Lines | 27 |
| Code Lines | 17 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
Complex classes like get_AllAlternativeImages.get_AllAlternativeImages() often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes.
Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.
| 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 |