-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmincheck.py
41 lines (34 loc) · 984 Bytes
/
mincheck.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
import sys
def get_listed(fn):
modules = set()
for line in file(fn).readlines():
modules.add(line.split()[1])
return modules
def get_dependencies(fn):
t = eval(file(fn).read())
modules = set()
depgraph = t['depgraph']
for mod, deps in depgraph.iteritems():
if mod != '__main__':
modules.add(mod)
modules.update(deps.keys())
return depgraph, modules
def main():
mods = get_listed(sys.argv[1])
depgraph, deps = get_dependencies(sys.argv[2])
print "Listed modules:", sorted(mods)
print
print "Dependent modules:", sorted(deps)
print
missing = deps.difference(mods)
if missing:
print "Missing modules in python-minimal:"
print missing
for m in missing:
users = []
for caller, callees in depgraph.iteritems():
if m in callees:
users.append(caller)
print m, "used in: ", users
sys.exit(len(missing))
main()