pycallgraph-visualizer 1.0.1__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- pycallgraph_visualizer/__init__.py +29 -0
- pycallgraph_visualizer/analyzer.py +1523 -0
- pycallgraph_visualizer/cli.py +181 -0
- pycallgraph_visualizer-1.0.1.dist-info/METADATA +36 -0
- pycallgraph_visualizer-1.0.1.dist-info/RECORD +9 -0
- pycallgraph_visualizer-1.0.1.dist-info/WHEEL +5 -0
- pycallgraph_visualizer-1.0.1.dist-info/entry_points.txt +2 -0
- pycallgraph_visualizer-1.0.1.dist-info/licenses/LICENSE +21 -0
- pycallgraph_visualizer-1.0.1.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Command-line interface for pycallgraph-visualizer
|
|
3
|
+
"""
|
|
4
|
+
|
|
5
|
+
import argparse
|
|
6
|
+
import os
|
|
7
|
+
import sys
|
|
8
|
+
import webbrowser
|
|
9
|
+
from pathlib import Path
|
|
10
|
+
from .analyzer import analyze_directory, generate_html_graph
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
def main():
|
|
14
|
+
"""Main entry point for the CLI"""
|
|
15
|
+
parser = argparse.ArgumentParser(
|
|
16
|
+
prog='pycallgraph',
|
|
17
|
+
description='Visualize Python code dependencies with interactive call graphs',
|
|
18
|
+
formatter_class=argparse.RawDescriptionHelpFormatter,
|
|
19
|
+
epilog="""
|
|
20
|
+
Examples:
|
|
21
|
+
# Analyze current directory
|
|
22
|
+
pycallgraph
|
|
23
|
+
|
|
24
|
+
# Analyze specific directory
|
|
25
|
+
pycallgraph /path/to/project
|
|
26
|
+
|
|
27
|
+
# Specify output file
|
|
28
|
+
pycallgraph -o my_graph.html
|
|
29
|
+
|
|
30
|
+
# Don't open browser automatically
|
|
31
|
+
pycallgraph --no-browser
|
|
32
|
+
|
|
33
|
+
# Increase complexity threshold
|
|
34
|
+
pycallgraph --complexity-threshold 15
|
|
35
|
+
"""
|
|
36
|
+
)
|
|
37
|
+
|
|
38
|
+
parser.add_argument(
|
|
39
|
+
'directory',
|
|
40
|
+
nargs='?',
|
|
41
|
+
default='.',
|
|
42
|
+
help='Directory to analyze (default: current directory)'
|
|
43
|
+
)
|
|
44
|
+
|
|
45
|
+
parser.add_argument(
|
|
46
|
+
'-o', '--output',
|
|
47
|
+
default='call_graph.html',
|
|
48
|
+
help='Output HTML file name (default: call_graph.html)'
|
|
49
|
+
)
|
|
50
|
+
|
|
51
|
+
parser.add_argument(
|
|
52
|
+
'--no-browser',
|
|
53
|
+
action='store_true',
|
|
54
|
+
help="Don't open the browser automatically"
|
|
55
|
+
)
|
|
56
|
+
|
|
57
|
+
parser.add_argument(
|
|
58
|
+
'--complexity-threshold',
|
|
59
|
+
type=int,
|
|
60
|
+
default=10,
|
|
61
|
+
help='Complexity threshold for flagging functions (default: 10)'
|
|
62
|
+
)
|
|
63
|
+
|
|
64
|
+
parser.add_argument(
|
|
65
|
+
'--include-tests',
|
|
66
|
+
action='store_true',
|
|
67
|
+
help='Include test files in analysis'
|
|
68
|
+
)
|
|
69
|
+
|
|
70
|
+
parser.add_argument(
|
|
71
|
+
'-v', '--verbose',
|
|
72
|
+
action='store_true',
|
|
73
|
+
help='Verbose output'
|
|
74
|
+
)
|
|
75
|
+
|
|
76
|
+
parser.add_argument(
|
|
77
|
+
'--version',
|
|
78
|
+
action='version',
|
|
79
|
+
version='%(prog)s 1.0.0'
|
|
80
|
+
)
|
|
81
|
+
|
|
82
|
+
args = parser.parse_args()
|
|
83
|
+
|
|
84
|
+
# Resolve directory path
|
|
85
|
+
directory = os.path.abspath(args.directory)
|
|
86
|
+
|
|
87
|
+
if not os.path.exists(directory):
|
|
88
|
+
print(f"❌ Error: Directory not found: {directory}", file=sys.stderr)
|
|
89
|
+
sys.exit(1)
|
|
90
|
+
|
|
91
|
+
if not os.path.isdir(directory):
|
|
92
|
+
print(f"❌ Error: Path is not a directory: {directory}", file=sys.stderr)
|
|
93
|
+
sys.exit(1)
|
|
94
|
+
|
|
95
|
+
# Check if there are any Python files
|
|
96
|
+
has_python_files = any(
|
|
97
|
+
f.endswith('.py')
|
|
98
|
+
for root, _, files in os.walk(directory)
|
|
99
|
+
for f in files
|
|
100
|
+
)
|
|
101
|
+
|
|
102
|
+
if not has_python_files:
|
|
103
|
+
print(f"❌ Error: No Python files found in: {directory}", file=sys.stderr)
|
|
104
|
+
sys.exit(1)
|
|
105
|
+
|
|
106
|
+
print("🔍 PyCallGraph Visualizer")
|
|
107
|
+
print("=" * 60)
|
|
108
|
+
print(f"📁 Analyzing: {directory}")
|
|
109
|
+
print()
|
|
110
|
+
|
|
111
|
+
try:
|
|
112
|
+
# Analyze the directory
|
|
113
|
+
analysis_result = analyze_directory(
|
|
114
|
+
directory
|
|
115
|
+
)
|
|
116
|
+
|
|
117
|
+
if analysis_result["total_functions"] == 0:
|
|
118
|
+
print("⚠️ No Python functions found in the directory.")
|
|
119
|
+
print(" Make sure the directory contains .py files with function definitions.")
|
|
120
|
+
sys.exit(1)
|
|
121
|
+
|
|
122
|
+
# Generate output file path
|
|
123
|
+
if os.path.isabs(args.output):
|
|
124
|
+
output_file = args.output
|
|
125
|
+
else:
|
|
126
|
+
output_file = os.path.join(directory, args.output)
|
|
127
|
+
|
|
128
|
+
# Generate HTML graph
|
|
129
|
+
generate_html_graph(analysis_result, output_file, directory)
|
|
130
|
+
|
|
131
|
+
# Print summary
|
|
132
|
+
print()
|
|
133
|
+
print("=" * 60)
|
|
134
|
+
print("📊 Analysis Complete!")
|
|
135
|
+
print("=" * 60)
|
|
136
|
+
print(f"📈 Total Functions: {analysis_result['total_functions']}")
|
|
137
|
+
print(f"📁 Total Files: {analysis_result['total_files']}")
|
|
138
|
+
print(f"🔗 Total Connections: {sum(len(v) for v in analysis_result['call_graph'].values())}")
|
|
139
|
+
print()
|
|
140
|
+
|
|
141
|
+
if analysis_result['circular_dependencies']:
|
|
142
|
+
print(f"🔴 Circular Dependencies: {len(analysis_result['circular_dependencies'])}")
|
|
143
|
+
else:
|
|
144
|
+
print("✅ No circular dependencies found")
|
|
145
|
+
|
|
146
|
+
if analysis_result['dead_functions']:
|
|
147
|
+
print(f"💀 Dead Functions: {len(analysis_result['dead_functions'])}")
|
|
148
|
+
else:
|
|
149
|
+
print("✅ No dead code found")
|
|
150
|
+
|
|
151
|
+
if analysis_result['high_complexity_functions']:
|
|
152
|
+
print(f"📈 High Complexity Functions: {len(analysis_result['high_complexity_functions'])}")
|
|
153
|
+
else:
|
|
154
|
+
print("✅ All functions have reasonable complexity")
|
|
155
|
+
|
|
156
|
+
print(f"🚪 Entry Points: {len(analysis_result['entry_points'])}")
|
|
157
|
+
print()
|
|
158
|
+
print(f"📄 Output: {output_file}")
|
|
159
|
+
|
|
160
|
+
# Open browser
|
|
161
|
+
if not args.no_browser:
|
|
162
|
+
print("🌐 Opening in browser...")
|
|
163
|
+
webbrowser.open('file://' + os.path.abspath(output_file))
|
|
164
|
+
|
|
165
|
+
print()
|
|
166
|
+
print("💡 Tips:")
|
|
167
|
+
print(" - Use search to filter functions")
|
|
168
|
+
print(" - Click function names to focus on their dependencies")
|
|
169
|
+
print(" - Hover over nodes for detailed metrics")
|
|
170
|
+
print(" - Red = Circular deps, Gray = Dead code, Orange = Complex, Green = Entry points")
|
|
171
|
+
|
|
172
|
+
except Exception as e:
|
|
173
|
+
print(f"❌ Error during analysis: {e}", file=sys.stderr)
|
|
174
|
+
if args.verbose:
|
|
175
|
+
import traceback
|
|
176
|
+
traceback.print_exc()
|
|
177
|
+
sys.exit(1)
|
|
178
|
+
|
|
179
|
+
|
|
180
|
+
if __name__ == '__main__':
|
|
181
|
+
main()
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: pycallgraph-visualizer
|
|
3
|
+
Version: 1.0.1
|
|
4
|
+
Summary: Visualize Python code dependencies with interactive call graphs
|
|
5
|
+
Home-page: https://github.com/Er-buddy/PyCallGraph-Visualizer/issues
|
|
6
|
+
Author: Rankush Vishwakarma
|
|
7
|
+
Author-email: er.rankush.vishwakarma.in@gmail.com
|
|
8
|
+
Project-URL: Bug Reports, https://github.com/Er-buddy/PyCallGraph-Visualizer/issues
|
|
9
|
+
Project-URL: Source, https://github.com/Er-buddy/PyCallGraph-Visualizer/issues
|
|
10
|
+
Keywords: call-graph visualization code-analysis python ast circular-dependency
|
|
11
|
+
Classifier: Development Status :: 4 - Beta
|
|
12
|
+
Classifier: Intended Audience :: Developers
|
|
13
|
+
Classifier: Topic :: Software Development :: Code Generators
|
|
14
|
+
Classifier: Topic :: Software Development :: Documentation
|
|
15
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
16
|
+
Classifier: Programming Language :: Python :: 3
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.8
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
21
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
22
|
+
Requires-Python: >=3.8
|
|
23
|
+
Description-Content-Type: text/markdown
|
|
24
|
+
License-File: LICENSE
|
|
25
|
+
Requires-Dist: pyvis>=0.3.2
|
|
26
|
+
Dynamic: author
|
|
27
|
+
Dynamic: author-email
|
|
28
|
+
Dynamic: classifier
|
|
29
|
+
Dynamic: description-content-type
|
|
30
|
+
Dynamic: home-page
|
|
31
|
+
Dynamic: keywords
|
|
32
|
+
Dynamic: license-file
|
|
33
|
+
Dynamic: project-url
|
|
34
|
+
Dynamic: requires-dist
|
|
35
|
+
Dynamic: requires-python
|
|
36
|
+
Dynamic: summary
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
pycallgraph_visualizer/__init__.py,sha256=E1N6uQci4ura-LJpSOehuIJPlO_en82G0tWpBhHmB_g,744
|
|
2
|
+
pycallgraph_visualizer/analyzer.py,sha256=VGRmnmM7f3OiKZyt5zVvrqHAc9IPvkNpCasbTiiw0wk,67585
|
|
3
|
+
pycallgraph_visualizer/cli.py,sha256=AwiGsdyawFDGFlH2VSRimeQWJeFtpNjUsXs_Wyw02kw,5545
|
|
4
|
+
pycallgraph_visualizer-1.0.1.dist-info/licenses/LICENSE,sha256=q53YqEH5OACuJ8YmE3i9pND509hapVaOX42ix2AMkZ8,1085
|
|
5
|
+
pycallgraph_visualizer-1.0.1.dist-info/METADATA,sha256=P74BvHSI6_YNcA0NQyE4qJrAmqe3lIECA6bB_KrzDCA,1474
|
|
6
|
+
pycallgraph_visualizer-1.0.1.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
7
|
+
pycallgraph_visualizer-1.0.1.dist-info/entry_points.txt,sha256=k15hB0Vtyr-QaDE91k9QG8_QmBViA63cHV_J5sB3PyI,64
|
|
8
|
+
pycallgraph_visualizer-1.0.1.dist-info/top_level.txt,sha256=KX4s7Fqg77k4263iuckooioPaJmg-h6BAa7f8fRKAOA,23
|
|
9
|
+
pycallgraph_visualizer-1.0.1.dist-info/RECORD,,
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 Your Name
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
pycallgraph_visualizer
|