Skip to content

SE-UoM/python-oop-pattern-finder

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

21 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

OOPatternDetector for Python

OOPatternDetector is a Python utility for detecting object-oriented programming (OOP) patterns, such as abstraction and inheritance in Python code. It analyzes source code and provides insights into the use of OOP principles.

Features

  • Detects classes that use abstraction via the abc module.
  • Detects classes that use the Inheritance pattern.

Installation

Option 1: Install from Source

Clone the repository and install the library locally:

git clone https://github.com/yourusername/oopatterndetector.git
cd oop_pattern_detector
pip install .

Option 2: Install from Git

Install the library directly from GitHub:

pip install git+https://github.com/SE-UoM/python-oop-pattern-finder.git

Usage

Basic Usage

The OOPatternDetector class is the main interface for detecting OOP patterns in Python code. You can use it to analyze a Python file or a directory containing Python files.

from oop_pattern_detector import OOPatternDetector

# Load the source code to analyze
source_code = """
from abc import ABC

class AbstractBase(ABC):
    pass

class ConcreteClass(AbstractBase):
    pass
"""

# Initialize the detector
detector = OOPatternDetector(source_code)

# Analyze the source code
classes = detector.analyze()

# Print class details
for cls in classes:
    print(f"Class: {cls.name}, Base Classes: {cls.base_classes}, Uses Abstraction: {cls.uses_abstraction}")

About

A simple script that finds if a python project uses specific OOP Patterns

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages