ó
    ×›‘hÖw  ã                   óÂ  • S r SSKrSSKrSSKrSSKJr  SSKJr  SSKJ	r	J
r
JrJrJrJrJrJrJrJrJr  SSKJrJr  SSKJrJr  SSKJr  SS	KJr  SS
KJr  SSK J!r!  SSK"J#r#  SSK$J%r%  SSK&J'r'  SSK(J)r)  SSK*J+r+J,r,  SSK-J.r.J/r/J0r0  SSK1J2r2J3r3J4r4J5r5  SSK6J7r7J8r8J9r9  S r:S\;S\8S\;4S jr< " S S\)Rz                  5      r> " S S\)Rz                  5      r? " S S\)Rz                  5      r@ " S S \+5      rA " S! S"\+5      rB " S# S$\+5      rC " S% S&\+5      rD " S' S(5      rES)rF " S* S+\RŽ                  \R�                  5      rIS,\\	\   \J4   S\S-   4S. jrK\" \95       " S/ S05      5       rL " S1 S2\+5      rMS3 rNS4rO\" 5       rP\" \95       " S5 S65      5       rQ\" \95       " S7 S85      5       rR1 S9krS " S: S;5      rT\T" 5       rU  SAS\8S<\7S=\\;   S>\\\#/S?4      S\V4
S@ jjrWg)BzG
twisted.web.util and twisted.web.template merged to avoid cyclic deps
é    N)ÚOrderedDict©Úescape)ÚIOÚAnyÚAnyStrÚCallableÚDictÚListÚMappingÚOptionalÚTupleÚUnionÚcast)ÚhandlerÚmake_parser)ÚAttributesNSImplÚLocator)Úimplementer)ÚDeferred)ÚLogger)Úurlpath)ÚFailure)ÚFilePath)ÚfullyQualifiedName)Úresource)ÚElementÚrenderer)ÚFlattenableÚflattenÚflattenString)ÚCDATAÚCommentÚTagÚslot)ÚIRenderableÚIRequestÚITemplateLoaderc                 ó    • S[        U 5       S3$ )a/  
Wraps <pre> tags around some text and HTML-escape it.

This is here since once twisted.web.html was deprecated it was hard to
migrate the html.PRE from current code to twisted.web.template.

For new code consider using twisted.web.template.

@return: Escaped text wrapped in <pre> tags.
@rtype: C{str}
z<pre>z</pre>r   )Útexts    Ú^C:\Users\psant\Downloads\Noiseback\school\venv\Lib\site-packages\twisted/web/_template_util.pyÚ_PREr,   ,   s   € ð ”6˜$“<�. Ð'Ð'ó    ÚURLÚrequestÚreturnc                 óè   • [        U [        5      (       d  [        S5      eUR                  SS5        UR	                  U 5        SS[        U R                  S5      5      R                  S5      0-  nU$ )a‹  
Generate a redirect to the given location.

@param URL: A L{bytes} giving the location to which to redirect.

@param request: The request object to use to generate the redirect.
@type request: L{IRequest<twisted.web.iweb.IRequest>} provider

@raise TypeError: If the type of C{URL} a L{str} instead of L{bytes}.

@return: A L{bytes} containing HTML which tries to convince the client
    agent
    to visit the new location even if it doesn't respect the I{FOUND}
    response code.  This is intended to be returned from a render method,
    eg::

        def render_GET(self, request):
            return redirectTo(b"http://example.com/", request)
zURL must be bytess   Content-Types   text/html; charset=utf-8sÀ   
<html>
    <head>
        <meta http-equiv="refresh" content="0;URL=%(url)s">
    </head>
    <body bgcolor="#FFFFFF" text="#000000">
    <a href="%(url)s">click here</a>
    </body>
</html>
s   urlúutf-8)Ú
isinstanceÚbytesÚ	TypeErrorÚ	setHeaderÚredirectr   ÚdecodeÚencode)r.   r/   Úcontents      r+   Ú
redirectTor;   ;   st   € ô( �cœ5×!Ñ!ÜÐ+Ó,Ð,Ø×Ñ�oÐ'BÔCØ×Ñ�SÔð	ð 	”�s—z‘z 'Ó*Ó+×2Ñ2°7Ó;ðñ€Gð €Nr-   c                   óD   ^ • \ rS rSrSrSrS\4U 4S jjrS rS r	Sr
U =r$ )	ÚRedirectéd   z‹
Resource that redirects to a specific URL.

@ivar url: Redirect target URL to put in the I{Location} response header.
@type url: L{bytes}
TÚurlc                 ó.   >• [         TU ]  5         Xl        g ©N)ÚsuperÚ__init__r?   )Úselfr?   Ú	__class__s     €r+   rC   ÚRedirect.__init__n   s   ø€ Ü‰ÑÔØ�r-   c                 ó.   • [        U R                  U5      $ rA   )r;   r?   )rD   r/   s     r+   ÚrenderÚRedirect.renderr   s   € Ü˜$Ÿ(™( GÓ,Ð,r-   c                 ó   • U $ rA   © ©rD   Únamer/   s      r+   ÚgetChildÚRedirect.getChildu   ó   € Øˆr-   )r?   )Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__ÚisLeafr4   rC   rH   rN   Ú__static_attributes__Ú__classcell__)rE   s   @r+   r=   r=   d   s*   ø† ñð €Fð˜E÷ ò-÷ð r-   r=   c                   ó.   • \ rS rSrSrSrS\S\4S jrSr	g)	ÚParentRedirectéy   u–  
Redirect to the nearest directory and strip any query string.

This generates redirects like::

    /              â†’  /
    /foo           â†’  /
    /foo?bar       â†’  /
    /foo/          â†’  /foo/
    /foo/bar       â†’  /foo/
    /foo/bar?baz   â†’  /foo/

However, the generated I{Location} header contains an absolute URL rather
than a path.

The response is the same regardless of HTTP method.
é   r/   r0   c                 ó¢   • [        [        R                  R                  U5      R	                  5       5      R                  S5      n[        X!5      $ )z>
Respond to all requests by redirecting to nearest directory.
Úascii)Ústrr   ÚURLPathÚfromRequestÚherer9   r;   )rD   r/   rb   s      r+   rH   ÚParentRedirect.renderŽ   s<   € ô ”7—?‘?×.Ñ.¨wÓ7×<Ñ<Ó>Ó?×FÑFÀwÓOˆÜ˜$Ó(Ð(r-   rK   N)
rQ   rR   rS   rT   rU   rV   r'   r4   rH   rW   rK   r-   r+   rZ   rZ   y   s!   † ñð$ €Fð)˜hð )¨5÷ )r-   rZ   c                   ó:   • \ rS rSrSrSrS rS rS rS r	S r
S	rg
)ÚDeferredResourceé–   zH
I wrap up a Deferred that will eventually result in a Resource
object.
r\   c                 óN   • [         R                  R                  U 5        Xl        g rA   )r   ÚResourcerC   Úd)rD   ri   s     r+   rC   ÚDeferredResource.__init__ž   s   € Ü×Ñ×"Ñ" 4Ô(Ø�r-   c                 ó   • U $ rA   rK   rL   s      r+   rN   ÚDeferredResource.getChild¢   rP   r-   c                 ó’   • U R                   R                  U R                  U5      R                  U R                  U5        SSKJn  U$ )Nr   )ÚNOT_DONE_YET)ri   ÚaddCallbackÚ_cbChildÚ
addErrbackÚ_ebChildÚtwisted.web.serverrn   )rD   r/   rn   s      r+   rH   ÚDeferredResource.render¥   s4   € Ø�‰×Ñ˜4Ÿ=™=¨'Ó2×=Ñ=¸d¿m¹mÈWÔUÝ3àÐr-   c                 óN   • UR                  [        R                  " X5      5        g rA   )rH   r   ÚgetChildForRequest)rD   Úchildr/   s      r+   rp   ÚDeferredResource._cbChild«   s   € Ø�‰”x×2Ò2°5ÓBÕCr-   c                 ó&   • UR                  U5        g rA   )ÚprocessingFailed)rD   Úreasonr/   s      r+   rr   ÚDeferredResource._ebChild®   s   € Ø× Ñ  Õ(r-   )ri   N)rQ   rR   rS   rT   rU   rV   rC   rN   rH   rp   rr   rW   rK   r-   r+   re   re   –   s(   † ñð
 €FòòòòDõ)r-   re   c                   ó>   • \ rS rSrSrS r\S 5       r\S 5       rSr	g)Ú_SourceLineElementé²   zï
L{_SourceLineElement} is an L{IRenderable} which can render a single line of
source code.

@ivar number: A C{int} giving the line number of the source code to be
    rendered.
@ivar source: A C{str} giving the source code to be rendered.
c                 óH   • [         R                  " X5        X l        X0l        g rA   )r   rC   ÚnumberÚsource)rD   Úloaderr�   r‚   s       r+   rC   Ú_SourceLineElement.__init__¼   s   € Ü×Ò˜Ô&ØŒØ�r-   c                 óF   • U" U R                   R                  SS5      5      $ )z1
Render the line of source as a child of C{tag}.
z  u    Â )r‚   Úreplace©rD   r/   Útags      r+   Ú
sourceLineÚ_SourceLineElement.sourceLineÁ   s!   € ñ
 �4—;‘;×&Ñ& tÐ-BÓCÓDÐDr-   c                 ó8   • U" [        U R                  5      5      $ )z.
Render the line number as a child of C{tag}.
)r_   r�   r‡   s      r+   Ú
lineNumberÚ_SourceLineElement.lineNumberÈ   s   € ñ
 ”3�t—{‘{Ó#Ó$Ð$r-   )r�   r‚   N)
rQ   rR   rS   rT   rU   rC   r   r‰   rŒ   rW   rK   r-   r+   r~   r~   ²   s6   † ñòð
 ñEó ðEð ñ%ó ó%r-   r~   c                   ó4   • \ rS rSrSrS rS r\S 5       rSr	g)Ú_SourceFragmentElementéÐ   a¢  
L{_SourceFragmentElement} is an L{IRenderable} which can render several lines
of source code near the line number of a particular frame object.

@ivar frame: A L{Failure<twisted.python.failure.Failure>}-style frame object
    for which to load a source line to render.  This is really a tuple
    holding some information from a frame object.  See
    L{Failure.frames<twisted.python.failure.Failure>} for specifics.
c                 ó<   • [         R                  " X5        X l        g rA   ©r   rC   Úframe©rD   rƒ   r“   s      r+   rC   Ú_SourceFragmentElement.__init__Û   ó   € Ü×Ò˜Ô&Ø�
r-   c              #   óÊ   #   • U R                   S   nU R                   S   n[        US-
  US-   5       H+  nU[        R                  " X5      R	                  5       4v •  M-     g7f)zü
Find the source line references by C{self.frame} and yield, in source
line order, it and the previous and following lines.

@return: A generator which yields two-tuples.  Each tuple gives a source
    line number and the contents of that source line.
r\   é   N)r“   ÚrangeÚ	linecacheÚgetlineÚrstrip)rD   ÚfilenamerŒ   ÚsnipLineNumbers       r+   Ú_getSourceLinesÚ&_SourceFragmentElement._getSourceLinesß   sZ   é € ð —:‘:˜a‘=ˆØ—Z‘Z ‘]ˆ
Ü# J°¡N°JÀ±NÖCˆNØ!¤9×#4Ò#4°XÓ#N×#UÑ#UÓ#WÐXÔXò Dùs   ‚A!A#c           	   #   óÎ   #   • U R                  5        HM  u  p4UR                  5       nX0R                  S   :X  a  SnOSn[        U" S0 SU0D65      n[	        XsU5      v •  MO     g7f)zÕ
Render the source line indicated by C{self.frame} and several
surrounding lines.  The active line will be given a I{class} of
C{"snippetHighlightLine"}.  Other lines will be given a I{class} of
C{"snippetLine"}.
r˜   ÚsnippetHighlightLineÚsnippetLineÚclassNrK   )rŸ   Úcloner“   Ú	TagLoaderr~   )rD   r/   rˆ   rŒ   r‰   ÚnewTagÚcssClassrƒ   s           r+   ÚsourceLinesÚ"_SourceFragmentElement.sourceLinesì   sd   é € ð '+×&:Ñ&:Ö&<Ñ"ˆJØ—Y‘Y“[ˆFØŸZ™Z¨™]Ó*Ø1‘à(�Ü™vÑ<¨°(Ð(;Ñ<Ó=ˆFÜ$ V¸ÓDÔDò '=ùs   ‚A#A%©r“   N)
rQ   rR   rS   rT   rU   rC   rŸ   r   r©   rW   rK   r-   r+   r�   r�   Ð   s(   † ñòòYð ñEó óEr-   r�   c                   ó^   • \ rS rSrSrS r\S 5       r\S 5       r\S 5       r	\S 5       r
Srg	)
Ú_FrameElementéþ   a”  
L{_FrameElement} is an L{IRenderable} which can render details about one
frame from a L{Failure<twisted.python.failure.Failure>}.

@ivar frame: A L{Failure<twisted.python.failure.Failure>}-style frame object
    for which to load a source line to render.  This is really a tuple
    holding some information from a frame object.  See
    L{Failure.frames<twisted.python.failure.Failure>} for specifics.
c                 ó<   • [         R                  " X5        X l        g rA   r’   r”   s      r+   rC   Ú_FrameElement.__init__	  r–   r-   c                 ó,   • U" U R                   S   5      $ )zI
Render the name of the file this frame references as a child of C{tag}.
r\   r«   r‡   s      r+   r�   Ú_FrameElement.filename  ó   € ñ
 �4—:‘:˜a‘=Ó!Ð!r-   c                 ó>   • U" [        U R                  S   5      5      $ )zK
Render the source line number this frame references as a child of
C{tag}.
r˜   )r_   r“   r‡   s      r+   rŒ   Ú_FrameElement.lineNumber  s   € ñ ”3�t—z‘z !‘}Ó%Ó&Ð&r-   c                 ó,   • U" U R                   S   5      $ )zF
Render the function name this frame references as a child of C{tag}.
r   r«   r‡   s      r+   ÚfunctionÚ_FrameElement.function  r³   r-   c                 ó@   • [        [        U5      U R                  5      $ )zV
Render the source code surrounding the line this frame references,
replacing C{tag}.
)r�   r¦   r“   r‡   s      r+   r‚   Ú_FrameElement.source#  s   € ô &¤i°£n°d·j±jÓAÐAr-   r«   N)rQ   rR   rS   rT   rU   rC   r   r�   rŒ   r·   r‚   rW   rK   r-   r+   r­   r­   þ   s^   † ñòð ñ"ó ð"ð ñ'ó ð'ð ñ"ó ð"ð ñBó óBr-   r­   c                   ó.   • \ rS rSrSrS r\S 5       rSrg)Ú_StackElementi,  zO
L{_StackElement} renders an L{IRenderable} which can render a list of frames.
c                 ó<   • [         R                  " X5        X l        g rA   )r   rC   ÚstackFrames)rD   rƒ   r¾   s      r+   rC   Ú_StackElement.__init__1  s   € Ü×Ò˜Ô&Ø&Õr-   c           	      óˆ   • U R                    Vs/ s H&  n[        [        UR                  5       5      U5      PM(     sn$ s  snf )zG
Render the list of frames in this L{_StackElement}, replacing C{tag}.
)r¾   r­   r¦   r¥   )rD   r/   rˆ   r“   s       r+   ÚframesÚ_StackElement.frames5  s@   € ð GK×FVÒFVó
ÚFV¸UŒMœ) C§I¡I£KÓ0°%Ö8ÑFVñ
ð 	
ùò 
s   �-?)r¾   N)	rQ   rR   rS   rT   rU   rC   r   rÁ   rW   rK   r-   r+   r¼   r¼   ,  s    † ñò'ð ñ
ó ó
r-   r¼   c                   óœ   • \ rS rSrSrSS\S    4S jjrSS\\   S\\   S\\   4S	 jjrS\\   S
\\   SS4S jr	S\\   S\\   4S jr
Srg)Ú
_NSContexti?  zD
A mapping from XML namespaces onto their prefixes in the document.
NÚparentc                 ó^   • Xl         Ub  [        UR                  5      U l        gSS0U l        g)zM
Pull out the parent's namespaces, if there's no parent then default to
XML.
Nz$http://www.w3.org/XML/1998/namespaceÚxml)rÅ   r   Únss)rD   rÅ   s     r+   rC   Ú_NSContext.__init__D  s+   € ð
 ŒØÑÜ;FÀvÇzÁzÓ;RˆD�Hà>ÀÐFˆD�Hr-   Úkri   r0   c                 ó8   • U R                   R                  X5      $ )zD
Get a prefix for a namespace.

@param d: The default prefix value.
)rÈ   Úget)rD   rÊ   ri   s      r+   rÌ   Ú_NSContext.getO  s   € ð �x‰x�|‰|˜AÓ!Ð!r-   Úvc                 ó:   • U R                   R                  X5        g)z8
Proxy through to setting the prefix for the namespace.
N)rÈ   Ú__setitem__)rD   rÊ   rÎ   s      r+   rÐ   Ú_NSContext.__setitem__W  s   € ð 	�‰×Ñ˜QÕ"r-   c                 ó8   • U R                   R                  U5      $ )z8
Proxy through to getting the prefix for the namespace.
)rÈ   Ú__getitem__)rD   rÊ   s     r+   rÓ   Ú_NSContext.__getitem__]  s   € ð �x‰x×#Ñ# AÓ&Ð&r-   )rÈ   rÅ   rA   )rQ   rR   rS   rT   rU   r   rC   r_   rÌ   rÐ   rÓ   rW   rK   r-   r+   rÄ   rÄ   ?  s}   † ññ	G˜x¨Ñ5õ 	Gñ"�X˜c‘]ð " x°¡}ð "ÀÈÁõ "ð#˜X c™]ð #¨x¸©}ð #Àô #ð'˜X c™]ð '¨x¸©}÷ 'r-   rÄ   z4http://twistedmatrix.com/ns/twisted.web.template/0.1c                   óP  • \ rS rSrSrS\\   4S jrS\SS4S jr	S$S	 jr
S$S
 jrS\S\SS4S jrS\\   S\SS4S jrS\\   SS4S jrS\\\4   S\\   S\SS4S jrS\SS4S jrS\\\4   S\\   SS4S jrS\S\S\SS4S jrS\SS4S jrS$S jrS$S  jrS!\SS4S" jrS#rg)%Ú_ToStanig  zX
A SAX parser which converts an XML document to the Twisted STAN
Document Object Model.
ÚsourceFilenamec                 ó<   • Xl         [        5       U l        SU l        g)z@
@param sourceFilename: the filename the XML was loaded out of.
FN)r×   rÄ   Ú	prefixMapÚinCDATA)rD   r×   s     r+   rC   Ú_ToStan.__init__m  s   € ð -ÔÜ#›ˆŒØˆ�r-   Úlocatorr0   Nc                 ó   • Xl         g)zI
Set the document locator, which knows about line and character numbers.
N)rÜ   )rD   rÜ   s     r+   ÚsetDocumentLocatorÚ_ToStan.setDocumentLocatoru  s	   € ð �r-   c                 óP   • / U l         U R                   U l        / U l        / U l        g)z
Initialise the document.
N)ÚdocumentÚcurrentÚstackÚ
xmlnsAttrs©rD   s    r+   ÚstartDocumentÚ_ToStan.startDocument{  s$   € ð $&ˆŒØ—}‘}ˆŒØ "ˆŒ
Ø13ˆ�r-   c                 ó   • g)z
Document ended.
NrK   rå   s    r+   ÚendDocumentÚ_ToStan.endDocument‡  ó   � r-   ÚtargetÚdatac                 ó   • g)z&
Processing instructions are ignored.
NrK   )rD   rì   rí   s      r+   ÚprocessingInstructionÚ_ToStan.processingInstructionŒ  rë   r-   ÚprefixÚuric                 óì   • [        U R                  5      U l        XR                  U'   U[        :X  a  gUc  U R                  R	                  SU45        gU R                  R	                  SU-  U45        g)z¯
Set up the prefix mapping, which maps fully qualified namespace URIs
onto namespace prefixes.

This gets called before startElementNS whenever an C{xmlns} attribute
is seen.
NÚxmlnszxmlns:%s)rÄ   rÙ   ÚTEMPLATE_NAMESPACErä   Úappend)rD   rñ   rò   s      r+   ÚstartPrefixMappingÚ_ToStan.startPrefixMapping‘  sg   € ô $ D§N¡NÓ3ˆŒØ$�‰�sÑð Ô$Ó$Øð ‰>Ø�O‰O×"Ñ" G¨S >Õ2à�O‰O×"Ñ" J°Ñ$7¸Ð#=Õ>r-   c                 óP   • U R                   R                  nUc   S5       eX l         g)zJ
"Pops the stack" on the prefix mapping.

Gets called after endElementNS.
Nz$More prefix mapping ends than starts)rÙ   rÅ   )rD   rñ   rÅ   s      r+   ÚendPrefixMappingÚ_ToStan.endPrefixMapping§  s*   € ð —‘×&Ñ&ˆØÑ!ÐIÐ#IÓIÐ!Ø�r-   ÚnamespaceAndNameÚqnameÚattrsc                 ó  • U R                   nU R                  R                  5       nU R                  R                  5       nUu  pxU[        :X  am  US:X  a  SnOdUS:X  a^   US   n	[        US   U	UUUS9n
U R                  R                  U
5        U R                  R                  U
5        U
R                  U l	        gSn[        U5      n[        UR                  5       5       H"  u  pÞUu  nnU[        :w  a  M  US:X  d  M  UnXÍ	 M$     [        5       nUR                  5        H6  u  u  nnnU R                  R                  U5      nUc  UnOU S	U 3nUUU'   M8     U[        :X  aœ  US
:X  a–  U R                  (       d  [!        S[         S35      eSU;  a  [!        S[         S35      e[#        SUUUUS9nUU R                  S   R$                  US   '   U R                  R                  U5        UR                  U l	        gU R&                  (       a+  UR)                  [        U R&                  5      5        / U l        U[        :w  a)  Ub&  U R                  U   nUb  U R                  U    S	U 3n[#        U[        [+        [,        [.        [0        [2        4   [2        4   U5      5      UUUUS9nU R                  R                  U5        U R                  R                  U5        UR                  U l	        g! [
         a    Sn	 GN£f = f)a%  
Gets called when we encounter a new xmlns attribute.

@param namespaceAndName: a (namespace, name) tuple, where name
    determines which type of action to take, if the namespace matches
    L{TEMPLATE_NAMESPACE}.
@param qname: ignored.
@param attrs: attributes on the element being started.
ÚtransparentÚ r%   )NÚdefaultN)NrM   )r  r�   rŒ   ÚcolumnNumberrH   Ú:Úattrz<{z}attr> as top-level elementrM   z }attr> requires a name attribute)rH   r�   rŒ   r  éÿÿÿÿ)Ú
attributesrH   r�   rŒ   r  )r×   rÜ   ÚgetLineNumberÚgetColumnNumberrõ   ÚKeyErrorr%   rã   rö   râ   Úchildrenr   ÚlistÚitemsrÙ   rÌ   ÚAssertionErrorr$   r  rä   Úupdater   r   r   r4   r_   )rD   rü   rý   rþ   r�   rŒ   r  ÚnsrM   r  ÚslrH   ÚorderedrÊ   rÎ   ÚattrNSÚjustTheNameÚnonTemplateAttrsÚattrNsÚattrNameÚnsPrefixÚattrKeyÚelrñ   s                           r+   ÚstartElementNSÚ_ToStan.startElementNS±  s  € ð  ×&Ñ&ˆØ—\‘\×/Ñ/Ó1ˆ
Ø—|‘|×3Ñ3Ó5ˆà#‰ˆØÔ#Ó#Ø�}Ó$Ø‘Ø˜“ð#à#Ð$5Ñ6�Gô
 Ø˜.Ñ)Ø#Ø%Ø)Ø!-ñ�ð —
‘
×!Ñ! "Ô%Ø—‘×#Ñ# BÔ'Ø!Ÿ{™{�”Øàˆä˜eÓ$ˆÜ˜Ÿ™›Ö)‰DˆAØ"#ÑˆF�KØÔ+Ó+ÙØ˜hÕ&Ø�Ø’Jñ *ô '›=ÐØ%,§]¡]¦_Ñ!ÑˆV�X Ø—~‘~×)Ñ)¨&Ó1ˆHØÑØ"‘à%˜J a¨ zÐ2�Ø()Ð˜WÓ%ñ &5ð Ô#Ó#¨°«Ø—:—:ä$ØÔ,Ð-Ð-IÐJóð ð Ð-Ó-ä$ØÔ,Ð-Ð-NÐOóð ô ØØØ!Ø%Ø)ñˆBð CEˆD�J‰J�r‰N×%Ñ%Ð&6°vÑ&>Ñ?Ø�J‰J×Ñ˜bÔ!ØŸ;™;ˆDŒLØð �?�?Ø×#Ñ#¤K°·±Ó$@ÔAØ ˆDŒOð Ô#Ó#¨©Ø—^‘^ BÑ'ˆFØÑ!ØŸ.™.¨Ñ,Ð-¨Q¨t¨fÐ5�ÜØÜ"Ü”WœU¤5¬# :Ñ.´Ð3Ñ4Ð6FÓGóð ØØ!Ø%ñ	
ˆð 	�
‰
×Ñ˜"ÔØ�‰×Ñ˜BÔØ—{‘{ˆ�øôs  ó #ð #“Gð#ús   ÁK8 Ë8LÌLÚchc                 óš   • U R                   (       a  U R                  S   R                  U5        gU R                  R                  U5        g)zU
Called when we receive some characters.  CDATA characters get passed
through as is.
r  N)rÚ   rã   rö   râ   )rD   r  s     r+   Ú
charactersÚ_ToStan.characters)  s6   € ð
 �<�<Ø�J‰J�r‰N×!Ñ! "Ô%ØØ�‰×Ñ˜BÕr-   rM   c                 óº   • U R                   R                  5         U R                   (       a  U R                   S   R                  U l        gU R                  U l        g)zz
A namespace tag is closed.  Pop the stack, if there's anything left in
it, otherwise return to the document's namespace.
r  N)rã   Úpopr  râ   rá   )rD   rM   rý   s      r+   ÚendElementNSÚ_ToStan.endElementNS3  s9   € ð
 	�
‰
�‰ÔØ�:�:ØŸ:™: b™>×2Ñ2ˆD�LàŸ=™=ˆD�Lr-   ÚpublicIdÚsystemIdc                 ó   • g©z
DTDs are ignored.
NrK   )rD   rM   r%  r&  s       r+   ÚstartDTDÚ_ToStan.startDTD>  rë   r-   Úargsc                 ó   • gr(  rK   )rD   r+  s     r+   ÚendDTDÚ_ToStan.endDTDC  rë   r-   c                 óH   • SU l         U R                  R                  / 5        g)z?
We're starting to be in a CDATA element, make a note of this.
TN)rÚ   rã   rö   rå   s    r+   Ú
startCDATAÚ_ToStan.startCDATAH  s   € ð ˆŒØ�
‰
×Ñ˜"Õr-   c                 ó¬   • SU l         SR                  U R                  R                  5       5      nU R                  R                  [        U5      5        g)zq
We're no longer in a CDATA element.  Collect up the characters we've
parsed and put them in a new CDATA object.
Fr  N)rÚ   Újoinrã   r"  râ   rö   r"   )rD   Úcomments     r+   ÚendCDATAÚ_ToStan.endCDATAO  s:   € ð
 ˆŒØ—'‘'˜$Ÿ*™*Ÿ.™.Ó*Ó+ˆØ�‰×ÑœE '›NÕ+r-   r:   c                 óL   • U R                   R                  [        U5      5        g)z-
Add an XML comment which we've encountered.
N)râ   rö   r#   )rD   r:   s     r+   r4  Ú_ToStan.commentX  s   € ð 	�‰×ÑœG GÓ,Õ-r-   )râ   rá   rÚ   rÜ   rÙ   r×   rã   rä   )r0   N)rQ   rR   rS   rT   rU   r   r_   rC   r   rÞ   ræ   ré   rï   r÷   rú   r   r   r  r  r#  r)  Úobjectr-  r0  r5  r4  rW   rK   r-   r+   rÖ   rÖ   g  sJ  † ñð
 x°¡}ô ð¨'ð °dô ô
4ôð
¨Cð °sð ¸tô ð
?¨°#©ð ?¸Sð ?ÀTô ?ð,  x°¡}ð  ¸ô  ðv#à  S ™/ðv#ð ˜‰}ðv#ð  ð	v#ð
 
ôv#ðp ˜Sð   Tô  ð	)  s¨C x¡ð 	)¸À#¹ð 	)È4ô 	)ð˜Sð ¨Cð ¸3ð À4ô ð
˜Fð  tô ô
ô,ð.˜sð . t÷ .r-   rÖ   Úflr   c                 ó   • [        5       nUR                  [        R                  S5        UR                  [        R                  S5        UR                  [        R
                  S5        UR                  [        R                  S5        [        [        U SS5      5      nUR                  U5        UR                  U5        UR                  [        R                  U5        UR                  U 5        UR                  $ )z�
Perform a SAX parse of an XML document with the _ToStan class.

@param fl: The XML document to be parsed.

@return: a C{list} of Stan objects.
r   r\   rM   N)r   Ú
setFeaturer   Úfeature_validationÚfeature_namespacesÚfeature_external_gesÚfeature_external_pesrÖ   ÚgetattrÚsetContentHandlerÚsetEntityResolverÚsetPropertyÚproperty_lexical_handlerÚparserá   )r:  ÚparserÚss      r+   Ú_flatsaxParserI  _  s¾   € ô ‹]€FØ
×Ñ”g×0Ñ0°!Ô4Ø
×Ñ”g×0Ñ0°!Ô4Ø
×Ñ”g×2Ñ2°AÔ6Ø
×Ñ”g×2Ñ2°AÔ6ä”˜˜F DÓ)Ó*€AØ
×Ñ˜QÔØ
×Ñ˜QÔØ
×Ñ”w×7Ñ7¸Ô;à
‡L�L�Ôà�:‰:Ðr-   c                   óD   • \ rS rSrSrS\\\4   4S jrS\	S   4S jr
Srg	)
Ú	XMLStringiw  z@
An L{ITemplateLoader} that loads and parses XML from a string.
rH  c                 ó˜   • [        U[        5      (       d  UR                  S5      n[        [        R
                  " U5      5      U l        g)z˜
Run the parser on a L{io.StringIO} copy of the string.

@param s: The string from which to load the XML.
@type s: L{str}, or a UTF-8 encoded L{bytes}.
Úutf8N)r3   r_   r8   rI  ÚioÚStringIOÚ_loadedTemplate)rD   rH  s     r+   rC   ÚXMLString.__init__}  s7   € ô ˜!œS×!Ñ!Ø—‘˜Ó ˆAä4AÄ"Ç+Â+ÈaÃ.Ó4QˆÔØ"r-   r0   r   c                 ó   • U R                   $ )z5
Return the document.

@return: the loaded document.
©rP  rå   s    r+   ÚloadÚXMLString.loadŠ  s   € ð ×#Ñ#Ð#r-   rS  N)rQ   rR   rS   rT   rU   r   r_   r4   rC   r   rT  rW   rK   r-   r+   rK  rK  w  s-   † ñð#˜%  U 
Ñ+ô #ð$�d˜=Ñ)÷ $r-   rK  c                   ób   • \ rS rSrSr\" S5      rS
S jr\S 5       r	\S 5       r
\S 5       rS	rg)ÚFailureElementi“  zô
L{FailureElement} is an L{IRenderable} which can render detailed information
about a L{Failure<twisted.python.failure.Failure>}.

@ivar failure: The L{Failure<twisted.python.failure.Failure>} instance which
    will be rendered.

@since: 12.1
ao  
<div xmlns:t="http://twistedmatrix.com/ns/twisted.web.template/0.1">
  <style type="text/css">
    div.error {
      color: red;
      font-family: Verdana, Arial, helvetica, sans-serif;
      font-weight: bold;
    }

    div {
      font-family: Verdana, Arial, helvetica, sans-serif;
    }

    div.stackTrace {
    }

    div.frame {
      padding: 1em;
      background: white;
      border-bottom: thin black dashed;
    }

    div.frame:first-child {
      padding: 1em;
      background: white;
      border-top: thin black dashed;
      border-bottom: thin black dashed;
    }

    div.location {
    }

    span.function {
      font-weight: bold;
      font-family: "Courier New", courier, monospace;
    }

    div.snippet {
      margin-bottom: 0.5em;
      margin-left: 1em;
      background: #FFFFDD;
    }

    div.snippetHighlightLine {
      color: red;
    }

    span.code {
      font-family: "Courier New", courier, monospace;
    }
  </style>

  <div class="error">
    <span t:render="type" />: <span t:render="value" />
  </div>
  <div class="stackTrace" t:render="traceback">
    <div class="frame" t:render="frames">
      <div class="location">
        <span t:render="filename" />:<span t:render="lineNumber" /> in
        <span class="function" t:render="function" />
      </div>
      <div class="snippet" t:render="source">
        <div t:render="sourceLines">
          <span class="lineno" t:render="lineNumber" />
          <code class="code" t:render="sourceLine" />
        </div>
      </div>
    </div>
  </div>
  <div class="error">
    <span t:render="type" />: <span t:render="value" />
  </div>
</div>
Nc                 ó<   • [         R                  " X5        Xl        g rA   )r   rC   Úfailure)rD   rY  rƒ   s      r+   rC   ÚFailureElement.__init__ë  s   € Ü×Ò˜Ô&Ø�r-   c                 óL   • U" [        U R                  R                  5      5      $ )z1
Render the exception type as a child of C{tag}.
)r   rY  Útyper‡   s      r+   r\  ÚFailureElement.typeï  s   € ñ
 Ô% d§l¡l×&7Ñ&7Ó8Ó9Ð9r-   c                 ój   • U" [        U R                  R                  5      R                  S5      5      $ )z2
Render the exception value as a child of C{tag}.
rM  )r_   rY  Úvaluer9   r‡   s      r+   r_  ÚFailureElement.valueö  s)   € ñ
 ”3�t—|‘|×)Ñ)Ó*×1Ñ1°&Ó9Ó:Ð:r-   c                 óT   • [        [        U5      U R                  R                  5      $ )zv
Render all the frames in the wrapped
L{Failure<twisted.python.failure.Failure>}'s traceback stack, replacing
C{tag}.
)r¼   r¦   rY  rÁ   r‡   s      r+   Ú	tracebackÚFailureElement.tracebacký  s   € ô œY s›^¨T¯\©\×-@Ñ-@ÓAÐAr-   ©rY  rA   )rQ   rR   rS   rT   rU   rK  rƒ   rC   r   r\  r_  rb  rW   rK   r-   r+   rW  rW  “  s^   † ññ ðI	óK€FôZð ñ:ó ð:ð ñ;ó ð;ð ñBó óBr-   rW  c                 ó  • / n[        S[        U 5      5      R                  UR                  5        [	        US   [
        5      (       a$  US   R                  S5      R                  SS5      $ US   R                  5         g)zý
Construct an HTML representation of the given failure.

Consider using L{FailureElement} instead.

@type myFailure: L{Failure<twisted.python.failure.Failure>}

@rtype: L{bytes}
@return: A string containing the HTML representation of the given failure.
Nr   r2   r^   Úxmlcharrefreplace)	r!   rW  ÚaddBothrö   r3   r4   r8   r9   ÚraiseException)Ú	myFailureÚresults     r+   ÚformatFailurerk    sm   € ð €FÜ�$œ yÓ1Ó2×:Ñ:¸6¿=¹=ÔIÜ�&˜‘)œU×#Ñ#ð �a‰y×Ñ Ó(×/Ñ/°Ð9LÓMÐMØ
ˆ1�I×ÑÕr-   r\   c                   ó6   • \ rS rSrSrS	S jrS\S   4S jrSrg)
r¦   i'  zB
An L{ITemplateLoader} that loads an existing flattenable object.
r   c                 ó   • Xl         g)z.
@param tag: The object which will be loaded.
N©rˆ   )rD   rˆ   s     r+   rC   ÚTagLoader.__init__-  s   € ð
 #&ŒØ.r-   r0   c                 ó   • U R                   /$ rA   rn  rå   s    r+   rT  ÚTagLoader.load5  s   € Ø—‘ˆzÐr-   rn  N)rˆ   r   )	rQ   rR   rS   rT   rU   rC   r   rT  rW   rK   r-   r+   r¦   r¦   '  s   † ñô/ð�d˜=Ñ)÷ r-   r¦   c                   ób   • \ rS rSrSrS\\   4S jrS\S   4S jr	S\
4S jrS\S   4S	 jrS
rg)ÚXMLFilei9  z>
An L{ITemplateLoader} that loads and parses XML from a file.
Úpathc                 ó~   • [        U[        5      (       d  [        R                  " S[        SS9  SU l         Xl        g)zN
Run the parser on a file.

@param path: The file from which to load the XML.
zhPassing filenames or file objects to XMLFile is deprecated since Twisted 12.1.  Pass a FilePath instead.r˜   )ÚcategoryÚ
stacklevelN)r3   r   ÚwarningsÚwarnÚDeprecationWarningrP  Ú_path)rD   rt  s     r+   rC   ÚXMLFile.__init__?  s?   € ô ˜$¤×)Ñ)Ü�MŠMð@ä+Øò	ð ?CˆÔØ=à$(Œ
Ø1r-   r0   r   c                 óì   • [        U R                  [        5      (       d  [        U R                  5      $ U R                  R	                  S5       n[        U5      sSSS5        $ ! , (       d  f       g= f)z8
Read and parse the XML.

@return: the loaded document.
ÚrN)r3   r{  r   rI  Úopen)rD   Úfs     r+   Ú_loadDocÚXMLFile._loadDocS  sJ   € ô ˜$Ÿ*™*¤h×/Ñ/Ü  §¡Ó,Ð,à—‘—‘ Ô%¨Ü$ QÓ'÷ &×%×%ús   ÁA%Á%
A3c                 ó$   • SU R                   < S3$ )Nz<XMLFile of Ú>)r{  rå   s    r+   Ú__repr__ÚXMLFile.__repr___  s   € Ø˜dŸj™j™^¨1Ð-Ð-r-   c                 ó^   • U R                   c  U R                  5       U l         U R                   $ )zT
Return the document, first loading it if necessary.

@return: the loaded document.
)rP  r�  rå   s    r+   rT  ÚXMLFile.loadb  s*   € ð ×ÑÑ'Ø#'§=¡=£?ˆDÔ Ø×#Ñ#Ð#r-   )rP  r{  N)rQ   rR   rS   rT   rU   r   r   rC   r   r�  r_   r…  rT  rW   rK   r-   r+   rs  rs  9  sE   † ñð2˜X c™]ô 2ð(
(˜$˜}Ñ-ô 
(ð.˜#ô .ð$�d˜=Ñ)÷ $r-   rs  >x   ÚaÚbÚiÚpÚqrH  ÚuÚbrÚddÚdlÚdtÚemÚh1Úh2Úh3Úh4Úh5Úh6ÚhrÚliÚolÚrpÚrtÚtdÚthÚtrÚttÚulÚbdiÚbdoÚbigÚcolÚdelÚdfnÚdirÚdivÚimgÚinsÚkbdÚmapÚnavÚpreÚsubÚsupÚvarÚwbrÚabbrÚareaÚbaseÚbodyÚciteÚcodeÚfontÚformÚheadÚhtmlÚlinkÚmarkÚmenuÚmetaÚrubyÚsampÚspanÚtimeÚasideÚaudioÚembedr“   ÚinputÚlabelÚmeterÚparamÚsmallÚstyleÚtableÚtbodyÚtfootÚtheadÚtitleÚvideoÚappletÚbuttonÚcanvasÚcenterÚfigureÚfooterÚheaderÚhgroupÚiframeÚkeygenÚlegendr9  ÚoptionÚoutputÚscriptÚselectr‚   ÚstrikeÚstrongÚacronymÚaddressÚarticleÚcaptionÚcommandÚdetailsÚisindexÚsectionÚsummaryÚbasefontÚcolgroupÚdatalistÚfieldsetÚframesetÚnoframesÚnoscriptÚoptgroupÚprogressÚtextareaÚ
blockquoteÚ
figcaptionc                   ó*   • \ rS rSrSrS\S\4S jrSrg)Ú_TagFactoryií  af  
A factory for L{Tag} objects; the implementation of the L{tags} object.

This allows for the syntactic convenience of C{from twisted.web.template
import tags; tags.a(href="linked-page.html")}, where 'a' can be basically
any HTML tag.

The class is not exposed publicly because you only ever need one of these,
and we already made it for you.

@see: L{tags}
ÚtagNamer0   c                 óŽ   • US:X  a  [        S5      $ UR                  S5      nU[        ;  a  [        SU< 35      e[        U5      $ )Nr   r  Ú_zunknown tag )r$   rœ   ÚVALID_HTML_TAG_NAMESÚAttributeError)rD   rÿ  s     r+   Ú__getattr__Ú_TagFactory.__getattr__û  sF   € Ø�mÓ#Ü�r“7ˆNà—.‘. Ó%ˆØÔ.Ó.Ü  <°©{Ð!;Ó<Ð<Ü�7‹|Ðr-   rK   N)	rQ   rR   rS   rT   rU   r_   r$   r  rW   rK   r-   r+   rþ  rþ  í  s   † ñð 3ð ¨3÷ r-   rþ  ÚelementÚdoctypeÚ_failElementr   c                 óT  ^ ^• Ub"  T R                  U5        T R                  S5        Tc  [        m[        T UT R                   5      nS[        S[        [
        S      4UU 4S jjnT S.S[        S[        S[        4S	 jjnUR                  U5        UR                  U5        [        $ )
a»  
Render an element or other L{IRenderable}.

@param request: The L{IRequest} being rendered to.
@param element: An L{IRenderable} which will be rendered.
@param doctype: A L{bytes} which will be written as the first line of
    the request, or L{None} to disable writing of a doctype.  The argument
    should not include a trailing newline and will default to the HTML5
    doctype C{'<!DOCTYPE html>'}.

@returns: NOT_DONE_YET

@since: 12.1
Nó   
rY  r0   c                 óÖ   >• [         R                  SU S9  [        TSS 5      nUb3  UR                  (       a"  Tc   e[	        TT" U 5      TR
                  5      $ TR                  S5        g )Nz/An error occurred while rendering the response.rd  Úsitesr   <div style="font-size:800%;background-color:#FFF;color:#F00">An error occurred while rendering the response.</div>)Ú
_moduleLogrY  rA  ÚdisplayTracebacksr    Úwrite)rY  r  r  r/   s     €€r+   ÚebÚrenderElement.<locals>.eb%  st   ø€ Ü×ÑØ=Àwð 	ñ 	
ô �w ¨Ó-ˆØÑ × 6× 6ØÑ+Ð+Ð+Ü˜7¡L°Ó$9¸7¿=¹=ÓIÐIà�M‰MðKôð r-   )r/   rj  r/   c                ó&   • UR                  5         U $ rA   )Úfinish)rj  r/   s     r+   r  ÚrenderElement.<locals>.finish6  s   € Ø�‰ÔØˆr-   )r  rW  r    r   r   r   r9  r'   rq   rg  rn   )r/   r  r  r  ri   r  r  s   `  `   r+   ÚrenderElementr    s    ù€ ð( ÑØ�‰�gÔØ�‰�eÔàÑÜ%ˆä�˜ '§-¡-Ó0€Að”Gð ¤¬°$©Ñ 8÷ ð ð" 7>ò ”vð ¬8ð Ä&õ ð ‡L�L�ÔØ‡I�IˆfÔÜÐr-   )s   <!DOCTYPE html>N)XrU   rN  rš   rx  Úcollectionsr   r¿  r   Útypingr   r   r   r	   r
   r   r   r   r   r   r   Úxml.saxr   r   Úxml.sax.xmlreaderr   r   Úzope.interfacer   Útwisted.internet.deferr   Útwisted.loggerr   Útwisted.pythonr   Útwisted.python.failurer   Útwisted.python.filepathr   Útwisted.python.reflectr   Útwisted.webr   Útwisted.web._elementr   r   Útwisted.web._flattenr   r    r!   Útwisted.web._stanr"   r#   r$   r%   Útwisted.web.iwebr&   r'   r(   r,   r4   r;   rh   r=   rZ   re   r~   r�   r­   r¼   rÄ   rõ   ÚContentHandlerÚEntityResolverrÖ   r_   rI  rK  rW  rk  rn   r  r¦   rs  r  rþ  Útagsr9  r  rK   r-   r+   Ú<module>r)     s2  ðñó 
Û Û Ý #Ý ÷÷ ÷ ñ ÷ )ß 7å &å +Ý !Ý "Ý *Ý ,Ý 5Ý  ß 2ß DÑ Dß 7Ó 7ß CÑ Cò(ð&�Eð & Hð &°ô &ôRˆx× Ñ ô ô*)�X×&Ñ&ô )ô:)�x×(Ñ(ô )ô8%˜ô %ô<+E˜Wô +Eô\+B�Gô +Bô\
�Gô 
÷&"'ñ "'ðJ LÐ ôu.ˆg×$Ñ$ g×&<Ñ&<ô u.ðp�e˜B˜v™J¨˜OÑ,ð °°mÑ1Dô ñ0 ˆ_Ó÷$ð $ó ð$ô6qB�Wô qBòhð8 €Ù‹X€
ñ ˆ_Ó÷ð ó ðñ" ˆ_Ó÷0$ð 0$ó ð0$ònyÐ ÷xñ ñ0 ƒ}€ð  2Ø=Añ	4Øð4àð4ð �e‰_ð4ð ˜8 W I¨yÐ$8Ñ9Ñ:ð	4ð
 ö4r-   