A package for parsing and analyzing code dependency graphs
Project description
DG-Parser
A Python package for parsing and analyzing code dependency graphs.
Features
- Parse Python code to generate dependency graphs
- Analyze module dependencies and relationships
- Command-line interface for quick analysis
- Export dependency graphs (i.e. Pickle)
Getting Started
Prerequisites
- Python 3.8 or higher
- pip package manager
Installation
- From PyPI (not yet published):
pip install dg-parser
- From source:
git clone https://github.com/nmd2k/DG-parser.git
cd DG-parser
pip install -e .
Basic Usage
1. Command Line Interface
The package provides a convenient CLI for quick analysis:
dp-parser analyze tests/test_data/sample_project
>>> Analyzing project: tests/test_data/sample_project
Function Signature: validate_input
Dependencies:
Calls: from utils import validate_input, transform_data
Parameters: ['data']
----------------------------------------------------------------------------------------------------
Function Signature: transform_data
Dependencies:
Calls: from utils import validate_input, transform_data
Parameters: ['data']
----------------------------------------------------------------------------------------------------
Function Signature: ValueError
Dependencies:
Calls: ValueError
Parameters: []
----------------------------------------------------------------------------------------------------
Function Signature: process_data
Dependencies:
transform_data
ValueError
validate_input
Calls: def process_data(data):
Parameters: ['data']
----------------------------------------------------------------------------------------------------
Dependency graph saved to: output/sample_project_graph.pkl
2. Python API
from dp_graph import PythonParser
# Create a dependency graph instance
parser = PythonParser()
# Parse a Python project
graph = parser.parse("/path/to/project")
# Get all dependencies
for node in graph.nodes.values():
print("\tFunction Signature:", node.signature)
print("\tDependencies:")
for dep in node.dependencies:
print(f"\t\t{dep.signature}")
print("\tCalls:", node.code.split("\n")[0])
print("\tParameters:", node.parameters)
print("-" * 100)
# Export the graph
# Comming soon
License
MIT License
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
dp_parser-0.1.0.tar.gz
(9.8 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file dp_parser-0.1.0.tar.gz.
File metadata
- Download URL: dp_parser-0.1.0.tar.gz
- Upload date:
- Size: 9.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.9.21
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b4490c6d0ba581089496140076ffac018ad8230ef9321920d0a7a755b4ad39c3
|
|
| MD5 |
50ef79a4a79e066c48630fadab4f80c1
|
|
| BLAKE2b-256 |
9f7e2a7cb5712b4e00c6114fc309bcdea93baf1e001a9c4bca768b1b39b94f91
|
File details
Details for the file dp_parser-0.1.0-py3-none-any.whl.
File metadata
- Download URL: dp_parser-0.1.0-py3-none-any.whl
- Upload date:
- Size: 9.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.9.21
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ce2db643a9805526f8922cec0fa057dc0d5f8a7d20df7cf95a4e7e0bb018ed18
|
|
| MD5 |
22fdb753e9695537675585413cfbc25f
|
|
| BLAKE2b-256 |
2102dfc2e30aadf8176bcf88e33bac8394f2b531cfed8b1c45f8797e87420f85
|