Conditions | 8 |
Total Lines | 31 |
Code Lines | 22 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | def invalidate_AlternativeImage(self, feature_selector=None): |
||
2 | """ |
||
3 | Remove derived images from this segment (due to changed coordinates). |
||
4 | |||
5 | If ``feature_selector`` is not none, remove only images with |
||
6 | matching ``@comments``, e.g. ``feature_selector=cropped,deskewed``. |
||
7 | """ |
||
8 | existing_images = self.AlternativeImage or [] |
||
9 | removed_images = [] |
||
10 | if feature_selector: |
||
11 | new_images = [] |
||
12 | for image in existing_images: |
||
13 | features = image.get_comments() or '' |
||
14 | if any(feature in features.split(',') |
||
15 | for feature in feature_selector.split(',') if feature): |
||
16 | removed_images.append(image) |
||
17 | else: |
||
18 | new_images.append(image) |
||
19 | self.AlternativeImage = new_images |
||
20 | else: |
||
21 | removed_images = existing_images |
||
22 | self.AlternativeImage = [] |
||
23 | if hasattr(self, 'id'): |
||
24 | name = self.id |
||
25 | elif hasattr(self, 'parent_object_') and hasattr(self.parent_object_, 'pcGtsId'): |
||
26 | name = self.parent_object_.pcGtsId |
||
27 | else: |
||
28 | name = '' |
||
29 | for image in removed_images: |
||
30 | self.gds_collector_.add_message('Removing AlternativeImage %s from "%s"' % ( |
||
31 | image.get_comments() or '', name)) |
||
32 |