From: W. Trevor King Date: Sun, 9 Jan 2011 02:45:12 +0000 (-0500) Subject: Set executable bits and add level arg to py2depgraph.mymf.import_hook(). X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=8b3ec8ef8eff5529842885436411e7cfd9774eb8;p=depgraph.git Set executable bits and add level arg to py2depgraph.mymf.import_hook(). --- diff --git a/README b/README index cbc6e5f..db51f4e 100644 --- a/README +++ b/README @@ -2,7 +2,7 @@ Originals from: "Toby Dickenson" 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, diff --git a/depgraph2dot.py b/depgraph2dot.py old mode 100644 new mode 100755 index 594e486..6d11157 --- a/depgraph2dot.py +++ b/depgraph2dot.py @@ -1,7 +1,7 @@ -#!/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 diff --git a/py2depgraph.py b/py2depgraph.py old mode 100644 new mode 100755 index f2bfe29..cb2bc86 --- a/py2depgraph.py +++ b/py2depgraph.py @@ -1,5 +1,7 @@ +#!/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 @@ -31,11 +33,11 @@ class mymf(modulefinder.ModuleFinder): 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