+
    Dfjw                     L   R t ^ RIt^ RIt^ RIt^ RIHt ^ RIHt ^ RIH	t	H
t
HtHtHtHtHtHtHtHtHt ^ RIHtHt ^ RIHtHt ^ RIHt ^ RIHt ^ R	IHt ^ R
I H!t! ^ RI"H#t# ^ RI$H%t% ^ RI&H't' ^ RI(H)t) ^ RI*H+t+H,t, ^ RI-H.t.H/t/H0t0 ^ RI1H2t2H3t3H4t4H5t5 ^ RI6H7t7H8t8H9t9 R t:R R lt; ! R R])Px                  4      t= ! R R])Px                  4      t> ! R R])Px                  4      t? ! R R]+4      t@ ! R R]+4      tA ! R  R!]+4      tB ! R" R#]+4      tC ! R$ R%4      tDR&tE ! R' R(]P                  ]P                  4      tHR) R* ltI]! ]94       ! R+ R,4      4       tJ ! R- R.]+4      tKR/ tL^tM]! 4       tN]! ]94       ! R0 R14      4       tO]! ]94       ! R2 R34      4       tP0 R4kR5kR6kR7kR8kR9kR:kR;kR<kR=kR>kR?kR@kRAkRBkRCkRDkREkRFkRGkRHkRIkRJkRKkRLkRMkRNkROkRPkRQkRRkRSkRTkRUkRVkRWkRXkRYkRZkR[kR\kR]kR^kR_kR`kRakRbkRckRdkRekRfkRgkRhkRikRjkRkkRlkRmkRnkRokRpkRqkRrkRskRtkRukRvkRwkRxkRykRzkR{kR|kR}kR~kRkRkRkRkRkRkRkRkRkRkRkRkRkRkRkRkRkRkRkRkRkRkRkRkRkRkRkRkRkRkRkRkRkRkRkRkRkRkRkRkRkRkRkRkRktQ ! R R4      tR]R! 4       tSRR R lltTR# )zG
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                     R\        V 4       R2# )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   &</usr/lib/python3/dist-packages/twisted/web/_template_util.py_PREr+   ,   s     6$<.''    c                <    V ^8  d   QhR\         R\        R\         /# )   URLrequestreturn)bytesr&   )formats   "r*   __annotate__r4   ;   s!     & &E &H & &r,   c                    \        V \        4      '       g   \        R4      hVP                  RR4       VP	                  V 4       RR\        V P                  R4      4      P                  R4      /,          pV# )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)
isinstancer2   	TypeError	setHeaderredirectr   decodeencode)r/   r0   contents   && r*   
redirectTor>   ;   st    ( c5!!+,,o'BCS	 	szz'*+227;G Nr,   c                   R   a a ] tR t^dt oRtRtV3R lV 3R lltR tR tRt	Vt
V ;t# )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}
Tc                    < V ^8  d   QhRS[ /# )r.   url)r2   )r3   __classdict__s   "r*   r4   Redirect.__annotate__n   s      E r,   c                0   < \         SV `  4        Wn        R # N)super__init__rB   )selfrB   	__class__s   &&r*   rH   Redirect.__init__n   s    r,   c                .    \        V P                  V4      # rF   )r>   rB   )rI   r0   s   &&r*   renderRedirect.renderr   s    $((G,,r,   c                    V # rF    rI   namer0   s   &&&r*   getChildRedirect.getChildu       r,   )rB   )__name__
__module____qualname____firstlineno____doc__isLeafrH   rM   rS   __static_attributes____classdictcell____classcell__)rJ   rC   s   @@r*   r@   r@   d   s*      F - r,   r@   c                   :   a  ] tR t^yt o Rt^tV 3R lR ltRtV tR# )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.
c                &   < V ^8  d   QhRS[ RS[/# )r.   r0   r1   )r&   r2   )r3   rC   s   "r*   r4   ParentRedirect.__annotate__   s     ) )h )5 )r,   c                    \        \        P                  P                  V4      P	                  4       4      P                  R4      p\        W!4      # )z>
Respond to all requests by redirecting to nearest directory.
ascii)strr   URLPathfromRequestherer<   r>   )rI   r0   rh   s   && r*   rM   ParentRedirect.render   s<     7??..w7<<>?FFwO$((r,   rP   N)	rV   rW   rX   rY   rZ   r[   rM   r\   r]   rC   s   @r*   r`   r`   y   s     $ F) )r,   r`   c                   F   a  ] tR t^t o Rt^tR tR tR tR t	R t
RtV tR# )	DeferredResourcezH
I wrap up a Deferred that will eventually result in a Resource
object.
c                P    \         P                  P                  V 4       Wn        R # rF   )r   ResourcerH   d)rI   ro   s   &&r*   rH   DeferredResource.__init__   s    ""4(r,   c                    V # rF   rP   rQ   s   &&&r*   rS   DeferredResource.getChild   rU   r,   c                    V P                   P                  V P                  V4      P                  V P                  V4       ^ RIHp V# )    )NOT_DONE_YET)ro   addCallback_cbChild
addErrback_ebChildtwisted.web.serverru   )rI   r0   ru   s   && r*   rM   DeferredResource.render   s4    4=='2==dmmWU3r,   c                P    VP                  \        P                  ! W4      4       R # rF   )rM   r   getChildForRequest)rI   childr0   s   &&&r*   rw   DeferredResource._cbChild   s    x225BCr,   c                (    VP                  V4       R # rF   )processingFailed)rI   reasonr0   s   &&&r*   ry   DeferredResource._ebChild   s      (r,   )ro   N)rV   rW   rX   rY   rZ   r[   rH   rS   rM   rw   ry   r\   r]   rj   s   @r*   rl   rl      s0     
 FD) )r,   rl   c                   J   a  ] tR t^t o RtR t]R 4       t]R 4       tRt	V t
R# )_SourceLineElementz
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                J    \         P                  ! W4       W n        W0n        R # rF   )r   rH   numbersource)rI   loaderr   r   s   &&&&r*   rH   _SourceLineElement.__init__   s    &r,   c                F    V! V P                   P                  RR4      4      # )z1
Render the line of source as a child of C{tag}.
z  u     )r   replacerI   r0   tags   &&&r*   
sourceLine_SourceLineElement.sourceLine   s!    
 4;;&&t-BCDDr,   c                8    V! \        V P                  4      4      # )z.
Render the line number as a child of C{tag}.
)re   r   r   s   &&&r*   
lineNumber_SourceLineElement.lineNumber   s    
 3t{{#$$r,   )r   r   N)rV   rW   rX   rY   rZ   rH   r   r   r   r\   r]   rj   s   @r*   r   r      s9     
 E E % %r,   r   c                   @   a  ] tR t^t o RtR tR t]R 4       tRt	V t
R# )_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                >    \         P                  ! W4       W n        R # rF   r   rH   framerI   r   r   s   &&&r*   rH   _SourceFragmentElement.__init__       &
r,   c              #     "   V P                   ^,          pV P                   ^,          p\        V^,
          V^,           4       F+  pV\        P                  ! W4      P	                  4       3x  K-  	  R# 5i)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.
N)r   range	linecachegetlinerstrip)rI   filenamer   snipLineNumbers   &   r*   _getSourceLines&_SourceFragmentElement._getSourceLines   sZ      ::a=ZZ]
#JNJNCN!9#4#4X#N#U#U#WXX Ds   A2A4c           	   #     "   V P                  4        FR  w  r4VP                  4       pW0P                  ^,          8X  d   RpMRp\        V! R/ RV/B 4      p\	        WsV4      x  KT  	  R# 5i)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"}.
snippetHighlightLinesnippetLineclassNrP   )r   cloner   	TagLoaderr   )rI   r0   r   r   r   newTagcssClassr   s   &&&     r*   sourceLines"_SourceFragmentElement.sourceLines   sd      '+&:&:&<"JYY[FZZ]*1(v<((;<=F$VDD '=s   A)A+r   N)rV   rW   rX   rY   rZ   rH   r   r   r   r\   r]   rj   s   @r*   r   r      s+     Y E Er,   r   c                   j   a  ] tR t^t o RtR t]R 4       t]R 4       t]R 4       t	]R 4       t
RtV tR# )	_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                >    \         P                  ! W4       W n        R # rF   r   r   s   &&&r*   rH   _FrameElement.__init__	  r   r,   c                4    V! V P                   ^,          4      # )zI
Render the name of the file this frame references as a child of C{tag}.
r   r   s   &&&r*   r   _FrameElement.filename      
 4::a=!!r,   c                F    V! \        V P                  ^,          4      4      # )zK
Render the source line number this frame references as a child of
C{tag}.
)re   r   r   s   &&&r*   r   _FrameElement.lineNumber  s     3tzz!}%&&r,   c                4    V! V P                   ^ ,          4      # )zF
Render the function name this frame references as a child of C{tag}.
r   r   s   &&&r*   function_FrameElement.function  r   r,   c                @    \        \        V4      V P                  4      # )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ndjjAAr,   r   N)rV   rW   rX   rY   rZ   rH   r   r   r   r   r   r\   r]   rj   s   @r*   r   r      sa      " " ' ' " " B Br,   r   c                   :   a  ] tR tRt o RtR t]R 4       tRtV t	R# )_StackElementi,  zO
L{_StackElement} renders an L{IRenderable} which can render a list of frames.
c                >    \         P                  ! W4       W n        R # rF   )r   rH   stackFrames)rI   r   r   s   &&&r*   rH   _StackElement.__init__1  s    &&r,   c           	         V P                    Uu. uF&  p\        \        VP                  4       4      V4      NK(  	  up# u upi )zG
Render the list of frames in this L{_StackElement}, replacing C{tag}.
)r   r   r   r   )rI   r0   r   r   s   &&& r*   frames_StackElement.frames5  s@     GKFVFV
FVUM)CIIK0%8FV
 	
 
s   ,>)r   N)
rV   rW   rX   rY   rZ   rH   r   r   r\   r]   rj   s   @r*   r   r   ,  s#     ' 
 
r,   r   c                   t   a  ] tR tRt o RtRV 3R lR lltRV 3R lR lltV 3R lR	 ltV 3R
 lR ltRt	V t
R# )
_NSContexti?  zD
A mapping from XML namespaces onto their prefixes in the document.
Nc                .   < V ^8  d   QhRS[ R,          /# )r.   parentr   )r   )r3   rC   s   "r*   r4   _NSContext.__annotate__D  s     	G 	Gx5 	Gr,   c                d    Wn         Ve   \        VP                  4      V n        R# RR/V n        R# )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)rI   r   s   &&r*   rH   _NSContext.__init__D  s+    
 ;Fvzz;RDH>FDHr,   c                \   < V ^8  d   QhRS[ S[,          RS[ S[,          RS[ S[,          /# )r.   kro   r1   r   re   )r3   rC   s   "r*   r4   r   O  s.     " "Xc] "x} " "r,   c                8    V P                   P                  W4      # )zD
Get a prefix for a namespace.

@param d: The default prefix value.
)r   get)rI   r   ro   s   &&&r*   r   _NSContext.getO  s     xx||A!!r,   c                J   < V ^8  d   QhRS[ S[,          RS[ S[,          RR/# )r.   r   vr1   Nr   )r3   rC   s   "r*   r4   r   W  s*     # #Xc] #x} # #r,   c                <    V P                   P                  W4       R# )z8
Proxy through to setting the prefix for the namespace.
N)r   __setitem__)rI   r   r   s   &&&r*   r   _NSContext.__setitem__W  s     	Q"r,   c                F   < V ^8  d   QhRS[ S[,          RS[ S[,          /# )r.   r   r1   r   )r3   rC   s   "r*   r4   r   ]  s#     ' 'Xc] 'x} 'r,   c                8    V P                   P                  V4      # )z8
Proxy through to getting the prefix for the namespace.
)r   __getitem__)rI   r   s   &&r*   r   _NSContext.__getitem__]  s     xx##A&&r,   )r   r   rF   )rV   rW   rX   rY   rZ   rH   r   r   r   r\   r]   rj   s   @r*   r   r   ?  s4     	G 	G" "# #' 'r,   r   z4http://twistedmatrix.com/ns/twisted.web.template/0.1c                   2  a  ] tR tRt o RtV 3R lR ltV 3R lR ltV 3R lR ltV 3R	 lR
 ltV 3R lR lt	V 3R lR lt
V 3R lR ltV 3R lR ltV 3R lR ltV 3R lR ltV 3R lR ltV 3R lR ltV 3R lR ltV 3R lR ltV 3R lR  ltR!tV tR"# )#_ToStanig  zX
A SAX parser which converts an XML document to the Twisted STAN
Document Object Model.
c                0   < V ^8  d   QhRS[ S[,          /# )r.   sourceFilenamer   )r3   rC   s   "r*   r4   _ToStan.__annotate__m  s      x} r,   c                >    Wn         \        4       V n        RV n        R# )z@
@param sourceFilename: the filename the XML was loaded out of.
FN)r   r   	prefixMapinCDATA)rI   r   s   &&r*   rH   _ToStan.__init__m  s     -#r,   c                $   < V ^8  d   QhRS[ RR/# )r.   locatorr1   N)r   )r3   rC   s   "r*   r4   r   u  s      ' d r,   c                    Wn         R# )zI
Set the document locator, which knows about line and character numbers.
N)r   )rI   r   s   &&r*   setDocumentLocator_ToStan.setDocumentLocatoru  s	     r,   c                   < V ^8  d   QhRR/# r.   r1   NrP   )r3   rC   s   "r*   r4   r   {  s     
4 
4t 
4r,   c                R    . V n         V P                   V n        . V n        . V n        R# )z
Initialise the document.
N)documentcurrentstack
xmlnsAttrsrI   s   &r*   startDocument_ToStan.startDocument{  s$     $&}} "
13r,   c                   < V ^8  d   QhRR/# r   rP   )r3   rC   s   "r*   r4   r     s      T r,   c                    R# )z
Document ended.
NrP   r   s   &r*   endDocument_ToStan.endDocument      r,   c                *   < V ^8  d   QhRS[ RS[ RR/# )r.   targetdatar1   Nre   )r3   rC   s   "r*   r4   r     s"      C s t r,   c                    R# )z&
Processing instructions are ignored.
NrP   )rI   r   r   s   &&&r*   processingInstruction_ToStan.processingInstruction  r   r,   c                :   < V ^8  d   QhRS[ S[,          RS[RR/# )r.   prefixurir1   Nr   )r3   rC   s   "r*   r4   r     s&     ? ?# ?S ?T ?r,   c                    \        V P                  4      V n        WP                  V&   V\        8X  d   R# Vf    V P                  P	                  RV34       R# V P                  P	                  RV,          V34       R# )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)rI   r  r  s   &&&r*   startPrefixMapping_ToStan.startPrefixMapping  sg     $DNN3$s $$ >OO""GS>2OO""J$7#=>r,   c                4   < V ^8  d   QhRS[ S[,          RR/# )r.   r  r1   Nr   )r3   rC   s   "r*   r4   r     s        x}    r,   c                T    V P                   P                  pVf   Q R4       hW n         R# )zJ
"Pops the stack" on the prefix mapping.

Gets called after endElementNS.
Nz$More prefix mapping ends than starts)r   r   )rI   r  r   s   && r*   endPrefixMapping_ToStan.endPrefixMapping  s*     &&!I#II!r,   c                V   < V ^8  d   QhRS[ S[S[3,          RS[S[,          RS[RR/# )r.   namespaceAndNameqnameattrsr1   N)r   re   r   r   )r3   rC   s   "r*   r4   r     sE     v# v#S/v# }v#  	v#
 
v#r,   c                   V P                   pV P                  P                  4       pV P                  P                  4       pVw  rxV\        8X  d|   VR8X  d   RpMqVR8X  dk    VR,          p	\        VR,          V	VVVR7      p
V P                  P                  V
4       V P                  P                  V
4       V
P                  V n	        R# Rp\        V4      p\        VP                  4       4       F$  w  rVw  ppV\        8w  d   K  VR8X  g   K   TpW K&  	  \        4       pVP                  4        F7  w  w  pppV P                  P                  V4      pVf   TpMV RV 2pVVV&   K9  	  V\        8X  d   VR	8X  d   V P                  '       g   \!        R
\         R24      hRV9  d   \!        R
\         R24      h\#        RVVVVR7      pVV P                  R,          P$                  VR,          &   V P                  P                  V4       VP                  V n	        R# V P&                  '       d,   VP)                  \        V P&                  4      4       . V n        V\        8w  d4   Ve0   V P                  V,          pVe   V P                  V,           RV 2p\#        V\        \+        \,        \.        \0        \2        3,          \2        3,          V4      4      VVVVR7      pV P                  P                  V4       V P                  P                  V4       VP                  V n	        R#   \
         d    Rp	 ELi ; i)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$   NrR   )defaultr   r   columnNumberrM   :attrz<{z}attr> as top-level elementz }attr> requires a name attribute)rM   r   r   r  )
attributesrM   r   r   r  )Nr  )NrR   )r   r   getLineNumbergetColumnNumberr  KeyErrorr$   r   r  r   childrenr   listitemsr   r   AssertionErrorr#   r  r   updater   r   r   r2   re   )rI   r  r  r  r   r   r  nsrR   r  slrM   orderedr   r   attrNSjustTheNamenonTemplateAttrsattrNsattrNamensPrefixattrKeyelr  s   &&&&                    r*   startElementNS_ToStan.startElementNS  s     &&\\//1
||335###}$##$56G
 .)#%)!- 

!!"%##B'!{{e$)DA"#FK++h&J * '=%,]]_!VX~~))&1H"%Jaz2()W% &5 ##:::$,--IJ  --$,--NO  !%)B CEDJJrN%%&6v&>?JJb!;;DL ???##K$@A DO ##^^B'F!..,-Qtf5"WU5#:.346FG !%	
 	

"B{{s   # #G#s   "	L2 2MMc                $   < V ^8  d   QhRS[ RR/# )r.   chr1   Nr   )r3   rC   s   "r*   r4   r   )  s        S  T  r,   c                    V P                   '       d%   V P                  R,          P                  V4       R# V P                  P                  V4       R# )zU
Called when we receive some characters.  CDATA characters get passed
through as is.
Nr  )r   r   r  r   )rI   r2  s   &&r*   
characters_ToStan.characters)  s8    
 <<<JJrN!!"%Br,   c                P   < V ^8  d   QhRS[ S[S[3,          RS[S[,          RR/# )r.   rR   r  r1   N)r   re   r   )r3   rC   s   "r*   r4   r   3  s.     	) 	)sCx 	)# 	)4 	)r,   c                    V P                   P                  4        V P                   '       d%   V P                   R,          P                  V n        R# V P                  V n        R# )zz
A namespace tag is closed.  Pop the stack, if there's anything left in
it, otherwise return to the document's namespace.
Nr  )r   popr  r   r   )rI   rR   r  s   &&&r*   endElementNS_ToStan.endElementNS3  s;    
 	

:::::b>22DL==DLr,   c                0   < V ^8  d   QhRS[ RS[ RS[ RR/# )r.   rR   publicIdsystemIdr1   Nr   )r3   rC   s   "r*   r4   r   >  s)      S C 3 4 r,   c                    R# z
DTDs are ignored.
NrP   )rI   rR   r<  r=  s   &&&&r*   startDTD_ToStan.startDTD>  r   r,   c                $   < V ^8  d   QhRS[ RR/# )r.   argsr1   N)object)r3   rC   s   "r*   r4   r   C  s      F t r,   c                    R# r?  rP   )rI   rC  s   &*r*   endDTD_ToStan.endDTDC  r   r,   c                   < V ^8  d   QhRR/# r   rP   )r3   rC   s   "r*   r4   r   H  s      D r,   c                J    RV n         V P                  P                  . 4       R# )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                   < V ^8  d   QhRR/# r   rP   )r3   rC   s   "r*   r4   r   O  s     , ,$ ,r,   c                    RV n         RP                  V P                  P                  4       4      pV P                  P                  \        V4      4       R# )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   r8  r   r  r!   )rI   comments   & r*   endCDATA_ToStan.endCDATAO  s:    
 ''$**..*+E'N+r,   c                $   < V ^8  d   QhRS[ RR/# )r.   r=   r1   Nr   )r3   rC   s   "r*   r4   r   X  s     . .s .t .r,   c                N    V P                   P                  \        V4      4       R# )z-
Add an XML comment which we've encountered.
N)r   r  r"   )rI   r=   s   &&r*   rO  _ToStan.commentX  s     	GG,-r,   )r   r   r   r   r   r   r   r   N)rV   rW   rX   rY   rZ   rH   r   r   r   r   r	  r  r/  r4  r9  r@  rF  rJ  rP  rO  r\   r]   rj   s   @r*   r   r   g  s     
  
4 
4 
 
? ?,   v# v#p   	) 	) 
 
 , ,. .r,   r   c                v    V ^8  d   QhR\         \        \        ,          \        3,          R\        R,          /# )r.   flr1   r   )r   r   r   re   r
   )r3   s   "r*   r4   r4   _  s,      eBvJO, m1D r,   c                    \        4       pVP                  \        P                  ^ 4       VP                  \        P                  ^4       VP                  \        P
                  ^ 4       VP                  \        P                  ^ 4       \        \        V RR4      4      pVP                  V4       VP                  V4       VP                  \        P                  V4       VP                  V 4       VP                  # )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.
rR   N)r   
setFeaturer   feature_validationfeature_namespacesfeature_external_gesfeature_external_pesr   getattrsetContentHandlersetEntityResolversetPropertyproperty_lexical_handlerparser   )rV  parserss   &  r*   _flatsaxParsere  _  s     ]F
g00!4
g00!4
g22A6
g22A6FD)*A
Q
Q
w77;
LL::r,   c                   H   a  ] tR tRt o RtV 3R lR ltV 3R lR ltRtV tR# )		XMLStringiw  z@
An L{ITemplateLoader} that loads and parses XML from a string.
c                6   < V ^8  d   QhRS[ S[S[3,          /# )r.   rd  )r   re   r2   )r3   rC   s   "r*   r4   XMLString.__annotate__}  s     # #%U
+ #r,   c                    \        V\        4      '       g   VP                  R4      p\        \        P
                  ! V4      4      V n        R# )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)r7   re   r;   re  ioStringIO_loadedTemplate)rI   rd  s   &&r*   rH   XMLString.__init__}  s7     !S!! A4A"++a.4Q"r,   c                .   < V ^8  d   QhRS[ R,          /# r.   r1   r   r
   )r3   rC   s   "r*   r4   ri    s     $ $d=) $r,   c                    V P                   # )z5
Return the document.

@return: the loaded document.
rn  r   s   &r*   loadXMLString.load  s     ###r,   rt  N	rV   rW   rX   rY   rZ   rH   ru  r\   r]   rj   s   @r*   rg  rg  w  s     # #$ $r,   rg  c                   n   a  ] tR tRt o Rt]! R4      tR
R lt]R 4       t	]R 4       t
]R 4       tR	tV tR# )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                >    \         P                  ! W4       Wn        R # rF   )r   rH   failure)rI   r{  r   s   &&&r*   rH   FailureElement.__init__  s    &r,   c                L    V! \        V P                  P                  4      4      # )z1
Render the exception type as a child of C{tag}.
)r   r{  typer   s   &&&r*   r~  FailureElement.type  s    
 %dll&7&7899r,   c                j    V! \        V P                  P                  4      P                  R4      4      # )z2
Render the exception value as a child of C{tag}.
rk  )re   r{  valuer<   r   s   &&&r*   r  FailureElement.value  s)    
 3t||))*11&9::r,   c                T    \        \        V4      V P                  P                  4      # )zv
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*   	tracebackFailureElement.traceback  s     Ys^T\\-@-@AAr,   r{  rF   )rV   rW   rX   rY   rZ   rg  r   rH   r   r~  r  r  r\   r]   rj   s   @r*   ry  ry    sa      I	KFZ : : ; ; B Br,   ry  c                   . p\        R\        V 4      4      P                  VP                  4       \	        V^ ,          \
        4      '       d)   V^ ,          P                  R4      P                  RR4      # V^ ,          P                  4        R# )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.
Nr6   rd   xmlcharrefreplace)	r    ry  addBothr  r7   r2   r;   r<   raiseException)	myFailureresults   & r*   formatFailurer    sm     F$y12::6==I&)U## ay(//9LMM
1Ir,   c                   H   a  ] tR tRt o RtV 3R lR ltV 3R lR ltRtV tR# )	r   i'  zB
An L{ITemplateLoader} that loads an existing flattenable object.
c                   < V ^8  d   QhRR/# )r.   r   r   rP   )r3   rC   s   "r*   r4   TagLoader.__annotate__-  s     / /M /r,   c                    Wn         R# )z.
@param tag: The object which will be loaded.
Nr   )rI   r   s   &&r*   rH   TagLoader.__init__-  s    
 #&.r,   c                .   < V ^8  d   QhRS[ R,          /# rq  rr  )r3   rC   s   "r*   r4   r  5  s      d=) r,   c                    V P                   .# rF   r  r   s   &r*   ru  TagLoader.load5  s    zr,   r  Nrw  rj   s   @r*   r   r   '  s     / / r,   r   c                   l   a  ] tR tRt o RtV 3R lR ltV 3R lR ltV 3R lR ltV 3R	 lR
 ltRt	V t
R# )XMLFilei9  z>
An L{ITemplateLoader} that loads and parses XML from a file.
c                0   < V ^8  d   QhRS[ S[,          /# )r.   path)r   r   )r3   rC   s   "r*   r4   XMLFile.__annotate__?  s     2 2Xc] 2r,   c                    \        V\        4      '       g   \        P                  ! R\        ^R7       RV n         Wn        R# )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.)category
stacklevelN)r7   r   warningswarnDeprecationWarningrn  _path)rI   r  s   &&r*   rH   XMLFile.__init__?  s?     $))MM@+	 ?C=$(
1r,   c                .   < V ^8  d   QhRS[ R,          /# rq  rr  )r3   rC   s   "r*   r4   r  S  s     
( 
($}- 
(r,   c                   \        V P                  \        4      '       g   \        V P                  4      # V P                  P	                  R4      ;_uu_ 4       p\        V4      uuRRR4       #   + '       g   i     R# ; i)z8
Read and parse the XML.

@return: the loaded document.
rN)r7   r  r   re  open)rI   fs   & r*   _loadDocXMLFile._loadDocS  sP     $**h// ,,%%$Q' &%%%s   A//B 	c                    < V ^8  d   QhRS[ /# )r.   r1   r   )r3   rC   s   "r*   r4   r  _  s     . .# .r,   c                $    R V P                   : R2# )z<XMLFile of >)r  r   s   &r*   __repr__XMLFile.__repr___  s    djj^1--r,   c                .   < V ^8  d   QhRS[ R,          /# rq  rr  )r3   rC   s   "r*   r4   r  b  s     $ $d=) $r,   c                `    V P                   f   V P                  4       V n         V P                   # )zT
Return the document, first loading it if necessary.

@return: the loaded document.
)rn  r  r   s   &r*   ru  XMLFile.loadb  s*     '#'==?D ###r,   )rn  r  N)rV   rW   rX   rY   rZ   rH   r  r  ru  r\   r]   rj   s   @r*   r  r  9  s2     2 2(
( 
(. .$ $r,   r  aabbracronymaddressappletareaarticleasideaudiobbasebasefontbdibdobig
blockquotebodybrbuttoncanvascaptioncentercitecodecolcolgroupcommanddatalistdddeldetailsdfndirdivdldtemembedfieldset
figcaptionfigurefontfooterformr   frameseth1h2h3h4h5h6headheaderhgrouphrhtmliiframeimginputinsisindexkeygenkbdlabellegendlilinkmapmarkmenumetameternavnoframesnoscriptrD  oloptgroupoptionoutputpparampreprogressqrprtrubyrd  sampscriptsectionselectsmallr   spanstrikestrongstylesubsummarysuptabletbodytdtextareatfootththeadtimetitletrttuulvarvideowbrc                   6   a  ] tR tRt o RtV 3R lR ltRtV tR# )_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}
c                &   < V ^8  d   QhRS[ RS[/# )r.   tagNamer1   )re   r#   )r3   rC   s   "r*   r4   _TagFactory.__annotate__  s      3 3 r,   c                    VR 8X  d   \        R4      # VP                  R4      pV\        9  d   \        RV: 24      h\        V4      # )r  r  _zunknown tag )r#   r   VALID_HTML_TAG_NAMESAttributeError)rI   r*  s   &&r*   __getattr___TagFactory.__getattr__  sF    m#r7N..%.. <{!;<<7|r,   rP   N)rV   rW   rX   rY   rZ   r0  r\   r]   rj   s   @r*   r(  r(    s      r,   r(  c                    V ^8  d   QhR\         R\        R\        \        ,          R\        \        \
        .R3,          ,          R\        /# )r.   r0   elementdoctype_failElementr   r1   )r&   r%   r   r2   r   r   rD  )r3   s   "r*   r4   r4     sO     4 444 e_4 8WIy$89:	4
 4r,   c                  a a Ve#   S P                  V4       S P                  R4       Sf   \        o\        S VS P                   4      pR VV 3R llpRS /R R llpVP                  V4       VP	                  V4       \
        # )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
   
c                T    V ^8  d   QhR\         R\        \        R,          ,          /# )r.   r{  r1   N)r   r   r   )r3   s   "r*   r4   #renderElement.<locals>.__annotate__%  s#      G $ 8 r,   c                    < \         P                  R V R7       \        SRR4      pVe6   VP                  '       d$   Sf   Q h\	        SS! V 4      SP
                  4      # SP                  R4       R# )z/An error occurred while rendering the response.r  siteNsr   <div style="font-size:800%;background-color:#FFF;color:#F00">An error occurred while rendering the response.</div>)
_moduleLogr{  r]  displayTracebacksr   write)r{  r;  r5  r0   s   & r*   ebrenderElement.<locals>.eb%  sw    =w 	 	
 w- 6 6 6+++7L$97==IIMMK r,   r0   c                <    V ^8  d   QhR\         R\        R\         /# )r.   r  r0   r1   )rD  r&   )r3   s   "r*   r4   r9  6  s!      v 8 & r,   c                &    VP                  4        V # rF   )finish)r  r0   s   &$r*   rC  renderElement.<locals>.finish6  s    r,   )r>  ry  r   rx   r  ru   )r0   r3  r4  r5  ro   r?  rC  s   f&&f   r*   renderElementrE    sv    ( ge%'--0A "g  LLIIfr,   )s   <!DOCTYPE html>N)UrZ   rl  r   r  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+   r>   rn   r@   r`   rl   r   r   r   r   r   r  ContentHandlerEntityResolverr   re  rg  ry  r  ru   r<  r   r  r.  r(  tagsrE  rP   r,   r*   <module>rY     s   
   #     ) 7 & + ! " * , 5   2 D D 7 7 C C(&Rx   *)X&& ):)x(( )8% %<+EW +E\+BG +B\
G 
&"' "'J L u.g$$g&<&< u.p0 _$ $ $6qBW qBh8 X
 _  " _0$ 0$ 0$nyy
y y 	y
 y y y y y y y y 
y 
y 
y  !y" #y$ 	%y& 'y( )y* +y, -y. /y0 1y2 
3y4 5y6 7y8 9y: 	;y< 
=y> ?y@ 
AyB 
CyD 
EyF 	GyH 	IyJ 	KyL MyN OyP QyR SyT UyV WyX YyZ [y\ ]y^ 	_y` 	ayb 	cyd 	eyf 	gyh 	iyj kyl myn oyp 	qyr syt uyv wyx 
yyz {y| 
}y~ y@ AyB 
CyD EyF GyH 	IyJ KyL 
MyN OyP QyR SyT UyV 
WyX YyZ [y\ ]y^ 	_y` ayb cyd eyf gyh iyj 
kyl myn oyp 	qyr 	syt uyv wyx yyz {y| }y~ y@ AyB CyD EyF GyH IyJ KyL 
MyN OyP 
QyR SyT UyV 	WyX YyZ [y\ 	]y^ _y` ayb cyd 	eyf 	gyh iyj 	kyl 
myn oyp 
qy x 0 }4 4r,   