Skip to content

Latest commit

History

21 Commits

Folders and files

NameName
Last commit message
Last commit date

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.

fromoop_pattern_detectorimportOOPatternDetector# Load the source code to analyzesource_code="""from abc import ABCclass AbstractBase(ABC): passclass ConcreteClass(AbstractBase): pass"""# Initialize the detectordetector=OOPatternDetector(source_code)
# Analyze the source codeclasses=detector.analyze()
# Print class detailsforclsinclasses:
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

0 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages