A light library for general purpose object factories
Project description
objectory = object + factory
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)
[]
>>> from objectory import AbstractFactory
>>> class BaseClass(metaclass=AbstractFactory):
... pass
...
>>> class MyClass(BaseClass):
... pass
...
>>> obj = BaseClass.factory("MyClass")
>>> print(obj)
<__main__.MyClass object at 0x...>
>>> 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.14 |
0.2.0 |
>=6.0,<7.0 |
>=3.9,<3.14 |
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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file objectory-0.2.0.tar.gz
.
File metadata
- Download URL: objectory-0.2.0.tar.gz
- Upload date:
- Size: 15.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.3 CPython/3.12.7 Linux/6.5.0-1025-azure
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | c47d447cc4b34d292ce4dd967bdad94554e5cac12940dfd808713f0f41a9fb6e |
|
MD5 | 9615c51214314062549e1947c3872ff4 |
|
BLAKE2b-256 | e56015b30e3cdc71bfe565e32818b8a6b09a442f1d5107ee9887b6413f399dca |
File details
Details for the file objectory-0.2.0-py3-none-any.whl
.
File metadata
- Download URL: objectory-0.2.0-py3-none-any.whl
- Upload date:
- Size: 17.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.3 CPython/3.12.7 Linux/6.5.0-1025-azure
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4da872ccc9768fe61bd14d37189a850a2524b19ebc3d33b71aa0c7b3423481e8 |
|
MD5 | 2bf2a66f897a190128b858b527949071 |
|
BLAKE2b-256 | f84aba733aa2e42a3e1d1903116904b365586798f5d12b4595dc1170a8ff3432 |