No project description provided
Project description
simpleregistry
Simple registries in Python.
Right now supports only object registries, but class registries are coming in the future releases:
import dataclasses
import simpleregistry
book_registry = simpleregistry.Registry('books')
@simpleregistry.register(book_registry)
@dataclasses.dataclass
class Book:
isbn: int
title: str
author: str
def __hash__(self) -> int:
return hash(self.isbn)
lord_of_the_rings = Book(123, 'The Lord of the Rings', 'J. R. R. Tolkien')
assert lord_of_the_rings in book_registry
assert len(book_registry) == 1
assert book_registry.all() == {lord_of_the_rings}
assert book_registry.get(isbn=123) == lord_of_the_rings
assert book_registry.filter(author='J. R. R. Tolkien') == {lord_of_the_rings}
Works with custom types, standard-library dataclasses and Pydantic. See tests for examples.
This project is currently in Alpha status. You are welcome to use it. Code should be stable, but the API may change.
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
simpleregistry-0.1.2.tar.gz
(3.1 kB
view details)
Built Distribution
File details
Details for the file simpleregistry-0.1.2.tar.gz
.
File metadata
- Download URL: simpleregistry-0.1.2.tar.gz
- Upload date:
- Size: 3.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/4.0.2 CPython/3.11.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | d42e8933079ea84a055ac575039baad1f3fa507ed0e049a6f3ef3c0f0cd5b91b |
|
MD5 | d945704e9ae0be89a79948ee971d4387 |
|
BLAKE2b-256 | 26e0afa10d11bf715f1c1bc5e3d467b85c19703b4ba3851184b8229065ecdb02 |
File details
Details for the file simpleregistry-0.1.2-py3-none-any.whl
.
File metadata
- Download URL: simpleregistry-0.1.2-py3-none-any.whl
- Upload date:
- Size: 3.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/4.0.2 CPython/3.11.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7c6072140302875d73fd193261a994122b55e75284b5c3dbd9bd7a0f3ee9928f |
|
MD5 | 72efea97d41dd3cb431410c4552cc922 |
|
BLAKE2b-256 | 7bbe71dbd016ce599c64fb36c72166785b8c0b1f970d563a94b597d1ae7c74a4 |