| Total Complexity | 12 | 
| Total Lines | 26 | 
| Duplicated Lines | 0 % | 
| 1 | import os | ||
| 4 | class Pipeline(object): | ||
| 5 | |||
| 6 | def __init__(self, files): | ||
| 7 | self.files = files | ||
| 8 | self.roots = set([f for f in files if f.parents == []]) | ||
| 9 | def locationBranchRecurse(image): | ||
| 10 |             branch = {} | ||
| 11 | loc = image.location.toString() | ||
| 12 | children = [f for f in files if loc in f.parents] | ||
| 13 | for child in children: | ||
| 14 | branch[child.location.toString()] = locationBranchRecurse(child) | ||
| 15 | return branch | ||
| 16 |         self.locationTree = {} | ||
| 17 | for f in self.roots: | ||
| 18 | self.locationTree[f.location.toString()] = locationBranchRecurse(f) | ||
| 19 | |||
| 20 | def asFilenameTree(self): | ||
| 21 | def toFilenameTree(d): | ||
| 22 |             new = {} | ||
| 23 | for k, v in d.iteritems(): | ||
| 24 | if isinstance(v, dict): | ||
| 25 | v = toFilenameTree(v) | ||
| 26 |                 newkey = os.path.basename(k.split(':')[1]) | ||
| 27 | new[newkey] = v | ||
| 28 | return new | ||
| 29 | return toFilenameTree(self.locationTree) | ||
| 30 | |||
| 34 |