Conditions | 8 |
Total Lines | 22 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | from niprov.dependencies import Dependencies |
||
10 | def forFile(self, image): |
||
11 | """Create a Pipeline object based on known files 'parents' field. |
||
12 | """ |
||
13 | filesByLocation = {image.location.toString():image} |
||
14 | |||
15 | def lookupRelativesRecursive(images, relationToLookFor): |
||
16 | if relationToLookFor is 'parents': |
||
17 | parentLocations = set() |
||
18 | for image in images: |
||
19 | parentLocations.update(image.provenance.get('parents',[])) |
||
20 | relatives = self.files.byLocations(list(parentLocations)) |
||
21 | elif relationToLookFor is 'children': |
||
22 | thisGenerationLocations = [i.location.toString() for i in images] |
||
23 | relatives = self.files.byParents(thisGenerationLocations) |
||
24 | for relative in relatives: |
||
25 | filesByLocation[relative.location.toString()] = relative |
||
26 | if relatives: |
||
27 | lookupRelativesRecursive(relatives, relationToLookFor) |
||
28 | |||
29 | lookupRelativesRecursive([image], 'parents') |
||
30 | lookupRelativesRecursive([image], 'children') |
||
31 | return Pipeline(filesByLocation.values()) |
||
32 |