🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
DemoInstallSign in
Socket

dp-parser

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

dp-parser

A package for parsing and analyzing code dependency graphs

0.1.0
PyPI
Maintainers
1

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

FAQs

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts