pyhpecw7.utils.xml.lib module

This module provides several utility functions for dealing with XML text and etree.Element XML objects.

pyhpecw7.utils.xml.lib.action_element_maker()[source]
pyhpecw7.utils.xml.lib.config_element_maker()[source]
pyhpecw7.utils.xml.lib.config_params(pmap, key_map, value_map={}, E=<lxml.builder.ElementMaker object>, fill_in=True)[source]
pyhpecw7.utils.xml.lib.data_elem_to_dict(elem, key_map, value_map={})[source]
pyhpecw7.utils.xml.lib.data_element_maker()[source]
pyhpecw7.utils.xml.lib.elem_to_dict(elem, ns, key_map, value_map={})[source]

Convert an XML etree.Element to a desired dictionary as specified by the key map and value map. :param elem: An ancestor element

of the tags specified in the key map.
Parameters:
  • ns (string) – The namespace to use when searching for XML tags.
  • key_map (dict) – A mapping from desired dictionary keys to XML tag names.
  • value_map (dict) – A mapping from XML tag names to dictionaries of mappings from XML text values to desired dictionary values.
Returns:

The desired dictionary.

pyhpecw7.utils.xml.lib.find_in_action(query, ele)[source]
pyhpecw7.utils.xml.lib.find_in_config(query, ele)[source]
pyhpecw7.utils.xml.lib.find_in_data(query, ele)[source]
pyhpecw7.utils.xml.lib.findall_in_action(query, ele)[source]
pyhpecw7.utils.xml.lib.findall_in_data(query, ele)[source]
pyhpecw7.utils.xml.lib.get_text(xml, tag)[source]

Return the text from a given tag and XML element.

pyhpecw7.utils.xml.lib.nc_element_maker()[source]
pyhpecw7.utils.xml.lib.operation_kwarg(operation=None)[source]
pyhpecw7.utils.xml.lib.remove_namespaces(xml)[source]

Remove the namespaces from an etree.Element object and return the modified object.

pyhpecw7.utils.xml.lib.reverse_value_map(key_map, value_map)[source]

Utility function for creating a “reverse” value map from a given key map and value map.