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
Code style: black Doc style: google Ruff Doc style: google
PYPI version Python BSD-3-Clause
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
>>> obj = factory("builtins.list")
>>> print(obj)
[]

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 0x...>

registry

>>> from objectory import Registry
>>> registry = Registry()
>>> @registry.register()
... class MyClass:
...     pass
...
>>> obj = registry.factory("MyClass")
>>> print(obj)
<__main__.MyClass object at 0x...>

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

It is highly recommended to use the last stable version available. 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
main >=6.0,<7.0 >=3.9,<3.13
0.1.2 >=6.0,<7.0 >=3.9,<3.13
0.1.1 >=6.0,<7.0 >=3.9,<3.13
0.1.0 >=6.0,<7.0 >=3.9,<3.13
0.0.9 >=6.0,<7.0 >=3.9,<3.13
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.1.2.tar.gz (15.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.1.2-py3-none-any.whl (17.4 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: objectory-0.1.2.tar.gz
  • Upload date:
  • Size: 15.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.7.1 CPython/3.10.13 Linux/6.2.0-1018-azure

File hashes

Hashes for objectory-0.1.2.tar.gz
Algorithm Hash digest
SHA256 1903db68b486e5efefa0b412bcac058fe6624a4ed27f42334c625937692fc6d4
MD5 9178d9de33f0847ad0e0908c1975d3d1
BLAKE2b-256 a8513bc02c45b770df9996ab7ae2911296fb59c5797a131c6cd3061665b888ee

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for objectory-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 b7ead22aa40b93193238b8642fac9ec8c1293e6bedf9cc86e799bd9afd7c887a
MD5 2083b83118097104c6d087de3cb40dd3
BLAKE2b-256 53cd6077a6b7c82b7b23f79af5ae0f8cd058f0055388b77ca4b571c39ccae420

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