mod_name, type, path) == False:
return False # don't draw nodes we wouldn't visit
return True
- def follow_edge_test(self, module_name, type, path,
+ def follow_edge_test(self, module_name, type, path,
dname, dtype, dpath):
LOG.debug('testing edge from %s %s %s to %s %s %s'
% (module_name, type, path, dname, dtype, dpath))
elif self._link_outside_visited_nodes == False \
and self._invisible_path(dpath) == True :
LOG.debug('invisible module path %s' % dpath)
- return False # don't draw edges to invisible path modules
+ return False # don't draw edges to invisible path modules
#elif dtype == imp.PKG_DIRECTORY:
# # don't draw edges to packages.
# LOG.debug('package')
def _fix_name(self, mod_name):
# Convert a module name to a syntactically correct node name
- return mod_name.replace('.','_')
+ return mod_name.replace('.','_')
def _label(self,s):
# Convert a module name to a formatted node label.
return '\\.\\n'.join(s.split('.'))
def _weight(self, mod_name, target_name):
# Return the weight of the dependency from a to b. Higher weights
# usually have shorter straighter edges. Return 1 if it has normal weight.
- # A value of 4 is usually good for ensuring that a related pair of modules
+ # A value of 4 is usually good for ensuring that a related pair of modules
# are drawn next to each other.
#
if target_name.split('.')[-1].startswith('_'):
vf = float(ord(n[3]))/0xff
r,g,b = colorsys.hsv_to_rgb(hf, 0.3+0.6*sf, 0.8+0.2*vf)
return '#%02x%02x%02x' % (r*256,g*256,b*256)
-
+
# abstract out most of the dot language for head and edge declarations
def _dot_node(self, name, attrs) :
string = ' %s' % self._fix_name(name)
if root_module != None :
self.add_module_target(root_module)
-
+
depgraph,type,paths = self.fill_missing_deps(depgraph, types, paths)
f = self.get_output_file()
if self._hooks.follow_edge_test(mod, type, path,
d, types[d], paths[d]) :
LOG.debug('follow to %s' % d)
- #print "%s, %s, %s, %s, %s, %s, %s" % (mod, deps, type, path, d, types[d], paths[d])
+ #print "%s, %s, %s, %s, %s, %s, %s" % (mod, deps, type, path, d, types[d], paths[d])
f.write(self._dotformat.edge(mod, deps, type, path,
d, types[d], paths[d]))
self.add_module_target(d)
if not depgraph.has_key(dep):
# if dep not listed in depgraph somehow...
# add it in, with no further dependencies
- depgraph[dep] = {}
+ depgraph[dep] = {}
# add dummies to types and paths too, if neccessary
if not dep in types :
types[dep] = None
else :
return None # no more modules! we're done.
-
+
if __name__=='__main__':
from optparse import OptionParser
_STREAM_HANDLER.setLevel(log_level)
# Fancyness with shared hooks instance so we can do slick thinks like
- # printing all modules just inside an invisible zone, since we'll need
+ # printing all modules just inside an invisible zone, since we'll need
# the dotformatter to know which nodes are visible.
hk = hooks(link_outside_visited_nodes=False)
dt = dotformat_Cext(colored=options.color, hooks_instance=hk)
self._paths = {}
self._last_caller = None
modulefinder.ModuleFinder.__init__(self,*args,**kwargs)
-
+
def import_hook(self, name, caller=None, fromlist=None, level=-1):
old_last_caller = self._last_caller
try:
return modulefinder.ModuleFinder.import_hook(self,name,caller,fromlist, level)
finally:
self._last_caller = old_last_caller
-
+
def import_module(self,partnam,fqname,parent):
r = modulefinder.ModuleFinder.import_module(self,partnam,fqname,parent)
if r is not None:
self._depgraph.setdefault(self._last_caller.__name__,{})[r.__name__] = 1
return r
-
+
def load_module(self, fqname, fp, pathname, (suffix, mode, type)):
r = modulefinder.ModuleFinder.load_module(self, fqname, fp, pathname, (suffix, mode, type))
if r is not None:
self._types[r.__name__] = type
self._paths[r.__name__] = pathname
return r
-
-
+
+
if __name__=='__main__':
from optparse import OptionParser
from pprint import pprint