|
ATLAS Offline Software
|
◆ get_dependencies()
def apydep.get_dependencies |
( |
|
filename, |
|
|
|
print_error = False |
|
) |
| |
Get all the imports/includes in a file.
Definition at line 41 of file apydep.py.
42 """Get all the imports/includes in a file."""
45 tree = ast.parse(
open(filename,
'rb').
read(), filename=filename)
46 except Exception
as e:
48 print(e, file=sys.stderr)
49 return DependencyFinder()
51 finder = DependencyFinder()
54 except Exception
as e:
56 print(e, f
'({os.path.basename(filename)})', file=sys.stderr)
◆ main()
Definition at line 93 of file apydep.py.
94 parser = argparse.ArgumentParser(description=__doc__)
96 parser.add_argument(
'path', metavar=
'DIRECTORY', nargs=
'?', default=
'./',
97 help=
'root of source tree [%(default)s]')
99 parser.add_argument(
'-o',
'--output', metavar=
'FILE', type=str,
100 help=
'output file for DOT graph')
102 parser.add_argument(
'-p',
'--packages', metavar=
'FILE', type=str,
103 help=
'path to packages.txt file [from release]')
105 parser.add_argument(
'-a',
'--all', action=
'store_true',
106 help=
'include non-athena dependencies')
108 parser.add_argument(
'-v',
'--verbose', action=
'store_true',
109 help=
'print parse errors')
111 args = parser.parse_args()
115 package_file = args.packages
or os.path.join(os.environ[
'AtlasArea'],
'InstallArea',
116 os.environ[
'BINARY_TAG'],
'packages.txt')
119 with open(package_file)
as f:
120 packages =
set(line.rstrip().
split(
'/')[-1]
for line
in f
if not line.startswith(
'#'))
121 except FileNotFoundError:
122 parser.error(f
"Cannot read '{package_file}'. Specify via '-p/--packages' or run with '-a/--all'")
125 filterFnc =
None if args.all
else lambda p : p
in packages
◆ make_graph()
def apydep.make_graph |
( |
|
deps, |
|
|
|
filterFnc = None |
|
) |
| |
Save the dependencies as dot graph, nodes filtered by filterFnc
Definition at line 81 of file apydep.py.
82 """Save the dependencies as dot graph, nodes filtered by filterFnc"""
84 graph = pygraphviz.AGraph(name=
'AthPyGraph', directed=
True)
86 for t
in [
'import',
'include']:
87 graph.add_edges_from(((a,b)
for b
in deps[a][t]
88 if a!=b
and (filterFnc
is None or (filterFnc(a)
and filterFnc(b)))),
◆ walk_tree()
def apydep.walk_tree |
( |
|
path = './' , |
|
|
|
print_error = False , |
|
|
|
filterFnc = None |
|
) |
| |
Walk the source tree and extract python dependencies, filtered by FilterFnc
Definition at line 61 of file apydep.py.
61 def walk_tree(path='./', print_error=False, filterFnc=None):
62 """Walk the source tree and extract python dependencies, filtered by FilterFnc"""
65 deps = defaultdict(
lambda : defaultdict(set))
66 for root, dirs, files
in os.walk(path):
67 if 'CMakeLists.txt' in files:
68 pkg = os.path.basename(root)
70 if (filterFnc
and not filterFnc(pkg)):
73 for f
in filter(
lambda p : os.path.splitext(p)[1]==
'.py', files):
75 deps[pkg][
'import'].
update(d.imports)
76 deps[pkg][
'include'].
update(d.includes)
IovVectorMap_t read(const Folder &theFolder, const SelectionCriterion &choice, const unsigned int limit=10)
def walk_tree(path='./', print_error=False, filterFnc=None)
constexpr std::enable_if_t< is_bitmask_v< E >, E & > set(E &lhs, E rhs)
Convenience function to set bits in a class enum bitmask.
void print(char *figname, TCanvas *c1)
def make_graph(deps, filterFnc=None)
def get_dependencies(filename, print_error=False)