Spamworldpro Mini Shell
Spamworldpro


Server : Apache/2.4.52 (Ubuntu)
System : Linux webserver 6.8.0-49-generic #49~22.04.1-Ubuntu SMP PREEMPT_DYNAMIC Wed Nov 6 17:42:15 UTC 2 x86_64
User : www-data ( 33)
PHP Version : 8.1.2-1ubuntu2.21
Disable Function : NONE
Directory :  /lib/python3/dist-packages/twisted/web/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : //lib/python3/dist-packages/twisted/web/__pycache__/static.cpython-310.pyc
o

�b���@sdZddlZddlZddlZddlZddlZddlZddlmZddl	m
Z
mZmZddl
mZmZddlmZddlmZddlmZmZdd	lmZmZmZdd
lmZmZddlmZddl m!Z!dd
l"m#Z#ddl$m%Z%ddl&m'Z'm(Z(m)Z)ddl*m+Z+e(�,d�Z-dd�Z.Gdd�de(j/�Z0eedddd��dd��Z1dd�Z2Gdd�de(j/�Z3Gdd�dej4�Z5dej6fd d!�Z7d"d#�Z8Gd$d%�d%e(j/ej9�Z:eej;�Gd&d'�d'��Z<Gd(d)�d)e<�Z=Gd*d+�d+e<�Z>Gd,d-�d-e<�Z?Gd.d/�d/e(j/�Z@d0d1�ZAGd2d3�d3e(j/�ZBdS)4z&
Static resources for L{twisted.web}.
�N)�escape)�Any�Callable�Dict)�quote�unquote)�implementer)�Version)�abstract�
interfaces)�
components�filepath�log)�nativeString�
networkString)�
deprecated)�platformType)�URL)�InsensitiveDict)�http�resource�server)�
redirectTozInvalid request URL.cCs|dkpd|vpttj�|vS)Ns..�/)r�os�sep��path�r�4/usr/lib/python3/dist-packages/twisted/web/static.py�isDangerous%sr c@s$eZdZdZdd�Zdd�ZeZdS)�Dataz/
    This is a static, in-memory resource.
    cCstj�|�||_||_dS)z�
        @param data: The bytes that make up this data resource.
        @type data: L{bytes}

        @param type: A native string giving the Internet media type for this
            content.
        @type type: L{str}
        N)r�Resource�__init__�data�type)�selfr$r%rrrr#.s	
z
Data.__init__cCs>|�dt|j��|�ddt|j�f�|jdkrdS|jS)N�content-type�content-length�%d�HEAD�)�	setHeaderrr%�lenr$�method�r&�requestrrr�
render_GET;s

zData.render_GETN)�__name__�
__module__�__qualname__�__doc__r#r1�render_HEADrrrrr!)s

r!�Twisted�cCst|�S)zK
    Add a trailing slash to C{request}'s URI. Deprecated, do not use.
    )�	_addSlash)r0rrr�addSlashEsr:cCs8t�|j�d��}|jt|j�dgd�}|���d�S)a$
    Add a trailing slash to C{request}'s URI.

    @param request: The incoming request to add the ending slash to.
    @type request: An object conforming to L{twisted.web.iweb.IRequest}

    @return: A URI with a trailing slash, with query and fragment preserved.
    @rtype: L{bytes}
    �ascii�r)	r�fromText�uri�decode�replace�listr�asText�encode)r0�urlrrrr9Ms
r9c@seZdZdd�Zdd�ZdS)�RedirectcCstj�|�t|�|_dS�N)rr"r#r9rDr/rrrr#^szRedirect.__init__cCst|j|�SrF)rrDr/rrr�renderb�zRedirect.renderN)r2r3r4r#rGrrrrrE]srEc@�(eZdZdZdd�Zdd�Zdd�ZdS)	�Registryz�
    I am a Componentized object that will be made available to internal Twisted
    file-based dynamic web content such as .rpy and .epy scripts.
    cCstj�|�i|_dSrF)r�
Componentizedr#�
_pathCache�r&rrrr#ls
zRegistry.__init__cCs||j|<dSrF)rL)r&r�rsrcrrr�	cachePathp�zRegistry.cachePathcCs|j�|�SrF)rL�get)r&rrrr�
getCachedPathsrHzRegistry.getCachedPathN)r2r3r4r5r#rOrRrrrrrJfs
rJcCs.||�tj�dddddddddd�	�tjS)aS
    Produces a mapping of extensions (with leading dot) to MIME types.

    It does this by calling the C{init} function of the L{mimetypes} module.
    This will have the side effect of modifying the global MIME types cache
    in that module.

    Multiple file locations containing mime-types can be passed as a list.
    The files will be sourced in that order, overriding mime-types from the
    files sourced beforehand, but only if a new entry explicitly overrides
    the current entry.

    @param mimetype_locations: Optional. List of paths to C{mime.types} style
        files that should be used.
    @type mimetype_locations: iterable of paths or L{None}
    @param init: The init function to call. Defaults to the global C{init}
        function of the C{mimetypes} module. For internal use (testing) only.
    @type init: callable
    z
text/plainzaudio/x-flacz	text/x-ozzapplication/x-shockwave-flashztext/vnd.wap.wmlzapplication/vnd.mozilla.xul+xml)	z.confz.diffz.flacz.javaz.ozz.swfz.wmlz.xulz.patch)�	mimetypes�	types_map�update)�mimetype_locations�initrrr�
loadMimeTypesws��
rXcCs`t�|���\}}t�d|���}||vr$||}tj�|�d��}nd}|�||�}||fS)Nr<�)r
�FilePath�splitext�_coerceToFilesystemEncoding�lowerrrrQ)�filename�types�	encodings�defaultType�p�ext�encr%rrr�getTypeAndEncoding�srec@s�eZdZUdZe�Zddd�ZiZee	e
e	egeffe
d<gd�ZdZ	
d0dd�Zd
d�Ze�d�Ze��Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�Zd d!�Zd1d"d#�Z d$d%�Z!d&d'�Z"e"Z#d(d)�Z$d*d+�Z%d,d-�Z&d.d/�Z'dS)2�Filea@
    File is a resource that represents a plain non-interpreted file
    (although it can look for an extension like .rpy or .cgi and hand the
    file to a processor for interpretation if you wish). Its constructor
    takes a file path.

    Alternatively, you can give a directory path to the constructor. In this
    case the resource will represent that directory, and its children will
    be files underneath that directory. This provides access to an entire
    filesystem tree with a single Resource.

    If you map the URL 'http://server/FILE' to a resource created as
    File('/tmp'), then http://server/FILE/ will return an HTML-formatted
    listing of the /tmp/ directory, and http://server/FILE/foo/bar.html will
    return the contents of /tmp/foo/bar.html .

    @cvar childNotFound: L{Resource} used to render 404 Not Found error pages.
    @cvar forbidden: L{Resource} used to render 403 Forbidden error pages.

    @ivar contentTypes: a mapping of extensions to MIME types used to set the
        default value for the Content-Type header.
        It is initialized with the values returned by L{loadMimeTypes}.
    @type contentTypes: C{dict}

    @ivar contentEncodings: a mapping of extensions to encoding types used to
        set default value for the Content-Encoding header.
    @type contentEncodings: C{dict}
    �gzip�bzip2)z.gzz.bz2�
processors)�indexz
index.htmlz	index.htmz	index.rpyN�	text/htmlrrcCsjtj�|�tj�||�||_|dvs|r(t�d�|s|r$dg|_n	g|_nt	|�|_|p1t
�|_dS)a�
        Create a file with the given path.

        @param path: The filename of the file from which this L{File} will
            serve data.
        @type path: C{str}

        @param defaultType: A I{major/minor}-style MIME type specifier
            indicating the I{Content-Type} with which this L{File}'s data
            will be served if a MIME type cannot be determined based on
            C{path}'s extension.
        @type defaultType: C{str}

        @param ignoredExts: A sequence giving the extensions of paths in the
            filesystem which will be ignored for the purposes of child
            lookup.  For example, if C{ignoredExts} is C{(".bar",)} and
            C{path} is a directory containing a file named C{"foo.bar"}, a
            request for the C{"foo"} child of this resource will succeed
            with a L{File} pointing to C{"foo.bar"}.

        @param registry: The registry object being used to handle this
            request.  If L{None}, one will be created.
        @type registry: L{Registry}

        @param allowExt: Ignored parameter, only present for backwards
            compatibility.  Do not pass a value for this parameter.
        )rrYz0ignoredExts should receive a list, not a boolean�*N)rr"r#r
rZra�warnings�warn�ignoredExtsrArJ�registry)r&rrarorp�allowExtrrrr#�s


z
File.__init__cCs|j�|�dS)zQIgnore the given extension.

        Serve file.ext if file is requested
        N)ro�append)r&rcrrr�	ignoreExt�szFile.ignoreExtzFile not found.cCs$|j}|��}t|||j|j|j�S)z�
        Return a resource that generates an HTML listing of the
        directory this path represents.

        @return: A resource that renders the directory to HTML.
        @rtype: L{DirectoryLister}
        )r�	listNames�DirectoryLister�contentTypes�contentEncodingsra)r&r�namesrrr�directoryListings
�zFile.directoryListingcCs t|t�r"z|�d�}Wnty!t�dd|���|jYSw|jdd�|��s/|jS|rFz|�	|�}Wnt
jyE|jYSw|j|j
�}|durT|��S|��se|j|j�}|dure|jS|��d}tdkrxt|j��|�}n|j�|�}|r�t�||j|j��S|�|j�S)az
        If this L{File}"s path refers to a directory, return a L{File}
        referring to the file named C{path} in that directory.

        If C{path} is the empty string, return a L{DirectoryLister}
        instead.

        @param path: The current path segment.
        @type path: L{bytes}

        @param request: The incoming request.
        @type request: An that provides L{twisted.web.iweb.IRequest}.

        @return: A resource representing the requested file or
            directory, or L{NoResource} if the path cannot be
            accessed.
        @rtype: An object that provides L{resource.IResource}.
        zutf-8Nz(Could not decode path segment as utf-8: F)�reraiserY�win32)�
isinstance�bytesr?�UnicodeDecodeErrorr�err�
childNotFound�restat�isdir�childr
�InsecurePath�childSearchPreauth�
indexNamesry�exists�siblingExtensionSearchror[rrrirQr�	IResourcerrp�createSimilarFile)r&rr0�fpath�	extension�	processorrrr�getChilds<

�
�z
File.getChildcC�|��S)zOpen a file and return it.)�openrMrrr�openForReadingO�zFile.openForReadingcCr�)zReturn file size.)�getsizerMrrr�getFileSizeSr�zFile.getFileSizec		CsZz
|�dd�\}}Wntytd��w|��}|dkr%td|����ttdttj|�d����}g}|D]s}z
|�dd�\}}WntyQtd	|����w|rizt|�}Wntyhtd	|����wd}|r�zt|�}Wnty�td	|����wd}|dur�|dur�||kr�td	|����n|dur�td	|����|�||f�q7|S)
a�
        Parse the value of a Range header into (start, stop) pairs.

        In a given pair, either of start or stop can be None, signifying that
        no value was provided, but not both.

        @return: A list C{[(start, stop)]} of pairs of length at least one.

        @raise ValueError: if the header is syntactically invalid or if the
            Bytes-Unit is anything other than "bytes'.
        �=rYzMissing '=' separator�byteszUnsupported Bytes-Unit: N�,�-zInvalid Byte-Range: )	�split�
ValueError�striprA�filter�mapr}�intrr)	r&�range�kind�value�unparsedRanges�parsedRanges�	byteRange�start�endrrr�_parseRangeHeaderWsL�����zFile._parseRangeHeadercCsf|��}|dur||}|}n|dur|}n||kr|d7}n||kr%|}||kr-d}}|||fS)a�
        Convert a start and end from a Range header to an offset and size.

        This method checks that the resulting range overlaps with the resource
        being served (and so has the value of C{getFileSize()} as an indirect
        input).

        Either but not both of start or end can be L{None}:

         - Omitted start means that the end value is actually a start value
           relative to the end of the resource.

         - Omitted end means the end of the resource should be the end of
           the range.

        End is interpreted as inclusive, as per RFC 2616.

        If this range doesn't overlap with any of this resource, C{(0, 0)} is
        returned, which is not otherwise a value return value.

        @param start: The start value from the header, or L{None} if one was
            not present.
        @param end: The end value from the header, or L{None} if one was not
            present.
        @return: C{(offset, size)} where offset is how far into this resource
            this resource the range begins and size is how long the range is,
            or C{(0, 0)} if the range does not overlap this resource.
        NrYr)r�)r&r�r��sizerrr�_rangeToOffsetAndSize�s
zFile._rangeToOffsetAndSizecCstd|||d|��f�S)a�
        Return a string suitable for the value of a Content-Range header for a
        range with the given offset and size.

        The offset and size are not sanity checked in any way.

        @param offset: How far into this resource the range begins.
        @param size: How long the range is.
        @return: The value as appropriate for the value of a Content-Range
            header.
        zbytes %d-%d/%drY)rr�)r&�offsetr�rrr�
_contentRange�s�zFile._contentRangecCs�|\}}|�||�\}}||krdkr/nn|�tj�|�dtd|��f��||fS|�tj�|�d|�||��||fS)a�
        Set up the response for Range headers that specify a single range.

        This method checks if the request is satisfiable and sets the response
        code and Content-Range header appropriately.  The return value
        indicates which part of the resource to return.

        @param request: The Request object.
        @param startAndEnd: A 2-tuple of start of the byte range as specified by
            the header and the end of the byte range as specified by the header.
            At most one of the start and end may be L{None}.
        @return: A 2-tuple of the offset and size of the range to return.
            offset == size == 0 indicates that the request is not satisfiable.
        r�
content-range�
bytes */%d)	r��setResponseCoder�REQUESTED_RANGE_NOT_SATISFIABLEr,rr��PARTIAL_CONTENTr�)r&r0�startAndEndr�r�r�r�rrr�_doSingleRangeRequest�s��zFile._doSingleRangeRequestcCsld}g}d}ttt��d�d�t��d���}|jr|j}nd}|D]B\}}	|�||	�\}
}|
|kr9dkr<nnq#||7}d}|�|
|�}tdt|�t|�t|�f�}
|t	|
�7}|�
|
|
|f�q#|s�|�tj
�|�dd	�|�d
td|��f��gdfSd
|d}|�
|ddf�|�tj�|�dtdt|��d���|�dd|t	|�f�|S)aq
        Set up the response for Range headers that specify a single range.

        This method checks if the request is satisfiable and sets the response
        code and Content-Type and Content-Length headers appropriately.  The
        return value, which is a little complicated, indicates which parts of
        the resource to return and the boundaries that should separate the
        parts.

        In detail, the return value is a tuple rangeInfo C{rangeInfo} is a
        list of 3-tuples C{(partSeparator, partOffset, partSize)}.  The
        response to this request should be, for each element of C{rangeInfo},
        C{partSeparator} followed by C{partSize} bytes of the resource
        starting at C{partOffset}.  Each C{partSeparator} includes the
        MIME-style boundary and the part-specific Content-type and
        Content-range headers.  It is convenient to return the separator as a
        concrete string from this method, because this method needs to compute
        the number of bytes that will make up the response to be able to set
        the Content-Length header of the response accurately.

        @param request: The Request object.
        @param byteRanges: A list of C{(start, end)} values as specified by
            the header.  For each range, at most one of C{start} and C{end}
            may be L{None}.
        @return: See above.
        Fri@B�xr�Tz/
--%s
Content-type: %s
Content-range: %s

r(�0r�r�r+s
--s--
r'z multipart/byteranges; boundary="�"r))rr��timer�getpidr%r�r�rr-rrr�rr�r,r�r�)r&r0�
byteRanges�matchingRangeFound�	rangeInfo�
contentLength�boundary�contentTyper�r��
partOffset�partSize�partContentRange�
partSeparator�
finalBoundaryrrr�_doMultipleRangeRequest�sT$������zFile._doMultipleRangeRequestcCsZ|dur|��}|�dd|f�|jr|�dt|j��|jr+|�dt|j��dSdS)a�
        Set the Content-length and Content-type headers for this request.

        This method is not appropriate for requests for multiple byte ranges;
        L{_doMultipleRangeRequest} will set these headers in that case.

        @param request: The L{twisted.web.http.Request} object.
        @param size: The size of the response.  If not specified, default to
            C{self.getFileSize()}.
        Nr(r)r'scontent-encoding)r�r,r%r�encoding)r&r0r�rrr�_setContentHeaders/s�zFile._setContentHeaderscCs�|�d�}|dur|�|�|�tj�t||�Sz|�|�}Wn#tyCt�	d|�
����|�|�|�tj�t||�YSwt|�dkra|�||d�\}}|�||�t
||||�S|�||�}t|||�S)a�
        Make a L{StaticProducer} that will produce the body of this response.

        This method will also set the response code and Content-* headers.

        @param request: The L{twisted.web.http.Request} object.
        @param fileForReading: The file object containing the resource.
        @return: A L{StaticProducer}.  Calling C{.start()} on this will begin
            producing the response.
        srangeNz Ignoring malformed Range header rYr)�	getHeaderr�r�r�OK�NoRangeStaticProducerr�r�r�msgr?r-r��SingleRangeStaticProducerr��MultipleRangeStaticProducer)r&r0�fileForReadingr�r�r�r�r�rrr�makeProducerBs&



�zFile.makeProducerc
Cs|�d�|jdurt|��|j|j|j�\|_|_|��s$|j	�
|�S|��r-|�|�S|�
dd�z|��}WntyX}z|jtjkrS|j�
|�WYd}~S�d}~ww|�|���tjuri|��dS|jdkry|�|�|��dS|�||�}|��tjS)z�
        Begin sending the contents of this L{File} (or a subset of the
        contents, based on the 'range' header) to the given request.
        FNs
accept-rangesr�r+r*)r�r%re�basenamervrwrar�r�r�rGr��redirectr,r��OSError�errno�EACCES�	forbidden�setLastModified�getModificationTimer�CACHED�closer.r�r�r�r�NOT_DONE_YET)r&r0r��e�producerrrrr1bs>

�
��

zFile.render_GETcCstt|�|�SrF)rr9r/rrrr��rPz
File.redirectcCs |��sgS|��}|��|SrF)r��listdir�sort)r&�	directoryrrrrt�s
zFile.listNamescCstt|fdd�|����S)NcSs|�tj�|j|��SrF)r�rr�join)�fileNamer&rrr�<lambda>�s�z#File.listEntities.<locals>.<lambda>)rAr�rtrMrrr�listEntities�s
��zFile.listEntitiescCs:|�||j|j|j�}|j|_|jdd�|_|j|_|SrF)�	__class__rarorprir�r�)r&r�frrrr��s
zFile.createSimilarFile)rkrNrrF)(r2r3r4r5rXrvrwrir�strrrr!�__annotations__r�r%r#rsr�
NoResourcer��ForbiddenResourcer�ryr�r�r�r�r�r�r�r�r�r�r1r6r�rtr�r�rrrrrf�s:

 
�+
<3+
M 4
rfc@s8eZdZdZejjZdd�Zdd�Zdd�Z	dd	�Z
d
S)�StaticProducerz�
    Superclass for classes that implement the business of producing.

    @ivar request: The L{IRequest} to write the contents of the file to.
    @ivar fileObject: The file the contents of which to write to the request.
    cCs||_||_dS)z*
        Initialize the instance.
        N)r0�
fileObject)r&r0r�rrrr#�s
zStaticProducer.__init__cC�
t|j��rF)�NotImplementedErrorr�rMrrrr���
zStaticProducer.startcCr�rF)r��resumeProducingrMrrrr��r�zStaticProducer.resumeProducingcCs|j��d|_dS)z�
        Stop producing data.

        L{twisted.internet.interfaces.IProducer.stopProducing}
        is called when our consumer has died, and subclasses also call this
        method when they are done producing data.
        N)r�r�r0rMrrr�
stopProducing�s

zStaticProducer.stopProducingN)r2r3r4r5r
�FileDescriptor�
bufferSizer#r�r�r�rrrrr��sr�c@s eZdZdZdd�Zdd�ZdS)r�zI
    A L{StaticProducer} that writes the entire file to the request.
    cCs|j�|d�dS)NF)r0�registerProducerrMrrrr��szNoRangeStaticProducer.startcCsL|jsdS|j�|j�}|r|j�|�dS|j��|j��|��dSrF)r0r��readr��write�unregisterProducer�finishr��r&r$rrrr��s

z%NoRangeStaticProducer.resumeProducingN)r2r3r4r5r�r�rrrrr��sr�c@rI)	r�zR
    A L{StaticProducer} that writes a single chunk of a file to the request.
    cCst�|||�||_||_dS)a

        Initialize the instance.

        @param request: See L{StaticProducer}.
        @param fileObject: See L{StaticProducer}.
        @param offset: The offset into the file of the chunk to be written.
        @param size: The size of the chunk to write.
        N)r�r#r�r�)r&r0r�r�r�rrrr#�s	
z"SingleRangeStaticProducer.__init__cCs&|j�|j�d|_|j�|d�dS�Nr)r��seekr��bytesWrittenr0r�rMrrrr�szSingleRangeStaticProducer.startcCs�|jsdS|j�t|j|j|j��}|r$|jt|�7_|j�|�|jr=|j|jkr?|j�	�|j�
�|��dSdSdSrF)r0r�r��minr�r�r�r-r�r�r�r�r�rrrr�s

�z)SingleRangeStaticProducer.resumeProducingN)r2r3r4r5r#r�r�rrrrr��s

r�c@s0eZdZdZdd�Zdd�Zdd�Zdd	�Zd
S)r�zR
    A L{StaticProducer} that writes several chunks of a file to the request.
    cCst�|||�||_dS)a�
        Initialize the instance.

        @param request: See L{StaticProducer}.
        @param fileObject: See L{StaticProducer}.
        @param rangeInfo: A list of tuples C{[(boundary, offset, size)]}
            where:
             - C{boundary} will be written to the request first.
             - C{offset} the offset into the file of chunk to write.
             - C{size} the size of the chunk to write.
        N)r�r#r�)r&r0r�r�rrrr#s
z$MultipleRangeStaticProducer.__init__cCs&t|j�|_|��|j�|d�dSr�)�iterr��	rangeIter�
_nextRanger0r�rMrrrr�)sz!MultipleRangeStaticProducer.startcCs*t|j�\|_}|_d|_|j�|�dSr�)�nextr��partBoundary�	_partSize�_partBytesWrittenr�r�)r&r�rrrr�.sz&MultipleRangeStaticProducer._nextRangecCs|jsdSg}d}d}||jkrg|jr#|t|j�7}|�|j�d|_|j�t|j||j|j	��}|j	t|�7_	|t|�7}|�|�|jrb|j	|jkrbz|�
�Wntyad}Ynw||jks|j�d�
|��|r�|j��|j��|��dSdS)NrFTr+)r0r�r�r-rrr�r�r�rrr��
StopIterationr�r�r�r�r�)r&r$�
dataLength�donerbrrrr�3sB

��
�
�

�z+MultipleRangeStaticProducer.resumeProducingN)r2r3r4r5r#r�r�r�rrrrr�sr�c@s"eZdZdZddd�Zdd�ZdS)�
ASISProcessorz
    Serve files exactly as responses without generating a status-line or any
    headers.  Inspired by Apache's mod_asis.
    NcCs"tj�|�||_|p
t�|_dSrF)rr"r#rrJrp)r&rrprrrr#ZszASISProcessor.__init__cCs d|_t|j|jd�}|�|�S)NrY)rp)�startedWritingrfrrprG)r&r0�resrrrrG_s
zASISProcessor.renderrF)r2r3r4r5r#rGrrrrrTs
rcCsD|dkrd|S|dkrd|dS|dkrd|dSd|dS)zG
    Format the given file size in bytes to human readable format.
    iz%iBiz%iKi@z%iMz%iGr)r�rrr�formatFileSizeesrc@sXeZdZdZdZdZdejejdfdd�Z	dd	�Z
d
d�Zdd
�Zde
fdd�ZeZdS)rua�
    Print the content of a directory.

    @ivar template: page template used to render the content of the directory.
        It must contain the format keys B{header} and B{tableContent}.
    @type template: C{str}

    @ivar linePattern: template used to render one line in the listing table.
        It must contain the format keys B{class}, B{href}, B{text}, B{size},
        B{type} and B{encoding}.
    @type linePattern: C{str}

    @ivar contentTypes: a mapping of extensions to MIME types used to populate
        the information of a member of this directory.
        It is initialized with the value L{File.contentTypes}.
    @type contentTypes: C{dict}

    @ivar contentEncodings: a mapping of extensions to encoding types.
        It is initialized with the value L{File.contentEncodings}.
    @type contentEncodings: C{dict}

    @ivar defaultType: default type used when no mimetype is detected.
    @type defaultType: C{str}

    @ivar dirs: filtered content of C{path}, if the whole content should not be
        displayed (default to L{None}, which means the actual content of
        C{path} is printed).
    @type dirs: L{None} or C{list}

    @ivar path: directory which content should be listed.
    @type path: C{str}
    a<html>
<head>
<title>%(header)s</title>
<style>
.even-dir { background-color: #efe0ef }
.even { background-color: #eee }
.odd-dir {background-color: #f0d0ef }
.odd { background-color: #dedede }
.icon { text-align: center }
.listing {
    margin-left: auto;
    margin-right: auto;
    width: 50%%;
    padding: 0.1em;
    }

body { border: 0; padding: 0; margin: 0; background-color: #efefef; }
h1 {padding: 0.1em; background-color: #777; color: white; border-bottom: thin white dashed;}

</style>
</head>

<body>
<h1>%(header)s</h1>

<table>
    <thead>
        <tr>
            <th>Filename</th>
            <th>Size</th>
            <th>Content type</th>
            <th>Content encoding</th>
        </tr>
    </thead>
    <tbody>
%(tableContent)s
    </tbody>
</table>

</body>
</html>
z�<tr class="%(class)s">
    <td><a href="%(href)s">%(text)s</a></td>
    <td>%(size)s</td>
    <td>%(type)s</td>
    <td>%(encoding)s</td>
</tr>
NrkcCs.tj�|�||_||_||_||_||_dSrF)rr"r#rvrwra�dirsr)r&�pathnamer	rvrwrarrrr#�s
zDirectoryLister.__init__c	Cs�g}g}|D]c}t|t�r|�d�}t|d�}t|�}t�|j��|�}|�	�r8|�
|d|ddddd��qt||j|j
|j�\}}	z|��}
Wn	tySYqw|�
||d||	rad|	pbdt|
�d��q||fS)a
        Helper returning files and directories in given directory listing, with
        attributes to be used to build a table content with
        C{self.linePattern}.

        @return: tuple of (directories, files)
        @rtype: C{tuple} of C{list}
        �utf8�/r<z[Directory])�text�hrefr�r%r�z[%s])r
rr%r�r�)r|r}r?rrr
rZrr�r�rrrervrwrar�r�r)r&r��filesr	rrD�escapedPath�	childPath�mimetyper�r�rrr�_getFilesAndDirectories�sD	


��
����	z'DirectoryLister._getFilesAndDirectoriescCsBg}t�ddg�}t||�D]\}}||d<|�|j|�q|S)zs
        Build a table content using C{self.linePattern} and giving elements odd
        and even classes.
        �odd�even�class)�	itertools�cycle�ziprr�linePattern)r&�elements�tableContent�
rowClasses�element�rowClassrrr�_buildTableContent	sz"DirectoryLister._buildTableContentcCs�|�dd�|jdurt�|j�}|��n|j}|�|�\}}d�|�||��}d�	t
tt|j
����}|j||d�}|�d�}|S)zB
        Render a listing of the content of C{self.path}.
        r'stext/html; charset=utf-8Nr<zDirectory listing for {})�headerrr)r,r	rr�rr�rr�r �formatrrrr>�templaterC)r&r0r�r	rrr!rrrrrGs

�
zDirectoryLister.render�returncCs
d|jS)Nz<DirectoryLister of %r>rrMrrr�__repr__-r�zDirectoryLister.__repr__)r2r3r4r5r#rrfrvrwr#rr rGr�r%�__str__rrrrruss!+
�1ru)Cr5r�rrSrr�rm�htmlr�typingrrr�urllib.parserr�zope.interfacer�incrementalr	�twisted.internetr
r�twisted.pythonrr
r�twisted.python.compatrr�twisted.python.deprecater�twisted.python.runtimer�twisted.python.urlr�twisted.python.utilr�twisted.webrrr�twisted.web.utilrr��dangerousPathErrorr r"r!r:r9rErKrJrWrXrerZrf�
IPullProducerr�r�r�r�rrrurrrr�<module>sX

	%#&?

Spamworldpro Mini