Current File : //usr/lib/python2.7/site-packages/requestbuilder/xmlparse.pyc
�
>�,Xc@s�yddlmZWn!ek
r7ddlmZnXyddlmZWn!ek
roddlmZnXdd�Z	dd�Z
d�ZdS(	i����(tcElementTree(tElementTree(t
ParseError(t
ExpatErrorcCs�|d
krd}nd
ifg}y�x|tj|dd�D]e\}}t|j�}|ddkr~|j|if�q=||kr$|ddj|g�|ddikr|jd
k	r�|dd|j|j�q!|dd|ji�q�|dd|j|dd�nj|ddikrt|jd
k	r_|j|dd|<q�i|dd|<n|dd|dd|<|j�|j	�q=WWn#t
tfk
r�td	��nX|ddS(
sZ
    Parse a stream of XML and return a nested dict.  The dict represents each
    XML element with a key that matches the element's name and a value of
    another dict if the element contains at least one child element, or the
    element's text if it does not.

    For each element whose name appears in the list_item_tags list, its dict
    value will instead be a list that aggregates the values of every element
    with that name.

    This function is designed to parse XML from AWS services that include list
    items alongside other elements, such as S3.

    Examples:
        <a><b>spam</b><c>eggs</c></a> -> {'a': {'b': 'spam', 'c': 'eggs'}}

        <a>
          <b>
            <c>spam</c>
          </b>          + ['b'] -> {'a': {'b': [{'c': 'spam'}, {'c': 'eggs'}]}}
          <b>
            <c>eggs</c>
          </b>
        </a>
    teventststarttenditsi����ii����sXML parse errorN((sstartsend(
tNoneRt	iterparset	_strip_nsttagtappendt
setdefaultttexttpoptclearRtSyntaxErrort
ValueError(t
xml_streamtlist_item_tagststackteventtelemR((s;/usr/lib/python2.7/site-packages/requestbuilder/xmlparse.pyt
parse_aws_xmls4	$
cCs�|d
krd}nd
ifg}y�x�tj|dd�D]�\}}t|j�}|ddkr�||kr�|j|gf�q�|j|if�q=||ddks�t�t|ddt�rG|ddikr'|j	d
k	r|ddj|j	�qD|ddji�q�|ddj|dd�nj|ddikr�|j	d
k	r�|j	|dd|<q�i|dd|<n|dd|dd|<|j
�|j�q=WWn#tt
fk
r�td	��nX|ddS(
s]
    Parse a stream of XML and return a nested dict.  The dict represents each
    XML element with a key that matches the element's name and a value of
    another dict if the element contains at least one child element, or the
    element's text if it does not.

    For each element whose name appears in the list_tags list, its dict
    value will instead be a list that aggregates the values of each of that
    element's children.

    This function is designed to parse XML from AWS services that explicitly
    start and end lists with their own elements, such as EC2.

    Examples:
        <a><b>spam</b><c>eggs</c></a> -> {'a': {'b': 'spam', 'c': 'eggs'}}

        <a>
          <b>
            <c>spam</c>
          </b>          + ['a'] -> {'a': [{'c': 'spam'}, {'c': 'eggs'}]}
          <b>
            <c>eggs</c>
          </b>
        </a>
    RRRiRi����i����isXML parse errorN((sstartsend(RRR	R
RRtAssertionErrort
isinstancetlistRRRRRR(Rt	list_tagsRRRR((s;/usr/lib/python2.7/site-packages/requestbuilder/xmlparse.pytparse_listdelimited_aws_xmlhs8	 
cCs-|ddkr%||jd�dS|SdS(Nit{t}i(tfind(telem_tag((s;/usr/lib/python2.7/site-packages/requestbuilder/xmlparse.pyR
�sN(t	xml.etreeRRtImportErrortxml.etree.ElementTreeRtxml.parsers.expatRRRRR
(((s;/usr/lib/python2.7/site-packages/requestbuilder/xmlparse.pyt<module>s

JN