MCPcopy Create free account
hub / github.com/ActiveState/code / dep

Function dep

recipes/Python/576570_Dependency_resolver/recipe-576570.py:1–19  ·  view source on GitHub ↗

Dependency resolver "arg" is a dependency dictionary in which the values are the dependencies of their respective keys.

(arg)

Source from the content-addressed store, hash-verified

1def dep(arg):
2 '''
3 Dependency resolver
4
5 "arg" is a dependency dictionary in which
6 the values are the dependencies of their respective keys.
7 '''
8 d=dict((k, set(arg[k])) for k in arg)
9 r=[]
10 while d:
11 # values not in keys (items without dep)
12 t=set(i for v in d.values() for i in v)-set(d.keys())
13 # and keys without value (items without dep)
14 t.update(k for k, v in d.items() if not v)
15 # can be done right away
16 r.append(t)
17 # and cleaned up
18 d=dict(((k, v-t) for k, v in d.items() if v))
19 return r
20
21if __name__=='__main__':
22 d=dict(

Callers 1

recipe-576570.pyFile · 0.85

Calls 7

dictFunction · 0.50
setFunction · 0.50
valuesMethod · 0.45
keysMethod · 0.45
updateMethod · 0.45
itemsMethod · 0.45
appendMethod · 0.45

Tested by

no test coverage detected