Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/tombulled/roster
Python object registers. Keep track of your classes, functions and data.
https://github.com/tombulled/roster
python register roster
Last synced: 23 days ago
JSON representation
Python object registers. Keep track of your classes, functions and data.
- Host: GitHub
- URL: https://github.com/tombulled/roster
- Owner: tombulled
- License: mit
- Created: 2021-04-12T16:17:26.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2022-10-27T20:49:11.000Z (about 2 years ago)
- Last Synced: 2024-11-11T07:46:59.940Z (about 1 month ago)
- Topics: python, register, roster
- Language: Python
- Homepage: https://pypi.org/project/roster/
- Size: 43.9 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# roster
Python object registers. Keep track of your classes, functions and data.## Installation
`roster` can be installed from [PyPI](https://pypi.org/project/roster/)
```console
pip install roster
```## Usage:
### `Record`
#### Default Record
```python
from roster import Recordnumbers: Record[int] = Record()
numbers(1)
numbers(2)
numbers(3)
``````python
>>> numbers
[1, 2, 3]
```#### Generate each `item`
```python
from roster import Recordcharacters: Record[str] = Record()
@characters.item
def character(char: str, /) -> str:
return char.upper()character('a')
character('b')
character('c')
``````python
>>> characters
['A', 'B', 'C']
```### `Register`
#### Default Register
```python
from roster import Registerservices: Register[str, type] = Register()
@services('youtube')
class YouTube: pass@services('spotify')
class Spotify: pass
``````python
>>> services
{'youtube': , 'spotify': }
```#### Generate each `key`
```python
from roster import Register
from typing import Callablefunctions: Register[str, Callable] = Register()
@functions.key
def function(name: str, /) -> str:
return name.upper()@function('foo')
def foo(): pass@function('bar')
def bar(): pass
``````python
>>> functions
{'FOO': , 'BAR': }
```#### Generate each `value`
```python
from roster import Register
from typing import Callablefunctions: Register[str, Callable] = Register()
@functions.value
def function(name: str, /) -> str:
return name.upper()@function('foo')
def foo(): pass@function('bar')
def bar(): pass
``````python
>>> functions
{: 'FOO', : 'BAR'}
```#### Generate each `entry`
```python
from roster import Register
from typing import Tupleidentifiers: Register[str, str] = Register()
@identifiers.entry
def identifier(code: str, /) -> Tuple[str, str]:
return (code[0], code.upper())identifier('foo')
identifier('bar')
``````python
>>> identifiers
{'f': 'FOO', 'b': 'BAR'}
```