Ë
    oj{  ã                   óÐ  — d Z ddlZddlZddlZddlmZ ddlmZ ddlm	Z	m
Z
mZmZmZmZmZmZmZmZmZ ddlmZmZ ddlmZmZ ddlmZ dd	lmZ dd
lmZ ddl m!Z! ddl"m#Z# ddl$m%Z% ddl&m'Z' ddl(m)Z) ddl*m+Z+m,Z, ddl-m.Z.m/Z/m0Z0 ddl1m2Z2m3Z3m4Z4m5Z5 ddl6m7Z7m8Z8m9Z9 d„ Z:de;de8de;fd„Z< G d„ de)jz                  «      Z> G d„ de>«      Z? G d„ de)jz                  «      Z@ G d„ d e)jz                  «      ZA G d!„ d"e+«      ZB G d#„ d$e+«      ZC G d%„ d&e+«      ZD G d'„ d(e+«      ZE G d)„ d*«      ZFd+ZG G d,„ d-ej�                  ej’                  «      ZJd.ee	e   eKf   ded/   fd0„ZL ee9«       G d1„ d2«      «       ZM G d3„ d4e+«      ZNd5„ ZOd6ZP e«       ZQ ee9«       G d7„ d8«      «       ZR ee9«       G d9„ d:«      «       ZSh d;£ZT G d<„ d=«      ZU eU«       ZV	 	 dCde8d>e7d?ee;   d@eee#gdAf      deWf
dB„ZXy)DzG
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                 ó    — dt        | «      › d�S )aK  
    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    ú</usr/lib/python3/dist-packages/twisted/web/_template_util.pyÚ_PREr,   ,   s   € ð ”6˜$“<�. Ð'Ð'ó    ÚURLÚrequestÚreturnc                 óÞ   — t        | t        «      st        d«      ‚|j                  dd«       |j	                  | «       ddt        | j                  d«      «      j                  d«      iz  }|S )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;   ;   sq   € ô( �cœ5Ô!ÜÐ+Ó,Ð,Ø×Ñ�oÐ'BÔCØ×Ñ�SÔð	ð 	”�s—z‘z 'Ó*Ó+×2Ñ2°7Ó;ðñ€Gð €Nr-   c                   ó8   ‡ — e Zd ZdZdZdefˆ fd„Zd„ Zd„ Zˆ xZ	S )ÚRedirectz›
    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                 ó0   •— t         ‰| �  «        || _        y ©N)ÚsuperÚ__init__r>   )Úselfr>   Ú	__class__s     €r+   rB   zRedirect.__init__n   s   ø€ Ü‰ÑÔØˆ�r-   c                 ó.   — t        | j                  |«      S r@   )r;   r>   )rC   r/   s     r+   ÚrenderzRedirect.renderr   s   € Ü˜$Ÿ(™( GÓ,Ð,r-   c                 ó   — | S r@   © ©rC   Únamer/   s      r+   ÚgetChildzRedirect.getChildu   ó   € Øˆr-   )
Ú__name__Ú
__module__Ú__qualname__Ú__doc__ÚisLeafr4   rB   rF   rK   Ú__classcell__)rD   s   @r+   r=   r=   d   s%   ø„ ñð €Fð˜Eõ ò-ör-   r=   c                   ó   — e Zd ZdZd„ Zd„ Zy)ÚChildRedirectorFc                 ó¸   — |j                  d«      dk(  r0|j                  d«      s|j                  d«      st        d|z  «      ‚t        j	                  | |«       y )Nz://éÿÿÿÿz..ú/zvIt seems you've given me a redirect (%s) that is a child of myself! That's not good, it'll cause an infinite redirect.)ÚfindÚ
startswithÚ
ValueErrorr=   rB   )rC   r>   s     r+   rB   zChildRedirector.__init__}   s[   € ð �X‰X�e‹_ Ò"Ø—^‘^ DÔ)Ø—^‘^ CÔ(äðRð ñ	óð ô 	×Ñ˜$ Õ$r-   c                 óf   — | j                   }|j                  d«      s|dz  }||z  }t        |«      S )NrW   )r>   ÚendswithrT   )rC   rJ   r/   ÚnewUrls       r+   rK   zChildRedirector.getChild�   s4   € Ø—‘ˆØ�‰˜sÔ#Ø�c‰MˆFØ�$‰ˆÜ˜vÓ&Ð&r-   N)rM   rN   rO   rQ   rB   rK   rH   r-   r+   rT   rT   z   s   „ Ø€Fò%ó 'r-   rT   c                   ó$   — e Zd ZdZdZdedefd„Zy)ÚParentRedirectuÆ  
    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                 ó¤   — t        t        j                  j                  |«      j	                  «       «      j                  d«      }t        ||«      S )zN
        Respond to all requests by redirecting to nearest directory.
        Úascii)Ústrr   ÚURLPathÚfromRequestÚherer9   r;   )rC   r/   rf   s      r+   rF   zParentRedirect.renderª   s>   € ô ”7—?‘?×.Ñ.¨wÓ7×<Ñ<Ó>Ó?×FÑFÀwÓOˆÜ˜$ Ó(Ð(r-   N)rM   rN   rO   rP   rQ   r'   r4   rF   rH   r-   r+   r_   r_   •   s!   „ ñð$ €Fð)˜hð )¨5ô )r-   r_   c                   ó2   — e Zd ZdZdZd„ Zd„ Zd„ Zd„ Zd„ Z	y)	ÚDeferredResourcezT
    I wrap up a Deferred that will eventually result in a Resource
    object.
    r`   c                 óP   — t         j                  j                  | «       || _        y r@   )r   ÚResourcerB   Úd)rC   rk   s     r+   rB   zDeferredResource.__init__º   s   € Ü×Ñ×"Ñ" 4Ô(Øˆ�r-   c                 ó   — | S r@   rH   rI   s      r+   rK   zDeferredResource.getChild¾   rL   r-   c                 ó’   — | j                   j                  | j                  |«      j                  | j                  |«       ddlm} |S )Nr   )ÚNOT_DONE_YET)rk   ÚaddCallbackÚ_cbChildÚ
addErrbackÚ_ebChildÚtwisted.web.serverrn   )rC   r/   rn   s      r+   rF   zDeferredResource.renderÁ   s4   € Ø�‰×Ñ˜4Ÿ=™=¨'Ó2×=Ñ=¸d¿m¹mÈWÔUÝ3àÐr-   c                 óN   — |j                  t        j                  ||«      «       y r@   )rF   r   ÚgetChildForRequest)rC   Úchildr/   s      r+   rp   zDeferredResource._cbChildÇ   s   € Ø�‰”x×2Ñ2°5¸'ÓBÕCr-   c                 ó&   — |j                  |«       y r@   )ÚprocessingFailed)rC   Úreasonr/   s      r+   rr   zDeferredResource._ebChildÊ   s   € Ø× Ñ  Õ(r-   N)
rM   rN   rO   rP   rQ   rB   rK   rF   rp   rr   rH   r-   r+   rh   rh   ²   s(   „ ñð
 €FòòòòDó)r-   rh   c                   ó6   — e Zd ZdZd„ Zed„ «       Zed„ «       Zy)Ú_SourceLineElementa  
    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                 óL   — t        j                  | |«       || _        || _        y r@   )r   rB   ÚnumberÚsource)rC   Úloaderr}   r~   s       r+   rB   z_SourceLineElement.__init__Ø   s    € Ü×Ñ˜˜vÔ&ØˆŒØˆ�r-   c                 óF   —  || j                   j                  dd«      «      S )zA
        Render the line of source as a child of C{tag}.
        z  u    Â )r~   Úreplace©rC   r/   Útags      r+   Ú
sourceLinez_SourceLineElement.sourceLineÝ   s!   € ñ
 �4—;‘;×&Ñ& tÐ-BÓCÓDÐDr-   c                 ó8   —  |t        | j                  «      «      S )z>
        Render the line number as a child of C{tag}.
        )rc   r}   r‚   s      r+   Ú
lineNumberz_SourceLineElement.lineNumberä   s   € ñ
 ”3�t—{‘{Ó#Ó$Ð$r-   N)rM   rN   rO   rP   rB   r   r„   r†   rH   r-   r+   r{   r{   Î   s6   „ ñòð
 ñEó ðEð ñ%ó ñ%r-   r{   c                   ó,   — e Zd ZdZd„ Zd„ Zed„ «       Zy)Ú_SourceFragmentElementa¾  
    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                 ó>   — t        j                  | |«       || _        y r@   ©r   rB   Úframe©rC   r   r‹   s      r+   rB   z_SourceFragmentElement.__init__÷   ó   € Ü×Ñ˜˜vÔ&Øˆ�
r-   c              #   óÆ   K  — | j                   d   }| j                   d   }t        |dz
  |dz   «      D ]*  }|t        j                  ||«      j	                  «       f–— Œ, y­w)a$  
        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)rC   Úfilenamer†   ÚsnipLineNumbers       r+   Ú_getSourceLinesz&_SourceFragmentElement._getSourceLinesû   sc   è ø€ ð —:‘:˜a‘=ˆØ—Z‘Z ‘]ˆ
Ü# J°¡N°JÀ±NÓCò 	YˆNØ!¤9×#4Ñ#4°X¸~Ó#N×#UÑ#UÓ#WÐXÓXñ	Yùs   ‚AA!c           	   #   óÎ   K  — | j                  «       D ]N  \  }}|j                  «       }|| j                  d   k(  rd}nd}t         |di d|i¤Ž«      }t	        |||«      –— ŒP y­w)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ÚclassNrH   )r–   Úcloner‹   Ú	TagLoaderr{   )rC   r/   rƒ   r†   r„   ÚnewTagÚcssClassr   s           r+   ÚsourceLinesz"_SourceFragmentElement.sourceLines  sr   è ø€ ð '+×&:Ñ&:Ó&<ò 	EÑ"ˆJ˜
Ø—Y‘Y“[ˆFØ˜TŸZ™Z¨™]Ò*Ø1‘à(�Ü™vÑ<¨°(Ð(;Ñ<Ó=ˆFÜ$ V¨Z¸ÓDÓDñ	Eùs   ‚A#A%N)rM   rN   rO   rP   rB   r–   r   rŸ   rH   r-   r+   rˆ   rˆ   ì   s(   „ ñòòYð ñEó ñEr-   rˆ   c                   óV   — e Zd ZdZd„ Zed„ «       Zed„ «       Zed„ «       Zed„ «       Z	y)Ú_FrameElementa°  
    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                 ó>   — t        j                  | |«       || _        y r@   rŠ   rŒ   s      r+   rB   z_FrameElement.__init__%  r�   r-   c                 ó,   —  || j                   d   «      S )zY
        Render the name of the file this frame references as a child of C{tag}.
        r`   ©r‹   r‚   s      r+   r”   z_FrameElement.filename)  ó   € ñ
 �4—:‘:˜a‘=Ó!Ð!r-   c                 ó>   —  |t        | j                  d   «      «      S )zc
        Render the source line number this frame references as a child of
        C{tag}.
        r�   )rc   r‹   r‚   s      r+   r†   z_FrameElement.lineNumber0  s   € ñ ”3�t—z‘z !‘}Ó%Ó&Ð&r-   c                 ó,   —  || j                   d   «      S )zV
        Render the function name this frame references as a child of C{tag}.
        r   r¤   r‚   s      r+   Úfunctionz_FrameElement.function8  r¥   r-   c                 ó@   — t        t        |«      | j                  «      S )zn
        Render the source code surrounding the line this frame references,
        replacing C{tag}.
        )rˆ   rœ   r‹   r‚   s      r+   r~   z_FrameElement.source?  s   € ô &¤i°£n°d·j±jÓAÐAr-   N)
rM   rN   rO   rP   rB   r   r”   r†   r¨   r~   rH   r-   r+   r¡   r¡     s^   „ ñòð ñ"ó ð"ð ñ'ó ð'ð ñ"ó ð"ð ñBó ñBr-   r¡   c                   ó&   — e Zd ZdZd„ Zed„ «       Zy)Ú_StackElementzW
    L{_StackElement} renders an L{IRenderable} which can render a list of frames.
    c                 ó>   — t        j                  | |«       || _        y r@   )r   rB   ÚstackFrames)rC   r   r­   s      r+   rB   z_StackElement.__init__M  s   € Ü×Ñ˜˜vÔ&Ø&ˆÕr-   c           	      ó‚   — | j                   D �cg c]%  }t        t        |j                  «       «      |«      ‘Œ' c}S c c}w )zW
        Render the list of frames in this L{_StackElement}, replacing C{tag}.
        )r­   r¡   rœ   r›   )rC   r/   rƒ   r‹   s       r+   Úframesz_StackElement.framesQ  s;   € ð GK×FVÑFVö
Ø=BŒMœ) C§I¡I£KÓ0°%Õ8ò
ð 	
ùò 
s   �*<N)rM   rN   rO   rP   rB   r   r¯   rH   r-   r+   r«   r«   H  s    „ ñò'ð ñ
ó ñ
r-   r«   c                   óˆ   — e Zd ZdZdded    fd„Zddee   dee   dee   fd„Zdee   d	ee   ddfd
„Zdee   dee   fd„Z	y)Ú
_NSContextzL
    A mapping from XML namespaces onto their prefixes in the document.
    NÚparentc                 ó^   — || _         |�t        |j                  «      | _        yddi| _        y)ze
        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)rC   r²   s     r+   rB   z_NSContext.__init__`  s-   € ð
 ˆŒØÐÜ;FÀvÇzÁzÓ;RˆD�Hà>ÀÐFˆD�Hr-   Úkrk   r0   c                 ó:   — | j                   j                  ||«      S )z\
        Get a prefix for a namespace.

        @param d: The default prefix value.
        )rµ   Úget)rC   r¶   rk   s      r+   r¸   z_NSContext.getk  s   € ð �x‰x�|‰|˜A˜qÓ!Ð!r-   Úvc                 ó<   — | j                   j                  ||«       y)zH
        Proxy through to setting the prefix for the namespace.
        N)rµ   Ú__setitem__)rC   r¶   r¹   s      r+   r»   z_NSContext.__setitem__s  s   € ð 	�‰×Ñ˜Q Õ"r-   c                 ó8   — | j                   j                  |«      S )zH
        Proxy through to getting the prefix for the namespace.
        )rµ   Ú__getitem__)rC   r¶   s     r+   r½   z_NSContext.__getitem__y  s   € ð �x‰x×#Ñ# AÓ&Ð&r-   r@   )
rM   rN   rO   rP   r   rB   rc   r¸   r»   r½   rH   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                   ó*  — e Zd ZdZdee   fd„Zdeddfd„Zd"d„Z	d"d	„Z
d
ededdfd„Zdee   deddfd„Zdee   ddfd„Zdeeef   dee   deddfd„Zdeddfd„Zdeeef   dee   ddfd„Zdedededdfd„Zdeddfd„Zd"d„Zd"d„Zd eddfd!„Zy)#Ú_ToStanzd
    A SAX parser which converts an XML document to the Twisted STAN
    Document Object Model.
    ÚsourceFilenamec                 ó>   — || _         t        «       | _        d| _        y)zP
        @param sourceFilename: the filename the XML was loaded out of.
        FN)rÀ   r±   Ú	prefixMapÚinCDATA)rC   rÀ   s     r+   rB   z_ToStan.__init__‰  s   € ð -ˆÔÜ#›ˆŒØˆ�r-   Úlocatorr0   Nc                 ó   — || _         y)zY
        Set the document locator, which knows about line and character numbers.
        N)rÄ   )rC   rÄ   s     r+   ÚsetDocumentLocatorz_ToStan.setDocumentLocator‘  s   € ð ˆ�r-   c                 óP   — g | _         | j                   | _        g | _        g | _        y)z*
        Initialise the document.
        N)ÚdocumentÚcurrentÚstackÚ
xmlnsAttrs©rC   s    r+   ÚstartDocumentz_ToStan.startDocument—  s$   € ð $&ˆŒØ—}‘}ˆŒØ "ˆŒ
Ø13ˆ�r-   c                  ó   — y)z!
        Document ended.
        NrH   rÌ   s    r+   ÚendDocumentz_ToStan.endDocument£  ó   � r-   ÚtargetÚdatac                  ó   — y)z6
        Processing instructions are ignored.
        NrH   )rC   rÑ   rÒ   s      r+   ÚprocessingInstructionz_ToStan.processingInstruction¨  rÐ   r-   ÚprefixÚuric                 óê   — t        | j                  «      | _        || j                  |<   |t        k(  ry|€| j                  j	                  d|f«       y| j                  j	                  d|z  |f«       y)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)rC   rÕ   rÖ   s      r+   ÚstartPrefixMappingz_ToStan.startPrefixMapping­  si   € ô $ D§N¡NÓ3ˆŒØ$ˆ�‰�sÑð Ô$Ò$Øð ˆ>Ø�O‰O×"Ñ" G¨S >Õ2à�O‰O×"Ñ" J°Ñ$7¸Ð#=Õ>r-   c                 óP   — | j                   j                  }|€J d«       ‚|| _         y)zb
        "Pops the stack" on the prefix mapping.

        Gets called after endElementNS.
        Nz$More prefix mapping ends than starts)rÂ   r²   )rC   rÕ   r²   s      r+   ÚendPrefixMappingz_ToStan.endPrefixMappingÃ  s,   € ð —‘×&Ñ&ˆØÐ!ÐIÐ#IÓIÐ!Øˆ�r-   ÚnamespaceAndNameÚqnameÚattrsc                 óò  — | j                   }| j                  j                  «       }| j                  j                  «       }|\  }}|t        k(  rn|dk(  rd}nf|dk(  ra	 |d   }	t        |d   |	|||¬«      }
| j                  j                  |
«       | j                  j                  |
«       |
j                  | _	        yd}t        |«      }t        |j                  «       «      D ]  \  }}|\  }}|t        k7  rŒ|dk(  sŒ|}||= Œ! t        «       }|j                  «       D ]4  \  \  }}}| j                  j                  |«      }|€|}n|› d	|› �}|||<   Œ6 |t        k(  r—|d
k(  r’| j                  st!        dt        › d�«      ‚d|vrt!        dt        › d�«      ‚t#        d||||¬«      }|| j                  d   j$                  |d   <   | j                  j                  |«       |j                  | _	        y| j&                  r+|j)                  t        | j&                  «      «       g | _        |t        k7  r'|�%| j                  |   }|�| j                  |   › d	|› �}t#        |t        t+        t,        t.        t0        t2        f   t2        f   |«      «      ||||¬«      }| j                  j                  |«       | j                  j                  |«       |j                  | _	        y# t
        $ r d}	Y �Œ“w xY w)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)NrJ   )rä   r”   r†   ÚcolumnNumberrF   ú:Úattrz<{z}attr> as top-level elementrJ   z }attr> requires a name attribute)rF   r”   r†   rå   rV   )Ú
attributesrF   r”   r†   rå   )rÀ   rÄ   ÚgetLineNumberÚgetColumnNumberrÙ   ÚKeyErrorr%   rÊ   rÚ   rÉ   Úchildrenr   ÚlistÚitemsrÂ   r¸   ÚAssertionErrorr$   rè   rË   Úupdater   r   r   r4   rc   )rC   rÞ   rß   rà   r”   r†   rå   ÚnsrJ   rä   ÚslrF   Úorderedr¶   r¹   ÚattrNSÚjustTheNameÚnonTemplateAttrsÚattrNsÚattrNameÚnsPrefixÚattrKeyÚelrÕ   s                           r+   ÚstartElementNSz_ToStan.startElementNSÍ  s  € ð  ×&Ñ&ˆØ—\‘\×/Ñ/Ó1ˆ
Ø—|‘|×3Ñ3Ó5ˆà#‰ˆˆDØÔ#Ò#Ø�}Ò$Ø‘Ø˜’ð#à#Ð$5Ñ6�Gô
 Ø˜.Ñ)Ø#Ø%Ø)Ø!-ô�ð —
‘
×!Ñ! "Ô%Ø—‘×#Ñ# BÔ'Ø!Ÿ{™{�”Øàˆä˜eÓ$ˆÜ˜Ÿ™›Ó)ò 	‰DˆAˆqØ"#ÑˆF�KØÔ+Ò+ØØ˜hÓ&Ø�Ø˜A‘Jð	ô '›=ÐØ%,§]¡]£_ò 	*Ñ!ÑˆV�X Ø—~‘~×)Ñ)¨&Ó1ˆHØÐØ"‘à%˜J a¨ zÐ2�Ø()Ð˜WÒ%ð	*ð Ô#Ò#¨°ªØ—:’:ä$ØÔ,Ð-Ð-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   ÁK' Ë'K6Ë5K6Úchc                 ó�   — | j                   r| j                  d   j                  |«       y| j                  j                  |«       y)zm
        Called when we receive some characters.  CDATA characters get passed
        through as is.
        rV   N)rÃ   rÊ   rÚ   rÉ   )rC   rý   s     r+   Ú
charactersz_ToStan.charactersE  s6   € ð
 �<Š<Ø�J‰J�r‰N×!Ñ! "Ô%ØØ�‰×Ñ˜BÕr-   rJ   c                 ó°   — | j                   j                  «        | j                   r| j                   d   j                  | _        y| j                  | _        y)z’
        A namespace tag is closed.  Pop the stack, if there's anything left in
        it, otherwise return to the document's namespace.
        rV   N)rÊ   Úpoprì   rÉ   rÈ   )rC   rJ   rß   s      r+   ÚendElementNSz_ToStan.endElementNSO  s9   € ð
 	�
‰
�‰ÔØ�:Š:ØŸ:™: b™>×2Ñ2ˆD�LàŸ=™=ˆD�Lr-   ÚpublicIdÚsystemIdc                  ó   — y©z#
        DTDs are ignored.
        NrH   )rC   rJ   r  r  s       r+   ÚstartDTDz_ToStan.startDTDZ  rÐ   r-   Úargsc                  ó   — yr  rH   )rC   r  s     r+   ÚendDTDz_ToStan.endDTD_  rÐ   r-   c                 óH   — d| _         | j                  j                  g «       y)zO
        We're starting to be in a CDATA element, make a note of this.
        TN)rÃ   rÊ   rÚ   rÌ   s    r+   Ú
startCDATAz_ToStan.startCDATAd  s   € ð ˆŒØ�
‰
×Ñ˜"Õr-   c                 ó¬   — d| _         dj                  | j                  j                  «       «      }| j                  j                  t        |«      «       y)z‰
        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"   )rC   Úcomments     r+   ÚendCDATAz_ToStan.endCDATAk  s:   € ð
 ˆŒØ—'‘'˜$Ÿ*™*Ÿ.™.Ó*Ó+ˆØ�‰×ÑœE '›NÕ+r-   r:   c                 óL   — | j                   j                  t        |«      «       y)z=
        Add an XML comment which we've encountered.
        N)rÉ   rÚ   r#   )rC   r:   s     r+   r  z_ToStan.commentt  s   € ð 	�‰×ÑœG GÓ,Õ-r-   )r0   N)rM   rN   rO   rP   r   rc   rB   r   rÆ   rÍ   rÏ   rÔ   rÛ   rÝ   r   r   rü   rÿ   r  r  Úobjectr
  r  r  r  rH   r-   r+   r¿   r¿   ƒ  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                 ó   — t        «       }|j                  t        j                  d«       |j                  t        j                  d«       |j                  t        j
                  d«       |j                  t        j                  d«       t        t        | dd«      «      }|j                  |«       |j                  |«       |j                  t        j                  |«       |j                  | «       |j                  S )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`   rJ   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+   Ú_flatsaxParser"  {  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                   ó8   — e Zd ZdZdeeef   fd„Zded   fd„Z	y)Ú	XMLStringzH
    An L{ITemplateLoader} that loads and parses XML from a string.
    r!  c                 óŒ   — t        |t        «      s|j                  d«      }t        t	        j
                  |«      «      | _        y)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   rc   r8   r"  ÚioÚStringIOÚ_loadedTemplate)rC   r!  s     r+   rB   zXMLString.__init__™  s4   € ô ˜!œSÔ!Ø—‘˜Ó ˆAä4AÄ"Ç+Á+ÈaÃ.Ó4QˆÔØ"r-   r0   r   c                 ó   — | j                   S )zM
        Return the document.

        @return: the loaded document.
        )r)  rÌ   s    r+   ÚloadzXMLString.load¦  s   € ð ×#Ñ#Ð#r-   N)
rM   rN   rO   rP   r   rc   r4   rB   r   r+  rH   r-   r+   r$  r$  “  s-   „ ñð#˜%  U 
Ñ+ó #ð$�d˜=Ñ)ô $r-   r$  c                   óX   — e Zd ZdZ ed«      Zdd„Zed„ «       Zed„ «       Z	ed„ «       Z
y)	ÚFailureElementa  
    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                 ó>   — t        j                  | |«       || _        y r@   )r   rB   Úfailure)rC   r/  r   s      r+   rB   zFailureElement.__init__  s   € Ü×Ñ˜˜vÔ&Øˆ�r-   c                 óL   —  |t        | j                  j                  «      «      S )zA
        Render the exception type as a child of C{tag}.
        )r   r/  Útyper‚   s      r+   r1  zFailureElement.type  s   € ñ
 Ô% d§l¡l×&7Ñ&7Ó8Ó9Ð9r-   c                 ój   —  |t        | j                  j                  «      j                  d«      «      S )zB
        Render the exception value as a child of C{tag}.
        r&  )rc   r/  Úvaluer9   r‚   s      r+   r3  zFailureElement.value  s)   € ñ
 ”3�t—|‘|×)Ñ)Ó*×1Ñ1°&Ó9Ó:Ð:r-   c                 óT   — t        t        |«      | j                  j                  «      S )z–
        Render all the frames in the wrapped
        L{Failure<twisted.python.failure.Failure>}'s traceback stack, replacing
        C{tag}.
        )r«   rœ   r/  r¯   r‚   s      r+   Ú	tracebackzFailureElement.traceback  s   € ô œY s›^¨T¯\©\×-@Ñ-@ÓAÐAr-   r@   )rM   rN   rO   rP   r$  r   rB   r   r1  r3  r5  rH   r-   r+   r-  r-  ¯  s^   „ ññ ðI	óK€FóZð ñ:ó ð:ð ñ;ó ð;ð ñBó ñBr-   r-  c                 óø   — g }t        dt        | «      «      j                  |j                  «       t	        |d   t
        «      r$|d   j                  d«      j                  dd«      S |d   j                  «        y)a  
    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   rb   Úxmlcharrefreplace)	r!   r-  ÚaddBothrÚ   r3   r4   r8   r9   ÚraiseException)Ú	myFailureÚresults     r+   ÚformatFailurer<  #  sj   € ð €FÜ�$œ yÓ1Ó2×:Ñ:¸6¿=¹=ÔIÜ�&˜‘)œUÔ#ð �a‰y×Ñ Ó(×/Ñ/°Ð9LÓMÐMØ
ˆ1�I×ÑÕr-   r`   c                   ó*   — e Zd ZdZdd„Zded   fd„Zy)rœ   zJ
    An L{ITemplateLoader} that loads an existing flattenable object.
    r   c                 ó   — || _         y)z>
        @param tag: The object which will be loaded.
        N©rƒ   )rC   rƒ   s     r+   rB   zTagLoader.__init__I  s   € ð
 #&ˆŒØ.r-   r0   c                 ó   — | j                   gS r@   r?  rÌ   s    r+   r+  zTagLoader.loadQ  s   € Ø—‘ˆzÐr-   N)rƒ   r   )rM   rN   rO   rP   rB   r   r+  rH   r-   r+   rœ   rœ   C  s   „ ñó/ð�d˜=Ñ)ô r-   rœ   c                   óR   — e Zd ZdZdee   fd„Zded   fd„Zde	fd„Z
ded   fd„Zy	)
ÚXMLFilezF
    An L{ITemplateLoader} that loads and parses XML from a file.
    Úpathc                 óz   — t        |t        «      st        j                  dt        d¬«       d| _        	 || _        y)zf
        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ÚDeprecationWarningr)  Ú_path)rC   rC  s     r+   rB   zXMLFile.__init__[  s>   € ô ˜$¤Ô)Ü�M‰Mð@ä+Øõ	ð ?CˆÔØ=à$(ˆŒ
Ø1r-   r0   r   c                 óØ   — t        | j                  t        «      st        | j                  «      S | j                  j	                  d«      5 }t        |«      cddd«       S # 1 sw Y   yxY w)zP
        Read and parse the XML.

        @return: the loaded document.
        ÚrN)r3   rJ  r   r"  Úopen)rC   Úfs     r+   Ú_loadDoczXMLFile._loadDoco  sP   € ô ˜$Ÿ*™*¤hÔ/Ü  §¡Ó,Ð,à—‘—‘ Ó%ð (¨Ü$ QÓ'÷(÷ (ò (ús   ÁA Á A)c                 ó"   — d| j                   ›d�S )Nz<XMLFile of ú>)rJ  rÌ   s    r+   Ú__repr__zXMLFile.__repr__{  s   € Ø˜dŸj™j˜^¨1Ð-Ð-r-   c                 ó\   — | j                   €| j                  «       | _         | j                   S )zl
        Return the document, first loading it if necessary.

        @return: the loaded document.
        )r)  rO  rÌ   s    r+   r+  zXMLFile.load~  s*   € ð ×ÑÐ'Ø#'§=¡=£?ˆDÔ Ø×#Ñ#Ð#r-   N)rM   rN   rO   rP   r   r   rB   r   rO  rc   rR  r+  rH   r-   r+   rB  rB  U  sE   „ ñð2˜X c™]ó 2ð(
(˜$˜}Ñ-ó 
(ð.˜#ó .ð$�d˜=Ñ)ô $r-   rB  >x   ÚaÚbÚiÚpÚqr!  Ú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Úlegendr  Ú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                   ó    — e Zd ZdZdedefd„Zy)Ú_TagFactorya†  
    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                 ó†   — |dk(  rt        d«      S |j                  d«      }|t        vrt        d|›�«      ‚t        |«      S )Nrâ   rã   Ú_zunknown tag )r$   r“   ÚVALID_HTML_TAG_NAMESÚAttributeError)rC   rÊ  s     r+   Ú__getattr__z_TagFactory.__getattr__  sF   € Ø�mÒ#Ü�r“7ˆNà—.‘. Ó%ˆØÔ.Ñ.Ü  <°¨{Ð!;Ó<Ð<Ü�7‹|Ðr-   N)rM   rN   rO   rP   rc   r$   rÏ  rH   r-   r+   rÉ  rÉ  	  s   „ ñð 3ð ¨3ô r-   rÉ  ÚelementÚdoctypeÚ_failElementr   c                 óH  ‡ ‡— |�"‰ j                  |«       ‰ j                  d«       ‰€t        Št        ‰ |‰ j                   «      }dt        dt        t
        d      fˆˆ fd„}‰ dœdt        dt        dt        fd	„}|j                  |«       |j                  |«       t        S )
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ó   
r/  r0   c                 óÎ   •— t         j                  d| ¬«       t        ‰dd «      }|�-|j                  r!‰€J ‚t	        ‰ ‰| «      ‰j
                  «      S ‰j                  d«       y )Nz/An error occurred while rendering the response.)r/  Úsitesr   <div style="font-size:800%;background-color:#FFF;color:#F00">An error occurred while rendering the response.</div>)Ú
_moduleLogr/  r  ÚdisplayTracebacksr    Úwrite)r/  rÖ  rÒ  r/   s     €€r+   ÚebzrenderElement.<locals>.ebA  st   ø€ Ü×ÑØ=Àwð 	ô 	
ô �w ¨Ó-ˆØÐ × 6Ò 6ØÐ+Ð+Ð+Ü˜7¡L°Ó$9¸7¿=¹=ÓIÐIà�M‰MðKôð r-   )r/   r;  r/   c                ó&   — |j                  «        | S r@   )Úfinish)r;  r/   s     r+   rÜ  zrenderElement.<locals>.finishR  s   € Ø�‰ÔØˆr-   )rÙ  r-  r    r   r   r   r  r'   rq   r8  rn   )r/   rÐ  rÑ  rÒ  rk   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)YrP   r'  r‘   rG  Ú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;   rj   r=   rT   r_   rh   r{   rˆ   r¡   r«   r±   rÙ   ÚContentHandlerÚEntityResolverr¿   rc   r"  r$  r-  r<  rn   r×  rœ   rB  rÍ  rÉ  Útagsr  rÝ  rH   r-   r+   ú<module>rñ     s>  ðñó 
Û Û Ý #Ý ÷÷ ÷ ñ ÷ )ß 7å &å +Ý !Ý "Ý *Ý ,Ý 5Ý  ß 2ß DÑ Dß 7Ó 7ß CÑ Cò(ð&�Eð & Hð &°ó &ôRˆx× Ñ ô ô,'�hô 'ô6)�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-   