A light library for general purpose object factories
Project description
objectory = object + factory
Overview
A light 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)
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>
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 let us know if you encounter a bug by filing an issue.
We welcome contributions from anyone, even if you are new to open source.
- If you are planning to contribute back bug-fixes, please do so without any further discussion.
- If you plan to contribute new features, utility functions, or extensions to the core, please first open an issue and discuss the feature with us.
Once you implement and test your feature or bug-fix, please submit a Pull Request.
Please feel free to open an issue to share your feedback or to request new features.
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
Hashes for objectory-0.0.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 47e2aade7c65018fa530471fc5faf4f27c5b720f204e92d3e116627b8c9dc0a8 |
|
MD5 | 86e88b969c8bdf70dd7d663ed956eac2 |
|
BLAKE2b-256 | 186c97c3f7e05e752e21b527fca9bba0540e8f3a264de83dd891d51d181f5ccc |