Giter Club home page Giter Club logo

roster's Introduction

roster

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

Installation

roster can be installed from PyPI

pip install roster

Usage:

Record

Default Record

from roster import Record

numbers: Record[int] = Record()

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

Generate each item

from roster import Record

characters: Record[str] = Record()

@characters.item
def character(char: str, /) -> str:
    return char.upper()

character('a')
character('b')
character('c')
>>> characters
['A', 'B', 'C']

Register

Default Register

from roster import Register

services: Register[str, type] = Register()

@services('youtube')
class YouTube: pass

@services('spotify')
class Spotify: pass
>>> services
{'youtube': <class '__main__.YouTube'>, 'spotify': <class '__main__.Spotify'>}

Generate each key

from roster import Register
from typing import Callable

functions: Register[str, Callable] = Register()

@functions.key
def function(name: str, /) -> str:
    return name.upper()

@function('foo')
def foo(): pass

@function('bar')
def bar(): pass
>>> functions
{'FOO': <function foo at 0x7f9c4f065790>, 'BAR': <function bar at 0x7f9c4f065820>}

Generate each value

from roster import Register
from typing import Callable

functions: Register[str, Callable] = Register()

@functions.value
def function(name: str, /) -> str:
    return name.upper()

@function('foo')
def foo(): pass

@function('bar')
def bar(): pass
>>> functions
{<function foo at 0x7f26443aa790>: 'FOO', <function bar at 0x7f26443aa820>: 'BAR'}

Generate each entry

from roster import Register
from typing import Tuple

identifiers: Register[str, str] = Register()

@identifiers.entry
def identifier(code: str, /) -> Tuple[str, str]:
    return (code[0], code.upper())

identifier('foo')
identifier('bar')
>>> identifiers
{'f': 'FOO', 'b': 'BAR'}

roster's People

Contributors

tombulled avatar

Stargazers

 avatar

Watchers

 avatar

roster's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.