Skip to main content

Tool for analysis of code dependency and calling relationship

Project description

Source Hunter

A convinient tool for analysing the dependency and calling relationship of source code.

while coding on large project, one may sometimes face the embarrassing situation to change the very base data models or interfaces which may have chance to break a lot of things. There are some tools like pydeps which gives you clue about what other modules your current module depends on(dependency graph), but it won't tell which modules will be affected if you change your module(calling graph). Source hunter is aiming at providing both calling and dependency graph at the same time.

Installation

Prerequisite

  1. Graphviz is needed for rendering
  2. The python wrapper named graphviz

How to install Graphviz

# On Ubuntu/Debian
sudo apt install graphviz

# On mac
brew install graphviz 

# On Centos/Fedora
sudo yum install graphviz

How to install graphviz the python package

If you install source_hunter using pip, you don't need to install this package manually. Otherwise, you may install graphviz by pip install graphviz

Install using pip:

pip install source_hunter

Install from source code:

git clone https://github.com/pyeprog/source_hunter.git
cd source_hunter
python setup.py install

Usage

# for help
hunt -h

# basic usage 
hunt [project_root_path] [target_module_file] [function_or_class]

# example
# search Usage of `YourModel` of `target_model.py` in current path
# and save the output pdf file at `~/saving/dir/saving_file_name.pdf`
# while ignoring all files with `test`, `pb2` or `migration` in its names.
cd ~/example_project
hunt . ./model/target_model.py YourModel \
    --path ~/saving/dir \
    --name saving_file_name \
    --ignore test --ignore pb2 --ignore migration
    
# output only to stdout
hunt . ./model/target_model.py YourModel --stdout

Output

Parse flask_reddit

cd flask_reddit
hunt . ./flask_reddit/users/models.py User
hunt . ./flask_reddit/users/models.py User --stdout

pdf

cd flask_reddit
hunt . ./flask_reddit/users/models.py User --stdout

shell

limitation

  1. Support only python3 project (will support more language soon)
  2. Not support import a as b or from a import b as c

Change log

  • v0.40:
    • Add support for dependency graph
    • refactor python parser
  • v0.36:
    • Add logger
    • refactor parser
  • v0.35:
    • Add support for png and pdf output format
    • fix stdout mal-format
  • v0.34:
    • Add support for parsing relative import of python project
  • v0.33:
    • Add python parser and graphviz for pdf output

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

source_hunter-0.40.tar.gz (11.3 kB view details)

Uploaded Source

File details

Details for the file source_hunter-0.40.tar.gz.

File metadata

  • Download URL: source_hunter-0.40.tar.gz
  • Upload date:
  • Size: 11.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/40.6.2 requests-toolbelt/0.9.1 tqdm/4.32.2 CPython/3.6.8

File hashes

Hashes for source_hunter-0.40.tar.gz
Algorithm Hash digest
SHA256 6e6ec3b068e1ef4f175111129236c738ad95fb0a7d19e7696812965ee4857d36
MD5 a839952980a90e13ea83148719039dde
BLAKE2b-256 82275780e207e98aa504006603fcbdbe2ffd5fef91471bbfad6c920a34fb1d5b

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page