Skip to main content

Convert simple Python scripts to class-based structured code

Project description

PyClassStruct

A powerful CLI tool that converts simple Python scripts to well-organized class-based structures.

Installation

pip install -e .

Usage

Analyze Python Files

Analyze files/folders to generate a report and classes.txt:

# Analyze a folder
pyclassstruct analyze ./my_scripts

# Analyze a single file
pyclassstruct analyze ./my_script.py

This generates:

  • report.txt - Statistics and structure visualization
  • classes.txt - Proposed class structure (edit this to customize)

Convert to Structured Classes

Convert scripts to class-based structure:

# Convert using auto-detection or existing classes.txt
pyclassstruct convert ./my_scripts

# Convert a single file
pyclassstruct convert ./my_script.py

This creates a structured/ folder with organized class files.

classes.txt Format

# Class definitions - one per line
# Format: ClassName: function1, function2, function3

UserManager: create_user, delete_user, update_user
DatabaseHandler: connect_db, query, close_connection

Features

  • 🔍 Smart Detection: Automatically groups related functions into classes
  • 📊 Dependency Analysis: Detects function call relationships
  • 🏷️ Naming Patterns: Groups functions by common prefixes
  • 📁 Flexible Input: Works with single files or entire folders
  • 📝 Customizable: Edit classes.txt to define your own structure

License

MIT License

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pyclassstruct-1.0.0.tar.gz (20.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pyclassstruct-1.0.0-py3-none-any.whl (23.9 kB view details)

Uploaded Python 3

File details

Details for the file pyclassstruct-1.0.0.tar.gz.

File metadata

  • Download URL: pyclassstruct-1.0.0.tar.gz
  • Upload date:
  • Size: 20.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.0

File hashes

Hashes for pyclassstruct-1.0.0.tar.gz
Algorithm Hash digest
SHA256 6c6b14b7fd6290fe393e9680a46db7871cd934433d7223936c6020326f5e39c4
MD5 e7bbf9abd7a69f3b5d9dcb6aad851334
BLAKE2b-256 4e16a5993e763b5602e4178984586b43341b1f5eb5c8a3ebb724eb09333eefa6

See more details on using hashes here.

File details

Details for the file pyclassstruct-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: pyclassstruct-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 23.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.0

File hashes

Hashes for pyclassstruct-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 0bb36f3ae0d17255845ba64dd01e4d65f05421f4e48cc24b11c7d8f7a67866a4
MD5 8693526c70bf4ba1944a7c5de0178273
BLAKE2b-256 0f08850622a201c17338e7ebe5bbafa379fc8e6a74ffc2ab3781ae0ceb3b3d9a

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page