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, u'roll', version=None)
def _dump_dice(data):
return u"{}d{}".format(*data)
@reg.loader(u'roll', version=None)
def _load_dice(data, version):
a, _, b = data.partition(u'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.1.tar.gz
(7.3 kB
view details)
Built Distribution
camel-0.1.1-py2.py3-none-any.whl
(23.1 kB
view details)
File details
Details for the file camel-0.1.1.tar.gz
.
File metadata
- Download URL: camel-0.1.1.tar.gz
- Upload date:
- Size: 7.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | f873fee166a6b98c29c92684911e1772cd3feb513b42ce98088f051eeb50883e |
|
MD5 | 6b6539ef7a9a84756b5593b1bd957f5e |
|
BLAKE2b-256 | 36c51958058e176a13fcea9fcf6159060b1b73051da449f7733253da32b5bf8f |
Provenance
File details
Details for the file camel-0.1.1-py2.py3-none-any.whl
.
File metadata
- Download URL: camel-0.1.1-py2.py3-none-any.whl
- Upload date:
- Size: 23.1 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 44765c6ff86232b6c976a5cbcf9c268e42357fba6d803eb9e2555a016c527e03 |
|
MD5 | c5b80c7d1cd87e4dfc3057446387d910 |
|
BLAKE2b-256 | b48cb0449e46f711a2bd2a9d5489246b102961a6ead1e58917148a4927ffed2f |