Package jazzparser :: Package utils :: Module domxml
[hide private]
[frames] | no frames]

Module domxml

source code

Handy XML processing utility functions.

Various XML processing utilities, using minidom, that are used in various places throughout the code.


Author: Mark Granroth-Wilding <mark.granroth-wilding@ed.ac.uk>

Classes [hide private]
  XmlReadError
Functions [hide private]
 
attrs_to_dict(attrs)
Converts a minidom NamedNodeMap that represents the attributes of a node into a dictionary.
source code
 
remove_unwanted_elements(node_list)
Minidom node lists include entries for carriage returns, for some reason.
source code
 
get_single_element_by_tag_name(node, tag_name, optional=False)
Returns an element that is a child of the given node and that has the tag name given.
source code
 
require_attrs(node, attrs)
Checks for the existence of the named attributes on the given node and raises an exception if they're not there.
source code
 
require_attr(node, attr)
Checks for the existence of the named attribute on the given node and raises an exception if it's not there.
source code
Variables [hide private]
  __package__ = 'jazzparser.utils'
Function Details [hide private]

attrs_to_dict(attrs)

source code 

Converts a minidom NamedNodeMap that represents the attributes of a node into a dictionary. The keys are attribute names. The values are the attributes' string values.

remove_unwanted_elements(node_list)

source code 

Minidom node lists include entries for carriage returns, for some reason. This function removes these from a list.

get_single_element_by_tag_name(node, tag_name, optional=False)

source code 

Returns an element that is a child of the given node and that has the tag name given. This method is used where it is assumed that one such tag exists. If there is none, an exception is raised. If there is more than one, the first is returned.

Returns:
the child of node with tag name tag_name

require_attrs(node, attrs)

source code 

Checks for the existence of the named attributes on the given node and raises an exception if they're not there.

Returns a tuple of their values if they're all found.

require_attr(node, attr)

source code 

Checks for the existence of the named attribute on the given node and raises an exception if it's not there.

Returns its value if it is there.