Pipeline   A
last analyzed

Complexity

Total Complexity 12

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
dl 0
loc 26
rs 10
c 0
b 0
f 0
wmc 12

4 Methods

Rating   Name   Duplication   Size   Complexity  
C __init__() 0 13 8
A locationBranchRecurse() 0 7 4
A asFilenameTree() 0 10 4
A toFilenameTree() 0 8 3
1
import os
2
3
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
31
32
33
34