Skip to main content
=====
Kylie
=====

.. image:: https://img.shields.io/travis/judy2k/kylie.svg
:target: https://travis-ci.org/judy2k/kylie

.. image:: https://img.shields.io/pypi/v/kylie.svg
:target: https://pypi.python.org/pypi/kylie


Kylie provides mappings between JSON data structures and Python objects. It
provides a reasonable amount of power with only a tiny bit of magic, and it has
100% code coverage.

* Free software: BSD license
* Documentation: https://kylie.readthedocs.org/

It supports name and type-mapping, and it's not bound to JSON, although it is
geared to serializing and de-serializing data to and from JSON-type data
structures such as dicts, lists, strings, numbers, and bools.


Example
-------

::

class SpanishInquisitionModel(Model):
inquisition_id = Attribute('id')
expected = Attribute(python_type=bool, serialized_type=int)

Then::

>>> surprise = SpanishInquisitionModel(inquisition_id=1234, expected=False)
>>> surprise.inquisition_id
1234
>>> surprise.serialize()
{'id': 1234, expected=0}

Note that the attribute ``inquisition_id`` becomes the dict key ``"id"``, and
expected is mapped to ``0`` instead of ``False``.

We can now take this dict, ``dumps`` it to JSON, and somewhere else call
the following on the json_data (which is a dict returned from ``loads``)::

>>> my_surprise = SpanishInquisitionModel.deserialize(json_data)
>>> my_surprise.inquisition_id
1234
>>> my_surprise.expected
False

Kylie also supports :ref:`nested models`, so you can embed other Model instances
inside the data, and Kylie will manage serialization and deserialization of
them for you.


Features
--------

* Allows :ref:`name mapping` between Models and python dictionary keys.
* Allows type conversion when serializing and de-serializing objects.
* Automatic serialization/deserialization of attributes that are also Models.
* Not bound to JSON in any way, and should also be useful for MessagePack_

.. _MessagePack: http://msgpack.org/


Non-Features
------------

So what doesn't Kylie do yet? Well, there are a few things, because it's
very new:

* Doesn't have any mechanism for validation. I am planning to add this, once I
decide the best way to do it. *Ideas welcome!*
* Doesn't have any built-in mechanism for choosing between different types to
deserialize a dict to. Again, you can do this through customized type mapper
functions. At the very least, I'll document this soon. I plan to add the
ability to automatically deserialize to a type based on, for example, a
``__type__`` item in the dict.
* No post-serialize or post-deserialize options, unless you do it yourself.
This would allow wiring up of objects that are referred to by ``id`` and
provided elsewhere in the serialized data-structure, for example.

So, lots to do! The amount of non-features currently outweighs the list of
features, but I think Kylie is already useful.


Why is it called Kylie?
-----------------------

I named it `especially for you`_. Back in the late 80's (I'm old!) Kylie and
Jason were today's Kim and Kanye. **This** Kylie works well with JSON. Geddit?

.. image:: http://upload.wikimedia.org/wikipedia/en/1/1a/KylieEspeciallyForYouCover.png

.. _especially for you: http://en.wikipedia.org/wiki/Especially_for_You




=======
History
=======

0.2.0 (2015-04-22)
------------------

* Added list support to Relation with ``sequence=True`` parameter.

0.1.1 (2015-04-12)
------------------

* Removed print statement inside class constructor.


0.1.0 (2015-04-12)
------------------

* First release on PyPI.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

kylie-0.2.0.tar.gz (16.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

kylie-0.2.0-py2.py3-none-any.whl (7.8 kB view details)

Uploaded Python 2Python 3

File details

Details for the file kylie-0.2.0.tar.gz.

File metadata

  • Download URL: kylie-0.2.0.tar.gz
  • Upload date:
  • Size: 16.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for kylie-0.2.0.tar.gz
Algorithm Hash digest
SHA256 7e1c30032251e9ea898480ba0c99505e6784486eeea6aa5087475a47eeec7d6b
MD5 5c70133f733dc04e2d0f3255f5065ee2
BLAKE2b-256 fa91a055995a7b2f0962ca53942093d9fe257496c9a1c5c3c148154d5a349397

See more details on using hashes here.

File details

Details for the file kylie-0.2.0-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for kylie-0.2.0-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 c2e21e92e6b4d9c380302531d93442181145b41ebdfd46b5f1291d3455d5ff3f
MD5 68df952cf6f05f045d245a905f227da2
BLAKE2b-256 d8771526ac3b9111bec11b362501c0430c1a4dad8b836b9fbc6b91fc21cf1978

See more details on using hashes here.

Release history Release notifications | RSS feed

0.3.1

2 files

0.3.0

2 files

This release

0.2.0 This release

2 files

0.1.1

2 files

0.1.0

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page