https://github.com/cizr/reverse-engineering-python
A collection of 2 scripts to generate UML diagrams from Python code. One uses Pyreverse for class diagrams, while the other leverages PlantUML to create both class and sequence diagrams, offering flexibility in code analysis and visualization.
https://github.com/cizr/reverse-engineering-python
pyreverse python reverse-engineering softwaremaintenance uml-diagrams
Last synced: 3 months ago
JSON representation
A collection of 2 scripts to generate UML diagrams from Python code. One uses Pyreverse for class diagrams, while the other leverages PlantUML to create both class and sequence diagrams, offering flexibility in code analysis and visualization.
- Host: GitHub
- URL: https://github.com/cizr/reverse-engineering-python
- Owner: Cizr
- Created: 2024-11-25T16:15:56.000Z (7 months ago)
- Default Branch: main
- Last Pushed: 2024-11-25T16:30:33.000Z (7 months ago)
- Last Synced: 2025-01-27T06:43:22.880Z (4 months ago)
- Topics: pyreverse, python, reverse-engineering, softwaremaintenance, uml-diagrams
- Language: Python
- Homepage:
- Size: 31.3 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README

# Reverse Engineering Python
This repository provides scripts for analyzing and visualizing Python code through UML diagrams and code metrics. It is designed to aid in reverse engineering efforts by offering insights into code structure and maintainability.
---
## Files and Features
### 1. **`pyreverseUML.py`**
**Purpose**: Generates a UML class diagram using `pyreverse`.- **How it works**:
- Utilizes the `pyreverse` tool to analyze a Python file and produce class diagrams in PNG format.
- Outputs are saved in a specified directory for easy access.
- Example: Analyzes relationships between classes and methods to visualize the code's structure.- **Key Benefits**:
- Quick and efficient generation of class diagrams.
- Ideal for understanding code relationships in a project.---
### 2. **`plantUML(EnhancedVersionWithSequence).py`**
**Purpose**: Creates both class and sequence diagrams using `PlantUML`.- **How it works**:
- Transforms Python code into `PlantUML` format for visualization.
- Users can generate class diagrams to understand structure and sequence diagrams to map the flow of interactions.
- Requires `PlantUML`installed on the system.- **Key Benefits**:
- Offers additional sequence diagrams for a deeper analysis of program flow.
- Flexible and supports custom UML needs.---
### 3. **`code_metrics.py`**
**Purpose**: Calculates cyclomatic complexity, maintainability index, and other metrics.- **How it works**:
- Analyzes a Python file to compute:
- **Lines of Code (LOC)**: Total lines in the file.
- **Cyclomatic Complexity**: Measures code complexity for readability and maintainability.
- **Maintainability Index (MI)**: Indicates how easy the code is to maintain.
- **Halstead Metrics**: Analyzes operations and operands in the code.
- Saves results in a JSON file for review.- **Key Benefits**:
- Helps in assessing the quality and maintainability of code.
- Useful for identifying areas that may need refactoring.---
## Setup and Requirements
1. **Python Dependencies**:
Install required Python packages using `pip`:
```bash
pip install pylint plantuml radon