HEX
Server: Apache/2.4.52 (Ubuntu)
System: Linux spn-python 5.15.0-89-generic #99-Ubuntu SMP Mon Oct 30 20:42:41 UTC 2023 x86_64
User: arjun (1000)
PHP: 8.1.2-1ubuntu2.20
Disabled: NONE
Upload Files
File: //usr/lib/python3/dist-packages/twisted/web/__pycache__/_template_util.cpython-310.pyc
o

�b�z�@s�dZddlZddlZddlZddlmZddlmZddlm	Z	m
Z
mZmZm
Z
mZmZmZmZmZmZddlmZmZddlmZddlmZdd	lmZdd
lmZddlm Z ddl!m"Z"dd
l#m$Z$ddl%m&Z&ddl'm(Z(ddl)m*Z*m+Z+ddl,m-Z-m.Z.m/Z/ddl0m1Z1m2Z2m3Z3m4Z4ddl5m6Z6m7Z7m8Z8dd�Z9de:de7de:fdd�Z;Gdd�de(j<�Z=Gdd�de=�Z>Gdd �d e(j<�Z?Gd!d"�d"e(j<�Z@Gd#d$�d$e*�ZAGd%d&�d&e*�ZBGd'd(�d(e*�ZCGd)d*�d*e*�ZDGd+d,�d,�ZEd-ZFGd.d/�d/ejGejH�ZId0ee	eeJfded1fd2d3�ZKee8�Gd4d5�d5��ZLGd6d7�d7e*�ZMd8d9�ZNd:ZOe�ZPee8�Gd;d<�d<��ZQee8�Gd=d>�d>��ZRhd?�ZSGd@dA�dA�ZTeT�ZU	B	dIde7dCe6dDee:dEeee"gdFfdeVf
dGdH�ZWdS)JzG
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)�Locator)�implementer)�Deferred)�Logger)�urlpath)�Failure)�FilePath)�fullyQualifiedName)�resource)�Element�renderer)�Flattenable�flatten�
flattenString)�CDATA�Comment�Tag�slot)�IRenderable�IRequest�ITemplateLoadercCsdt|��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)�text�r(�</usr/lib/python3/dist-packages/twisted/web/_template_util.py�_PRE,sr*�URL�request�returncCs8t|t�s	td��|�dd�|�|�dd|i}|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)
    zURL must be bytessContent-Typestext/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>
surl)�
isinstance�bytes�	TypeError�	setHeader�redirect)r+r,�contentr(r(r)�
redirectTo;s


��r4cs:eZdZdZdZdef�fdd�Zdd�Zdd	�Z�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�urlcst���||_dS�N)�super�__init__r6��selfr6��	__class__r(r)r9ns

zRedirect.__init__cCst|j|�Sr7)r4r6)r;r,r(r(r)�renderrszRedirect.rendercC�|Sr7r(�r;�namer,r(r(r)�getChildu�zRedirect.getChild)
�__name__�
__module__�__qualname__�__doc__�isLeafr/r9r>rB�
__classcell__r(r(r<r)r5dsr5c@s eZdZdZdd�Zdd�ZdS)�ChildRedirectorFcCs>|�d�dkr|�d�s|�d�std|��t�||�dS)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�
ValueErrorr5r9r:r(r(r)r9}s����zChildRedirector.__init__cCs(|j}|�d�s|d7}||7}t|�S)NrL)r6�endswithrJ)r;rAr,�newUrlr(r(r)rB�s

zChildRedirector.getChildN)rDrErFrHr9rBr(r(r(r)rJzsrJc@s&eZdZdZdZdedefdd�ZdS)�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,r-cCs$ttj�|�����d�}t||�S)zN
        Respond to all requests by redirecting to nearest directory.
        �ascii)�strr�URLPath�fromRequest�here�encoder4)r;r,rXr(r(r)r>�s
zParentRedirect.renderN)rDrErFrGrHr%r/r>r(r(r(r)rR�srRc@s<eZdZdZdZdd�Zdd�Zdd�Zd	d
�Zdd�Z	d
S)�DeferredResourcezT
    I wrap up a Deferred that will eventually result in a Resource
    object.
    rScCstj�|�||_dSr7)r�Resourcer9�d)r;r\r(r(r)r9��
zDeferredResource.__init__cCr?r7r(r@r(r(r)rB�rCzDeferredResource.getChildcCs*|j�|j|��|j|�ddlm}|S)Nr)�NOT_DONE_YET)r\�addCallback�_cbChild�
addErrback�_ebChild�twisted.web.serverr^)r;r,r^r(r(r)r>�szDeferredResource.rendercCs|�t�||��dSr7)r>r�getChildForRequest)r;�childr,r(r(r)r`�szDeferredResource._cbChildcCs|�|�dSr7)�processingFailed)r;�reasonr,r(r(r)rb��zDeferredResource._ebChildN)
rDrErFrGrHr9rBr>r`rbr(r(r(r)rZ�srZc@s0eZdZdZdd�Zedd��Zedd��ZdS)	�_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.
    cCst�||�||_||_dSr7)rr9�number�source)r;�loaderrjrkr(r(r)r9�s
z_SourceLineElement.__init__cCs||j�dd��S)zA
        Render the line of source as a child of C{tag}.
        z  u  )rk�replace�r;r,�tagr(r(r)�
sourceLine�sz_SourceLineElement.sourceLinecCs|t|j��S)z>
        Render the line number as a child of C{tag}.
        )rUrjrnr(r(r)�
lineNumber��z_SourceLineElement.lineNumberN)rDrErFrGr9rrprqr(r(r(r)ri�s	
ric@s,eZdZdZdd�Zdd�Zedd��ZdS)	�_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.
    cC�t�||�||_dSr7�rr9�frame�r;rlrvr(r(r)r9�r]z_SourceFragmentElement.__init__ccsH�|jd}|jd}t|d|d�D]
}|t�||���fVqdS)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.
        rS�N)rv�range�	linecache�getline�rstrip)r;�filenamerq�snipLineNumberr(r(r)�_getSourceLines�s�

�z&_SourceFragmentElement._getSourceLinesccs\�|��D]&\}}|��}||jdkrd}nd}t|did|i���}t|||�VqdS)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"}.
        rx�snippetHighlightLine�snippetLine�classNr()r�clonerv�	TagLoaderri)r;r,rorqrp�newTag�cssClassrlr(r(r)�sourceLiness��z"_SourceFragmentElement.sourceLinesN)rDrErFrGr9rrr�r(r(r(r)rs�s

rsc@sHeZdZdZdd�Zedd��Zedd��Zedd	��Zed
d��Z	dS)
�
_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.
    cCrtr7rurwr(r(r)r9%r]z_FrameElement.__init__cC�||jd�S)zY
        Render the name of the file this frame references as a child of C{tag}.
        rS�rvrnr(r(r)r})rrz_FrameElement.filenamecCs|t|jd��S)zc
        Render the source line number this frame references as a child of
        C{tag}.
        rx)rUrvrnr(r(r)rq0sz_FrameElement.lineNumbercCr�)zV
        Render the function name this frame references as a child of C{tag}.
        rr�rnr(r(r)�function8rrz_FrameElement.functioncCstt|�|j�S)zn
        Render the source code surrounding the line this frame references,
        replacing C{tag}.
        )rsr�rvrnr(r(r)rk?sz_FrameElement.sourceN)
rDrErFrGr9rr}rqr�rkr(r(r(r)r�s



r�c@s$eZdZdZdd�Zedd��ZdS)�
_StackElementzW
    L{_StackElement} renders an L{IRenderable} which can render a list of frames.
    cCrtr7)rr9�stackFrames)r;rlr�r(r(r)r9Mr]z_StackElement.__init__cs�fdd�|jD�S)zW
        Render the list of frames in this L{_StackElement}, replacing C{tag}.
        csg|]}tt����|��qSr()r�r�r�)�.0rv�ror(r)�
<listcomp>Vs�z(_StackElement.frames.<locals>.<listcomp>)r�rnr(r�r)�framesQs
�z_StackElement.framesN)rDrErFrGr9rr�r(r(r(r)r�Hs
r�c@s�eZdZdZddedfdd�Zddeedeedeefd	d
�Zdeedeeddfdd
�Zdeedeefdd�Z	dS)�
_NSContextzL
    A mapping from XML namespaces onto their prefixes in the document.
    N�parentcCs,||_|durt|j�|_dSddi|_dS)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)r;r�r(r(r)r9`sz_NSContext.__init__�kr\r-cCs|j�||�S)z\
        Get a prefix for a namespace.

        @param d: The default prefix value.
        )r��get)r;r�r\r(r(r)r�ksz_NSContext.get�vcCs|j�||�dS)zH
        Proxy through to setting the prefix for the namespace.
        N)r��__setitem__)r;r�r�r(r(r)r�ssz_NSContext.__setitem__cCs|j�|�S)zH
        Proxy through to getting the prefix for the namespace.
        )r��__getitem__)r;r�r(r(r)r�ysz_NSContext.__getitem__r7)
rDrErFrGrr9rUr�r�r�r(r(r(r)r�[s$r�z4http://twistedmatrix.com/ns/twisted.web.template/0.1c	@sNeZdZdZdeefdd�Zdeddfdd	�Zd1d
d�Z	d1dd
�Z
dededdfdd�Zdeededdfdd�Zdeeddfdd�Z
deeefdeedeeeeefefddfdd�Zdeddfdd�Zd eeefdeeddfd!d"�Zd ed#ed$eddfd%d&�Zd'eddfd(d)�Zd1d*d+�Zd1d,d-�Zd.eddfd/d0�ZdS)2�_ToStanzd
    A SAX parser which converts an XML document to the Twisted STAN
    Document Object Model.
    �sourceFilenamecCs||_t�|_d|_dS)zP
        @param sourceFilename: the filename the XML was loaded out of.
        FN)r�r��	prefixMap�inCDATA)r;r�r(r(r)r9�s
z_ToStan.__init__�locatorr-NcC�
||_dS)zY
        Set the document locator, which knows about line and character numbers.
        N)r�)r;r�r(r(r)�setDocumentLocator�s
z_ToStan.setDocumentLocatorcCsg|_|j|_g|_g|_dS)z*
        Initialise the document.
        N)�document�current�stack�
xmlnsAttrs�r;r(r(r)�
startDocument�s
z_ToStan.startDocumentcC�dS)z!
        Document ended.
        Nr(r�r(r(r)�endDocument��z_ToStan.endDocument�target�datacCr�)z6
        Processing instructions are ignored.
        Nr()r;r�r�r(r(r)�processingInstruction�r�z_ToStan.processingInstruction�prefix�uricCsVt|j�|_||j|<|tkrdS|dur|j�d|f�dS|j�d||f�dS)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�xmlnszxmlns:%s)r�r��TEMPLATE_NAMESPACEr��append)r;r�r�r(r(r)�startPrefixMapping�s	
z_ToStan.startPrefixMappingcCs"|jj}|dusJd��||_dS)zb
        "Pops the stack" on the prefix mapping.

        Gets called after endElementNS.
        Nz$More prefix mapping ends than starts)r�r�)r;r�r�r(r(r)�endPrefixMapping�s
z_ToStan.endPrefixMapping�namespaceAndName�qname�attrscCsP|j}|j��}|j��}|\}}|tkrO|dkrd}n3|dkrOz|d}	Wnty1d}	Ynwt|d|	|||d�}
|j�|
�|j	�|
�|
j
|_	dSd}t|�}t|�
��D]\}}
|\}}|tkrhq[|dkrq|
}||=q[t�}|�
�D]\\}}}
|j�|�}|dur�|}n|�d	|��}|
||<qy|tkr�|d
kr�|js�tdt�d���d
|vr�tdt�d���td||||d�}||jdj|d
<|j�|�|j
|_	dS|jr�|�t|j��g|_|tkr�|dur�|j|}|dur�|j|�d	|��}t|ttttttftf|��||||d�}|j�|�|j	�|�|j
|_	dS)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)NrA)r�r}rq�columnNumberr>�:�attrz<{z}attr> as top-level elementrAz }attr> requires a name attribute)r>r}rqr�rK)�
attributesr>r}rqr�)r�r��
getLineNumber�getColumnNumberr��KeyErrorr#r�r�r��childrenr�list�itemsr�r��AssertionErrorr"r�r��updaterrrr/rU)r;r�r�r�r}rqr��nsrAr��slr>r�r��attrNS�justTheName�nonTemplateAttrs�attrNs�attrName�nsPrefix�attrKey�elr�r(r(r)�startElementNS�s�

���	

�
��
��
z_ToStan.startElementNS�chcCs*|jr
|jd�|�dS|j�|�dS)zm
        Called when we receive some characters.  CDATA characters get passed
        through as is.
        rKN)r�r�r�r�)r;r�r(r(r)�
charactersEsz_ToStan.charactersrAcCs.|j��|jr|jdj|_dS|j|_dS)z�
        A namespace tag is closed.  Pop the stack, if there's anything left in
        it, otherwise return to the document's namespace.
        rKN)r��popr�r�r�)r;rAr�r(r(r)�endElementNSOs
z_ToStan.endElementNS�publicId�systemIdcCr��z#
        DTDs are ignored.
        Nr()r;rAr�r�r(r(r)�startDTDZr�z_ToStan.startDTD�argscGr�r�r()r;r�r(r(r)�endDTD_r�z_ToStan.endDTDcCsd|_|j�g�dS)zO
        We're starting to be in a CDATA element, make a note of this.
        TN)r�r�r�r�r(r(r)�
startCDATAdsz_ToStan.startCDATAcCs*d|_d�|j���}|j�t|��dS)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 )r;�commentr(r(r)�endCDATAksz_ToStan.endCDATAr3cCs|j�t|��dS)z=
        Add an XML comment which we've encountered.
        N)r�r�r!)r;r3r(r(r)r�tsz_ToStan.comment)r-N)rDrErFrGrrUr9rr�r�r�r�r�r�r
rr�r�r�r��objectr�r�r�r�r(r(r(r)r��s2



���
�x"


	r��flrcCs�t�}|�tjd�|�tjd�|�tjd�|�tjd�tt|dd��}|�	|�|�
|�|�tj|�|�
|�|jS)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.
    rrSrAN)r�
setFeaturer�feature_validation�feature_namespaces�feature_external_ges�feature_external_pesr��getattr�setContentHandler�setEntityResolver�setProperty�property_lexical_handler�parser�)r��parser�sr(r(r)�
_flatsaxParse{s


r�c@s8eZdZdZdeeeffdd�Zdedfdd�Z	d	S)
�	XMLStringzH
    An L{ITemplateLoader} that loads and parses XML from a string.
    r�cCs(t|t�s
|�d�}tt�|��|_dS)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)r.rU�decoder��io�StringIO�_loadedTemplate)r;r�r(r(r)r9�s

zXMLString.__init__r-rcCs|jS)zM
        Return the document.

        @return: the loaded document.
        )r�r�r(r(r)�load�szXMLString.loadN)
rDrErFrGrrUr/r9r
r�r(r(r(r)r��s
r�c@sFeZdZdZed�Zddd�Zedd��Zedd	��Z	ed
d��Z
dS)
�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>
NcCst�||�||_dSr7)rr9�failure)r;r�rlr(r(r)r9r]zFailureElement.__init__cCs|t|jj��S)zA
        Render the exception type as a child of C{tag}.
        )rr��typernr(r(r)r�szFailureElement.typecCs|t|jj��d��S)zB
        Render the exception value as a child of C{tag}.
        r�)rUr��valuerYrnr(r(r)r�szFailureElement.valuecCstt|�|jj�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�rnr(r(r)�	tracebackszFailureElement.tracebackr7)rDrErFrGr�rlr9rr�r�r�r(r(r(r)r��s
�
M

r�cCsNg}tdt|���|j�t|dt�r|d�d��dd�S|d��dS)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.
    Nrzutf-8rT�xmlcharrefreplace)	rr��addBothr�r.r/r�rY�raiseException)�	myFailure�resultr(r(r)�
formatFailure#s
rrSc@s,eZdZdZd
dd�Zdedfdd�Zd	S)r�zJ
    An L{ITemplateLoader} that loads an existing flattenable object.
    rorcCr�)z>
        @param tag: The object which will be loaded.
        Nr�)r;ror(r(r)r9IszTagLoader.__init__r-cCs|jgSr7r�r�r(r(r)r�QszTagLoader.loadN)ror)rDrErFrGr9r
r�r(r(r(r)r�Cs
r�c@sPeZdZdZdefdd�Zdedfdd�Zdefd	d
�Z	dedfdd�Z
d
S)�XMLFilezF
    An L{ITemplateLoader} that loads and parses XML from a file.
    �pathcCs,t|t�s
tjdtdd�d|_	||_dS)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.rx)�category�
stacklevelN)r.r�warnings�warn�DeprecationWarningr��_path)r;rr(r(r)r9[s
�zXMLFile.__init__r-rcCsNt|jt�st|j�S|j�d��}t|�Wd�S1s wYdS)zP
        Read and parse the XML.

        @return: the loaded document.
        �rN)r.r	rr��open)r;�fr(r(r)�_loadDocos

$�zXMLFile._loadDoccCsd|j�d�S)Nz<XMLFile of �>)r	r�r(r(r)�__repr__{rhzXMLFile.__repr__cCs|jdur
|��|_|jS)zl
        Return the document, first loading it if necessary.

        @return: the loaded document.
        N)r�r
r�r(r(r)r�~s

zXMLFile.loadN)rDrErFrGrr9r
r
rUrr�r(r(r(r)rUsr>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�embedrv�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�selectrk�strike�strong�acronym�address�article�caption�command�details�isindex�section�summary�basefont�colgroup�datalist�fieldset�frameset�noframes�noscript�optgroup�progress�textarea�
blockquote�
figcaptionc@s"eZdZdZdedefdd�ZdS)�_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.html 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}
    �tagNamer-cCs8|dkrtd�S|�d�}|tvrtd|����t|�S)Nr�r��_zunknown tag )r"r|�VALID_HTML_TAG_NAMES�AttributeError)r;r�r(r(r)�__getattr__s
z_TagFactory.__getattr__N)rDrErFrGrUr"r�r(r(r(r)r�	s
r��<!DOCTYPE html>�element�doctype�_failElementrcs�|dur��|���d��durt�t�|�j�}dtdttdf��fdd�}�d�dtd	tdtfd
d�}|�|�|�	|�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�r-csTtjd|d�t�dd�}|dur#|jr#�dusJ�t��|��j�S��d�dS)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,r(r)�ebAs��zrenderElement.<locals>.eb)r,rr,cSs|��|Sr7)�finish)rr,r(r(r)r�RszrenderElement.<locals>.finish)r�r�rrrrr�r%rar�r^)r,r�r�r�r\r�r�r(r�r)�
renderElement$s

 

r�)r�N)XrGr�rzr�collectionsrrFr�typingrrrrr	r
rrr
rr�xml.saxrr�xml.sax.xmlreaderr�zope.interfacer�twisted.internet.deferr�twisted.loggerr�twisted.pythonr�twisted.python.failurer�twisted.python.filepathr�twisted.python.reflectr�twisted.webr�twisted.web._elementrr�twisted.web._flattenrrr�twisted.web._stanr r!r"r#�twisted.web.iwebr$r%r&r*r/r4r[r5rJrRrZrirsr�r�r�r��ContentHandler�EntityResolverr�rUr�r�r�rr^r�r�rr�r��tagsr�r�r(r(r(r)�<module>s|4
)..%"yt7|������