forked from schism-dev/schism
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcull_depends.py
executable file
·30 lines (27 loc) · 983 Bytes
/
cull_depends.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
#!/usr/bin/env python
import string
import os.path as pth
def cull_depends(infile,outfile, targets):
inp = open(infile,'r')
inlines = inp.readlines()
inp.close()
out = open(outfile,'w')
assert inlines[0].startswith("# DO NOT DELETE")
out.write(inlines[0])
for line in inlines[1:]:
target,depends = line.split(":")
#print "depends: %s" % [pth.splitext(x)[0] for x in depends.strip().split(" ")]
moddeps = [x for x in depends.strip().split(" ") if pth.splitext(x)[0] in targets]
#print "targets: %s" % targets
#print "target: %s" % target
#print moddeps
if len(moddeps) > 0:
out.write("%s: %s\n" % (target,string.join(moddeps," ")))
if __name__ == "__main__":
import sys
infile = sys.argv[1]
outfile = sys.argv[2]
targets = [pth.splitext(x)[0] for x in sys.argv[3].split()]
#print "targets: %s" %targets
print("Culling dependencies")
cull_depends(infile,outfile,targets)