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.7.0.tar.gz (6.1 kB view hashes)

Uploaded Source

Built Distribution

registerer-0.7.0-py3-none-any.whl (6.1 kB view hashes)

Uploaded Python 3

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