https://github.com/zhongjiajie/stmdency
A Python library for extracting dependencies between statements
https://github.com/zhongjiajie/stmdency
ast parser python statement-parsers
Last synced: 12 months ago
JSON representation
A Python library for extracting dependencies between statements
- Host: GitHub
- URL: https://github.com/zhongjiajie/stmdency
- Owner: zhongjiajie
- License: mit
- Created: 2022-12-20T09:59:14.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2023-10-18T11:54:43.000Z (over 2 years ago)
- Last Synced: 2025-06-27T00:50:06.150Z (12 months ago)
- Topics: ast, parser, python, statement-parsers
- Language: Python
- Homepage: https://stmdency.rtfd.io
- Size: 56.6 KB
- Stars: 3
- Watchers: 2
- Forks: 0
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Stmdency
[](https://pypi.org/project/stmdency/)
[](https://pypi.org/project/stmdency/)
[](https://raw.githubusercontent.com/zhongjiajie/stmdency/main/LICENSE)
[](https://pypi.org/project/stmdency/)
[](https://pepy.tech/project/stmdency)
[](https://codecov.io/github/zhongjiajie/stmdency?branch=main)
[](https://github.com/psf/black)
[](https://github.com/zhongjiajie/stmdency/actions/workflows/ci.yaml)
[](https://stmdency.readthedocs.io/en/latest/?badge=latest)
Stmdency, **ST**ate**M**ent depen**DENCY** is a Python library for extracting dependencies between Python statements.
## Installation
```shell
python -m pip install --upgrade stmdency
```
## Usage
Let's say we have a Python script named `test.py` with the following content:
```python
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:
```python
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:
```python
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](https://stmdency.readthedocs.io).
## Who is using stmdency?
- [dolphinscheduler-sdk-python](https://github.com/apache/dolphinscheduler-sdk-python): Python API to manage Dolphinscheduler workflow by code, aka PyDolphinscheduler.