Skip to main content

A light library for general purpose object factories

Project description

objectory = object + factory

CI CI Codecov
PYPI version Python BSD-3-Clause Code style: black Doc style: google
Downloads Monthly downloads

Overview

A Python library for general purpose object factories. In particular, it focuses on dynamic object factory implementations where objects can be registered dynamically without changing the code of the factory. An object factory can be used to instantiate an object from its configuration. The current implementation contains both abstract factory and registry approaches.

factory

from objectory import factory


class MyClass:
    pass


obj = factory("MyClass")
print(obj)

abstract factory

from objectory import AbstractFactory


class BaseClass(metaclass=AbstractFactory):
    pass


class MyClass(BaseClass):
    pass


obj = BaseClass.factory("MyClass")
print(obj)

Output:

<__main__.MyClass object at 0x123456789>

registry

from objectory import Registry

registry = Registry()


@registry.register()
class MyClass:
    pass


obj = registry.factory("MyClass")
print(obj)
<__main__.MyClass object at 0x123456789>

Please read the documentation to learn more about these approaches.

Installation

We highly recommend installing a virtual environment. objectory can be installed from pip using the following command:

pip install objectory

Please check the get started page to see other alternatives to install the library.

Contributing

Please check the instructions in CONTRIBUTING.md.

API stability

:warning: While objectory is in development stage, no API is guaranteed to be stable from one release to the next. In fact, it is very likely that the API will change multiple times before a stable 1.0.0 release. In practice, this means that upgrading objectory to a new version will possibly break any code that was using the old version of objectory.

License

objectory is licensed under BSD 3-Clause "New" or "Revised" license available in LICENSE file.

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

objectory-0.0.4.tar.gz (14.3 kB view details)

Uploaded Source

Built Distribution

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

objectory-0.0.4-py3-none-any.whl (17.1 kB view details)

Uploaded Python 3

File details

Details for the file objectory-0.0.4.tar.gz.

File metadata

  • Download URL: objectory-0.0.4.tar.gz
  • Upload date:
  • Size: 14.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.5.1 CPython/3.10.12 Linux/5.15.0-1040-azure

File hashes

Hashes for objectory-0.0.4.tar.gz
Algorithm Hash digest
SHA256 f4473e12a7621956e0d718b86b6eecbcab2879567e985305addd7ebea4a78cd4
MD5 d9fb4947f3062f9c4747bb26086a822e
BLAKE2b-256 d373618cbd88654bab7c8583f298a6970d13066f7c3bd71f78213d9a3740c4fc

See more details on using hashes here.

File details

Details for the file objectory-0.0.4-py3-none-any.whl.

File metadata

  • Download URL: objectory-0.0.4-py3-none-any.whl
  • Upload date:
  • Size: 17.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.5.1 CPython/3.10.12 Linux/5.15.0-1040-azure

File hashes

Hashes for objectory-0.0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 4cc1b772e30557f2fefe9f84285fc6af6799653ba17c6dcf8ade984985d64634
MD5 a5c2215b0eff26111dab84f016b2df5d
BLAKE2b-256 1aa9999ffe053fddd2bd5b547b05e0382ec2e98162616336697f543da2d40d5f

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