Everything you need to implement maintainable and easy to use registry patterns in your project.
Project description
Registerer
Sometimes you may want to use a string to identify a specific function or class. This is a common way of designing your code, but it can be tricky to do it without repeating yourself. Registerer is a tool that helps you to do this easily, and also makes sure that your code is explicit and type safe.
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file registerer-1.0.0.tar.gz.
File metadata
- Download URL: registerer-1.0.0.tar.gz
- Upload date:
- Size: 5.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c810852e108a32412a05dbde26f6db183047bab41ee471cd3f121a669f75c500
|
|
| MD5 |
6ed3fd430d8e61b3dde787a894fba1bf
|
|
| BLAKE2b-256 |
59fe6b060afdb5af97be33e72b5ddbb84d7fa43302f0645ae89501d7cee5a985
|
Provenance
The following attestation bundles were made for registerer-1.0.0.tar.gz:
Publisher:
ci.yml on danialkeimasi/python-registerer
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
registerer-1.0.0.tar.gz -
Subject digest:
c810852e108a32412a05dbde26f6db183047bab41ee471cd3f121a669f75c500 - Sigstore transparency entry: 517787968
- Sigstore integration time:
-
Permalink:
danialkeimasi/python-registerer@5683b52d09b5a6f297ad8475b8ba1819f2e0ab2c -
Branch / Tag:
refs/tags/v1.0.0 - Owner: https://github.com/danialkeimasi
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
ci.yml@5683b52d09b5a6f297ad8475b8ba1819f2e0ab2c -
Trigger Event:
push
-
Statement type:
File details
Details for the file registerer-1.0.0-py3-none-any.whl.
File metadata
- Download URL: registerer-1.0.0-py3-none-any.whl
- Upload date:
- Size: 6.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
53d93ea5c8753ad9806bd1fc846a5eb3bc33131bce5823cf6ea6a80e0d09abf4
|
|
| MD5 |
3df08add61a9fbef95397f7d128f0183
|
|
| BLAKE2b-256 |
51d0e124647adb09dd69294bb43d46b8fc449271b52216792ecdfebd3870bbd2
|
Provenance
The following attestation bundles were made for registerer-1.0.0-py3-none-any.whl:
Publisher:
ci.yml on danialkeimasi/python-registerer
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
registerer-1.0.0-py3-none-any.whl -
Subject digest:
53d93ea5c8753ad9806bd1fc846a5eb3bc33131bce5823cf6ea6a80e0d09abf4 - Sigstore transparency entry: 517787998
- Sigstore integration time:
-
Permalink:
danialkeimasi/python-registerer@5683b52d09b5a6f297ad8475b8ba1819f2e0ab2c -
Branch / Tag:
refs/tags/v1.0.0 - Owner: https://github.com/danialkeimasi
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
ci.yml@5683b52d09b5a6f297ad8475b8ba1819f2e0ab2c -
Trigger Event:
push
-
Statement type: