From 3075a2c72990aa936060dd89fc9e98d9f065e01d Mon Sep 17 00:00:00 2001 From: Mike Crute Date: Sun, 26 Jul 2009 13:17:20 -0400 Subject: Cleaning up spaces --- depgraph2dot.py | 26 +++++++++++++------------- py2depgraph.py | 16 ++++++++-------- 2 files changed, 21 insertions(+), 21 deletions(-) diff --git a/depgraph2dot.py b/depgraph2dot.py index bbebf18..050da44 100644 --- a/depgraph2dot.py +++ b/depgraph2dot.py @@ -24,7 +24,7 @@ import sys, getopt, colorsys, imp, md5 class pydepgraphdot: - def main(self,argv): + def main(self,argv): opts,args = getopt.getopt(argv,'',['mono']) self.colored = 1 for o,v in opts: @@ -35,7 +35,7 @@ class pydepgraphdot: def fix(self,s): # Convert a module name to a syntactically correct node name return s.replace('.','_') - + def render(self): p,t = self.get_data() @@ -44,9 +44,9 @@ class pydepgraphdot: for v in d.keys(): if not p.has_key(v): p[v] = {} - - f = self.get_output_file() - + + f = self.get_output_file() + f.write('digraph G {\n') #f.write('concentrate = true;\n') #f.write('ordering = out;\n') @@ -86,7 +86,7 @@ class pydepgraphdot: if self.toocommon(k,type): a.append('peripheries=2') return a - + def edge_attributes(self,k,v): a = [] weight = self.weight(k,v) @@ -96,11 +96,11 @@ class pydepgraphdot: if length: a.append('minlen=%d' % length) return a - + def get_data(self): t = eval(sys.stdin.read()) return t['depgraph'],t['types'] - + def get_output_file(self): return sys.stdout @@ -133,11 +133,11 @@ class pydepgraphdot: # dont draw references to packages. return 1 return 0 - + def weight(self,a,b): # 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. This is a default policy - please override. # if b.split('.')[-1].startswith('_'): @@ -146,7 +146,7 @@ class pydepgraphdot: # together return 4 return 1 - + def alien(self,a,b): # Return non-zero if references to this module are strange, and should be drawn # extra-long. the value defines the length, in rank. This is also good for putting some @@ -166,7 +166,7 @@ class pydepgraphdot: # same package have the same color. Unpackaged modules are grey t = self.normalise_module_name_for_hash_coloring(s,type) return self.color_from_name(t) - + def normalise_module_name_for_hash_coloring(self,s,type): if type==imp.PKG_DIRECTORY: return s @@ -176,7 +176,7 @@ class pydepgraphdot: return '' else: return s[:i] - + def color_from_name(self,name): n = md5.md5(name).digest() hf = float(ord(n[0])+ord(n[1])*0xff)/0xffff diff --git a/py2depgraph.py b/py2depgraph.py index 5e97e06..bff29fd 100644 --- a/py2depgraph.py +++ b/py2depgraph.py @@ -28,7 +28,7 @@ class mymf(modulefinder.ModuleFinder): self._types = {} self._last_caller = None modulefinder.ModuleFinder.__init__(self,*args,**kwargs) - + def import_hook(self, name, caller=None, fromlist=None): old_last_caller = self._last_caller try: @@ -36,27 +36,27 @@ class mymf(modulefinder.ModuleFinder): return modulefinder.ModuleFinder.import_hook(self,name,caller,fromlist) 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 return r - - -def main(argv): + + +def main(argv): path = sys.path[:] debug = 0 exclude = [] mf = mymf(path,debug,exclude) mf.run_script(argv[0]) pprint.pprint({'depgraph':mf._depgraph,'types':mf._types}) - + if __name__=='__main__': - main(sys.argv[1:]) \ No newline at end of file + main(sys.argv[1:]) -- cgit v1.2.3