anyconfig/backend/xml.py
def container_to_etree(obj, parent=None, to_str=None, **options):
    """
    Convert a dict-like object to XML ElementTree.

    :param obj: Container instance to convert to
    :param parent: XML ElementTree parent node object or None
    :param to_str: Callable to convert value to string or None
    :param options: Keyword options,

        - tags: Dict of tags for special nodes to keep XML info, attributes,
          text and children nodes, e.g. {"attrs": "@attrs", "text": "#text"}
    """
    if to_str is None:
        to_str = _to_str_fn(**options)

    if not anyconfig.utils.is_dict_like(obj):
        if parent is not None and obj:
            parent.text = to_str(obj)  # Parent is a leaf text node.
        return parent  # All attributes and text should be set already.

    options = _complement_tag_options(options)
    (attrs, text, children) = operator.itemgetter(*_ATC)(options)

    for key, val in anyconfig.compat.iteritems(obj):
        if key == attrs:
            _elem_set_attrs(val, parent, to_str)
        elif key == text:
            parent.text = to_str(val)
        elif key == children:
            for celem in _elem_from_descendants(val, **options):
                parent.append(celem)
        else:
            parent = _get_or_update_parent(key, val, to_str, parent=parent,
                                           **options)

    return ET.ElementTree(parent)

    Convert a dict-like object to XML ElementTree.

    :param obj: Container instance to convert to
    :param parent: XML ElementTree parent node object or None
    :param to_str: Callable to convert value to string or None
    :param options: Keyword options,

        - tags: Dict of tags for special nodes to keep XML info, attributes,
          text and children nodes, e.g. {"attrs": "@attrs", "text": "#text"}
    
Convert a dict-like object to XML ElementTree.
Convert a dict - like object to XML ElementTree .
def container_to_etree(obj, parent=None, to_str=None, **options):
    if to_str is None:
        to_str = _to_str_fn(**options)
    if not anyconfig.utils.is_dict_like(obj):
        if parent is not None and obj:
            parent.text = to_str(obj)  
        return parent  
    options = _complement_tag_options(options)
    (attrs, text, children) = operator.itemgetter(*_ATC)(options)
    for key, val in anyconfig.compat.iteritems(obj):
        if key == attrs:
            _elem_set_attrs(val, parent, to_str)
        elif key == text:
            parent.text = to_str(val)
        elif key == children:
            for celem in _elem_from_descendants(val, **options):
                parent.append(celem)
        else:
            parent = _get_or_update_parent(key, val, to_str, parent=parent,
                                           **options)
    return ET.ElementTree(parent)
def container_to_etree ( obj , parent = None , to_str = None , ** options ) : if to_str is None : to_str = _to_str_fn ( ** options ) if not anyconfig . utils . is_dict_like ( obj ) : if parent is not None and obj : parent . text = to_str ( obj ) return parent options = _complement_tag_options ( options ) ( attrs , text , children ) = operator . itemgetter ( * _ATC ) ( options ) for key , val in anyconfig . compat . iteritems ( obj ) : if key == attrs : _elem_set_attrs ( val , parent , to_str ) elif key == text : parent . text = to_str ( val ) elif key == children : for celem in _elem_from_descendants ( val , ** options ) : parent . append ( celem ) else : parent = _get_or_update_parent ( key , val , to_str , parent = parent , ** options ) return ET . ElementTree ( parent )
Convert a dict-like object to XML ElementTree.
Convert a dict - like object to XML ElementTree .
"""
    Convert a dict-like object to XML ElementTree.

    :param obj: Container instance to convert to
    :param parent: XML ElementTree parent node object or None
    :param to_str: Callable to convert value to string or None
    :param options: Keyword options,

        - tags: Dict of tags for special nodes to keep XML info, attributes,
          text and children nodes, e.g. {"attrs": "@attrs", "text": "#text"}
    """ # Parent is a leaf text node. # All attributes and text should be set already.
obj
Container instance to convert to
Container instance to convert to
parent
XML ElementTree parent node object or None
XML ElementTree parent node object or None
to_str
Callable to convert value to string or None
Callable to convert value to string or None
options
Keyword options,
tags: Dict of tags for special nodes to keep XML info, attributes,
text and children nodes, e.g.
Keyword options tags : Dict of tags for special nodes to keep XML info attributes text and children nodes e . g .