| |
- average(elements, attrname)
- compound_object(element_name, attrnames, warn=False)
- return a class which delegates bracket access to an internal dict.
Missing attributes are delegated to the child dict for convenience.
@note: Care must be taken when child nodes and attributes have the same names
- create_document(root_element_name, attrs=None, schema=None)
- iskeyword = __contains__(...)
- x.__contains__(y) <==> y in x.
- parse(xmlfile, element_names, element_attrs={}, attr_conversions={}, heterogeneous=False, warn=False)
- Parses the given element_names from xmlfile and yield compound objects for
their xml subtrees (no extra objects are returned if element_names appear in
the subtree) The compound objects provide all element attributes of
the root of the subtree as attributes unless attr_names are supplied. In this
case attr_names maps element names to a list of attributes which are
supplied. If attr_conversions is not empty it must map attribute names to
callables which will be called upon the attribute value before storing under
the attribute name.
The compound objects gives dictionary style access to list of compound
objects o for any children with the given element name
o['child_element_name'] = [osub0, osub1, ...]
As a shorthand, attribute style access to the list of child elements is
provided unless an attribute with the same name as the child elements
exists (i.e. o.child_element_name = [osub0, osub1, ...])
@Note: All elements with the same name must have the same type regardless of
the subtree in which they occur (heterogeneous cases may be handled by
setting heterogeneous=True (with reduced parsing speed)
@Note: Attribute names may be modified to avoid name clashes
with python keywords. (set warn=True to receive renaming warnings)
@Note: The element_names may be either a single string or a list of strings.
@Example: parse('plain.edg.xml', ['edge'])
- parse_fast(xmlfile, element_name, attrnames, warn=False, optional=False, encoding='utf8')
- Parses the given attrnames from all elements with element_name
@Note: The element must be on its own line and the attributes must appear in
the given order.
@Example: parse_fast('plain.edg.xml', 'edge', ['id', 'speed'])
- parse_fast_nested(xmlfile, element_name, attrnames, element_name2, attrnames2, warn=False, optional=False, encoding='utf8')
- Parses the given attrnames from all elements with element_name
And attrnames2 from element_name2 where element_name2 is a child element of element_name
@Note: The element must be on its own line and the attributes must appear in
the given order.
@Example: parse_fast_nested('fcd.xml', 'timestep', ['time'], 'vehicle', ['id', 'speed', 'lane']):
- quoteattr(val)
- reduce(...)
- reduce(function, sequence[, initial]) -> value
Apply a function of two arguments cumulatively to the items of a sequence,
from left to right, so as to reduce the sequence to a single value.
For example, reduce(lambda x, y: x+y, [1, 2, 3, 4, 5]) calculates
((((1+2)+3)+4)+5). If initial is present, it is placed before the items
of the sequence in the calculation, and serves as a default when the
sequence is empty.
- sum(elements, attrname)
- writeHeader(outf, script=None, root=None, schemaPath=None)
|