Skip to main content

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

  1. From PyPI (not yet published):
pip install dg-parser
  1. 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

Metadata

Release files for dp-parser 0.1.0

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

Source distribution (sdist)

Source distribution for dp-parser 0.1.0
File Size Uploaded
dp_parser-0.1.0.tar.gz 9.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for dp-parser 0.1.0
File Interpreter ABI Platform
dp_parser-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 19.3 kB

Release files / dp_parser-0.1.0.tar.gz

Download URL dp_parser-0.1.0.tar.gz
Size 9.8 kB
Tags Source
SHA-256 checksum
How to use checksums
b4490c6d0ba581089496140076ffac018ad8230ef9321920d0a7a755b4ad39c3
BLAKE2b-256 checksum
How to use checksums
9f7e2a7cb5712b4e00c6114fc309bcdea93baf1e001a9c4bca768b1b39b94f91
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.9.21

Release files / dp_parser-0.1.0-py3-none-any.whl

Download URL dp_parser-0.1.0-py3-none-any.whl
Size 9.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
ce2db643a9805526f8922cec0fa057dc0d5f8a7d20df7cf95a4e7e0bb018ed18
BLAKE2b-256 checksum
How to use checksums
2102dfc2e30aadf8176bcf88e33bac8394f2b531cfed8b1c45f8797e87420f85
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.9.21

Release history Release notifications | RSS feed

This release

0.1.0 This release

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