pds4_tools.reader.read_label module

Functions

read_label(filename[, ...])

Reads a PDS4 XML Label into an ElementTree Element object.

Details

read_label(filename, strip_extra_whitespace=True, enforce_default_prefixes=False, include_namespace_map=False, decode_py2=False)[source]

Reads a PDS4 XML Label into an ElementTree Element object.

Parameters
filenamestr or unicode

The filename, including the path, of the XML label.

strip_extra_whitespacebool, optional

If True, then for element text and attribute values, it collapses contiguous whitespaces (including space, tab and newlines) into a single space, and removes leading and trailing whitespace altogether. However, this only done if the value has a single line with non-whitespace characters. Defaults to False.

enforce_default_prefixesbool, optional

If True, strips the default namespace, and ensures that default PDS4 prefixes are used for known namespaces (PDS4_NAMESPACES). Defaults to False.

include_namespace_mapbool, optional

If True, changes method return to a tuple, where the first value is the label ElementTree object as usual and the second is a dict with keys being the namespace URIs and values being the namespace prefixes in this label. Defaults to False.

decode_py2bool, optional

If True, decodes UTF-8 byte strings (str) into unicode strings in Python 2. Option is ignored in Python 3. Defaults to False.

Returns
ElementTree Element

Root element for the read-in PDS4 label