Skip to main content

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: c2g-project

Metadata

Release files for code2graph 0.0.5

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for code2graph 0.0.5
File Size Uploaded
code2graph-0.0.5.tar.gz 4.0 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for code2graph 0.0.5
File Interpreter ABI Platform
code2graph-0.0.5-py3-none-any.whl Python 3 none any Details

Total release size: 10.6 kB

Release files / code2graph-0.0.5.tar.gz

Download URL code2graph-0.0.5.tar.gz
Size 4.0 kB
Tags Source
SHA-256 checksum
How to use checksums
8db536cddcc036be405e53478b709c78aaa5bd83d10b468508b57067d416cb5a
BLAKE2b-256 checksum
How to use checksums
9d1e829c0da5238d4182a7cd02922593039683c3a2b05498a32bfcf7a8308454
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/52.0.0 requests-toolbelt/0.9.1 tqdm/4.30.0 CPython/3.6.9

Release files / code2graph-0.0.5-py3-none-any.whl

Download URL code2graph-0.0.5-py3-none-any.whl
Size 6.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
aea0b66e5c8a9a96bdc755795ebd061bfec16406b927bbe2d1f4dce98e586c82
BLAKE2b-256 checksum
How to use checksums
9acb7725de8bcf20a70f1bf15775d1325c7366ba32738309e661de41085d03b9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/52.0.0 requests-toolbelt/0.9.1 tqdm/4.30.0 CPython/3.6.9

Release history Release notifications | RSS feed

This release

0.0.5 This release

2 release files

0.0.4

2 release files

0.0.3

2 release files

0.0.2

2 release files

0.0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page