Python serialization for adults
Project description
Camel is a library that lets you describe how to serialize your objects to YAML — and refuses to serialize them if you don’t.
Quick example:
from camel import Camel, CamelRegistry class DieRoll(tuple): def __new__(cls, a, b): return tuple.__new__(cls, [a, b]) def __repr__(self): return "DieRoll(%s,%s)" % self reg = CamelRegistry() @reg.dumper(DieRoll, 'roll', version=None) def _dump_dice(data): return "{}d{}".format(*data) @reg.loader('roll', version=None) def _load_dice(data, version): a, _, b = data.partition('d') return DieRoll(int(a), int(b)) value = DieRoll(3, 6) camel = Camel([reg]) print(camel.dump(value)) # !roll 3d6
Docs: http://camel.readthedocs.org/en/latest/
GitHub: https://github.com/eevee/camel
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
camel-0.1.tar.gz
(7.2 kB
view details)
Built Distribution
File details
Details for the file camel-0.1.tar.gz
.
File metadata
- Download URL: camel-0.1.tar.gz
- Upload date:
- Size: 7.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9403f17c52d8410297c330ef31f0a63bcb53ec3b63d2c90df802bf726f84925c |
|
MD5 | 120a86185280d209c1c738ce3e7bf016 |
|
BLAKE2b-256 | 2bf63e00c732983c7c233823b72086911c1d05cc1c9e7a6556967a83b6e65159 |
Provenance
File details
Details for the file camel-0.1-py2.py3-none-any.whl
.
File metadata
- Download URL: camel-0.1-py2.py3-none-any.whl
- Upload date:
- Size: 9.6 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | df7c8fdf9a3df60f49dc66b06b2d919d46a117954442ca8a1daee0d1edf1ad77 |
|
MD5 | 5c5f81cf276b728bab14a6b5d37e142c |
|
BLAKE2b-256 | 272a6a8381925aab130a5618c1779c8dab704931f16dd56903e82f026cefe344 |