Skip to main content

Everything you need to implement maintainable and easy to use registry patterns in your project.

Project description

Registerer

pypi ci codecov license

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

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


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)

Uploaded Source

Built Distribution

registerer-0.6.0-py3-none-any.whl (6.0 kB view details)

Uploaded Python 3

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

Hashes for registerer-0.6.0.tar.gz
Algorithm Hash digest
SHA256 60bdcedd3c875c0b22bb7db3433772a6fc0934df1dc6e760c56d2c729fd50741
MD5 6b9213fcdb464c8a99ea9da35cf19ca1
BLAKE2b-256 d0a738a52ad0120dbcbcea504c7e7fd6c5e0bea96ff425f03190425e674f2226

See more details on using hashes here.

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

Hashes for registerer-0.6.0-py3-none-any.whl
Algorithm Hash digest
SHA256 e7d29a84971e82c5a51157ceb94f55771e3437bf2595a39e1bfc6ee31bab4a22
MD5 76422477904314ba58d10c209b8d4ba5
BLAKE2b-256 71dae8733d80a94deb0fba8ee2ce8b143f9b15d034d3788c73a034f6b0b06f9e

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page