ó
    ×›‘h…#  ã            
       ó˜  • S r SSKrSSKJr  SSKJrJr  SSKJr  SSK	J
r
JrJr  SR                  \" \" SS	S
S5      5      5      r\R                  " \\SS9  \
  \   " S S\5      rS rS'S jrS rS rS rS rS(S jrS rS rS rS)S jr " S S\R<                  5      rS*S jr S*S jr!S*S jr"S r#S  r$S*S! jr%S" r&S# r'S$ r(S% r)S& r*g)+z^
A library for performing interesting tasks with DOM objects.

This module is now deprecated.
é    N)ÚStringIO)ÚVersionÚgetVersionString)Úmicrodom)ÚescapeÚgetElementsByTagNameÚunescapez+twisted.web.domhelpers was deprecated at {}ÚTwistedé   é
   é   )Ú
stacklevelc                   ó   • \ rS rSrSrg)ÚNodeLookupErroré   © N)Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__static_attributes__r   ó    ÚZC:\Users\psant\Downloads\Noiseback\school\venv\Lib\site-packages\twisted/web/domhelpers.pyr   r      s   † Úr   r   c                 óì   • UR                    Hd  n[        US5      (       aD  UR                  (       a3  UR                  S[	        UR                  5      UR                  U-  5        [        XU5        Mf     g)zu
Look through the given node's children for strings, and
attempt to do string substitution with the given parameter.
Ú	nodeValuer   N)Ú
childNodesÚhasattrr   ÚreplaceDataÚlenÚ
substitute)ÚrequestÚnodeÚsubsÚchilds       r   r    r    !   sS   € ð
 —”ˆÜ�5˜+×&Ñ&¨5¯?¯?Ø×Ñ˜a¤ U§_¡_Ó!5°u·±ÈÑ7MÔNÜ�7 4Ö(ò !r   c                 óÌ  • [        U S5      (       a@  U R                  5       (       a+  U H%  n[        U R                  U5      5      U:X  d  M#  U s  $    U R	                  5       (       a~  [        U R
                  S5      (       a  U R
                  R                  nO[        U R
                  5      n[        U5       H'  n[        U R
                  U   U5      nU(       d  M%  Us  $    gg)zl
(internal) Get a node with the specified C{nodeId} as any of the C{class},
C{id} or C{pattern} attributes.
ÚhasAttributesÚlengthN)
r   r&   ÚstrÚgetAttributeÚhasChildNodesr   r'   r   ÚrangeÚ_get)r"   ÚnodeIdÚ	nodeAttrsÚnodeAttrr'   ÚchildNumÚresults          r   r,   r,   ,   s·   € ô ˆt�_×%Ñ%¨$×*<Ñ*<×*>Ñ*>Û!ˆHÜ�4×$Ñ$ XÓ.Ó/°6Õ9Ø’ñ "ð ×Ñ×ÑÜ�4—?‘? H×-Ñ-Ø—_‘_×+Ñ+‰Fä˜Ÿ™Ó)ˆFÜ˜fžˆHÜ˜$Ÿ/™/¨(Ñ3°VÓ<ˆFßˆvØ’ò &ð r   c                 ó@   • [        X5      nU(       a  U$ [        U5      e)z•
Get a node with the specified C{nodeId} as any of the C{class},
C{id} or C{pattern} attributes. If there is no such node, raise
L{NodeLookupError}.
)r,   r   ©r"   r-   r1   s      r   Úgetr4   A   s!   € ô �$Ó€FÞØˆÜ
˜&Ó
!Ð!r   c                 ó   • [        X5      $ )zŒ
Get a node with the specified C{nodeId} as any of the C{class},
C{id} or C{pattern} attributes.  If there is no such node, return
L{None}.
)r,   )r"   r-   s     r   ÚgetIfExistsr6   M   s   € ô �ÓÐr   c                 ó@   • [        X5      nU(       a  [        U5        U$ )z½Get a node with the specified C{nodeId} as any of the C{class},
C{id} or C{pattern} attributes. If there is no such node, raise
L{NodeLookupError}. Remove all child nodes before returning.
)r4   Ú	clearNoder3   s      r   ÚgetAndClearr9   V   s   € ô
 �Ó€FÞÜ�&ÔØ€Mr   c                 ó"   • / U R                   SS& g)z*
Remove all children from the given node.
N)r   )r"   s    r   r8   r8   a   s   € ð €D‡O�O‘AÑr   c           	      óJ  • / n[        U [        / 5      5      (       d  [        U R                  XU5      $ U  Hi  n[	        US5      (       d  M  [        UR                  U5      5      U:X  a  UR                  U5        U(       a  MN  UR                  [        XQX#5      5        Mk     U$ )zP
Find subnodes in the given node where the given attribute
has the given value.
r)   )	Ú
isinstanceÚtypeÚlocateNodesr   r   r(   r)   ÚappendÚextend)ÚnodeListÚkeyÚvalueÚ	noNestingÚ
returnListÚ	childNodes         r   r>   r>   h   s’   € ð
 €JÜ�h¤ R£×)Ñ)Ü˜8×.Ñ.°¸IÓFÐFÛˆ	Ü�y .×1Ñ1ÙÜˆy×%Ñ% cÓ*Ó+¨uÓ4Ø×Ñ˜iÔ(ÞÙØ×Ñœ+ i°eÓGÖHñ ð Ðr   c                 ó´   • [        U S5      (       d  g U R                  X5        U R                  5       (       a   U R                   H  n[	        X1U5        M     g g )NÚsetAttribute)r   rH   r*   r   ÚsuperSetAttribute)r"   rB   rC   r$   s       r   rI   rI   {   sL   € Ü�4˜×(Ñ(ØØ×Ñ�cÔ!Ø×Ñ×ÑØ—_”_ˆEÜ˜e¨%Ö0ò %ð r   c                 ó  • [        U S5      (       d  g U R                  U5      nU(       a  U R                  XS-   U-   5        OU R                  X5        U R                  5       (       a   U R                   H  n[        XAU5        M     g g ©NrH   Ú/)r   r)   rH   r*   r   ÚsuperPrependAttribute©r"   rB   rC   Úoldr$   s        r   rM   rM   „   sv   € Ü�4˜×(Ñ(ØØ
×
Ñ
˜CÓ
 €CÞ
Ø×Ñ˜# s™{¨SÑ0Õ1à×Ñ˜#Ô%Ø×Ñ×ÑØ—_”_ˆEÜ! %¨eÖ4ò %ð r   c                 ó  • [        U S5      (       d  g U R                  U5      nU(       a  U R                  XS-   U-   5        OU R                  X5        U R                  5       (       a   U R                   H  n[        XAU5        M     g g rK   )r   r)   rH   r*   r   ÚsuperAppendAttributerN   s        r   rQ   rQ   ‘   sv   € Ü�4˜×(Ñ(ØØ
×
Ñ
˜CÓ
 €CÞ
Ø×Ñ˜# S™y¨5Ñ0Õ1à×Ñ˜#Ô%Ø×Ñ×ÑØ—_”_ˆEÜ  ¨UÖ3ò %ð r   c                 ód  • / nUR                   nU /n[        U5      S:”  a€  UR                  S5      n[        US5      (       a>  UR                  b1  U(       a  [        UR                  5      nOUR                  nU" U5        UR                  USS& [        U5      S:”  a  M€  UR                  U5      $ )aL  Visit each child node and collect its text data, if any, into a string.
For example::
    >>> doc=microdom.parseString('<a>1<b>2<c>3</c>4</b></a>')
    >>> gatherTextNodes(doc.documentElement)
    '1234'
With dounescape=1, also convert entities back into normal characters.
@return: the gathered nodes as a single string
@rtype: strr   r   N)r?   r   Úpopr   r   r	   r   Újoin)ÚiNodeÚ
dounescapeÚjoinWithÚgatheredÚgathered_appendÚsliceÚcÚvals           r   ÚgatherTextNodesr]   ž   s–   € ð €HØ—o‘o€OØˆG€EÜ
ˆe‹*�q‹.Ø�I‰I�a‹LˆÜ�1�k×"Ñ" q§{¡{Ñ'>ÞÜ˜qŸ{™{Ó+‘à—k‘k�Ù˜CÔ Ø—L‘Lˆˆbˆqˆ	ô ˆe‹*�q�.ð �=‰=˜Ó"Ð"r   c                   ó.   • \ rS rSrSr      SS jrSrg)ÚRawTexté¶   a  This is an evil and horrible speed hack. Basically, if you have a big
chunk of XML that you want to insert into the DOM, but you don't want to
incur the cost of parsing it, you can construct one of these and insert it
into the DOM. This will most certainly only work with microdom as the API
for converting nodes to xml is different in every DOM implementation.

This could be improved by making this class a Lazy parser, so if you
inserted this into the DOM and then later actually tried to mutate this
node, it would be parsed then.
Nc                 óF   • UR                  U U R                   U 35        g ©N)ÚwriteÚdata)ÚselfÚwriterÚindentÚ	addindentÚnewlÚstripÚ
nsprefixesÚ	namespaces           r   ÚwritexmlÚRawText.writexmlÂ   s!   € ð 	�‰˜�x §	¡	˜{¨4¨&Ð1Õ2r   r   )Ú ro   ro   r   NN)r   r   r   r   Ú__doc__rm   r   r   r   r   r_   r_   ¶   s    † ñ	ð ØØØØØ÷
3r   r_   c                 ó¸   • Uc  / nU R                  5       (       d  U$ U R                   H-  nU" U5      (       a  UR                  U5        [        X1U5        M/     U$ rb   ©r*   r   r?   Ú	findNodes©ÚparentÚmatcherÚaccumr$   s       r   rs   rs   Ï   sV   € Ø�}ØˆØ×Ñ×!Ñ!ØˆØ×"Ô"ˆá�5�>‰>Ø�L‰L˜ÔÜ�% %Ö(ñ	 #ð
 €Lr   c                 óÖ   • Uc  / nU R                  5       (       d  U$ U R                   H<  nU" U5      (       a  UR                  U5        U" U5      (       d  M0  [        XAX#5        M>     U$ rb   )r*   r   r?   ÚfindNodesShallowOnMatch)ru   rv   ÚrecurseMatcherrw   r$   s        r   ry   ry   Ü   sa   € Ø�}ØˆØ×Ñ×!Ñ!ØˆØ×"Ô"ˆá�5�>‰>Ø�L‰L˜ÔÙ˜%× Ó Ü# E°NÖJñ #ð €Lr   c                 ó¼   • Uc  / nU R                  5       (       d  U$ U R                   H/  nU" U5      (       a  UR                  U5        M#  [        X1U5        M1     U$ rb   rr   rt   s       r   ÚfindNodesShallowr|   ê   sV   € Ø�}ØˆØ×Ñ×!Ñ!ØˆØ×"Ô"ˆÙ�5�>‰>Ø�L‰L˜Öä�e eÖ,ñ	 #ð
 €Lr   c                 ó$   ^• [        U U4S j5      $ )zv
Return an iterable of the elements which are direct children of C{parent}
and which have the C{attribute} attribute.
c                 óR   >• [        U SS 5      S L=(       a    U R                  T5      $ ©NÚtagName)ÚgetattrÚhasAttribute©ÚnÚ	attributes    €r   Ú<lambda>Ú2findElementsWithAttributeShallow.<locals>.<lambda>þ   s$   ø€ ”'˜!˜Y¨Ó-°TÐ9×W¸a¿n¹nÈYÓ>WÐWr   )r|   )ru   r…   s    `r   Ú findElementsWithAttributeShallowrˆ   ÷   s   ø€ ô
 ØÜWóð r   c                 ó"   • [        U U4S j5      $ )zu
Return an iterable of the elements which are children of C{parent} for
which the predicate C{matcher} returns true.
c                 ó>   • [        U SS 5      S L=(       a    U" U 5      $ r   )r�   )r„   rv   s     r   r†   ÚfindElements.<locals>.<lambda>	  s#   € ¤7¨1¨i¸Ó#>ÀdÐ#J÷ $Ù�A‹Jð$r   ©rs   )ru   rv   s     r   ÚfindElementsr�     s   € ô
 ØØ!ó 	óð r   c                 óN   • U(       a  [        U X4S j5      $ [        X4S j5      $ )Nc                 óZ   • U R                  U5      =(       a    U R                  U5      U:H  $ rb   )r‚   r)   )r„   r…   rC   s      r   r†   Ú+findElementsWithAttribute.<locals>.<lambda>  s(   € ¸¿¹ÀyÓ8Q÷ 93Ø—‘˜yÓ)¨UÑ2ð93r   c                 ó$   • U R                  U5      $ rb   )r‚   rƒ   s     r   r†   r�     s   € °1·>±>À)Ô3Lr   )r�   )ru   r…   rC   s      r   ÚfindElementsWithAttributer’     s2   € ÞÜØØ )ó 3ó
ð 	
ô ØÓLó
ð 	
r   c                 ó    • [        X4S j5      $ )Nc                 ó    • U R                   U:H  $ rb   )ÚnodeName)r„   Únames     r   r†   Ú findNodesNamed.<locals>.<lambda>  s   € °!·*±*ÀÒ2Dr   rŒ   )ru   r–   s     r   ÚfindNodesNamedr˜     s   € Ü�VÓDÓEÐEr   c                 ó¢   • U R                    H?  n[        US5      (       a   UR                  SUR                  -   5        M4  [	        X!5        MA     g )Nrd   ro   )r   r   rc   rd   ÚwriteNodeData)r"   ÚoldioÚsubnodes      r   rš   rš     s:   € Ø—?”?ˆÜ�7˜F×#Ñ#Ø�K‰K˜˜WŸ\™\Ñ)Ö*ä˜'Ö)ò	 #r   c                 óL   • [        5       n[        X5        UR                  5       $ rb   )r   rš   Úgetvalue)r"   r›   s     r   ÚgetNodeTextrŸ   '  s   € Ü‹J€EÜ�$ÔØ�>‰>ÓÐr   c                 ód   • / nU (       a&  UR                  U 5        U R                  n U (       a  M&  U$ rb   )r?   Ú
parentNode)r"   Úls     r   Ú
getParentsr£   -  s,   € Ø
€AÞ
Ø	�‰�ŒØ�‰ˆ÷ ˆ$ð €Hr   c                 ól   • U R                    Vs/ s H  n[        USS5      U:X  d  M  UPM     sn$ s  snf )zfnamedChildren(parent, nodeName) -> children (not descendants) of parent
that have tagName == nodeName
r€   ro   )r   r�   )ru   r•   r„   s      r   ÚnamedChildrenr¥   5  s4   € ð ×(Ò(ÓRÒ(�!¬G°A°yÀ"Ó,EÈÑ,Q�AÑ(ÑRÐRùÒRs   �1¨1))ÚidÚclassÚmodelÚpattern)é   )r   ro   rb   )+rp   ÚwarningsÚior   Úincrementalr   r   Útwisted.webr   Útwisted.web.microdomr   r   r	   ÚformatÚwarningStringÚwarnÚDeprecationWarningÚ	Exceptionr   r    r,   r4   r6   r9   r8   r>   rI   rM   rQ   r]   ÚTextr_   rs   ry   r|   rˆ   r�   r’   r˜   rš   rŸ   r£   r¥   r   r   r   Ú<module>r¶      sè   ðñ
ó
 Ý ç 1å  ß GÑ Gà=×DÑDÙ‘W˜Y¨¨B°Ó2Ó3ó€ð 	‡‚ˆmÐ/¸AÒ >ñ Ù ô	�iô 	ò)ôò*	"òòòôò&1ò
5ò
4ô#ô03ˆh�m‰mô 3ô2
ôô
òò	ô

òFò*òòóSr   