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.
Features
Free software: BSD license
Documentation: https://kylie.readthedocs.org/
Allows name mapping between Models and python dictionary keys.
Allows type conversion when serializing and de-serializing objects.
Automatic serialization/deserialization of nested models.
Not bound to JSON in any way, and should also be useful for MessagePack
Supports Python 2.6+ & 3.3+
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 supports nested models, so you can embed other Model instances inside the data, and Kylie will manage serialization and deserialization of them for you.
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 plan to add this once I decide the best way to do it. Ideas welcome!
No post-deserialize option, 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, still some important things to do, but I think Kylie is already useful.
Why is it called Kylie?
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?
History
0.3.0 (2015-06-05)
MappedModelChoice & BaseModelChoice for determining Model to deserialize at runtime.
Change to internal Attribute interface (will lead to minor version bump)
_apply_model has been replaced with a direct set of attr_name.
Minor code quality improvements.
Documentation improvements.
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.
Metadata
Release files for kylie 0.3.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| kylie-0.3.1.tar.gz | 19.0 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| kylie-0.3.1-py2.py3-none-any.whl | Python 3, Python 2 | none | any | Details |
Total release size: 28.1 kB
Release files / kylie-0.3.1.tar.gz
| Download URL | kylie-0.3.1.tar.gz |
|---|---|
| Size | 19.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
c5df453509ca82c6b4fc450248c38cac928a11be1fdce901bbebae40425a4789
|
|
BLAKE2b-256 checksum How to use checksums |
a7fb2c4ef9d741f6ffcfebd2c415888a32c9b75b386bade37eb3dc89b8f2ead3
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Release files / kylie-0.3.1-py2.py3-none-any.whl
| Download URL | kylie-0.3.1-py2.py3-none-any.whl |
|---|---|
| Size | 9.1 kB |
| Tags | Python 2 Python 3 |
|
SHA-256 checksum How to use checksums |
c34a21545145bc0ec7e9a311ac3e5cc2b34eb39ff72402b1c736f77bf2f9a2eb
|
|
BLAKE2b-256 checksum How to use checksums |
2a3f5cd9a83d0fe9dbc88ad2f38bb4fcadcfa54fbd6c6af6b3290f74120c6a80
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Security for kylie 0.3.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.