
    (ph0H                     n   S r SSKJr  SSKJr  SSKJr  SSKJr  \	r
SSKr\" \" \\R                  " 5       SS 5      5      S:  a  SS	KJr
  SS
KJr  SrSrSr " S S\5      r " S S5      rS\SSSS4S jrSS jr           SS jr  SS jr\S:X  al  SSKrSSK r  \RB                  RD                  r!\RF                  RD                  r#\RJ                  SS u  r&\" \&5      r&S r' \" \!\&\'\	S9r(\&S:X  a
  \'" / \(5        ggg! \$ a    \RB                  r!\RF                  r# NXf = f! \) a     gf = f) z:Makes working with XML feel like you are working with JSON    )expat)XMLGenerator)AttributesImpl)StringION   )      )OrderedDict)isgeneratorzMartin Blechz0.14.2MITc                       \ rS rSrSrg)ParsingInterrupted    N)__name__
__module____qualname____firstlineno____static_attributes__r       </var/www/html/venv/lib/python3.13/site-packages/xmltodict.pyr   r      s    r   r   c                   r    \ rS rSrSS SSSSSS	\SS
S	S	S4S jrS rS rS rS r	S r
S rS rS rS rSrg	)_DictSAXHandler   r   c                      gNTr   )argss    r   <lambda>_DictSAXHandler.<lambda>   s    Tr   T@#textF N:z#commentc                     / U l         / U l        / U l        S U l        Xl        X0l        X l        X@l        XPl        X`l	        Xpl
        Xl        Xl        Xl        Xl        Xl        U	" 5       U l        Xl        Xl        g 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/   r0   r1   r2   r3   r4   r5   r7   r8   s                  r   __init___DictSAXHandler.__init__   s{     	
		$&*&"&.* 0 0#6 $&6&8#$&r   c                 
   U R                   c  U$ UR                  U R                  5      nUS:X  a  U$ US U XS-   S  pC U R                   U   nU(       d  U$ U R                  R	                  XT45      $ ! [         a    Un N3f = f)N   )r5   rfindr4   KeyErrorjoin)r9   	full_namei	namespacenameshort_namespaces         r   _build_name_DictSAXHandler._build_name=   s    ??"OOD4457#BQ-Q344	("ooi8O K++00/1HII  	('O	(s   A3 3BBc           	      ~    [        U[        5      (       a  U$ U R                  [        USS S2   USS S2   5      5      $ )Nr   r   r>   )
isinstancedictr2   zip)r9   attrss     r   _attrs_to_dict_DictSAXHandler._attrs_to_dictM   s@    eT""L$$Sqt!teADqDk%BCCr   c                 2    X R                   U=(       d    S'   g )Nr"   )r6   )r9   prefixuris      r   startNamespaceDecl"_DictSAXHandler.startNamespaceDeclR   s    47##FLb1r   c                 4   U R                  U5      nU R                  U5      nU(       a5  U R                  (       a$  U R                  US'   U R                  5       U l        U R                  R                  X2=(       d    S 45        [        U R                  5      U R                  :  a  U R                  R                  U R                  U R                  45        U R                  (       a  / nUR                  5        Hn  u  pVU R                  U R                  U5      -   nU R                  (       a  U R                  U R                  XV5      nOXV4nU(       d  M]  UR                  U5        Mp     U R                  U5      nOS nU=(       d    S U l	        / U l
        g g )Nxmlns)rG   rN   r6   r2   r&   appendlenr*   r'   r)   r(   r+   itemsr-   r1   )r9   rB   rM   rE   attr_entrieskeyvalueentrys           r   startElement_DictSAXHandler.startElementU   s;   	*##E*T00!88E'N*.*?*?*AD'		$./tyy>T__,JJtyy$))45!"'++-JC**4+;+;C+@@C)) $ 2 2499c I!$u$++E2 #0 --l;DIDI! -r   c                 "   U R                  U5      n[        U R                  5      U R                  :X  ap  U R                  nUc8  U R
                  (       d  S O$U R                  R                  U R
                  5      nU R                  U R                  U5      nU(       d  [        eU R                  (       Ga1  U R
                  (       d  S O$U R                  R                  U R
                  5      nU R                  nU R                  R                  5       u  U l        U l        U R                  (       a   U(       a  UR                  5       =(       d    S nU(       a$  U R                  (       a  Uc  U R                  5       nUbE  U(       a  U R!                  X0R"                  U5        U R!                  U R                  X#5      U l        O0U R!                  U R                  X%5      U l        OS U l        / U l        U R                  R                  5         g r%   )rG   rX   r&   r*   r)   r(   r0   rA   r,   r   r'   popr3   stripr/   r2   	push_datar.   )r9   rB   rE   r)   should_continuer(   s         r   
endElement_DictSAXHandler.endElementn   sf   	*tyy>T__,99D|$(II!1166tyyA  #00DAO"((::: $		D--22499= 99D#'::>>#3 DIty$$zz|+t((T\,,.NN4> NN499dA	 NN499dA	DIDI		r   c                 n    U R                   (       d	  U/U l         g U R                   R                  U5        g r%   )r(   rW   r9   r(   s     r   
characters_DictSAXHandler.characters   s$    yyDIIIT"r   c                     U R                   (       a  UR                  5       nU R                  U R                  U R                  U5      U l        g r%   )r3   rb   rc   r)   r8   rh   s     r   comments_DictSAXHandler.comments   s4      ::<DNN499d.>.>E	r   c                 \   U R                   b%  U R                  U R                  X#5      nUc  U$ Uu  p#Uc  U R                  5       n X   n[        U[        5      (       a  UR                  U5        U$ XS/X'    U$ ! [         a&    U R                  X#5      (       a  U/X'    U$ X1U'    U$ f = fr%   )r1   r&   r2   rJ   listrW   r@   _should_force_list)r9   r)   r[   r(   resultr\   s         r   rc   _DictSAXHandler.push_data   s    )''		3=F~IC<((*D
	!IE%&&T"  #M	   	!&&s11!F	  !S		!s   *A; 3A; ;%B+#B+*B+c                     U R                   (       d  g[        U R                   [        5      (       a  U R                   $  XR                   ;   $ ! [         a"    U R                  U R                  S S X5      s $ f = f)NFr=   )r7   rJ   bool	TypeErrorr&   )r9   r[   r\   s      r   rp   "_DictSAXHandler._should_force_list   sc    doot,,??"	?//)) 	???499Sb>3>>	?s   A )A98A9)r-   r.   r0   r8   r(   r2   r/   r7   r)   r,   r*   r6   r4   r5   r&   r1   r'   r3   r+   )r   r   r   r   _dictr:   rG   rN   rS   r^   re   ri   rl   rc   rp   r   r   r   r   r   r      sb    1! ""!##"'"&%(  '!'FJ D
82>#F
*?r   r   Fr#   Tc                 d   [        SSU0UD6n[        U [        5      (       a  U=(       d    SnU R                  U5      n U(       d  SnUR                  " UU5      n	 SU	l        UR                  U	l        UR                  U	l
        UR                  U	l        UR                  U	l        U(       a  UR                  U	l        SU	l        U(       a   Sn
U	R$                  R'                  U
S5        [-        U S5      (       a  U	R/                  U 5        UR4                  $ [1        U 5      (       a9  U  H  nU	R3                  US	5        M     U	R3                  S
S5        UR4                  $ U	R3                  U S5        UR4                  $ ! [         a     GN+f = f! [         a    S U	l        S U	l         Nf = f)ab  Parse 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',
            },
        }
r4   utf-8NTz4http://apache.org/xml/features/disallow-doctype-declc                     g r%   r   xs    r   r   parse.<locals>.<lambda>]  s    dr   c                      g)Nr>   r   r{   s    r   r   r}   _  s    r   readFr   r   )r   rJ   strencodeParserCreateordered_attributesAttributeErrorrS   StartNamespaceDeclHandlerr^   StartElementHandlerre   EndElementHandlerri   CharacterDataHandlerrl   CommentHandlerbuffer_text_reader
setFeatureDefaultHandlerExternalEntityRefHandlerhasattr	ParseFiler   Parser)   )	xml_inputencodingr   process_namespacesr4   disable_entitiesprocess_commentskwargshandlerparserfeaturechunks               r   parser      s   L  (2E ( &(G)S!!&w$$X.	"F$(! (/'A'AF$!(!5!5F&11F")"4"4F ' 0 0F		;LGNN%%gt4 y&!!# << 
Y		ELL& S$ << 	Y%<<;    	; %3F!.:F+	;s$   F F 
FFF/.F/c                    U(       d  U $  U R                  US5      u  p@UR                  UR                  U5      5      nU(       a-  SR                  UR	                  U5      (       a  UOSXRU 5      n U $ U n U $ ! [
         a     U $ f = f)Nr>   z{}{}{}{}r"   )rsplitgetrb   format
startswith
ValueError)rE   r5   ns_sepr-   nsns_ress         r   _process_namespacer   k  s    6;;vq)  56 &,   ==55K2D" K 26 	 K   Ks   A7 7
BBc                 6   [        XX5      n Ub  U" X5      nUc  g Uu  p[        US5      (       a  [        U[        [        45      (       a  U/n[        U5       GH  u  nnU(       a  US:X  a  US:  a  [        S5      eUc  [        5       nOn[        U[        5      (       a  U(       a  SOSnOM[        U[        [        45      (       d2  U(       a   [        US5      (       a  [        UU445      nO[        U5      n[        U[        5      (       a  [        UU445      nS n[        5       n/ nUR                  5        H  u  nnUU:X  a  UnM  UR                  U5      (       a  [        UXU5      nUS:X  a\  [        U[        5      (       aG  UR                  5        H1  u  nnSR                  U(       a  SU 3OS	5      n[        U5      UU'   M3     M  [        U[        5      (       d  [        U5      nUUU[        U5      S  '   M  UR                  UU45        M     [        U	[        5      (       a  S
U	-  n	U(       a  UR                  XY-  5        UR!                  U [#        U5      5        U(       a  U(       a  UR                  U5        U H  u  nn[%        UUUX4US-   UXxXU
US9  M     Ub  UR'                  U5        U(       a  U(       a  UR                  XY-  5        UR)                  U 5        U(       d  GM  U(       d  GM  UR                  U5        GM     g )N__iter__r   zdocument with multiple rootstruefalsez@xmlnszxmlns{}r#   r"    r>   )r5   r4   expand_iter)r   r   rJ   r   rK   	enumerater   rw   rt   rY   r   r   rX   rW   intignorableWhitespacer^   r   _emitri   re   )r[   r\   content_handlerr-   r.   depthpreprocessorprettynewlindentr4   r5   full_documentr   rq   indexvcdatarM   childrenikivkattr	child_keychild_values                             r   r   r   z  s    S.A
OCc)>
5*%%EC;)G)Ge$qUaZEAI;<<9A4  AAc{++wq*55K+-.Fa	1~'(AggiFBY}}[))'J(35>jT&:&: "
1(//1!A3"E&)!fd !+ !"c**RB/1b[)*+,OORH%!  " fc""6\F//?$$S.*?@h//5&."I{)[/%'<&9)	+ '/ &&u-h//?""3'6ee//5k %r   c                    U(       a  [        U 5      S:w  a  [        S5      eSnUc  [        5       nSnU(       a  [        XS5      nO[        X5      nU(       a  UR	                  5         U R                  5        H  u  p[        XU4SU0UD6  M     U(       a  UR                  5         U(       a$  UR                  5       n	 U	R                  U5      n	U	$ g! [         a     U	$ f = f)ax  Emit 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.

    r>   z$Document must have exactly one root.FNTr   )rX   r   r   r   startDocumentrY   r   endDocumentgetvaluedecoder   )

input_dictoutputr   r   short_empty_elementsr   must_returnr   r[   r\   s
             r   unparser     s    " ZA-?@@K~&v>&v8%%' &&(
c/ 	 		 ) ##%!	LL*E    		s    C 
C"!C"__main__r>   c                 <    [         R                  " X4[        5        gr   )marshaldumpstdout)r&   r)   s     r   handle_itemr     s    d\6*r   )r*   r,   r2   )r#   r    )r    r!   r   NF
	r#   NTN)Nry   TF)*__doc__xml.parsersr   xml.sax.saxutilsr   xml.sax.xmlreaderr   ior   rK   rw   platformtuplemapr   python_version_tuplecollectionsr
   inspectr   
__author____version____license__	Exceptionr   r   r   r   r   r   r   sysr   stdinbufferr   r   argvr*   r   rootKeyboardInterruptr   r   r   <module>r      s   <  ) ,  S(//1"15	67&@0 
	 	\? \?~ #%E!D5pf  !I6X FJ!&(V z		  ""
 HHQRLMZZJU *#.&*, ?D! -   		$  s$   #,D ,D+ D('D(+D43D4