Skip to main content

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.1.tar.gz (3.6 kB view details)

Uploaded Source

Built Distribution

simpleregistry-0.1.1-py3-none-any.whl (5.4 kB view details)

Uploaded Python 3

File details

Details for the file simpleregistry-0.1.1.tar.gz.

File metadata

  • Download URL: simpleregistry-0.1.1.tar.gz
  • Upload date:
  • Size: 3.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/4.0.2 CPython/3.11.5

File hashes

Hashes for simpleregistry-0.1.1.tar.gz
Algorithm Hash digest
SHA256 f61fe3b3c19dd9d4264562c6ec7b736f01b5623254ff89d517439aa09c27a81a
MD5 50aabb1b9f218d5beb2a3f23f98c9f85
BLAKE2b-256 07d0597aa35bb2e42ada84fb8aa1d6d8d7bf23e256db0ee7541700bd6044b20f

See more details on using hashes here.

File details

Details for the file simpleregistry-0.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for simpleregistry-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 397b68801db09081edd21c043c81944a73cedfaebc7fb5618788ccc443e85263
MD5 3fca601899116b83583a4c80a89fbc7d
BLAKE2b-256 f851033760ac0521b3bd1a0ce29c080220a7c728addd79e55a490218e5dcc3db

See more details on using hashes here.

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