Everything you need to implement maintainable and easy to use registry patterns in your project.
Project description
Registerer
Implement maintainable and easy to use registry patterns in your project.
TLDR
Write this:
import registerer
command_handler_registry = registerer.Registerer()
@command_handler_registry.register()
def info(args):
return "how can i help you?"
@command_handler_registry.register()
def play(args):
return "let me play a song for you"
command = "info"
args = {}
assert command_handler_registry[command](args) == "how can i help you?"
Instead of this, which violates the Open-Closed Principle (OCP):
def info(args):
return "how can i help you?"
def play(args):
return "let me play a song for you"
def command_handler(command, args):
if command == "info":
return info(args)
if command == "play":
return play(args)
command = "play"
args = {}
assert command_handler(command, args) == "let me play a song for you"
Links
- For more information Read the docs.
Installation
You can install the latest version of registerer from PyPI:
pip install registerer
Features
- It's completely type-safe, thus you will get suggestions from your IDE.
- Writing custom validations for registered items is provided without any inheritance.
- generate choices for Django from registered items.
- And so on...
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
registerer-0.6.0.tar.gz
(6.0 kB
view details)
Built Distribution
File details
Details for the file registerer-0.6.0.tar.gz
.
File metadata
- Download URL: registerer-0.6.0.tar.gz
- Upload date:
- Size: 6.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.2.1 CPython/3.10.9 Linux/6.1.4-arch1-1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 60bdcedd3c875c0b22bb7db3433772a6fc0934df1dc6e760c56d2c729fd50741 |
|
MD5 | 6b9213fcdb464c8a99ea9da35cf19ca1 |
|
BLAKE2b-256 | d0a738a52ad0120dbcbcea504c7e7fd6c5e0bea96ff425f03190425e674f2226 |
File details
Details for the file registerer-0.6.0-py3-none-any.whl
.
File metadata
- Download URL: registerer-0.6.0-py3-none-any.whl
- Upload date:
- Size: 6.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.2.1 CPython/3.10.9 Linux/6.1.4-arch1-1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | e7d29a84971e82c5a51157ceb94f55771e3437bf2595a39e1bfc6ee31bab4a22 |
|
MD5 | 76422477904314ba58d10c209b8d4ba5 |
|
BLAKE2b-256 | 71dae8733d80a94deb0fba8ee2ce8b143f9b15d034d3788c73a034f6b0b06f9e |