Skip to content

A Python library for extracting dependencies between statements

License

Notifications You must be signed in to change notification settings

zhongjiajie/stmdency

Repository files navigation

Stmdency

PyPi Version PyPi Python Versions PyPi License PyPi Status Downloads Coverage Status Code style: black CI Documentation Status

Stmdency, STateMent depenDENCY is a Python library for extracting dependencies between Python statements.

Installation

python -m pip install --upgrade stmdency

Usage

Let's say we have a Python script named test.py with the following content:

a = 1
b = 2

def bar():
   b = a + 3
   print(a, b)

def foo():
   bar(b)

We want to extract function foo and all its dependencies. stmdency can do this for us:

from stmdency.extractor import Extractor

with open("test.py", "r") as f:
   source = f.read()
   extractor = Extractor(source)
   print(extractor.get_code("foo"))

The output will be:

a = 1

def bar():
    b = a + 3
    print(a, b)

b = 2

def foo():
    bar(b)

Documentation

The documentation host read the doc and is available at https://stmdency.readthedocs.io.

Who is using stmdency?