pycirce
Some primitive combinators for structurally decoding Python dataclass's,
namedtuple's, or other types.
Usage
pycirce.decode_list
The decode_list combinator accepts a decoder as its first argument and returns a decoder:
>>> decode_intlist = decode_list(int)
>>> decode_intlist(["1", "2", "3"])
[1, 2, 3]
pycirce.decode_object
The decode_object combinator accepts a constructor as its first argument,
as well as a kwarg of parameter names to decoders for that particular name.
>>> @dataclass
... class Person:
... name: str
... age: int
...
>>> decode_person = decode_object(Person)()
>>> decode_person({"name": "John Smith", "age": "45"})
Person(name='John Smith', age=45)
If members don't require downstream decoders, the second argument list kwargs can be empty:
>>> @dataclass
... class Person:
... name: str
... age: str
...
>>> decode_person = decode_object(Person)()
>>> decode_person({"name": "John Smith", "age": "45"})
Person(name='John Smith', age="45")
Metadata
Release files for pycirce 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| pycirce-0.1.0.tar.gz | 3.7 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| pycirce-0.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 7.0 kB
Release files / pycirce-0.1.0.tar.gz
| Download URL | pycirce-0.1.0.tar.gz |
|---|---|
| Size | 3.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
71d4aedc037d2082bf8e2513d72f95edf1971c75f97dff2b2c5521aff79a1dea
|
|
BLAKE2b-256 checksum How to use checksums |
9bf835a461a3bce1eed06b3c256869da012b2ec1d6af07dec7d38d90e8c72bd1
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.11.7
|
Release files / pycirce-0.1.0-py3-none-any.whl
| Download URL | pycirce-0.1.0-py3-none-any.whl |
|---|---|
| Size | 3.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
d54569693516d3d5a2f0dfd79b70f0e403255db030b669972bbf182fbc2e74c1
|
|
BLAKE2b-256 checksum How to use checksums |
2b7d63af240c41004426cc0f03fb03266e59c10ec46383193b7aca7252c8bb78
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.11.7
|