Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def get_dir(self):
if ( type(self) in [FortranSubroutine,FortranFunction] and
type(self.parent) is FortranInterface and
not self.parent.generic ):
return 'interface'
elif type(self) is FortranSubmodule:
return 'module'
elif ( type(self) in [FortranSourceFile,FortranProgram,FortranModule,
GenericSource,FortranBlockData]
or ( type(self) in [FortranType,FortranInterface,FortranFunction,
FortranSubroutine, FortranSubmoduleProcedure]
and type(self.parent) in [FortranSourceFile,FortranProgram,
FortranModule, FortranSubmodule,
FortranBlockData] ) ):
return self.obj
else:
return None
dot.node(getattr(n[0],'name',n[0]),**gd.get_node(n[0],cls=n[1]).attribs)
dot.node('This Page\'s Entity')
call_svg = dot.pipe().decode('utf-8')
# Generate key for file graph
dot = Digraph('Graph Key',graph_attr={'size':'8.90625,1000.0',
'concentrate':'false'},
node_attr={'shape':'box',
'height':'0.0',
'margin':'0.08',
'fontname':'Helvetica',
'fontsize':'10.5'},
edge_attr={'fontname':'Helvetica',
'fontsize':'9.5'},
format='svg', engine='dot')
dot.node('Source File',**gd.get_node('Source File',cls=FortranSourceFile).attribs)
dot.node('This Page\'s Entity')
file_svg = dot.pipe().decode('utf-8')
except RuntimeError:
graphviz_installed = False
if graphviz_installed:
NODE_DIAGRAM = """
<p>Nodes of different colours represent the following: </p>
{}
"""
MOD_GRAPH_KEY = (NODE_DIAGRAM + """
<p>Solid arrows point from a submodule to the (sub)module which it is
descended from. Dashed arrows point from a module or program unit to </p>
def get_dir(self):
if ( type(self) in [FortranSubroutine,FortranFunction] and
type(self.parent) is FortranInterface and
not self.parent.generic ):
return 'interface'
elif type(self) is FortranSubmodule:
return 'module'
elif ( type(self) in [FortranSourceFile,FortranProgram,FortranModule,
GenericSource,FortranBlockData]
or ( type(self) in [FortranType,FortranInterface,FortranFunction,
FortranSubroutine, FortranSubmoduleProcedure]
and type(self.parent) in [FortranSourceFile,FortranProgram,
FortranModule, FortranSubmodule,
FortranBlockData] ) ):
return self.obj
else:
return None
return ''
def get_dir(self):
return ''
sub = Proc('Subroutine','Subroutine')
func = Proc('Function','Function')
intr = Proc('Interface','Interface')
gd.register('Module',FortranModule)
gd.register('Submodule',FortranSubmodule)
gd.register('Type',FortranType)
gd.register(sub,FortranSubroutine)
gd.register(func,FortranFunction)
gd.register(intr,FortranInterface)
gd.register('Unknown Procedure Type',FortranSubroutine)
gd.register('Program',FortranProgram)
gd.register('Source File',FortranSourceFile)
try:
# Generate key for module graph
dot = Digraph('Graph Key',graph_attr={'size':'8.90625,1000.0',
'concentrate':'false'},
node_attr={'shape':'box',
'height':'0.0',
'margin':'0.08',
'fontname':'Helvetica',
'fontsize':'10.5'},
edge_attr={'fontname':'Helvetica',
'fontsize':'9.5'},
format='svg', engine='dot')
for n in [('Module',FortranModule),('Submodule',FortranSubmodule),(sub,FortranSubroutine),(func,FortranFunction),('Program', FortranProgram)]:
dot.node(getattr(n[0],'name',n[0]),**gd.get_node(n[0],cls=n[1]).attribs)
dot.node('This Page\'s Entity')
def is_sourcefile(obj, cls):
return isinstance(obj,FortranSourceFile) or issubclass(cls,FortranSourceFile)
def __init__(self,source,first_line,parent=None,inherited_permission=None,
strings=[]):
self.num_lines = 0
if not isinstance(self,FortranSourceFile): self.num_lines += 1
if type(self) != FortranSourceFile:
FortranBase.__init__(self,source,first_line,parent,inherited_permission,
strings)
incontains = False
if type(self) is FortranSubmodule:
permission = "private"
else:
permission = "public"
typestr = ''
for vtype in self.settings['extra_vartypes']:
typestr = typestr + '|' + vtype
self.VARIABLE_RE = re.compile(self.VARIABLE_STRING.format(typestr),re.IGNORECASE)
blocklevel = 0
associatelevel = 0
def __init__(self,obj,gd,hist={}):
super(FileNode,self).__init__(obj)
self.afferent = set() # Things depending on this file
self.efferent = set() # Things this file depends on
if not self.fromstr:
for mod in obj.modules:
for dep in mod.deplist:
if dep.hierarchy[0] == obj:
continue
elif dep.hierarchy[0] in hist:
n = hist[dep.hierarchy[0]]
else:
n = gd.get_node(dep.hierarchy[0],FortranSourceFile,newdict(hist,obj,self))
n.afferent.add(self)
self.efferent.add(n)
for mod in obj.submodules:
for dep in mod.deplist:
if dep.hierarchy[0] == obj:
continue
elif dep.hierarchy[0] in hist:
n = hist[dep.hierarchy[0]]
else:
n = gd.get_node(dep.hierarchy[0],FortranSourceFile,newdict(hist,obj,self))
n.afferent.add(self)
self.efferent.add(n)
for proc in obj.functions + obj.subroutines:
for dep in proc.deplist:
if dep.hierarchy[0] == obj:
continue
def __init__(self,source,first_line,parent=None,inherited_permission=None,
strings=[]):
self.num_lines = 0
if not isinstance(self,FortranSourceFile): self.num_lines += 1
if type(self) != FortranSourceFile:
FortranBase.__init__(self,source,first_line,parent,inherited_permission,
strings)
incontains = False
if type(self) is FortranSubmodule:
permission = "private"
else:
permission = "public"
typestr = ''
for vtype in self.settings['extra_vartypes']:
typestr = typestr + '|' + vtype
self.VARIABLE_RE = re.compile(self.VARIABLE_STRING.format(typestr),re.IGNORECASE)
blocklevel = 0
associatelevel = 0
obj.usedbygraph = ford.graphs.UsedByGraph(obj,self.webdir)
self.modules.add(obj)
elif isinstance(obj,FortranType):
obj.inhergraph = ford.graphs.InheritsGraph(obj,self.webdir)
obj.inherbygraph = ford.graphs.InheritedByGraph(obj,self.webdir)
self.types.add(obj)
elif isinstance(obj,(FortranFunction,FortranSubroutine,FortranInterface,FortranSubmoduleProcedure)):
obj.callsgraph = ford.graphs.CallsGraph(obj,self.webdir)
obj.calledbygraph = ford.graphs.CalledByGraph(obj,self.webdir)
obj.usesgraph = ford.graphs.UsesGraph(obj,self.webdir)
self.procedures.add(obj)
elif isinstance(obj,FortranProgram):
obj.usesgraph = ford.graphs.UsesGraph(obj,self.webdir)
obj.callsgraph = ford.graphs.CallsGraph(obj,self.webdir)
self.programs.add(obj)
elif isinstance(obj,FortranSourceFile):
obj.afferentgraph = ford.graphs.AfferentGraph(obj,self.webdir)
obj.efferentgraph = ford.graphs.EfferentGraph(obj,self.webdir)
self.sourcefiles.add(obj)
elif isinstance(obj,FortranBlockData):
obj.usesgraph = ford.graphs.UsesGraph(obj,self.webdir)
self.blockdata.add(obj)
usenodes = list(self.modules)
callnodes = list(self.procedures)
for p in self.programs:
if len(p.usesgraph.added) > 1: usenodes.append(p)
if len(p.callsgraph.added) > 1: callnodes.append(p)
for p in self.procedures:
if len(p.usesgraph.added) > 1: usenodes.append(p)
for b in self.blockdata:
if len(b.usesgraph.added) > 1: usenodes.append(b)
self.usegraph = ford.graphs.ModuleGraph(usenodes,self.webdir,'module~~graph')