
    	h              	       D   S SK r S SKrS SKJs  Jr  S r " S S\R                  5      r  SS jr SS jr	 SS jr
S	 r    SS
 jr    SS jrS r  SS jr  SSSSSSS\S.S jjr  SSSSSSS\S.S jjr  SSSSSSS\S.S jjr\ R&                  S 5       rg)    Nc                  t    [         R                  R                  5        V Vs0 s H  u  pX_M	     snn $ s  snn f N)ET_namespace_mapitems)uriprefixs     M/var/www/html/env/lib/python3.13/site-packages/et_xmlfile/incremental_tree.pycurrent_global_nsmapr   /   s7    ')'8'8'>'>'@'@'@  s   4c                   4    \ rS rSr    SSSSSS.S jjrSrg)	IncrementalTree5   NTF)short_empty_elementsnsmaproot_ns_onlyminimal_ns_onlyc                b   U(       d  SnOUS;  a  [        SU-  5      eU(       d  Sn[        X5       u  pUS:X  a?  U(       d+  Uc5  UR                  5       S:w  a!  UR                  5       S;  a  U
" SU< S	35        US
:X  a!  [        R                  " XR
                  5        OUS:X  a  SnOSnU(       a"  SU;   a  [        S5      eUR                  5       nO0 nU(       a  XMS'   U(       d  U	(       aA  [        U R
                  UU5      nU	(       d#  U(       a  UR                  U5        U(       a  XMS'   [        R                  R                  5        VVs0 s H  u  pX_M	     nnnSU;   a  [        S5      e0 n[        U
U R
                  UUUSUUS9  SSS5        gs  snnf ! , (       d  f       g= f)a	  Write element tree to a file as XML.

Arguments:
  *file_or_filename* -- file name or a file object opened for writing

  *encoding* -- the output encoding (default: US-ASCII)

  *xml_declaration* -- bool indicating if an XML declaration should be
                       added to the output. If None, an XML declaration
                       is added if encoding IS NOT either of:
                       US-ASCII, UTF-8, or Unicode

  *default_namespace* -- sets the default XML namespace (for "xmlns").
                         Takes precedence over any default namespace
                         provided in nsmap or
                         xml.etree.ElementTree.register_namespace().

  *method* -- either "xml" (default), "html, "text", or "c14n"

  *short_empty_elements* -- controls the formatting of elements
                            that contain no content. If True (default)
                            they are emitted as a single self-closed
                            tag, otherwise they are emitted as a pair
                            of start/end tags

  *nsmap* -- a mapping of namespace prefixes to URIs. These take
             precedence over any mappings registered using
             xml.etree.ElementTree.register_namespace(). The
             default_namespace argument, if supplied, takes precedence
             over any default namespace supplied in nsmap. All supplied
             namespaces will be declared on the root element, even if
             unused in the document.

  *root_ns_only* -- bool indicating namespace declrations should only
                    be written on the root element.  This requires two
                    passes of the xml tree adding additional time to
                    the writing process. This is primarily meant to
                    mimic xml.etree.ElementTree's behaviour.

  *minimal_ns_only* -- bool indicating only namespaces that were used
                       to qualify elements or attributes should be
                       declared. All namespace declarations will be
                       written on the root element regardless of the
                       value of the root_ns_only arg. Requires two
                       passes of the xml tree adding additional time to
                       the writing process.

xml)textr   htmlzunknown method %rus-asciiNunicode)utf-8r   z<?xml version='1.0' encoding='z'?>
r   FTzTFound None as default nsmap prefix in nsmap. Use "" as the default namespace prefix. zxFound None as default nsmap prefix in nsmap registered with register_namespace. Use "" for the default namespace prefix.)is_htmlis_rootr   	new_nsmap)
ValueError_get_writerlowerr   _serialize_text_rootcopy_namespacesupdater   r   _serialize_ns_xml)selffile_or_filenameencodingxml_declarationdefault_namespacemethodr   r   r   r   writedeclared_encodingr   r   r   r	   global_nsmapnsmap_scopes                     r
   r-   IncrementalTree.write7   s   z F22069::!H)48R#+ (I5)//19NN ARTU""5**5U?#G"Gu}(F  !&

I "I$$5bM? !,

)!!I
 +  &,,U3,,=bM353D3D3J3J3L 3LKCFK3L    <'$W  !!JJ # )='	k 54X Y 54s   D F F!0F F  
F. )NNNN)__name__
__module____qualname____firstlineno__r-   __static_attributes__r2       r
   r   r   5   s0    
 B "B Br8   r   c                 ~    [        U 5      nUb  SU ;  a  US-  n SU 3nXP;  a  XQ;  a  U(       a  XR;  a  U$ US-  nM$  )Nr      ns)len)r0   global_prefixeslocal_nsmapr+   ir	   s         r
   _make_new_ns_prefixr@      s]     	KA$;)> 	
Q
aS%-6#< M	Q r8   Fc                     UR                  5        H  u  pgX:X  d  M  Xa;  d  M  Un  O   [        XS9nXU'   XU'   U(       d  XU '   US:w  a  UR                  U5        U$ )a1  Find a prefix that doesn't conflict with the ns scope or create a new prefix

This function mutates nsmap_scope, global_nsmap, new_namespace_prefixes and
uri_to_prefix. It is intended to keep state in _serialize_ns_xml consistent
while deduplicating the house keeping code or updating these dictionaries.
)r=   r   )r   r@   add)	r   r0   r/   new_namespace_prefixesuri_to_prefix!for_default_namespace_attr_prefixglobal_prefix
global_urir	   s	            r
   _get_or_create_prefixrH      sn    $ &2%7%7%9!!A"F &: %[O"V,#c""6*Mr8   c                     UR                  5        H  u  pVX`:X  d  M  US:w  d  M  Us  $    UR                  5        H  u  pVX`:X  d  M  US:w  d  M  Us  $    [        R                  R                  U 5      nU(       a  XQ;  a  U$ [	        UUUU5      $ )Nr   )r   r   r   getr@   )r+   r   r>   r=   provided_default_namespacer	   r   s          r
   #_find_default_namespace_attr_prefixrL      s     {{}#"M % #((*#"M +
 ""#45F&%"	 r8   c           
      n   / nU R                  5        GH^  u  p[        U[        R                  5      (       a  UR                  n US S S:X  a  USS  R                  SS5      n
 XjS      nU(       ds  U(       a  UnOiUR                  5        H  u  pXS   :X  d  M  US:w  d  M  Un  O>   U(       d"  UR                  5       nUR                  5       nSn[        U
S   UUUUSS9nUnU SU
S    3n[        U	[        R                  5      (       aQ  U	R                  S S S:w  a  U	R                  n	O1U	R                  SS  R                  SS5      n
 XjS      nU SU
S    3n	UR                  X45        GMa     XrU4$ ! [         a?    U(       d"  UR                  5       nUR                  5       nSn[        U
S   UUUU5      n GNWf = f! [         a    [        R                  " U5         Nf = f! [         a>    U(       d"  UR                  5       nUR                  5       nSn[        U
S   UUUU5      n Nf = f)	Nr:   {}r   Tr   )rE   :)r   
isinstancer   QNamer   rsplitKeyErrorr#   rH   	TypeError_raise_serialization_errorappend)elemis_nsmap_scope_changeddefault_ns_attr_prefixr0   r/   rC   rD   
item_partskvuri_and_namer	   	known_uris                r
   process_attribsr`     sk    J

a""A2	-!u| u||C3*?;F$ -!71<1B1B1D-F(O;"9? 6 % 2E
 $:
 /:.>.>.@0=0B0B0D9= 6%: ,Q + , 6 -BF&F 6<2haQ01 a""vvbqzS FF vvabz00a8*?;F" haQ011&!_ ` {::Q   1
 '2&6&6&8(5(:(:(<15.2$Q#$.%FX  	-))!,	-   1
 '2&6&6&8(5(:(:(<15.2$Q#$.%FsW   G$E:+,GG#AGG,:AG?GGG G)(G),AH43H4c
                 x	   UR                   nUR                  nU[        R                  L a  U " SU-  5        SnSnGOU[        R                  L a  U " SU-  5        SnSnGOU	(       aR  SnUR                  5       nUR                  U	5        [        U	R                  5       5      nUR                  S5        SnSnOSn[        5       nUcD  SU;   a  [        S5      eUR                  5        VVs0 s H	  u  nnUU_M     nnnSU;   a  SXrS   '   Uc'  UnU(       a  U " [        R                  " U5      5        GOSn[        U[        R                  5      (       a  UR                  n USS	 S
:X  a6  US	S R                  SS	5      n UUS      nU(       a  U SUS	    3nOUS	   nOSU;   a  [        S5      e U " SU-   5        UR(                  (       a  [+        UUUUUUU5      u  npO/ nU(       a  / n[-        U5       H*  nUU   nU(       a  SU-   nOSnUR/                  UU45        M,     U(       aI  U " SR1                  U VVs/ s H#  u  nnSU S[        R2                  " U5       S3PM%     snn5      5        OHU " SR1                  U VVs/ s H#  u  nnSU S[        R4                  " U5       S3PM%     snn5      5        U(       a  U(       aI  U " SR1                  U VVs/ s H#  u  nnSU S[        R2                  " U5       S3PM%     snn5      5        OHU " SR1                  U VVs/ s H#  u  nnSU S[        R4                  " U5       S3PM%     snn5      5        U(       ag  U " S5        UR7                  5       nU(       a1  US:X  d  US:X  a	  U " U5        OU " [        R                  " U5      5        U[        R8                  ;   a  SnOTU(       d  [;        U5      (       d  U(       d,  U " S5        U(       a  U " [        R                  " U5      5        O
SnU " S5        UUUUU4$ s  snnf ! [          a?    U(       d"  UR                  5       nUR                  5       nSn[#        US   UUUU5      n GNf = f! [$         a    [        R&                  " U5         GNf = fs  snnf s  snnf s  snnf s  snnf )a  Write the opening tag (including self closing) and element text.

Refer to _serialize_ns_xml for description of arguments.

nsmap_scope should be an empty dictionary on first call. All nsmap prefixes
must be strings with the default namespace prefix represented by "".

eg.
- <foo attr1="one">      (returns tag = 'foo')
- <foo attr1="one">text  (returns tag = 'foo')
- <foo attr1="one" />    (returns tag = None)

Returns:
    tag:
        The tag name to be closed or None if no closing required.
    nsmap_scope:
        The current nsmap after any prefix to uri additions from this
        element. This is the input dict if unmodified or an updated copy.
    default_ns_attr_prefix:
        The prefix for the default namespace to use with attrs.
    uri_to_prefix:
        The current uri to prefix map after any uri to prefix additions
        from this element. This is the input dict if unmodified or an
        updated copy.
    next_remains_root:
        A bool indicating if the child element(s) should be treated as
        their own roots.
z	<!--%s-->NFz<?%s?>Tr   zIFound None as a namespace prefix. Use "" as the default namespace prefix.r   r:   rN   rO   r   rP   <cannot use non-qualified names with default_namespace option<zxmlns:xmlns z="">scriptstylez />)tagr   r   CommentProcessingInstructionr#   r%   setkeysdiscardr   r   _escape_cdatarQ   rR   rS   rT   rH   rU   rV   attribr`   sortedrW   join_escape_attrib_html_escape_attribr    
HTML_EMPTYr<   )r-   rX   r0   r/   r   r   r   rD   rZ   r   kwargsrj   r   next_remains_rootrY   rC   r	   r   r^   r[   ns_attrsr\   r]   ltags                           r
   write_elem_startr{   t  s   R ((C99D
bjjkD !!	((	(ho!%)"%**,Ky)%()9%:""**51 M%)"%*"%(U" {" _  =H<M<M<OP<O[VSS&[<OMP[  24"o.; !(b&&t,- %#rxx((hh/3$ r7c>#&qr7>>#q#9L!.|A!?" !',q/):;*1o;&$V  ' #){{BQ** *!C?
2K  
% 67A#AA$qL#OOQF+ 8 "''U]"^U]TQPQQqcB,B,B1,E+Fa#HU]"^_`"''PX"YPX1QqcB,=,=a,@+A#CPX"YZ["''U_"`U_TQPQQqcB,B,B1,E+Fa#HU_"`ab"''PZ"[PZ1QqcB,=,=a,@+A#CPZ"[\]c
yy{x'47?db..t452==(CT*>c
"**401e e QL $ 5
 +6*:*:*<K,9,>,>,@M592!6(O'(2)"0  3--c236 #_"Y #a"[sa   -P+%Q= P1 Q= Q= $Q= *R$*R*#*R0,*R61AQ:6Q= 9Q::Q= = R! R!c
                     [        U UUUUUUUUU	S9
u  nnnnnU H  n[        U UUUUUUUUSS9
  M     U(       a  U " SU S35        UR                  (       a'  U " [        R                  " UR                  5      5        gg)a  Serialize an element or tree using 'write' for output.

Args:
    write:
        A function to write the xml to its destination.
    elem:
        The element to serialize.
    nsmap_scope:
        The current prefix to uri mapping for this element. This should be
        an empty dictionary for the root element. Additional namespaces are
        progressively added using the new_nsmap arg.
    global_nsmap:
        A dict copy of the globally registered _namespace_map in uri to
        prefix form
    short_empty_elements:
      Controls the formatting of elements that contain no content. If True
      (default) they are emitted as a single self-closed tag, otherwise
      they are emitted as a pair of start/end tags.
    is_html:
        Set to True to serialize as HTML otherwise XML.
    is_root:
        Boolean indicating if this is a root element.
    uri_to_prefix:
        Current state of the mapping of uri to prefix.
    default_ns_attr_prefix:
    new_nsmap:
        New prefix -> uri mapping to be applied to this element.
)r   Nz</rg   )r{   r&   tailr   rp   )r-   rX   r0   r/   r   r   r   rD   rZ   r   rw   rj   rx   es                 r
   r&   r&   6  s    ^ 		  "	
  3%qkyybtyy)* r8   c              #   D  #    [        5       n[        5       nU R                  5        GH  nUR                  n[        U[        5      (       a  XA;  a  UR                  U5        US4v   O[        U[        R                  5      (       a)  UR                  nXA;  a  UR                  U5        US4v   O?Ub<  U[        R                  La)  U[        R                  La  [        R                  " U5        UR                  5        H  u  pV[        U[        R                  5      (       a  UR                  nXR;  a  UR                  U5        US4v   [        U[        R                  5      (       d  Mm  UR                  U;  d  M  UR                  UR                  5        UR                  S4v   M     UR                  n[        U[        R                  5      (       d  GM  UR                  U;  d  GM  UR                  UR                  5        UR                  S4v   GM     g7f)z/Iterate through all the qualified names in elemTNF)rm   iterrj   rQ   strrB   r   rR   r   rl   rk   rV   r   )rX   seen_el_qnamesseen_other_qnames	this_elemrj   keyvaluer   s           r
   _qnames_iterr     s    UNYY[	mmc3(""3'4iRXX&&((C(""3'4iO23332::%))#.#//+JC#rxx((hh+!%%c*5j %**::%66%))%**5**e++ , ~~dBHH%%yy 11!%%dii0ii&&E !s   E'H -H ?AH H /1H c                    Uc  0 n0 n0 nUR                  5        VVs0 s H  u  pVXe_M	     nnnUb  SXq'   OSU;   a  SXrS   '   [        [        R                  R	                  5       5      nSn	Sn
[        U 5       H  u  p USS S:X  a  USS R                  SS5      nUR                  US   5      nUcp  UR                  US   5      nUb  XS;   a8  [        R                  R                  US   5      nUb  XS;   a  [        UUUU5      nU(       d  U(       a  US   X5'   XTUS   '   U(       d-  U(       d$  U
(       d  [        US   UUUU5      n
US   X:'   M  M  M  M  U(       a  Sn	M  M     SU;   a  U	(       a  [        S	5      eUR                  S
S5        U$ s  snnf ! [         a    [        R                  " U5         GMF  f = f)zGFind all namespaces used in the document and return a prefix to uri mapNr   Fr:   rN   rO   r   Trb   r   )r   rm   r   r   valuesr   rS   rJ   r@   rL   rU   rV   r   pop)rX   r+   r   	out_nsmapseen_uri_to_prefixr	   r   local_prefix_mapr=   has_unqual_eldefault_namespace_attr_prefixqnameis_elr^   s                 r
   r$   r$     s    }I 8={{}E}}E$.0+	u&(r#"++2245OM$(!$T*'	1RayC$QRy//Q7+//Q@>-11,q/BF~)<!#!2!2!6!6|A!G!>V-@%8 ) / % 1	&F ,8O	)>D<?;V4Q 5X$Q!')51 @LAI< 5RVu  $(M K +T 
Y=J
 	
 MM%{ Fb  	1))%00	1s   F?CF	F G ?G T)r*   r+   r   r   r   r   tree_clsc                    US:X  a  [         R                  " 5       O[         R                  " 5       n
U	" U 5      R                  U
UUUUUUUUS9	  U
R	                  5       $ )a  Generate string representation of XML element.

All subelements are included.  If encoding is "unicode", a string
is returned. Otherwise a bytestring is returned.

*element* is an Element instance, *encoding* is an optional output
encoding defaulting to US-ASCII, *method* is an optional output which can
be one of "xml" (default), "html", "text" or "c14n", *default_namespace*
sets the default XML namespace (for "xmlns").

Returns an (optionally) encoded string containing the XML data.

r   r*   r+   r,   r   r   r   r   )ioStringIOBytesIOr-   getvalue)elementr)   r,   r*   r+   r   r   r   r   r   streams              r
   tostringr     s`    4 ')3R[[]FW'+1!'  
 ??r8   c                p    / n
[         R                  " U
5      nU	" U 5      R                  UUUUUUUUUS9	  U
$ )Nr   )r   _ListDataStreamr-   )r   r)   r,   r*   r+   r   r   r   r   r   lstr   s               r
   tostringlistr   $  sS     C$FW'+1!'  
 Jr8   c                &    [        U UUUUUUUUU	S9
$ )ztostring with options that produce the same results as xml.etree.ElementTree.tostring

root_ns_only=True is a bit slower than False as it needs to traverse the
tree one more time to collect all the namespaces.
)	r)   r,   r*   r+   r   r   r   r   r   )r   )
r   r)   r,   r*   r+   r   r   r   r   r   s
             r
   compat_tostringr   A  s/    $ '+1!' r8   c              #     #     U R                   nUR                  5       S:X  a  U[        U SS 5      =(       d    S4v   g [        R                  " 5        n[        U [        R                  5      (       a  U nO[        U [        R                  5      (       a2  [        R                  " U 5      nUR                  UR                  5        OF[        R                  " 5       nS Ul        X$l          U R                  Ul        U R                  Ul        [        R                   " UUSSS9nUR                  UR                  5        UR                   U4v   S S S 5        g ! [         a     NWf = f! , (       d  f       g = f! [         aP    UR                  5       S:X  a  Sn[#        U SUSS	9 nUR                   U4v   S S S 5         g ! , (       d  f        g = ff = f7f)
Nr   r)   r   c                      g)NTr2   r2   r8   r
   <lambda>_get_writer.<locals>.<lambda>  s    Dr8   xmlcharrefreplace
)r)   errorsnewlinew)r)   r   )r-   r    getattr
contextlib	ExitStackrQ   r   BufferedIOBase	RawIOBaseBufferedWritercallbackdetachwritableseekabletellAttributeErrorTextIOWrapperopen)r(   r)   r-   stackfiles        r
   r   r   d  s    -+ && >>y(!1:tDOOO %%'5.0A0ABB+D 0",,??,,-=>D NN4;;/ ,,.D$0DM!&J )9(A(A$4$9$9	 ''19/B046 t{{+jj(**9 ('& * ' ('  '>>y(H"C(,.15**h&&. . . .	's   GE: AGBE),"EAE)	G
E&#E)%E&&E))
E73G:,G&G7G?G
G	GGGG)NN)Fr   )FNNN)r   r   xml.etree.ElementTreeetreeElementTreer   r   r   r@   rH   rL   r`   r{   r&   r   r$   r   r   r   contextmanagerr   r2   r8   r
   <module>r      s+  R  	 " "Dbnn DT 	> ',!R  $<Z;H R K+\&'V 
K` &
 
&V 
 
> 
 
F 0+ 0+r8   