Skip to main content

Python object registers. Keep track of your classes, functions and data.

Project description

roster

Python object registers. Keep track of your classes, functions and data.

Installation

pip install roster

Usage:

Record

Example: Standard Record

import roster

numbers = roster.Record()

numbers(1)
numbers(2)
numbers(3)
>>> numbers
[1, 2, 3]

Example: Hooked Record

import roster

square_numbers = roster.Record(hook=lambda n: n ** 2)

square_numbers(1)
square_numbers(2)
square_numbers(3)
>>> square_numbers
[1, 4, 9]

Example: Decorator

import roster

classes = roster.Record()

@classes
class Foo: pass

@classes
class Bar: pass
Usage
>>> classes
[<class '__main__.Foo'>, <class '__main__.Bar'>]

Register

Example: Standard Register

import roster

functions = roster.Register()

@functions(author = 'Sam')
def foo(): ...

@functions(author = 'Robbie')
def bar(): ...
>>> functions
{
    <function foo at 0x7fa9110a50d0>: Context(author='Sam'),
    <function bar at 0x7fa9110a5160>: Context(author='Robbie')
}

Example: Hooked Register

import roster
import dataclasses

@dataclasses.dataclass
class Route:
    path: str
    method: str = 'GET'

routes = roster.Register(hook=Route)

@routes('/user', method = 'POST')
def create_user(name: str) -> str:
    return f'Created user: {name!r}'
>>> routes
{<function create_user at 0x7f2f9d775ee0>: Route(path='/user', method='POST')}

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

roster-0.1.7.tar.gz (3.1 kB view hashes)

Uploaded Source

Built Distribution

roster-0.1.7-py3-none-any.whl (3.4 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