"""ANUGA specific dependency graph Usage: python anuga_dependencies.py """ import sys import os.path import imp from depgraph2dot import pydepgraphdot class ANUGAdepgraph(pydepgraphdot): def toocommon(self,s,type): """ Return true if references to this module are uninteresting. Such references do not get drawn. This is ANUGA specific. """ if s=='__main__': # references *to* __main__ are never interesting. # Omitting them means that __main__ floats to the top of the page return False return True #if type in [imp.PY_SOURCE, imp.C_EXTENSION] and s.startswith('anuga'): if s.startswith('anuga.utilities'): return True elif s.startswith('anuga.caching'): return True elif type in [imp.PY_SOURCE, imp.PKG_DIRECTORY] and s.startswith('anuga'): # Only consider ANUGA source modules and packages if s.startswith('anuga.config'): return True # Except config.py if s == 'anuga': return True # Except the anuga root itself # sys.stderr.write('Draw dependency to %s\n' % s) return False else: return True 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 # are drawn next to each other. This is a default policy - please override. # if b.split('.')[-1].startswith('_'): # A module that starts with an underscore. You need a special reason to # import these (for example random imports _random), so draw them close # together return 4 # if a nd b exist in the same directory, draw closer together a_dir = os.path.basename(os.path.dirname(a)) b_dir = os.path.basename(os.path.dirname(b)) if a_dir == b_dir: return 4 return 3 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 # vertical space between seperate subsystems. This is a default policy - please override. # return 0 def label(self,s): # Convert a module name to a formatted node label. # # Remove leading 'anuga' in label I = s.split('.') if len(I) > 1: if I[0] == 'anuga': I = I[1:] return '\\.\\n'.join(I) def main(): ANUGAdepgraph().main(sys.argv[1:]) if __name__=='__main__': main()