A command-line tool to analyze Python code, generate a call-graph diagram, and report on API usage.
- Python 3.6+
- Graphviz (command-line)
- Python packages:
pip install graphviz
python main.py <path> [options]<path>
A Python file or directory to analyze.
-
-o, --output <prefix>
Output filename prefix for the generated PNG graph.
Default:callflow -
-t, --target <module.func>
One or more target API names to highlight in the graph (e.g.-t yaml.load).
If omitted, all detected API usages are processed and--forcebehavior is applied.
- Scans the given path (file or directory) for
.pyfiles.- Logs:
or
[INFO] Collected <N> Python files for analysis[INFO] Single file mode: <file>
- Logs:
- Parses each file and builds a call graph using
utils.ast_to_png. - Renders the call graph as
<prefix>.png. - Prints three API lists to the console:
Externally exposed APIs: <api1> <api2> Internally only APIs: <api3> … Unused APIs: <api4> …
python main.py ./src -t yaml.load -t requests.get -o api_graph[INFO] Collected 14 Python files for analysis
[INFO] Starting analysis on 14 files in test_target
[INFO] Graph saved to api_graph.png
Externally exposed APIs:
yaml.load
Internally only APIs:
Unused APIs:
request.get- Generates
api_graph.png - Prints lists of external, internal-only, and unused APIs to the console.
