untangle


Nameuntangle JSON
Version 1.2.1 PyPI version JSON
download
home_page
SummaryConverts XML to Python objects
upload_time2022-07-02 14:09:30
maintainer
docs_urlNone
authorChristian Stefanescu
requires_python>=3.7,<4.0
licenseMIT
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            untangle
========

[![Build Status](https://github.com/stchris/untangle/actions/workflows/build.yml/badge.svg)](https://github.com/stchris/untangle/actions)
[![PyPi version](https://img.shields.io/pypi/v/untangle.svg)](https://pypi.python.org/pypi/untangle)
<a href="https://github.com/psf/black"><img alt="Code style: black" src="https://img.shields.io/badge/code%20style-black-000000.svg"></a>

[Documentation](http://readthedocs.org/docs/untangle/en/latest/)

* Converts XML to a Python object.
* Siblings with similar names are grouped into a list.
* Children can be accessed with ``parent.child``, attributes with ``element['attribute']``.
* You can call the ``parse()`` method with a filename, an URL or an XML string.
* Substitutes ``-``, ``.`` and ``:`` with ``_`` ``<foobar><foo-bar/></foobar>`` can be accessed with ``foobar.foo_bar``, ``<foo.bar.baz/>`` can be accessed with ``foo_bar_baz`` and ``<foo:bar><foo:baz/></foo:bar>`` can be accessed with ``foo_bar.foo_baz``
* Works with Python 3.7 - 3.10

Installation
------------

With pip:
```
pip install untangle
```

With conda:
```
conda install -c conda-forge untangle
```

Conda feedstock maintained by @htenkanen. Issues and questions about conda-forge packaging / installation can be done [here](https://github.com/conda-forge/untangle-feedstock/issues).

Usage
-----
(See and run <a href="https://github.com/stchris/untangle/blob/main/examples.py">examples.py</a> or this blog post: [Read XML painlessly](http://pythonadventures.wordpress.com/2011/10/30/read-xml-painlessly/) for more info)

```python
import untangle
obj = untangle.parse(resource)
```

``resource`` can be:

* a URL
* a filename
* an XML string

Running the above code and passing this XML:

```xml
<?xml version="1.0"?>
<root>
	<child name="child1"/>
</root>
```
allows it to be navigated from the ``untangle``d object like this:

```python
obj.root.child['name'] # u'child1'
```

Changelog
---------

see CHANGELOG.md


            

Raw data

            {
    "_id": null,
    "home_page": "",
    "name": "untangle",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.7,<4.0",
    "maintainer_email": "",
    "keywords": "",
    "author": "Christian Stefanescu",
    "author_email": "hello@stchris.net",
    "download_url": "https://files.pythonhosted.org/packages/a1/69/4fbd17bc16143343c022d845fd0fc2fc3bd89f85a5dce897cf00ad2c0e70/untangle-1.2.1.tar.gz",
    "platform": null,
    "description": "untangle\n========\n\n[![Build Status](https://github.com/stchris/untangle/actions/workflows/build.yml/badge.svg)](https://github.com/stchris/untangle/actions)\n[![PyPi version](https://img.shields.io/pypi/v/untangle.svg)](https://pypi.python.org/pypi/untangle)\n<a href=\"https://github.com/psf/black\"><img alt=\"Code style: black\" src=\"https://img.shields.io/badge/code%20style-black-000000.svg\"></a>\n\n[Documentation](http://readthedocs.org/docs/untangle/en/latest/)\n\n* Converts XML to a Python object.\n* Siblings with similar names are grouped into a list.\n* Children can be accessed with ``parent.child``, attributes with ``element['attribute']``.\n* You can call the ``parse()`` method with a filename, an URL or an XML string.\n* Substitutes ``-``, ``.`` and ``:`` with ``_`` ``<foobar><foo-bar/></foobar>`` can be accessed with ``foobar.foo_bar``, ``<foo.bar.baz/>`` can be accessed with ``foo_bar_baz`` and ``<foo:bar><foo:baz/></foo:bar>`` can be accessed with ``foo_bar.foo_baz``\n* Works with Python 3.7 - 3.10\n\nInstallation\n------------\n\nWith pip:\n```\npip install untangle\n```\n\nWith conda:\n```\nconda install -c conda-forge untangle\n```\n\nConda feedstock maintained by @htenkanen. Issues and questions about conda-forge packaging / installation can be done [here](https://github.com/conda-forge/untangle-feedstock/issues).\n\nUsage\n-----\n(See and run <a href=\"https://github.com/stchris/untangle/blob/main/examples.py\">examples.py</a> or this blog post: [Read XML painlessly](http://pythonadventures.wordpress.com/2011/10/30/read-xml-painlessly/) for more info)\n\n```python\nimport untangle\nobj = untangle.parse(resource)\n```\n\n``resource`` can be:\n\n* a URL\n* a filename\n* an XML string\n\nRunning the above code and passing this XML:\n\n```xml\n<?xml version=\"1.0\"?>\n<root>\n\t<child name=\"child1\"/>\n</root>\n```\nallows it to be navigated from the ``untangle``d object like this:\n\n```python\nobj.root.child['name'] # u'child1'\n```\n\nChangelog\n---------\n\nsee CHANGELOG.md\n\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Converts XML to Python objects",
    "version": "1.2.1",
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "md5": "b67fc1c895e85e26933f71b98c6ba6fd",
                "sha256": "1e783bb75996daf46ff7239ba049ee0eb54c056e235ac34809d74ea9e9898dd1"
            },
            "downloads": -1,
            "filename": "untangle-1.2.1-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "b67fc1c895e85e26933f71b98c6ba6fd",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.7,<4.0",
            "size": 4816,
            "upload_time": "2022-07-02T14:09:28",
            "upload_time_iso_8601": "2022-07-02T14:09:28.861485Z",
            "url": "https://files.pythonhosted.org/packages/c7/4a/7f7857e04d5499af7c20b82b6bae13cb4ca7543aabcef06b4069a09462d9/untangle-1.2.1-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "md5": "60b402a34d2d854ee8f7e3b39f7875b4",
                "sha256": "ae76522472722b31b303d5100c3c6f8b7dd4952b7b6c9d31e6d7b4a56f1a6d30"
            },
            "downloads": -1,
            "filename": "untangle-1.2.1.tar.gz",
            "has_sig": false,
            "md5_digest": "60b402a34d2d854ee8f7e3b39f7875b4",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.7,<4.0",
            "size": 4809,
            "upload_time": "2022-07-02T14:09:30",
            "upload_time_iso_8601": "2022-07-02T14:09:30.670493Z",
            "url": "https://files.pythonhosted.org/packages/a1/69/4fbd17bc16143343c022d845fd0fc2fc3bd89f85a5dce897cf00ad2c0e70/untangle-1.2.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2022-07-02 14:09:30",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "lcname": "untangle"
}
        
Elapsed time: 0.03992s