| |
- average(elements, attrname)
- buildHeader(script=None, root=None, schemaPath=None, rootAttrs='', options=None, includeXMLDeclaration=False)
- Builds an XML header with schema information and a comment on how the file has been generated
(script name, arguments and datetime).
If script name is not given, it is determined from the command line call.
If root is not given, no root element is printed (and thus no schema).
If schemaPath is not given, it is derived from the root element.
If rootAttrs is given as a string, it can be used to add further attributes to the root element.
If rootAttrs is set to None, the schema related attributes are not printed.
- compound_object(element_name, attrnames, warn=False, sort=True)
- 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)
- insertOptionsHeader(filename, options)
- Inserts a comment header with the options used to call the script into an existing file.
- iskeyword = __contains__(...) method of builtins.frozenset instance
- x.__contains__(y) <==> y in x.
- parse(xmlfile, element_names=None, element_attrs=None, attr_conversions=None, heterogeneous=True, warn=False, ignoreXmlns=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. If you set "optional=True", missing attributes will be set to None.
Make sure that you list all (potential) attributes (even the ones you are not interested in)
in this case. You can only leave out attributes at the end.
@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
If you set "optional=True", missing attributes will be set to None.
Make sure that you list all (potential) attributes (even the ones you are not interested in)
in this case. You can only leave out attributes at the end.
@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']):
- parse_fast_structured(xmlfile, element_name, attrnames, nested, warn=False, optional=False, encoding='utf8')
- Parses the given attrnames from all elements with element_name and nested elements of level 1.
Unlike parse_fast_nested this function can handle multiple different child elements and
returns objects where the child elements can be accessed by name (e.g. timestep.vehicle[0])
as with the parse method. The returned object is not modifiable though.
If you set "optional=True", missing attributes will be set to None.
Make sure that you list all (potential) attributes (even the ones you are not interested in)
in this case. You can only leave out attributes at the end.
@Note: Every element must be on its own line and the attributes must appear in the given order.
@Example: parse_fast_structured('fcd.xml', 'timestep', ['time'],
{'vehicle': ['id', 'speed', 'lane'], 'person': ['id', 'speed', 'edge']}):
- parselines(xmlline, element_name, element_attrs=None, attr_conversions=None, heterogeneous=True, warn=False, addRoot='dummy')
- quoteattr(val, ensureUnicode=False)
- reduce(...)
- reduce(function, iterable[, initial]) -> value
Apply a function of two arguments cumulatively to the items of a sequence
or iterable, from left to right, so as to reduce the iterable 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 iterable in the calculation, and serves as a default when the
iterable is empty.
- sum(elements, attrname)
- supports_comments()
- writeHeader(outf, script=None, root=None, schemaPath=None, rootAttrs='', options=None, includeXMLDeclaration=True)
- Writes an XML header with schema information and a comment on how the file has been generated
(script name, arguments and datetime). Please use this as first call whenever you open a
SUMO related XML file for writing from your script.
If script name is not given, it is determined from the command line call.
If root is not given, no root element is printed (and thus no schema).
If schemaPath is not given, it is derived from the root element.
If rootAttrs is given as a string, it can be used to add further attributes to the root element.
If rootAttrs is set to None, the schema related attributes are not printed.
|