Mini Shell

Direktori : /usr/lib/python3.6/site-packages/__pycache__/
Upload File :
Current File : //usr/lib/python3.6/site-packages/__pycache__/requests_file.cpython-36.pyc

3

��KZ��@stddlmZddlmZmZddlmZmZddlZddl	Z	ddl
Z
ddlZddlZddl
mZGdd�de�ZdS)�)�BaseAdapter)�urlparse�unquote)�Response�codesN)�BytesIOc@seZdZdd�Zdd�ZdS)�FileAdaptercKs>|jdkrtd|j��t|j�}|jr:|jdkr:td��t�}�y(dd�|jjd�D�}x|rv|d	rv|jd	�q\Wt	d
d�|D��r�t
tjt
jtj���|o�|d	jd�s�|d	jd
��r|jd	�}|jd�r�|dd�d
}x$|o�|d	�r|jd	�q�Wnd}|t
jt
jj|�}|�rNt
jj|��rNt
jt
jj|f|��}tj|d�|_|jj|j_Wn�t
k
�r�}zv|jtjk�r�tj|_n |jtjk�r�tj|_ntj|_t|�jt j!d��}	t"|	�|_t#|	�|j$d<|jj|j_WYdd}~Xn<Xtj%|_|j|_t
j&|jj'��}
t(j)|
j*��r:|
j+|j$d<|S)z� Wraps a file, described in request, in a Response object.

            :param request: The PreparedRequest` being "sent".
            :returns: a Response object containing the file
        �GET�HEADzInvalid request method %sZ	localhostz5file: URLs with hostname components are not permittedcSsg|]}t|��qS�)r)�.0�prr�#/usr/lib/python3.6/requests_file.py�
<listcomp>'sz$FileAdapter.send.<locals>.<listcomp>�/rcss|]}tj|kVqdS)N)�os�sep)rr
rrr�	<genexpr>/sz#FileAdapter.send.<locals>.<genexpr>�|�:N���rbFzContent-Length)r	r
���),�method�
ValueErrorrZurlZnetlocr�path�split�pop�any�IOError�errno�ENOENTr�strerror�endswithr�join�
splitdrive�io�open�raw�closeZrelease_connZEACCESrZ	forbiddenZstatus_codeZ	not_foundZbad_request�str�encode�locale�getpreferredencodingr�lenZheaders�ok�fstat�fileno�stat�S_ISREG�st_mode�st_size)�selfZrequest�kwargsZ	url_partsZresp�
path_partsZ
path_driver�eZresp_strZ	resp_statrrr�send
sR






zFileAdapter.sendcCsdS)Nr)r7rrrr*mszFileAdapter.closeN)�__name__�
__module__�__qualname__r;r*rrrrrs`r)Zrequests.adaptersrZrequests.compatrrZrequestsrrr!rr3r-r'Zsixrrrrrr�<module>s