%PDF- %PDF-
Direktori : /proc/self/root/usr/lib/python2.7/site-packages/requestbuilder/ |
Current File : //proc/self/root/usr/lib/python2.7/site-packages/requestbuilder/xmlparse.pyc |
� >�,Xc @ s� y d d l m Z Wn! e k r7 d d l m Z n Xy d d l m Z Wn! e k ro d d l m Z n Xd d � Z d d � Z d � Z d S( i����( t cElementTree( t ElementTree( t ParseError( t ExpatErrorc C s� | d k r d } n d i f g } y�x|t j | d d �D]e\ } } t | j � } | d d k r~ | j | i f � q= | | k r$| d d j | g � | d d i k r | j d k r� | d d | j | j � q!| d d | j i � q�| d d | j | d d � nj | d d i k rt| j d k r_| j | d d | <q�i | d d | <n | d d | d d | <| j � | j � q= WWn# t t f k r�t d � � n X| d d S( 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> t eventst startt endi t si����i i����s XML parse errorN( ( s starts end( t NoneR t iterparset _strip_nst tagt appendt setdefaultt textt popt clearR t SyntaxErrort ValueError( t xml_streamt list_item_tagst stackt eventt elemR ( ( s; /usr/lib/python2.7/site-packages/requestbuilder/xmlparse.pyt parse_aws_xml s4 $ c C s� | d k r d } n d i f g } y�x�t j | d d �D]�\ } } t | j � } | d d k r� | | k r� | j | g f � q�| j | i f � q= | | d d k s� t � t | d d t � rG| d d i k r'| j d k r| d d j | j � qD| d d j i � q�| d d j | d d � nj | d d i k r�| j d k r�| j | d d | <q�i | d d | <n | d d | d d | <| j � | j � q= WWn# t t f k r�t d � � n X| d d S( 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> R R R i R i����i����i s XML parse errorN( ( s starts end( R R R R R R t AssertionErrort isinstancet listR R R R R R ( R t list_tagsR R R R ( ( s; /usr/lib/python2.7/site-packages/requestbuilder/xmlparse.pyt parse_listdelimited_aws_xmlh s8 c C s- | d d k r% | | j d � d S| Sd S( Ni t {t }i ( t find( t elem_tag( ( s; /usr/lib/python2.7/site-packages/requestbuilder/xmlparse.pyR � s N( t xml.etreeR R t ImportErrort xml.etree.ElementTreeR t xml.parsers.expatR R R R R ( ( ( s; /usr/lib/python2.7/site-packages/requestbuilder/xmlparse.pyt <module> s JN