Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
if only:
if name in uspecs:
ret_types[name] = obj
else:
ret_types[name] = obj
for name, obj in self.pub_vars.items():
name = name.lower()
if only:
if name in uspecs:
ret_vars[name] = obj
else:
ret_vars[name] = obj
return (ret_procs,ret_absints,ret_types,ret_vars)
class FortranSubmodule(FortranModule):
def _initialize(self,line):
FortranModule._initialize(self,line)
self.name = line.group(3)
self.ancestor = line.group(2)
self.ancestor_mod = line.group(1)
self.modprocedures = []
del self.public_list
del self.private_list
del self.protected_list
def _cleanup(self):
# Create list of all local procedures. Ones coming from other modules
# will be added later, during correlation.
self.process_attribs()
self.variables = [v for v in self.variables if 'external' not in v.attribs]
self.all_procs = {}
def graph_all(self):
for obj in tqdm(iter(self.graph_objs), file=sys.stdout, total=len(self.graph_objs), unit=''):
if isinstance(obj,FortranModule):
obj.usesgraph = ford.graphs.UsesGraph(obj,self.webdir)
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)
if mod.ancestor:
if type(mod.ancestor) is ford.sourceform.FortranSubmodule:
uselist.insert(0,mod.ancestor)
elif self.settings['warn'].lower() == 'true':
print('Warning: could not identify parent SUBMODULE of SUBMODULE ' + mod.name)
else:
uselist.insert(0,mod.ancestor_mod)
mod.deplist = uselist
deplist[mod] = set(uselist)
elif self.settings['warn'].lower() == 'true':
print('Warning: could not identify parent MODULE of SUBMODULE ' + mod.name)
# Get dependencies for programs and top-level procedures as well,
# if dependency graphs are to be produced
if self.settings['graph'].lower() == 'true':
for proc in self.procedures:
proc.deplist = set([m for m in get_deps(proc) if type(m) == ford.sourceform.FortranModule])
for prog in self.programs:
prog.deplist = set([m for m in get_deps(prog) if type(m) == ford.sourceform.FortranModule])
for block in self.blockdata:
block.deplist = set([m for m in get_deps(block) if type(m) == ford.sourceform.FortranModule])
ranklist = toposort.toposort_flatten(deplist)
for proc in self.procedures:
if proc.parobj == 'sourcefile': ranklist.append(proc)
ranklist.extend(self.programs)
ranklist.extend(self.blockdata)
# Perform remaining correlations for the project
for container in ranklist:
if type(container) != str: container.correlate(self)
for container in ranklist:
if type(container) != str: container.prune()
self.num_lines += self.modprocedures[-1].num_lines - 1
else:
raise Exception("Found module procedure in {}".format(type(self).__name__[7:].upper()))
elif self.BLOCK_DATA_RE.match(line):
if hasattr(self,'blockdata'):
self.blockdata.append(FortranBlockData(source,self.BLOCK_DATA_RE.match(line),self))
self.num_lines += self.blockdata[-1].num_lines - 1
else:
raise Exception("Found BLOCK DATA in {}".format(type(self).__name__[7:].upper()))
elif self.BLOCK_RE.match(line):
blocklevel += 1
elif self.ASSOCIATE_RE.match(line):
associatelevel += 1
elif self.MODULE_RE.match(line):
if hasattr(self,'modules'):
self.modules.append(FortranModule(source,
self.MODULE_RE.match(line),self))
self.num_lines += self.modules[-1].num_lines - 1
else:
raise Exception("Found MODULE in {}".format(type(self).__name__[7:].upper()))
elif self.SUBMODULE_RE.match(line):
if hasattr(self,'submodules'):
self.submodules.append(FortranSubmodule(source,
self.SUBMODULE_RE.match(line),self))
self.num_lines += self.submodules[-1].num_lines - 1
else:
raise Exception("Found SUBMODULE in {}".format(type(self).__name__[7:].upper()))
elif self.PROGRAM_RE.match(line):
if hasattr(self,'programs'):
self.programs.append(FortranProgram(source,
self.PROGRAM_RE.match(line),self))
self.num_lines += self.programs[-1].num_lines - 1
self.num_lines += self.modprocedures[-1].num_lines - 1
else:
raise Exception("Found module procedure in {}".format(type(self).__name__[7:].upper()))
elif self.BLOCK_DATA_RE.match(line):
if hasattr(self,'blockdata'):
self.blockdata.append(FortranBlockData(source,self.BLOCK_DATA_RE.match(line),self))
self.num_lines += self.blockdata[-1].num_lines - 1
else:
raise Exception("Found BLOCK DATA in {}".format(type(self).__name__[7:].upper()))
elif self.BLOCK_RE.match(line):
blocklevel += 1
elif self.ASSOCIATE_RE.match(line):
associatelevel += 1
elif self.MODULE_RE.match(line):
if hasattr(self,'modules'):
self.modules.append(FortranModule(source,
self.MODULE_RE.match(line),self))
self.num_lines += self.modules[-1].num_lines - 1
else:
raise Exception("Found MODULE in {}".format(type(self).__name__[7:].upper()))
elif self.SUBMODULE_RE.match(line):
if hasattr(self,'submodules'):
self.submodules.append(FortranSubmodule(source,
self.SUBMODULE_RE.match(line),self))
self.num_lines += self.submodules[-1].num_lines - 1
else:
raise Exception("Found SUBMODULE in {}".format(type(self).__name__[7:].upper()))
elif self.PROGRAM_RE.match(line):
if hasattr(self,'programs'):
self.programs.append(FortranProgram(source,
self.PROGRAM_RE.match(line),self))
self.num_lines += self.programs[-1].num_lines - 1
if only:
if name in uspecs:
ret_types[name] = obj
else:
ret_types[name] = obj
for name, obj in self.pub_vars.items():
name = name.lower()
if only:
if name in uspecs:
ret_vars[name] = obj
else:
ret_vars[name] = obj
return (ret_procs,ret_absints,ret_types,ret_vars)
class FortranSubmodule(FortranModule):
def _initialize(self,line):
FortranModule._initialize(self,line)
self.name = line.group(3)
self.ancestor = line.group(2)
self.ancestor_mod = line.group(1)
self.modprocedures = []
del self.public_list
del self.private_list
del self.protected_list
def _cleanup(self):
# Create list of all local procedures. Ones coming from other modules
# will be added later, during correlation.
self.process_attribs()
self.variables = [v for v in self.variables if 'external' not in v.attribs]
self.all_procs = {}
# Generate graph keys
gd = GraphData()
class Proc(object):
def __init__(self,name,proctype):
self.name = name
self.proctype = proctype
self.ident = ''
def get_url(self):
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',
def _initialize(self,line):
FortranModule._initialize(self,line)
self.name = line.group(3)
self.ancestor = line.group(2)
self.ancestor_mod = line.group(1)
self.modprocedures = []
del self.public_list
del self.private_list
del self.protected_list