2006-12-07 13:41:40 +00:00
|
|
|
#!/usr/bin/python
|
|
|
|
|
|
|
|
import os
|
2007-08-02 12:09:30 +00:00
|
|
|
import sys
|
2008-05-29 05:25:36 +00:00
|
|
|
import glob
|
2007-08-02 12:09:30 +00:00
|
|
|
|
2008-05-29 05:25:36 +00:00
|
|
|
if len(sys.argv) == 2 and (sys.argv[1] in ['-h', '--help']):
|
|
|
|
print >>sys.stderr, 'Usage: module_graph.py [module1 module2 module3]\n\tWhen no module is specified, all modules in current directory are used'
|
|
|
|
sys.exit(1)
|
2007-08-02 12:09:30 +00:00
|
|
|
|
|
|
|
modules = sys.argv[1:]
|
2008-05-29 05:25:36 +00:00
|
|
|
if not len(modules):
|
|
|
|
modules = map(os.path.dirname, glob.glob(os.path.join('*', '__terp__.py')))
|
|
|
|
|
2007-08-02 12:09:30 +00:00
|
|
|
done = []
|
2006-12-07 13:41:40 +00:00
|
|
|
|
|
|
|
print 'digraph G {'
|
2007-08-02 12:09:30 +00:00
|
|
|
while len(modules):
|
|
|
|
f = modules.pop(0)
|
|
|
|
done.append(f)
|
2006-12-07 13:41:40 +00:00
|
|
|
if os.path.isfile(os.path.join(f,"__terp__.py")):
|
|
|
|
info=eval(file(os.path.join(f,"__terp__.py")).read())
|
2007-04-21 13:30:47 +00:00
|
|
|
if info.get('installable', True):
|
2006-12-07 13:41:40 +00:00
|
|
|
for name in info['depends']:
|
2007-08-02 12:09:30 +00:00
|
|
|
if name not in done+modules:
|
|
|
|
modules.append(name)
|
2006-12-07 13:41:40 +00:00
|
|
|
print '\t%s -> %s;' % (f, name)
|
|
|
|
print '}'
|