Product
Introducing License Enforcement in Socket
Ensure open-source compliance with Socket’s License Enforcement Beta. Set up your License Policy and secure your software!
Data-structure definition/validation/traversal, mapping and serialisation toolkit for Python
Odin
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.
+---------+-------------------------------------------------------------------------------------------------------------+ | Docs/ | .. image:: https://readthedocs.org/projects/odin/badge/?version=latest | | Help | :target: https://odin.readthedocs.org/ | | | :alt: ReadTheDocs | | | .. image:: https://img.shields.io/badge/gitterim-timsavage.odin-brightgreen.svg?style=flat | | | :target: https://gitter.im/timsavage/odin | | | :alt: Gitter.im | +---------+-------------------------------------------------------------------------------------------------------------+ | Build | .. image:: https://github.com/python-odin/odin/actions/workflows/python-package.yml/badge.svg | | | :target: https://github.com/python-odin/odin/actions/workflows/python-package.yml | | | :alt: Python package | +---------+-------------------------------------------------------------------------------------------------------------+ | Quality | .. image:: https://sonarcloud.io/api/project_badges/measure?project=python-odin_odin&metric=sqale_rating | | | :target: https://sonarcloud.io/dashboard?id=python-odin_odin | | | :alt: Maintainability | | | .. image:: https://sonarcloud.io/api/project_badges/measure?project=python-odin_odin&metric=security_rating | | | :target: https://sonarcloud.io/project/security_hotspots | | | :alt: Security | | | .. image:: https://sonarcloud.io/api/project_badges/measure?project=python-odin_odin&metric=coverage | | | :target: https://sonarcloud.io/code?id=python-odin_odin | | | :alt: Test Coverage | | | .. image:: https://img.shields.io/badge/code%20style-black-000000.svg | | | :target: https://github.com/ambv/black | | | :alt: Once you go Black... | +---------+-------------------------------------------------------------------------------------------------------------+ | Package | .. image:: https://img.shields.io/pypi/v/odin | | | :target: https://pypi.io/pypi/odin/ | | | :alt: Latest Version | | | .. image:: https://img.shields.io/pypi/pyversions/odin | | | :target: https://pypi.io/pypi/odin/ | | | .. image:: https://img.shields.io/pypi/l/odin | | | :target: https://pypi.io/pypi/odin/ | | | .. image:: https://img.shields.io/pypi/wheel/odin | | | :alt: PyPI - Wheel | | | :target: https://pypi.io/pypi/odin/ | +---------+-------------------------------------------------------------------------------------------------------------+
Highlights
1
supportedSphinx <http://sphinx-doc.org/>
_:sup:1
certain contrib items are not supported. Pint is not installable with PyPy.
Use cases
Quick links
Documentation <https://odin.readthedocs.org/>
_Project home <https://github.com/python-odin/odin>
_Issue tracker <https://github.com/python-odin/odin/issues>
_Upcoming features
In development
Requires
Optional
Contrib
Pint <http://pint.readthedocs.org/>
_ library.Development
Example
Definition
.. code-block:: python
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()
Using Annotations
.. code-block:: python
import odin
class Author(odin.AnnotatedResource):
name: str
class Publisher(odin.AnnotatedResource):
name: str
website: Optional[odin.Url]
class Book(odin.AnnotatedResource):
title: str
authors: List[Author]
publisher: Publisher
genre: str
num_pages: int
Usage::
>>> 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"
}
FAQs
Data-structure definition/validation/traversal, mapping and serialisation toolkit for Python
We found that odin demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Ensure open-source compliance with Socket’s License Enforcement Beta. Set up your License Policy and secure your software!
Product
We're launching a new set of license analysis and compliance features for analyzing, managing, and complying with licenses across a range of supported languages and ecosystems.
Product
We're excited to introduce Socket Optimize, a powerful CLI command to secure open source dependencies with tested, optimized package overrides.