pydantic-xml


Namepydantic-xml JSON
Version 2.11.0 PyPI version JSON
download
home_pagehttps://github.com/dapper91/pydantic-xml
Summarypydantic xml extension
upload_time2024-05-11 09:51:22
maintainerNone
docs_urlNone
authorDmitry Pershin
requires_python>=3.8
licenseUnlicense
keywords pydantic xml serialization deserialization lxml
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage
            
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/45/a4283035a792e4a3197a0553ffccc3fd875782f6e736dcced00290ce445b/pydantic_xml-2.11.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.11.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": "811e57d56528e24ea912d3daa818adb162e52032cbbd43a7689f1ff71657955c",
                "md5": "89889edb78607b80e135d1fe986e349d",
                "sha256": "033b2b997a99bdb18ab93d7ed66a5bc9ec490753afc011f084bd625ad2d0bdfd"
            },
            "downloads": -1,
            "filename": "pydantic_xml-2.11.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "89889edb78607b80e135d1fe986e349d",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8",
            "size": 39427,
            "upload_time": "2024-05-11T09:51:20",
            "upload_time_iso_8601": "2024-05-11T09:51:20.516441Z",
            "url": "https://files.pythonhosted.org/packages/81/1e/57d56528e24ea912d3daa818adb162e52032cbbd43a7689f1ff71657955c/pydantic_xml-2.11.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "0045a4283035a792e4a3197a0553ffccc3fd875782f6e736dcced00290ce445b",
                "md5": "0cfef578ed5319b71d1ba33834d790dd",
                "sha256": "7fbe816b8251b45aabe0c11992fc52e2921afd8f46f256b3f60ed82f869361da"
            },
            "downloads": -1,
            "filename": "pydantic_xml-2.11.0.tar.gz",
            "has_sig": false,
            "md5_digest": "0cfef578ed5319b71d1ba33834d790dd",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8",
            "size": 25004,
            "upload_time": "2024-05-11T09:51:22",
            "upload_time_iso_8601": "2024-05-11T09:51:22.540557Z",
            "url": "https://files.pythonhosted.org/packages/00/45/a4283035a792e4a3197a0553ffccc3fd875782f6e736dcced00290ce445b/pydantic_xml-2.11.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-05-11 09:51:22",
    "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"
}
        
Elapsed time: 0.25030s