A package for creating directed graph from python files
Project description
Code2graph
This repo contains a project for creating a directed graph from python files in a specific destination. The code2graph generates a dot files that can be visualized by Graphviz (or any other application). If you want code2graph also can generate an svg/png file but if your host machine doesn't have enough memory it will face problems to visualize huge projects.
Each node in the graph is a function in the python files and it points to all other functions/libraries that have been used in that function.
NOTE:
This project has been tested only on Linux and not on Windows or Mac.
Installation
This program has been published as a pip package and can be installed via below command:
pip install code2graph
Usage
$ code2graph.py -h
Usage:
test.py PATH [ --svg] [ --png] [--scope=<SCP>]
test.py [ -h | --help ]
test.py -v
Arguments:
PATH The path to directory that you want to generate its graph. This can be the root of a project and code2graph will recursively finds all the python files there or just any directory containing python files. Note: the path must end with "/" for example:("/home/guest/workspace/")
Options:
-h --help Show this screen
--svg Generates an svg file in addition to the dot files
--png Generates a png file in addition to the dot files
--scope=<SCP> Defines the scope of the generating graph:
file --> graph (dot file + svg/png) will be created only for each python file and will be saved with the same name and at the same path of the file
project --> graph (dot file + svg/png) will be created only for the whole project (PATH) and single graphs will not be created for each python file
all --> both will be generated [default: all]
-v Version
# Example usage:
$ code2graph.py /home/user/workspace/code2graph/sample_graph/ --png --scope all
The above example usage will generate one dot file and one png file for each python file in the sample_graph
directory and in addition to that it will also generate one dot file and one png file for all the python files in that directroy which you can see here as an example:
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for code2graph-0.0.3-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9d64616e8bc1fe9d2f524489281d65ee3788a4223e1790c949d1fc436efe32e3 |
|
MD5 | 675513f5a69d22b67887ad72cc2b9a7f |
|
BLAKE2b-256 | 987c77c3e5b881ac6dcbf5f2952bc47f76db2ae70df5e3f8df30a7b91d3519c3 |