HEX
Server: Apache/2.4.52 (Ubuntu)
System: Linux spn-python 5.15.0-89-generic #99-Ubuntu SMP Mon Oct 30 20:42:41 UTC 2023 x86_64
User: arjun (1000)
PHP: 8.1.2-1ubuntu2.20
Disabled: NONE
Upload Files
File: //home/arjun/projects/env/lib/python3.10/site-packages/__pycache__/xmltodict.cpython-310.pyc
o

we�J�@sVdZzddlmZWneyddlmZYnwddlmZddlm	Z	zddl
mZWn!eyOzddlmZWneyLddlmZYnwYnwe
ZddlZeeee��dd���d	krkdd
lmZddlmZzeZWney�eZYnwzeZWney�eZYnwdZd
ZdZ Gdd�de!�Z"Gdd�de#�Z$deddddfdd�Z%d(dd�Z&											d)dd�Z'		d*d!d"�Z(e)d#k�r)ddl*Z*ddl+Z+z
e*j,j-Z,e*j.j-Z.Wne/y�e*j,Z,e*j.Z.Ynwe*j0d$d�\Z1ee1�Z1d%d&�Z2ze%e,e1e2e
d'�Z3e1dk�re2ge3�WdSWdSe4�y(YdSwdS)+z:Makes working with XML feel like you are working with JSON�)�pyexpat)�expat)�XMLGenerator)�AttributesImpl)�StringION�)��)�OrderedDict)�isgeneratorzMartin Blechz0.13.0�MITc@seZdZdS)�ParsingInterruptedN)�__name__�
__module__�__qualname__�rr�B/home/arjun/projects/env/lib/python3.10/site-packages/xmltodict.pyr
'sr
c@s~eZdZddd�dddddd	edd
d	d	dfdd
�Zdd�Zdd�Zdd�Zdd�Zdd�Z	dd�Z
dd�Zdd�Zdd�Z
d	S) �_DictSAXHandlerrcG�dS�NTr)�argsrrr�<lambda>.�z_DictSAXHandler.<lambda>T�@�#textF�N�:z#commentcCsxg|_g|_g|_d|_||_||_||_||_||_||_	||_
||_|	|_|
|_
||_||_|	�|_|
|_||_dS�N)�path�stack�data�item�
item_depth�xml_attribs�
item_callback�attr_prefix�	cdata_key�force_cdata�cdata_separator�
postprocessor�dict_constructor�strip_whitespace�namespace_separator�
namespaces�namespace_declarations�
force_list�comment_key)�selfr"r$r#r%r&r'r(r)r*r+r,r-r/r0rrr�__init__,s&
z_DictSAXHandler.__init__cCs�|jdur|S|�|j�}|dkr|S|d|�||dd�}}z|j|}Wnty4|}Ynw|s9|S|j�||f�S)N����)r-�rfindr,�KeyError�join)r1�	full_name�i�	namespace�name�short_namespacerrr�_build_nameOs
�z_DictSAXHandler._build_namecCs2t|t�r|S|�t|ddd�|ddd���S)Nrrr4)�
isinstance�dictr*�zip)r1�attrsrrr�_attrs_to_dict_s
$z_DictSAXHandler._attrs_to_dictcCs||j|pd<dS)Nr)r.)r1�prefix�urirrr�startNamespaceDecldsz"_DictSAXHandler.startNamespaceDeclcCs�|�|�}|�|�}|r|jr|j|d<|��|_|j�||p df�t|j�|jkrt|j�|j	|j
f�|jrhg}|��D]#\}}|j
|�|�}|jrV|�|j||�}n||f}|ra|�|�q>|�|�}nd}|pmd|_	g|_
dSdS)N�xmlns)r=rBr.r*r�append�lenr"rr!r r#�itemsr%r))r1r8rAr;�attr_entries�key�value�entryrrr�startElementgs.





�

�z_DictSAXHandler.startElementcCs|�|�}t|j�|jkr,|j}|dur |jsdn|j�|j�}|�|j|�}|s,t	��|j
r�|js4dn|j�|j�}|j}|j
��\|_|_|jrR|rR|�
�pQd}|r_|jr_|dur_|��}|durw|rm|�||j|�|�|j||�|_n|�|j||�|_nd|_g|_|j��dSr)r=rHrr"r!r r(r7r$r
r�popr+�stripr'r*�	push_datar&)r1r8r;r!�should_continuer rrr�
endElement�s8

�
�
z_DictSAXHandler.endElementcCs"|js	|g|_dS|j�|�dSr)r rG�r1r rrr�
characters�sz_DictSAXHandler.characterscCs&|jr|��}|�|j|j|�|_dSr)r+rPrQr!r0rTrrr�comments�sz_DictSAXHandler.commentscCs�|jdur|�|j||�}|dur|S|\}}|dur|��}z||}t|t�r1|�|�W|S||g||<W|StyU|�||�rN|g||<Y|S|||<Y|Swr)r)rr*r>�listrGr6�_should_force_list)r1r!rKr �resultrLrrrrQ�s*

��
��z_DictSAXHandler.push_datacCsT|jsdSt|jt�r|jSz||jvWSty)|�|jdd�||�YSw)NFr3)r/r>�bool�	TypeErrorr)r1rKrLrrrrX�s�z"_DictSAXHandler._should_force_list)rrr�_dictr2r=rBrErNrSrUrVrQrXrrrrr+s2
�#rFrTcKs0tdd|i|��}t|t�r|sd}|�|�}|sd}|�||�}	zd|	_Wn	ty/Ynw|j|	_|j	|	_
|j|	_|j
|	_|rF|j|	_d|	_|rjzd}
|	j�|
d�Wntyidd�|	_dd�|	_Ynwt|d	�rw|	�|�|jSt|�r�|D]}|	�|d
�q}|	�dd�|jS|	�|d�|jS)
aParse the given XML input and convert it into a dictionary.

    `xml_input` can either be a `string`, a file-like object, or a generator of strings.

    If `xml_attribs` is `True`, element attributes are put in the dictionary
    among regular child elements, using `@` as a prefix to avoid collisions. If
    set to `False`, they are just ignored.

    Simple example::

        >>> import xmltodict
        >>> doc = xmltodict.parse("""
        ... <a prop="x">
        ...   <b>1</b>
        ...   <b>2</b>
        ... </a>
        ... """)
        >>> doc['a']['@prop']
        u'x'
        >>> doc['a']['b']
        [u'1', u'2']

    If `item_depth` is `0`, the function returns a dictionary for the root
    element (default behavior). Otherwise, it calls `item_callback` every time
    an item at the specified depth is found and returns `None` in the end
    (streaming mode).

    The callback function receives two parameters: the `path` from the document
    root to the item (name-attribs pairs), and the `item` (dict). If the
    callback's return value is false-ish, parsing will be stopped with the
    :class:`ParsingInterrupted` exception.

    Streaming example::

        >>> def handle(path, item):
        ...     print('path:%s item:%s' % (path, item))
        ...     return True
        ...
        >>> xmltodict.parse("""
        ... <a prop="x">
        ...   <b>1</b>
        ...   <b>2</b>
        ... </a>""", item_depth=2, item_callback=handle)
        path:[(u'a', {u'prop': u'x'}), (u'b', None)] item:1
        path:[(u'a', {u'prop': u'x'}), (u'b', None)] item:2

    The optional argument `postprocessor` is a function that takes `path`,
    `key` and `value` as positional arguments and returns a new `(key, value)`
    pair where both `key` and `value` may have changed. Usage example::

        >>> def postprocessor(path, key, value):
        ...     try:
        ...         return key + ':int', int(value)
        ...     except (ValueError, TypeError):
        ...         return key, value
        >>> xmltodict.parse('<a><b>1</b><b>2</b><b>x</b></a>',
        ...                 postprocessor=postprocessor)
        {'a': {'b:int': [1, 2], 'b': 'x'}}

    You can pass an alternate version of `expat` (such as `defusedexpat`) by
    using the `expat` parameter. E.g:

        >>> import defusedexpat
        >>> xmltodict.parse('<a>hello</a>', expat=defusedexpat.pyexpat)
        {'a': 'hello'}

    You can use the force_list argument to force lists to be created even
    when there is only a single child of a given level of hierarchy. The
    force_list argument is a tuple of keys. If the key for a given level
    of hierarchy is in the force_list argument, that level of hierarchy
    will have a list as a child (even if there is only one sub-element).
    The index_keys operation takes precedence over this. This is applied
    after any user-supplied postprocessor has already run.

        For example, given this input:
        <servers>
          <server>
            <name>host1</name>
            <os>Linux</os>
            <interfaces>
              <interface>
                <name>em0</name>
                <ip_address>10.0.0.1</ip_address>
              </interface>
            </interfaces>
          </server>
        </servers>

        If called with force_list=('interface',), it will produce
        this dictionary:
        {'servers':
          {'server':
            {'name': 'host1',
             'os': 'Linux'},
             'interfaces':
              {'interface':
                [ {'name': 'em0', 'ip_address': '10.0.0.1' } ] } } }

        `force_list` can also be a callable that receives `path`, `key` and
        `value`. This is helpful in cases where the logic that decides whether
        a list should be forced is more complex.


        If `process_comment` is `True` then comment will be added with comment_key
        (default=`'#comment'`) to then tag which contains comment

            For example, given this input:
            <a>
              <b>
                <!-- b comment -->
                <c>
                    <!-- c comment -->
                    1
                </c>
                <d>2</d>
              </b>
            </a>

            If called with process_comment=True, it will produce
            this dictionary:
            'a': {
                'b': {
                    '#comment': 'b comment',
                    'c': {

                        '#comment': 'c comment',
                        '#text': '1',
                    },
                    'd': '2',
                },
            }
    r,�utf-8NTz4http://apache.org/xml/features/disallow-doctype-declcSsdSrr��xrrrrprzparse.<locals>.<lambda>cWr)Nr4rr^rrrrrr�readF�r)rr>�_unicode�encode�ParserCreate�ordered_attributes�AttributeErrorrE�StartNamespaceDeclHandlerrN�StartElementHandlerrS�EndElementHandlerrU�CharacterDataHandlerrV�CommentHandler�buffer_text�_reader�
setFeature�DefaultHandler�ExternalEntityRefHandler�hasattr�	ParseFiler�Parser!)�	xml_input�encodingr�process_namespacesr,�disable_entities�process_comments�kwargs�handler�parser�feature�chunkrrr�parse�sX
�

�
�
�

��r~rcCsl|s|Sz
|�|d�\}}Wn
tyY|Sw|�|�|��}|r2d�|�|�r,|nd|||�n|}|S)Nr4z{}{}{}{}r)�rsplit�
ValueError�getrP�format�
startswith)r;r-�ns_sepr%�ns�ns_resrrr�_process_namespace~s"����r�r�
�	cCs�t|||
|�}|dur|||�}|durdS|\}}t|d�r)t|t�s)t|t�r,|g}t|�D�]\}}|rC|dkrC|dkrCtd��|durKt�}n.t|t�r\|rWt	d�}n"t	d�}nt|t�sy|
rut|d�rut|t�sut|
|ff�}nt	|�}t|t�r�t||ff�}d}t�}g}|�
�D]W\}}||kr�|}q�|�|�r�t|||
|�}|dkr�t|t�r�|�
�D]\}}d�|r�d�|�nd	�}t	|�||<q�q�t|t	�s�t	|�}|||t
|�d�<q�|�||f�q�|r�|�||	�|�|t|��|�r|�r|�|�|D]\}}t||||||d
||||	||
|
d�
�q|du�r)|�|�|�r6|�r6|�||	�|�|�|�rF|�rF|�|�q0dS)N�__iter__rzdocument with multiple roots�true�falsez@xmlnszxmlns{}z:{}rr4)r-r,�expand_iter)r�rqr>�_basestringr?�	enumerater�r\rZrbrIr�r�rHrG�ignorableWhitespacerNr�_emitrUrS)rKrL�content_handlerr%r&�depth�preprocessor�pretty�newl�indentr,r-�
full_documentr�rY�index�v�cdatarA�children�ik�iv�k�attr�	child_key�child_valuerrrr��s�

��





�


�



��r�r]c
Ks�|rt|�dkrtd��d}|durt�}d}|r t||d�}nt||�}|r+|��|��D]\}}	t||	|fd|i|��q/|rF|��|r_|��}	z|	�	|�}	W|	St
y^Y|	SwdS)axEmit an XML document for the given `input_dict` (reverse of `parse`).

    The resulting XML document is returned as a string, but if `output` (a
    file-like object) is specified, it is written there instead.

    Dictionary keys prefixed with `attr_prefix` (default=`'@'`) are interpreted
    as XML node attributes, whereas keys equal to `cdata_key`
    (default=`'#text'`) are treated as character data.

    The `pretty` parameter (default=`False`) enables pretty-printing. In this
    mode, lines are terminated with `'
'` and indented with `'	'`, but this
    can be customized with the `newl` and `indent` parameters.

    r4z$Document must have exactly one root.FNTr�)rHr�rr�
startDocumentrIr��endDocument�getvalue�decoderf)
�
input_dict�outputrur��short_empty_elementsry�must_returnr�rKrLrrr�unparse�s6
����r��__main__r4cCst�||ft�dSr)�marshal�dump�stdout)rr!rrr�handle_itemsr�)r"r$r*)rr)rrrNFr�r�rNTN)Nr]TF)5�__doc__�defusedexpatrr�ImportError�xml.parsers�xml.sax.saxutilsr�xml.sax.xmlreaderr�	cStringIOr�ior?r\�platform�tuple�map�int�python_version_tuple�collectionsr
�inspectr�
basestringr��	NameError�str�unicoderb�
__author__�__version__�__license__�	Exceptionr
�objectrr~r�r�r�r�sysr��stdin�bufferr�rf�argvr"r��root�KeyboardInterruptrrrr�<module>s������� 
�
5
�O
�
+
��
���