Skip to main content

Objectscript class code generation library for Python

Project description

PyObjectscript Gen

Objectscript class code generation library for Python


Features

  • Objectscript class code generation
  • Clean and simple to use interface in python
  • Extensible classes for custom usage

Installation

You can install the package using pip:

pip install pyobjectscript_gen

Or from source:

git clone https://github.com/Antoine-dh/pyobjectscript_gen.git
pip install .

Usage

Here's a basic example of how to use the library:

from pyobjectscript_gen.cls import *

cls = Class(
    name="Demo.MyExample.MyClass",
    extends=["%RegisteredObject"]
)

# example of declaratively creating properties
cls.components = [
    Property(
        name="Property1",
        type="%String",
    ),
    Property(
        name="Property2",
        type="%Numeric",
    ),
]

# example of iteratively creating a method
method = Method("MyMethod")
method.return_type = "%String"
method.impl = [
    "set returnvalue=..Property1_..Property2",
    "quit returnvalue"
]

# append method to class components
cls.components.append(method)

# generate on sys.stdout
cls.generate()

See the generated class in examples/generated/basic.cls


Requirements

  • Python 3.9+
  • Jinja2

Documentation

You can find the full documentation at: Read the docs

All the documentation can also be found in code with python docstrings in src/pyobjectscript_gen/cls.py


Running Examples

All examples code can be found in examples/ and their respective output classes in examples/generated/

# Basic class example with 2 properties and a method
python3 -m examples.basic > basic.cls

# Test class for every features capable to be generated by the library
python3 -m examples.features > features.cls

# Real life example of multiple classes generation using custom subclasses of the library's components
# Generates a simple REST example with a business operation, request and response classes in the specified directory
mkdir output/
python3 -m examples.rest ./output/

More examples to come...


Contributing

Contributions are welcome!

To get started:

git clone https://github.com/Antoine-dh/pyobjectscript_gen.git
python -m venv .venv
source .venv/bin/activate  # On Windows, use .venv\bin\activate.bat
pip install -r requirements.txt

License

This project is licensed under the GNU General Public License.

Project details


Release history Release notifications | RSS feed

This version

1.0

Download files

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

Source Distribution

pyobjectscript_gen-1.0.tar.gz (628.5 kB view details)

Uploaded Source

Built Distribution

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

pyobjectscript_gen-1.0-py3-none-any.whl (16.3 kB view details)

Uploaded Python 3

File details

Details for the file pyobjectscript_gen-1.0.tar.gz.

File metadata

  • Download URL: pyobjectscript_gen-1.0.tar.gz
  • Upload date:
  • Size: 628.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.3

File hashes

Hashes for pyobjectscript_gen-1.0.tar.gz
Algorithm Hash digest
SHA256 accdbaf80f12c4f14a4ca2706078fd1fdff516062c2e5a4a473d52d2cc6c179c
MD5 dcfa1d225aa8c5d6249259a91f3d0f14
BLAKE2b-256 5b6f08fad117c1d9f00719351c8d93124c9c6b5d0454e387a688f60969b33804

See more details on using hashes here.

File details

Details for the file pyobjectscript_gen-1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for pyobjectscript_gen-1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 22a170e6d3c1359b74b64f7799aae036ef287787638fad95ffba92ef486a10ba
MD5 fb54019b02ac9244d83316c9eddb6394
BLAKE2b-256 8cc7a78ac56708631bc08be12842d48d43123e586f8da442bf7d7dbd76f79acd

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