Skip to main content

objectifiedetree

build-status-image pypi-version wheel

Overview

Wouldn’t it be nice to use dot notation for ElementTrees? This package allows for:

tree = ET.fromstring('<root><a><b c="asdf" /></a></root>')
a = tree.a
b = a.b
b.attrib['c'] == "asdf" # True

tree.a will be a `Element <https://docs.python.org/3.4/library/xml.etree.elementtree.html#xml.etree.ElementTree.Element>`__ with the extra `__getattr__ <https://github.com/arve0/objectifiedetree/blob/master/objectifiedetree/__init__.py#L11-12>`__ method. This means that you can use the element as you would do normally, but names in your XML that crases with python’s methods or attributes must be accessed through tree.find(xpath).

This package uses the python implementation of etree, which makes it slower than etree found in CPython. An alternative would be to monkey-patch the built-in with forbiddenfruit, but I haven’t looked into this.

objectifiedetree has copied the python implementation of etree from CPython 3.4 Lib/xml/etree and will probably only work with Python 3.4.

Installation

Install using pip…

pip install objectifiedetree

Example

from objectifiedetree import *

tree = ET.parse('/path/to/file.xml')
# dot notation :-)
el = tree.xpath.to.your.element

# use normal etree attributes
print(el.attrib)

# access name crashes
attrib_el = el.find('./attrib')

Development

Install dependencies and link development version of objectifiedetree to pip:

git clone https://github.com/arve0/objectifiedetree
cd objectifiedetree
pip install -r requirements.txt # install dependencies and objectifiedetree-package

Testing

tox

Build documentation locally

To build the documentation:

pip install -r docs/requirements.txt
make docs

Metadata

Release files for objectifiedetree 0.0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for objectifiedetree 0.0.1
File Size Uploaded Provenance
objectifiedetree-0.0.1.tar.gz 27.6 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for objectifiedetree 0.0.1
File Interpreter ABI Platform
objectifiedetree-0.0.1-py2.py3-none-any.whl Python 2, Python 3 none any Details

Total release size: 53.0 kB

Release files / objectifiedetree-0.0.1.tar.gz

Download URL objectifiedetree-0.0.1.tar.gz
Size 27.6 kB
Tags Source
SHA-256 checksum
How to use checksums
4a79af55ca09e0239be4d6c0f85b58e6f96ccf9ca3361799d4f7b2932e1cb672
BLAKE2b-256 checksum
How to use checksums
5a20d3223783b8e8c4a05bc07615de6e04ab203c6643d7e165c40800c6ae1d8d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release files / objectifiedetree-0.0.1-py2.py3-none-any.whl

Download URL objectifiedetree-0.0.1-py2.py3-none-any.whl
Size 25.4 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
f8cfdff46c9e78dc7d6c806981733e32c57d29033b828a05021d580788bf37ce
BLAKE2b-256 checksum
How to use checksums
1b587abafae2a0bbe04ffcbccb13d406f25569788cb32ee4d98d526ece6f9ad0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Security for objectifiedetree 0.0.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

Release history Release notifications | RSS feed

This release

0.0.1 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page