skip to navigation
skip to content

camel 0.1.2

Python serialization for adults

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])

# !roll 3d6
# ...



File Type Py Version Uploaded on Size
camel-0.1.2-py2.py3-none-any.whl (md5) Python Wheel py2.py3 2017-05-29 22KB
camel-0.1.2.tar.gz (md5) Source 2017-05-29 7KB