Your IP : 216.73.216.213


Current Path : /opt/alt/python37/lib/python3.7/site-packages/webob/__pycache__/
Upload File :
Current File : //opt/alt/python37/lib/python3.7/site-packages/webob/__pycache__/static.cpython-37.pyc

B

��vP
�@s�ddlZddlZddlmZddlmZddlmZddgZde_	e�
dd�e�
d	d
�dZGdd�de�Z
Gd
d�de�ZGdd�de�ZdS)�N)�exc)�wsgify)�Response�FileApp�DirectoryAppztext/javascriptz.jszimage/x-iconz.icoic@s$eZdZdZdd�Zedd��ZdS)rz{An application that will send the file at the given filename.

    Adds a mime type based on `mimetypes.guess_type()`.
    cKsH||_t�|�\}}|�d|�|�d|�|�dd�||_t|_dS)N�content_type�content_encodingZ
accept_ranges�bytes)�filename�	mimetypesZ
guess_type�
setdefault�kw�open�_open)�selfr
r
rr�r�=/opt/alt/python37/lib/python3.7/site-packages/webob/static.py�__init__szFileApp.__init__c
Cs�|jdkrt�d|j�Syt�|j�}Wn<ttfk
rf}zd|j|f}tj|d�Sd}~XYnXy|�	|jd�}Wn4ttfk
r�}zd|}t�
|�Sd}~XYnXd|jkr�|jd|t�}nt
|�}tf||j|jd�|j��jS)	N)ZGETZHEADzYou cannot %s a filezCan't open %r: %s)�comment�rbz,You are not permitted to view this file (%s)zwsgi.file_wrapper)�app_iterZcontent_lengthZ
last_modified)�methodrZHTTPMethodNotAllowed�os�statr
�IOError�OSError�HTTPNotFoundr�
HTTPForbidden�environ�
BLOCK_SIZE�FileIterr�st_size�st_mtimer
Zconditional_response_app)r�reqr�e�msg�filerrrr�__call__#s*


zFileApp.__call__N)�__name__�
__module__�__qualname__�__doc__rrr'rrrrrs
c@s"eZdZdd�Zddd�ZeZdS)r cCs
||_dS)N)r&)rr&rrrrCszFileIter.__init__Nccs�|dkrt}|r,|j�|�|dk	r,||8}zVxP|j�|dk	rHt||�n|�}|sVdS|V|dk	r0|t|�8}|dkr0dSq0WWd|j��XdS)a_Iter over the content of the file.

        You can set the `seek` parameter to read the file starting from a
        specific position.

        You can set the `limit` parameter to read the file up to specific
        position.

        Finally, you can change the number of bytes read at once by setting the
        `block_size` parameter.
        Nr)rr&�seek�read�min�len�close)rr,�limit�
block_size�datarrr�app_iter_rangeFs&
zFileIter.app_iter_range)NNN)r(r)r*rr4�__iter__rrrrr Bs
#r c@s6eZdZdZd
dd�Zdd�Zedd	��Zd
d�ZdS)ra�An application that serves up the files in a given directory.

    This will serve index files (by default ``index.html``), or set
    ``index_page=None`` to disable this.  If you set
    ``hide_index_with_redirect=True`` (it defaults to False) then
    requests to, e.g., ``/index.html`` will be redirected to ``/``.

    To customize `FileApp` instances creation (which is what actually
    serves the responses), override the `make_fileapp` method.
    �
index.htmlFcKsbtj�|�|_|j�tjj�s0|jtjj7_tj�|j�sLtd|j��||_||_||_	dS)Nz+Path does not exist or is not directory: %r)
r�path�abspath�endswith�sep�isdirr�
index_page�hide_index_with_redirect�
fileapp_kw)rr7r<r=r
rrrrxszDirectoryApp.__init__cCst|f|j�S)N)rr>)rr7rrr�make_fileapp�szDirectoryApp.make_fileappcCs�tj�tj�|j|j�d���}tj�|�r>|jr>|�||�S|jr�|j	r�|�
tjj|j�r�|j�
dd�d}|d7}|jr�|d|j7}td|d�Stj�|�s�tj|d�S|�|j�s�t��S|�|�SdS)N�/�r�?i-)�status�location)r)rr7r8�join�	path_info�lstripr;r<�indexr=r9r:�path_url�rsplit�query_stringr�isfilerr�
startswithrr?)rr#r7Znew_urlrrrr'�s$zDirectoryApp.__call__cCshtj�||j�}tj�|�s(tj|d�S|j�d�s^|j	d}|j
rR|d|j
7}td|d�S|�|�S)N)rr@rBi-)rCrD)
rr7rEr<rLrrrFr9rIrKrr?)rr#r7Z
index_path�urlrrrrH�s
zDirectoryApp.indexN)r6F)	r(r)r*r+rr?rr'rHrrrrrls


)rr�webobrZ	webob.decrZwebob.responser�__all__�_winregZadd_typer�objectrr rrrrr�<module>s/*