o
    
j6h                     @   s  d dl Z d dlZd dlZd dlZd dlZd dlZd dlZd dlm	Z	m
Z
 d dlmZ d dlmZ d dlmZ d dlmZ d dlmZ d dlmZ d d	lmZmZmZ d d
lmZ dZee Z!de"de"fddZ#G dd dZ$de"de%fddZ&dedej'ddfddZ(dS )    N)AnyDict)parse)LinkCollector)PackageFinder)get_default_environment)SelectionPreferences)
PipSession)adjacent_tmp_filecheck_path_ownerreplace)
ensure_dirz%Y-%m-%dT%H:%M:%SZkeyreturnc                 C   s   |   }t| }|S N)encodehashlibsha224	hexdigest)r   	key_bytesname r   p/var/www/html/chefvision.cloud.itp360.com/venv/lib/python3.10/site-packages/pip/_internal/self_outdated_check.py_get_statefile_name   s   r   c                   @   sH   e Zd ZdeddfddZedefddZded	ejddfd
dZdS )SelfCheckState	cache_dirr   Nc              
   C   s   i | _ d | _|rDtj|dt| j| _z"t| jdd}t	|| _ W d    W d S 1 s/w   Y  W d S  t
ttfyC   Y d S w d S )N	selfcheckzutf-8)encoding)statestatefile_pathospathjoinr   r   openjsonloadOSError
ValueErrorKeyError)selfr   	statefiler   r   r   __init__!   s   &zSelfCheckState.__init__c                 C   s   t jS r   )sysprefix)r)   r   r   r   r   2   s   zSelfCheckState.keypypi_versioncurrent_timec                 C   s   | j sd S ttj| j sd S ttj| j  | j|t|d}t	j
|ddd}t| j }||  W d    n1 sBw   Y  z
t|j| j  W d S  ty[   Y d S w )N)r   
last_checkr.   T),:)	sort_keys
separators)r   r   r    r!   dirnamer   r   strftimeSELFCHECK_DATE_FMTr$   dumpsr
   writer   r   r   r&   )r)   r.   r/   r   textfr   r   r   save6   s$   zSelfCheckState.save)	__name__
__module____qualname__strr+   propertyr   datetimer<   r   r   r   r   r       s
    r   pkgc                 C   s   t  | }|duod|jkS )zChecks whether pkg was installed by pip

    This is used not to display the upgrade message when pip is in fact
    installed by system package manager, such as dnf on Fedora.
    Npip)r   get_distribution	installer)rC   distr   r   r   was_installed_by_pipY   s   rH   sessionoptionsc                 C   sT  t  d}|s
dS |j}d}zt|jd}tj }d|jv r<d|jv r<tj|jd t	}|| 
 dk r<|jd }|du rqtj| |dd}td	d	d
}	tj||	d|jv d}
|
dj}|du rfW dS t|j}||| t|}||k o|j|jkotd}|sW dS tj d}td||| W dS  ty   tjddd Y dS w )zCheck for an update for pip.

    Limit the frequency of checks to once per week. State is stored either in
    the active virtualenv or in the user's USER_CACHE_DIR keyed off the prefix
    of the pip script path.
    rD   N)r   r0   r.   i:	 T)rJ   suppress_no_indexF)allow_yankedallow_all_prereleaseshtml5lib)link_collectorselection_prefsuse_deprecated_html5libz -m pipzYou are using pip version %s; however, version %s is available.
You should consider upgrading via the '%s install --upgrade pip' command.z5There was an error checking the latest version of pip)exc_info)r   rE   versionr   r   rB   utcnowr   strptimer7   total_secondsr   creater   r   deprecated_features_enabledfind_best_candidatebest_candidater@   r<   parse_versionbase_versionrH   r,   
executableloggerwarning	Exceptiondebug)rI   rJ   installed_distpip_versionr.   r   r/   r0   rO   rP   finderrZ   remote_versionlocal_version_is_olderpip_cmdr   r   r   pip_self_version_checkc   sn   






rh   ))rB   r   r$   loggingoptparseos.pathr    r,   typingr   r   pip._vendor.packaging.versionr   r[   pip._internal.index.collectorr   "pip._internal.index.package_finderr   pip._internal.metadatar   $pip._internal.models.selection_prefsr   pip._internal.network.sessionr	   pip._internal.utils.filesystemr
   r   r   pip._internal.utils.miscr   r7   	getLoggerr=   r^   r@   r   r   boolrH   Valuesrh   r   r   r   r   <module>   s,    
9
