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: //home/arjun/projects/env/lib/python3.10/site-packages/__pycache__/requests_file.cpython-310.pyc
o

'wey�@stddlmZddlmZmZddlmZmZddlZddl	Z	ddl
Z
ddlZddlZddl
mZGdd�de�ZdS)�)�BaseAdapter)�urlparse�unquote)�Response�codesN)�BytesIOcs.eZdZd�fdd�	Zdd�Zdd�Z�ZS)	�FileAdapterTcstt|���||_dS�N)�superr�__init__�_set_content_length)�self�set_content_length��	__class__��F/home/arjun/projects/env/lib/python3.10/site-packages/requests_file.pyrs
zFileAdapter.__init__c
KsJ|jdvrtd|j��t|j�}|jr|jdkrtd��t�}z�dd�|j�d�D�}|r=|ds=|�d�|r=|dr2t	d	d
�|D��rPt
tjt
�tj���|r�|d�d�s`|d�d�r�|�d�}|�d�rr|d
d�d}|r�|ds�|�d�|r�|drxnd}|t
jt
jj|�}|r�t
j�|�s�t
jt
jj|g|�R�}t�|d�|_|jj|j_WnMt
�y}z@|jtjkr�tj|_n|jtjkr�tj|_ntj|_t|��t �!d��}	t"|	�|_|j#r�t$|	�|j%d<|jj|j_WYd
}~|Sd
}~wwtj&|_|j|_t
�'|j�(��}
t)�*|
j+��r#|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 %s�	localhostz5file: URLs with hostname components are not permittedcSsg|]}t|��qSr)r��.0�prrr�
<listcomp>,sz$FileAdapter.send.<locals>.<listcomp>�/rcss�|]}tj|vVqdSr	)�os�seprrrr�	<genexpr>4s�z#FileAdapter.send.<locals>.<genexpr>�|�:N�����rbFzContent-Length)-�method�
ValueErrorr�url�netlocr�path�split�pop�any�IOError�errno�ENOENTr�strerror�endswithr�join�
splitdrive�io�open�raw�close�release_conn�EACCESr�	forbidden�status_code�	not_found�bad_request�str�encode�locale�getpreferredencodingrr�len�headers�ok�fstat�fileno�stat�S_ISREG�st_mode�st_size)r
�request�kwargs�	url_parts�resp�
path_parts�
path_driver'�e�resp_str�	resp_statrrr�sendsf


���


��



��zFileAdapter.sendcCsdSr	r)r
rrrr5tszFileAdapter.close)T)�__name__�
__module__�__qualname__rrRr5�
__classcell__rrrrr
sbr)�requests.adaptersr�requests.compatrr�requestsrrr,rrEr>r2�sixrrrrrr�<module>s