madisonmay / blackwidow Goto Github PK
View Code? Open in Web Editor NEWVisualizing Python Project Import Graphs
License: MIT License
Visualizing Python Project Import Graphs
License: MIT License
Because labels are missing, it's hard to figure out what is what just by looking at it. Tried to ofc add a g and to add the circle and a text label to it. But my d3 skills are next to none, and it turned out to be not working after many attempts.
Couldn't find a better visualizer for my project yet, only this one. So i resorted to using this visualization and editing the image with photoshop. It made me feel like an idiot, but it worked for now ;)
On windows the only way to exit is by using process explorer to kill the process - even control-C does not exit. Tested on Windows 10 Python 2.7.12
turns out, ast.parse() can raise a syntax error, so the try at line 50 should have a second except to catch errors other than IO error.
In the following, the package code that causes the error was not executed when the interpreter is Python 3, but ast doesn't know that. Actually turns out it isn't even in the current level of PyInstaller, so don't bother trying to reproduce. Just the general point, ast.parse() is capable of throwing a syntax error.
python -m blackwidow.web PyInstaller
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/runpy.py", line 170, in _run_module_as_main
"__main__", mod_spec)
File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/runpy.py", line 85, in _run_code
exec(code, run_globals)
File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/blackwidow/web.py", line 99, in <module>
web = Web(project_path, exclude=args.exclude)
File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/blackwidow/web.py", line 27, in __init__
Node(file, package_root=self.package_root) for file in self.files
File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/blackwidow/web.py", line 27, in <listcomp>
Node(file, package_root=self.package_root) for file in self.files
File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/blackwidow/node.py", line 21, in __init__
self.edges = imported_modules(filename, package_root=package_root)
File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/blackwidow/imports.py", line 52, in imported_modules
tree = ast.parse(fd.read(), filename=filename)
File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/ast.py", line 35, in parse
return compile(source, filename, mode, PyCF_ONLY_AST)
File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/PyInstaller/lib/pefile_py2.py", line 82
IMAGE_ORDINAL_FLAG = 0x80000000L
^
SyntaxError: invalid syntax
Instead of also mapping import from external libraries.
Well this is more like a feature that I think will be cool to have. Probably you can place the "nodes" information in something a graph database(Neo4j) and use its browser for visualisation and navigation between the nodes.
Hopefully maintain both 2 and 3 support in the same repo. Time to break out six
.
To prevent users from having to dig through and hover over each element in order to find the one they're looking for.
Current implementation assumes all imports are of modules. Logic should be added to ensure results are filtered down to modules only, rather than a mix of modules, functions and classes.
For qutebrowser I get this:
Not sure if there's much that can be done to actually improve the output, but I think a way to zoom in (or to enforce more spacing between nodes?) would help a lot.
Do you not support modules?
>>> python -m blackwidow.web flask_sockets
ValueError: Not a package: flask_sockets
Needs a collection of sample projects + a unittest suite.
python -m blackwidow.web setuptools
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/runpy.py", line 170, in _run_module_as_main
"__main__", mod_spec)
File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/runpy.py", line 85, in _run_code
exec(code, run_globals)
File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/blackwidow/web.py", line 99, in <module>
web = Web(project_path, exclude=args.exclude)
File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/blackwidow/web.py", line 27, in __init__
Node(file, package_root=self.package_root) for file in self.files
File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/blackwidow/web.py", line 27, in <listcomp>
Node(file, package_root=self.package_root) for file in self.files
File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/blackwidow/node.py", line 21, in __init__
self.edges = imported_modules(filename, package_root=package_root)
File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/blackwidow/imports.py", line 52, in imported_modules
tree = ast.parse(fd.read(), filename=filename)
File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/ast.py", line 35, in parse
return compile(source, filename, mode, PyCF_ONLY_AST)
File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/setuptools/tests/script-with-bom.py", line 1
# -*- coding: utf-8 -*-
^
SyntaxError: invalid character in identifier
I tried running your package via the readme instructions on github.com/EntilZha/ScalaFunctional, but got this error (python 2.7.10):
$ python -m blackwidow.web functional --exclude *test*
Traceback (most recent call last):
File "/usr/local/Cellar/python/2.7.10_2/Frameworks/Python.framework/Versions/2.7/lib/python2.7/runpy.py", line 162, in _run_module_as_main
"__main__", fname, loader, pkg_name)
File "/usr/local/Cellar/python/2.7.10_2/Frameworks/Python.framework/Versions/2.7/lib/python2.7/runpy.py", line 72, in _run_code
exec code in run_globals
File "/usr/local/lib/python2.7/site-packages/blackwidow/web.py", line 112, in <module>
web.visualize()
File "/usr/local/lib/python2.7/site-packages/blackwidow/web.py", line 64, in visualize
with open(json_file, 'w') as fd:
IOError: [Errno 2] No such file or directory: '/usr/local/lib/python2.7/site-packages/blackwidow/viz/static/graph.json'
On python3, I get a different error, which makes me think that this is a python 2 package?
$ python3 -m blackwidow.web functional --exclude *test*
Traceback (most recent call last):
File "/usr/local/Cellar/python3/3.5.0/Frameworks/Python.framework/Versions/3.5/lib/python3.5/runpy.py", line 170, in _run_module_as_main
"__main__", mod_spec)
File "/usr/local/Cellar/python3/3.5.0/Frameworks/Python.framework/Versions/3.5/lib/python3.5/runpy.py", line 85, in _run_code
exec(code, run_globals)
File "/usr/local/lib/python3.5/site-packages/blackwidow/web.py", line 12, in <module>
from blackwidow.viz.server import serve
File "/usr/local/lib/python3.5/site-packages/blackwidow/viz/server.py", line 6, in <module>
import SimpleHTTPServer, BaseHTTPServer
ImportError: No module named 'SimpleHTTPServer'
Instead of simply coloring the links.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.