pydantic-xml


Namepydantic-xml JSON
Version 2.14.1 PyPI version JSON
download
home_pagehttps://github.com/dapper91/pydantic-xml
Summarypydantic xml extension
upload_time2024-11-28 19:06:50
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/5f/c9/9b03c5c804cbc18afa3e1f025b92ff4103065022071c4c5c6c86668b4159/pydantic_xml-2.14.1.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.1",
    "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": "5d1ff919e1c4f4f85308b7cb385ecc01ddd7ab077b8e12555cecf6075547e29e",
                "md5": "e8bbb5d3ec45146d16e54dfb40a89835",
                "sha256": "7d794a6c7db7b0aef521fa3ccf589b19ed3df63bb1aeac5017583ff28763d973"
            },
            "downloads": -1,
            "filename": "pydantic_xml-2.14.1-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "e8bbb5d3ec45146d16e54dfb40a89835",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8",
            "size": 40559,
            "upload_time": "2024-11-28T19:06:49",
            "upload_time_iso_8601": "2024-11-28T19:06:49.486884Z",
            "url": "https://files.pythonhosted.org/packages/5d/1f/f919e1c4f4f85308b7cb385ecc01ddd7ab077b8e12555cecf6075547e29e/pydantic_xml-2.14.1-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "5fc99b03c5c804cbc18afa3e1f025b92ff4103065022071c4c5c6c86668b4159",
                "md5": "0fc924252d189debf556236dafd17c12",
                "sha256": "75969a2a5bb361588e1a07b045875ac7b168eb9a937e0aff483ca31a02f2b7e2"
            },
            "downloads": -1,
            "filename": "pydantic_xml-2.14.1.tar.gz",
            "has_sig": false,
            "md5_digest": "0fc924252d189debf556236dafd17c12",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8",
            "size": 25993,
            "upload_time": "2024-11-28T19:06:50",
            "upload_time_iso_8601": "2024-11-28T19:06:50.559805Z",
            "url": "https://files.pythonhosted.org/packages/5f/c9/9b03c5c804cbc18afa3e1f025b92ff4103065022071c4c5c6c86668b4159/pydantic_xml-2.14.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-11-28 19:06:50",
    "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.42152s