Skip to main content

A light library for general purpose object factories

Project description

objectory = object + factory

CI Documentation Nightly Tests Nightly Package Tests
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)
<__main__.MyClass object at 0x123456789>

abstract factory

>>> from objectory import AbstractFactory
>>> class BaseClass(metaclass=AbstractFactory):
...     pass
...
>>> class MyClass(BaseClass):
...     pass
...
>>> obj = BaseClass.factory("MyClass")
>>> print(obj)
<__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. The following is the corresponding objectory versions and supported dependencies.

objectory tornado python
0.0.8 >=6.0,<7.0 >=3.9,<3.13
0.0.7 >=6.0,<7.0 >=3.9,<3.12

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.8.tar.gz (14.7 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.8-py3-none-any.whl (17.4 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: objectory-0.0.8.tar.gz
  • Upload date:
  • Size: 14.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.6.1 CPython/3.10.13 Linux/6.2.0-1012-azure

File hashes

Hashes for objectory-0.0.8.tar.gz
Algorithm Hash digest
SHA256 c9a9ebc1b1f08d1d1764d44309da97d9feccf51e94fa9f7269e1738215900279
MD5 8fdf346299f286941ef9c56b2f723cdc
BLAKE2b-256 6a83f158106485f9775207ca69818754764397a92324919a1d161bc8ac9d66ab

See more details on using hashes here.

File details

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

File metadata

  • Download URL: objectory-0.0.8-py3-none-any.whl
  • Upload date:
  • Size: 17.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.6.1 CPython/3.10.13 Linux/6.2.0-1012-azure

File hashes

Hashes for objectory-0.0.8-py3-none-any.whl
Algorithm Hash digest
SHA256 38b7096b3e7d220b35a4afd752add8d2e9042760593c5528dab99250353351cb
MD5 bedc083878c45a8b2e10992d7c5283a4
BLAKE2b-256 d8f892908e5e5d81e0418f43977ad6698d009a183260c99780d267861f36eb21

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