Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

History

44 Commits

Repository files navigation

Camel

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:

fromcamelimportCamel, CamelRegistryclassDieRoll(tuple):
def__new__(cls, a, b):
returntuple.__new__(cls, [a, b])
def__repr__(self):
return"DieRoll(%s,%s)"%selfreg=CamelRegistry()
@reg.dumper(DieRoll, u'roll', version=None)def_dump_dice(data):
returnu"{}d{}".format(*data)
@reg.loader(u'roll', version=None)def_load_dice(data, version):
a, _, b=data.partition(u'd')
returnDieRoll(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

About

Python serialization for adults

Resources

Stars

158 stars

Watchers

7 watching

Forks

Releases

Packages

Used by

Contributors

Languages