Registry / serialization / et-xmlfile

et-xmlfile

JSON →
library2.0.0pypypi✓ verified 10d ago

A low-memory library for creating large XML files, implementing lxml's xmlfile module for the standard library. Current version: 2.0.0, released on October 25, 2024. Maintained by CharlieX. Requires Python 3.8 or higher. Release cadence: approximately every 3 years.

pip install et-xmlfile
INSTALL
IMPORT
SIG · ET-XMLFILE
E
et-xmlfile
serializationpythonv2.0.0
Install
1.6s avg
Import
49ms
Disk
16MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v2.0.0 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.95 runs
installs and imports cleanly · install 0.0s · import 0.052s · 17.9MB
glibc
py 3.103.95 runs
installs and imports cleanly · install 1.6s · import 0.046s · 18MB
16MB installed
● package 16MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

xmlfile
from et_xmlfile import xmlfile
Ensure correct import path to access the xmlfile context manager.

A minimal example demonstrating how to use et-xmlfile to create an XML file in memory.

from io import BytesIO from xml.etree.ElementTree import Element from et_xmlfile import xmlfile out = BytesIO() with xmlfile(out) as xf: el = Element('root') xf.write(el) assert out.getvalue() == b'<root />'
Debug
Known issues
gotchaUsing the .element() method on the xmlfile context manager may negatively affect performance. It's recommended to create Elements and write them directly.
fix
Avoid using the .element() method; instead, create Elements and write them directly.
affects: 2.0.0
gotchaRunning pip as the 'root' user can result in broken permissions and conflicting behaviour with the system package manager. It is recommended to use a virtual environment instead.
fix
Avoid running pip as the 'root' user; instead, use a virtual environment for package installation or run pip as a non-root user.
affects: pip:all
gotchaRunning pip as the 'root' user can result in broken permissions and conflicting behaviour with the system package manager, potentially rendering your system unusable.
fix
It is recommended to use a virtual environment instead (https://pip.pypa.io/warnings/venv). Alternatively, use the --root-user-action option if you understand the implications and wish to suppress this warning.
affects: all
Errors
Common errors & fixes
ModuleNotFoundError: No module named 'et_xmlfile'
The `et-xmlfile` library is not installed in the Python environment, or the Python interpreter cannot find it due to an incorrect environment setup or path issue.
fix
Install the library using pip: `pip install et-xmlfile`
AttributeError: 'xmlfile' object has no attribute 'tag'
This error occurs when attempting to access an attribute like 'tag' (which belongs to an `Element` object from `xml.etree.ElementTree`) directly on the `et_xmlfile.xmlfile` object, mistakenly treating the file writer as an XML element.
fix
Ensure you are calling methods like `write()` or `element()` on the `xmlfile` object for streaming, and manipulate `xml.etree.ElementTree.Element` objects for their attributes (like `tag` or `text`) before writing them.
TypeError: write() argument must be str, not bytes
The `write()` method of the `xmlfile` object, or an underlying file object, received an argument of an incorrect type (e.g., bytes instead of a string or an `Element` object), or vice-versa depending on the context manager's stream type.
fix
Ensure that the argument passed to `write()` is an `xml.etree.ElementTree.Element` instance as shown in examples, or a string if writing raw XML data, and matches the expected type of the underlying output stream (e.g., `BytesIO` expects bytes, regular file objects might expect strings).
Upgrade
Version history
2.0.0latest on PyPI · released Oct 25, 2024
Audit
Dependencies

No dependency data recorded yet.

Agent activity
44 hits · last 30 days
node
42
Resources
et-xmlfile — pip install et-xmlfile · libregistry