pydantic-xml extension
======================
.. image:: https://static.pepy.tech/personalized-badge/pydantic-xml?period=month&units=international_system&left_color=grey&right_color=orange&left_text=Downloads/month
:target: https://pepy.tech/project/pydantic-xml
:alt: Downloads/month
.. image:: https://github.com/dapper91/pydantic-xml/actions/workflows/test.yml/badge.svg?branch=master
:target: https://github.com/dapper91/pydantic-xml/actions/workflows/test.yml
:alt: Build status
.. image:: https://img.shields.io/pypi/l/pydantic-xml.svg
:target: https://pypi.org/project/pydantic-xml
:alt: License
.. image:: https://img.shields.io/pypi/pyversions/pydantic-xml.svg
:target: https://pypi.org/project/pydantic-xml
:alt: Supported Python versions
.. image:: https://codecov.io/gh/dapper91/pydantic-xml/branch/master/graph/badge.svg
:target: https://codecov.io/gh/dapper91/pydantic-xml
:alt: Code coverage
.. image:: https://readthedocs.org/projects/pydantic-xml/badge/?version=stable&style=flat
:alt: ReadTheDocs status
:target: https://pydantic-xml.readthedocs.io
``pydantic-xml`` is a `pydantic <https://docs.pydantic.dev>`_ extension providing model fields xml binding
and xml serialization / deserialization.
It is closely integrated with ``pydantic`` which means it supports most of its features.
Features
--------
- pydantic v1 / v2 support
- flexable attributes, elements and text binding
- python collection types support (``Dict``, ``TypedDict``, ``List``, ``Set``, ``Tuple``, ...)
- ``Union`` type support
- pydantic `generic models <https://docs.pydantic.dev/latest/usage/models/#generic-models>`_ support
- pydantic `computed fields <https://docs.pydantic.dev/latest/usage/computed_fields/>`_ support
- `lxml <https://lxml.de/>`_ xml parser support
- ``xml.etree.ElementTree`` standard library xml parser support
What is not supported?
______________________
- `dataclasses <https://docs.pydantic.dev/usage/dataclasses/>`_
- `callable discriminators <https://docs.pydantic.dev/latest/concepts/unions/#discriminated-unions-with-callable-discriminator>`_
Getting started
---------------
The following model fields binding:
.. code-block:: python
class Product(BaseXmlModel):
status: Literal['running', 'development'] = attr() # extracted from the 'status' attribute
launched: Optional[int] = attr(default=None) # extracted from the 'launched' attribute
title: str # extracted from the element text
class Company(BaseXmlModel):
trade_name: str = attr(name='trade-name') # extracted from the 'trade-name' attribute
website: HttpUrl = element() # extracted from the 'website' element text
products: List[Product] = element(tag='product', default=[]) # extracted from the 'Company' element's children
defines the XML document:
.. code-block:: xml
<Company trade-name="SpaceX">
<website>https://www.spacex.com</website>
<product status="running" launched="2013">Several launch vehicles</product>
<product status="running" launched="2019">Starlink</product>
<product status="development">Starship</product>
</Company>
See `documentation <https://pydantic-xml.readthedocs.io>`_ for more details.
Raw data
{
"_id": null,
"home_page": "https://github.com/dapper91/pydantic-xml",
"name": "pydantic-xml",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.8",
"maintainer_email": null,
"keywords": "pydantic, xml, serialization, deserialization, lxml",
"author": "Dmitry Pershin",
"author_email": "dapper1291@gmail.com",
"download_url": "https://files.pythonhosted.org/packages/00/b6/24614cb775badf8d8fd512e9e725172302b128589ad13149a15be4d9f224/pydantic_xml-2.14.0.tar.gz",
"platform": null,
"description": "\npydantic-xml extension\n======================\n\n.. image:: https://static.pepy.tech/personalized-badge/pydantic-xml?period=month&units=international_system&left_color=grey&right_color=orange&left_text=Downloads/month\n :target: https://pepy.tech/project/pydantic-xml\n :alt: Downloads/month\n.. image:: https://github.com/dapper91/pydantic-xml/actions/workflows/test.yml/badge.svg?branch=master\n :target: https://github.com/dapper91/pydantic-xml/actions/workflows/test.yml\n :alt: Build status\n.. image:: https://img.shields.io/pypi/l/pydantic-xml.svg\n :target: https://pypi.org/project/pydantic-xml\n :alt: License\n.. image:: https://img.shields.io/pypi/pyversions/pydantic-xml.svg\n :target: https://pypi.org/project/pydantic-xml\n :alt: Supported Python versions\n.. image:: https://codecov.io/gh/dapper91/pydantic-xml/branch/master/graph/badge.svg\n :target: https://codecov.io/gh/dapper91/pydantic-xml\n :alt: Code coverage\n.. image:: https://readthedocs.org/projects/pydantic-xml/badge/?version=stable&style=flat\n :alt: ReadTheDocs status\n :target: https://pydantic-xml.readthedocs.io\n\n\n``pydantic-xml`` is a `pydantic <https://docs.pydantic.dev>`_ extension providing model fields xml binding\nand xml serialization / deserialization.\nIt is closely integrated with ``pydantic`` which means it supports most of its features.\n\n\nFeatures\n--------\n\n- pydantic v1 / v2 support\n- flexable attributes, elements and text binding\n- python collection types support (``Dict``, ``TypedDict``, ``List``, ``Set``, ``Tuple``, ...)\n- ``Union`` type support\n- pydantic `generic models <https://docs.pydantic.dev/latest/usage/models/#generic-models>`_ support\n- pydantic `computed fields <https://docs.pydantic.dev/latest/usage/computed_fields/>`_ support\n- `lxml <https://lxml.de/>`_ xml parser support\n- ``xml.etree.ElementTree`` standard library xml parser support\n\nWhat is not supported?\n______________________\n\n- `dataclasses <https://docs.pydantic.dev/usage/dataclasses/>`_\n- `callable discriminators <https://docs.pydantic.dev/latest/concepts/unions/#discriminated-unions-with-callable-discriminator>`_\n\nGetting started\n---------------\n\nThe following model fields binding:\n\n.. code-block:: python\n\n class Product(BaseXmlModel):\n status: Literal['running', 'development'] = attr() # extracted from the 'status' attribute\n launched: Optional[int] = attr(default=None) # extracted from the 'launched' attribute\n title: str # extracted from the element text\n\n\n class Company(BaseXmlModel):\n trade_name: str = attr(name='trade-name') # extracted from the 'trade-name' attribute\n website: HttpUrl = element() # extracted from the 'website' element text\n products: List[Product] = element(tag='product', default=[]) # extracted from the 'Company' element's children\n\ndefines the XML document:\n\n.. code-block:: xml\n\n <Company trade-name=\"SpaceX\">\n <website>https://www.spacex.com</website>\n <product status=\"running\" launched=\"2013\">Several launch vehicles</product>\n <product status=\"running\" launched=\"2019\">Starlink</product>\n <product status=\"development\">Starship</product>\n </Company>\n\n\nSee `documentation <https://pydantic-xml.readthedocs.io>`_ for more details.\n",
"bugtrack_url": null,
"license": "Unlicense",
"summary": "pydantic xml extension",
"version": "2.14.0",
"project_urls": {
"Documentation": "https://pydantic-xml.readthedocs.io",
"Homepage": "https://github.com/dapper91/pydantic-xml",
"Repository": "https://github.com/dapper91/pydantic-xml"
},
"split_keywords": [
"pydantic",
" xml",
" serialization",
" deserialization",
" lxml"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "8cb4ba91e5ce95e67637652189fca252833178e33dd980746ea1ca2d99dd37af",
"md5": "e28f60f369219518a3b32f5ef8db7dcd",
"sha256": "01a64132ccf7921c6b3aac4fa7912dcd6d1858b1ea6087f0518d7af0bc2d2d7d"
},
"downloads": -1,
"filename": "pydantic_xml-2.14.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "e28f60f369219518a3b32f5ef8db7dcd",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.8",
"size": 40525,
"upload_time": "2024-11-09T14:36:39",
"upload_time_iso_8601": "2024-11-09T14:36:39.011111Z",
"url": "https://files.pythonhosted.org/packages/8c/b4/ba91e5ce95e67637652189fca252833178e33dd980746ea1ca2d99dd37af/pydantic_xml-2.14.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "00b624614cb775badf8d8fd512e9e725172302b128589ad13149a15be4d9f224",
"md5": "dbe41dd9f362c5c9019b9be47719168b",
"sha256": "f6dadf6a2783598826f3b406c8e5ff5a2fc19994f48e9fd75f596279643ff59a"
},
"downloads": -1,
"filename": "pydantic_xml-2.14.0.tar.gz",
"has_sig": false,
"md5_digest": "dbe41dd9f362c5c9019b9be47719168b",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.8",
"size": 25947,
"upload_time": "2024-11-09T14:36:40",
"upload_time_iso_8601": "2024-11-09T14:36:40.630601Z",
"url": "https://files.pythonhosted.org/packages/00/b6/24614cb775badf8d8fd512e9e725172302b128589ad13149a15be4d9f224/pydantic_xml-2.14.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-11-09 14:36:40",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "dapper91",
"github_project": "pydantic-xml",
"travis_ci": false,
"coveralls": true,
"github_actions": true,
"lcname": "pydantic-xml"
}