Viewing File: /lib/python3.6/site-packages/pip/_vendor/cachecontrol/caches/__pycache__/file_cache.cpython-36.pyc

3

�Pf�
�@sdddlZddlZddlmZddlmZddlmZddlm	Z	dd�Z
Gd	d
�d
e�Zdd�ZdS)
�N)�LockFile)�
MkdirLockFile�)�	BaseCache)�CacheControllercCs�tj}|tjtjBO}ttd�r*|tjO}ttd�r>|tjO}ytj|�Wntt	fk
rdYnXtj
|||�}ytj|d�Stj|��YnXdS)N�
O_NOFOLLOW�O_BINARY�wb)
�os�O_WRONLY�O_CREAT�O_EXCL�hasattrrr�remove�IOError�OSError�open�fdopen�close)�filenameZfmode�flags�fd�r� /usr/lib/python3.6/file_cache.py�_secure_open_writes 




rc@sBeZdZddd�Zedd��Zd	d
�Zdd�Zd
d�Zdd�Z	dS)�	FileCacheF��NcCsN|dk	r|dk	rtd��|r t}|dkr,t}||_||_||_||_||_dS)Nz/Cannot use use_dir_lock and lock_class together)�
ValueErrorrr�	directory�forever�filemode�dirmode�
lock_class)�selfrr r!r"Zuse_dir_lockr#rrr�__init__4szFileCache.__init__cCstj|j��j�S)N)�hashlibZsha224�encodeZ	hexdigest)�xrrrr'GszFileCache.encodecCs4|j|�}t|dd��|g}tjj|jf|��S)N�)r'�listr
�path�joinr)r$�nameZhashed�partsrrr�_fnKs
z
FileCache._fnc	Cs8|j|�}tjj|�sdSt|d��
}|j�SQRXdS)N�rb)r/r
r+�existsr�read)r$�keyr-�fhrrr�getRs

z
FileCache.getcCs||j|�}ytjtjj|�|j�Wnttfk
r<YnX|j|��*}t	|j|j
��}|j|�WdQRXWdQRXdS)N)r/r
�makedirsr+�dirnamer"rrr#rr!�write)r$r3�valuer-�lockr4rrr�setZs
z
FileCache.setcCs|j|�}|jstj|�dS)N)r/r r
r)r$r3r-rrr�deletehs
zFileCache.delete)FrrNN)
�__name__�
__module__�__qualname__r%�staticmethodr'r/r5r;r<rrrrr3s
rcCstj|�}|j|�S)z\Return the file cache path based on the URL.

    This does not ensure the file exists!
    )rZ	cache_urlr/)ZurlZ	filecacher3rrr�url_to_file_pathns
rA)
r&r
Zpip._vendor.lockfilerZ"pip._vendor.lockfile.mkdirlockfiler�cacherZ
controllerrrrrArrrr�<module>s(;
Back to Directory File Manager
<