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?
______________________
- `dynamic model creation <https://docs.pydantic.dev/usage/models/#dynamic-model-creation>`_
- `dataclasses <https://docs.pydantic.dev/usage/dataclasses/>`_
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/2c/06/6e537e2196b729c34bd1ff1c22b02f46e86832309fff92def091015062b0/pydantic_xml-2.9.2.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- `dynamic model creation <https://docs.pydantic.dev/usage/models/#dynamic-model-creation>`_\n- `dataclasses <https://docs.pydantic.dev/usage/dataclasses/>`_\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.9.2",
"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": "34606f4bf47509aae6649880eac05cf0a09432bee32ec755faa3192b163e92e0",
"md5": "cd1e0831d0bd81330b57c66c55cd78b5",
"sha256": "35414f95dcdebe39d044ccb61980f071e2814875bf7321f60bfc1563e953146f"
},
"downloads": -1,
"filename": "pydantic_xml-2.9.2-py3-none-any.whl",
"has_sig": false,
"md5_digest": "cd1e0831d0bd81330b57c66c55cd78b5",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.8",
"size": 37061,
"upload_time": "2024-04-18T19:31:25",
"upload_time_iso_8601": "2024-04-18T19:31:25.332127Z",
"url": "https://files.pythonhosted.org/packages/34/60/6f4bf47509aae6649880eac05cf0a09432bee32ec755faa3192b163e92e0/pydantic_xml-2.9.2-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "2c066e537e2196b729c34bd1ff1c22b02f46e86832309fff92def091015062b0",
"md5": "b4ea23149d1429aab036defc20b9acea",
"sha256": "3856aa48f79b4f998177439dcc8a72b13aa57ff440d19f59940778f32e66d0d3"
},
"downloads": -1,
"filename": "pydantic_xml-2.9.2.tar.gz",
"has_sig": false,
"md5_digest": "b4ea23149d1429aab036defc20b9acea",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.8",
"size": 23962,
"upload_time": "2024-04-18T19:31:27",
"upload_time_iso_8601": "2024-04-18T19:31:27.168819Z",
"url": "https://files.pythonhosted.org/packages/2c/06/6e537e2196b729c34bd1ff1c22b02f46e86832309fff92def091015062b0/pydantic_xml-2.9.2.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-04-18 19:31:27",
"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"
}