http://tarind.com/depgraph.html
Generate python module dependency graphs using dot (graphviz package)
-$ python py2depgraph.py path/to/my/script.py | python depgraph2dot.py | dot -T png -o depgraph.png
+$ py2depgraph.py path/to/my/script.py | depgraph2dot.py | dot -T png -o depgraph.png
I added some code to also save the path of any modules,
so it would be easier to only print modules with particular paths,
-#!/usr/bin/python
+#!/usr/bin/env python
#
# Copyright 2004 Toby Dickenson
-# Copyright 2008-2010 W. Trevor King
+# Copyright 2008-2011 W. Trevor King
#
# Permission is hereby granted, free of charge, to any person obtaining
# a copy of this software and associated documentation files (the
+#!/usr/bin/env python
+#
# Copyright 2004 Toby Dickenson
-# Copyright 2008-2010 W. Trevor King
+# Copyright 2008-2011 W. Trevor King
#
# Permission is hereby granted, free of charge, to any person obtaining
# a copy of this software and associated documentation files (the
self._last_caller = None
modulefinder.ModuleFinder.__init__(self,*args,**kwargs)
- def import_hook(self, name, caller=None, fromlist=None):
+ def import_hook(self, name, caller=None, fromlist=None, level=-1):
old_last_caller = self._last_caller
try:
self._last_caller = caller
- return modulefinder.ModuleFinder.import_hook(self,name,caller,fromlist)
+ return modulefinder.ModuleFinder.import_hook(self,name,caller,fromlist, level)
finally:
self._last_caller = old_last_caller