From adb5e4b678b95e2f3d939ffae7dacff0fe431ecd Mon Sep 17 00:00:00 2001 From: "W. Trevor King" Date: Sat, 8 Jan 2011 22:35:04 -0500 Subject: [PATCH] Strip trailing whitespace from all files. --- README | 4 ++-- depgraph2dot.py | 20 ++++++++++---------- py2depgraph.py | 10 +++++----- 3 files changed, 17 insertions(+), 17 deletions(-) diff --git a/README b/README index db51f4e..f181014 100644 --- a/README +++ b/README @@ -4,8 +4,8 @@ http://tarind.com/depgraph.html Generate python module dependency graphs using dot (graphviz package) $ 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, +I added some code to also save the path of any modules, +so it would be easier to only print modules with particular paths, or to make the boundary between python and other languages more clear. Now the default is to only print modules I wrote or those involving comedi, diff --git a/depgraph2dot.py b/depgraph2dot.py index 01d36c7..5edd590 100755 --- a/depgraph2dot.py +++ b/depgraph2dot.py @@ -92,7 +92,7 @@ class hooks (object) : 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)) @@ -112,7 +112,7 @@ class hooks (object) : 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') @@ -183,14 +183,14 @@ class dotformat (object) : 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('_'): @@ -231,7 +231,7 @@ class dotformat (object) : 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) @@ -333,7 +333,7 @@ class pydepgraphdot (object) : 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() @@ -365,7 +365,7 @@ class pydepgraphdot (object) : 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) @@ -387,7 +387,7 @@ class pydepgraphdot (object) : 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 @@ -415,7 +415,7 @@ class pydepgraphdot (object) : else : return None # no more modules! we're done. - + if __name__=='__main__': from optparse import OptionParser @@ -433,7 +433,7 @@ if __name__=='__main__': _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) diff --git a/py2depgraph.py b/py2depgraph.py index f525f88..a733fc4 100755 --- a/py2depgraph.py +++ b/py2depgraph.py @@ -34,7 +34,7 @@ class mymf(modulefinder.ModuleFinder): 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: @@ -42,21 +42,21 @@ class mymf(modulefinder.ModuleFinder): 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 -- 2.26.2