Skip to main content

Data-structure definition/validation/traversal, mapping and serialisation toolkit for Python

Project description

Odin provides a declarative framework for defining resources (classes) and their relationships, validation of the fields that make up the resources and mapping between objects (either a resource, or other python structures).

Odin also comes with built in serialisation tools for importing and exporting data from resources.

License https://img.shields.io/pypi/v/odin.svg?style=flat Travis CI Status Code cov Requirements Status Gitter.im

Highlights

  • Class based declarative style

  • Fields for building composite resources

  • Field and Resource level validation

  • Mapping between resources or extended to other object types (eg Django Models)

  • Easy extension to support custom fields

  • Python 2.6 1, Python 2.7+, Python 3.3+ and PyPy 1 supported

  • Integration with Django (see baldr)

  • Support for documenting resources with Sphinx

  • Minimal dependencies (base functionality only requires six)

1 certain contrib items are not supported. Pint is not installable with PyPy.

Upcoming features

In development

  • XML Codec (export completed)

  • Complete documentation coverage

  • Improvements for CSV Codec (writing, reading multi resource CSV’s)

  • RESTful interface with support for Flask and Django

  • Integration with other libraries (ie Django Models/Forms)

  • Integration with SQLAlchemy

Requires

  • six

Optional

  • simplejson - Odin will use simplejson if it is available or fallback to the builtin json library

  • msgpack-python - To enable use of the msgpack codec

  • pyyaml - To enable use of the YAML codec

Contrib

  • jinja2 >= 2.7 - For documentation generation

  • pint - Support for physical quantities using the Pint library.

Development

  • pytest - Testing

  • pytest-cov - Coverage reporting

Example

With definition:

import odin

class Author(odin.Resource):
    name = odin.StringField()

class Publisher(odin.Resource):
    name = odin.StringField()

class Book(odin.Resource):
    title = odin.StringField()
    authors = odin.ArrayOf(Author)
    publisher = odin.DictAs(Publisher)
    genre = odin.StringField()
    num_pages = odin.IntegerField()
>>> b = Book(
        title="Consider Phlebas",
        genre="Space Opera",
        publisher=Publisher(name="Macmillan"),
        num_pages=471
    )
>>> b.authors.append(Author(name="Iain M. Banks"))
>>> from odin.codecs import json_codec
>>> json_codec.dumps(b, indent=4)
{
    "$": "Book",
    "authors": [
        {
            "$": "Author",
            "name": "Iain M. Banks"
        }
    ],
    "genre": "Space Opera",
    "num_pages": 471,
    "publisher": {
        "$": "Publisher",
        "name": "Macmillan"
    },
    "title": "Consider Phlebas"
}

Authors

Tim Savage

Special Mention

I would like to acknowledge the strong influence on the design of Odin Resources from the Django ORM and it’s notable contributor Malcolm Tredinnick. He was a valued colleague who’s untimely passing left a large void in our company and the wider community.

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

odin-0.8.2.tar.gz (69.6 kB view details)

Uploaded Source

Built Distribution

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

odin-0.8.2-py2.py3-none-any.whl (93.7 kB view details)

Uploaded Python 2Python 3

File details

Details for the file odin-0.8.2.tar.gz.

File metadata

  • Download URL: odin-0.8.2.tar.gz
  • Upload date:
  • Size: 69.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for odin-0.8.2.tar.gz
Algorithm Hash digest
SHA256 6063e08a7a1fa69847c75af51181dec31d11477b2b6a2c3fb40c909e6ef318c4
MD5 f4904ebcade481d9ff38b5f3a4c81922
BLAKE2b-256 6b6427325d03845892e6994f94b95d4cf0805a4dc116f4385c6089194c2e7c57

See more details on using hashes here.

File details

Details for the file odin-0.8.2-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for odin-0.8.2-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 a789cc3f1e41ad0ba0c16f44b4d8226182b07607e98cbf3d48ca207c13f7280f
MD5 b434ae1d10e5eee399b5957794b949ac
BLAKE2b-256 e4ff9138557c3da0233ba26b2c3a57bd7984003e25b599d8076c5bf2dfe95fca

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page