
    *,h                     2   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Zd dl	m
Z
 d dlmZmZ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 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) d dl*m+Z+m,Z,m-Z- d dl.m/Z/ dZ0 ejb                  e2      Z3de4de4fdZ5 G d d      Z6e
 G d d             Z7de4de8fdZ9de$dejt                  dee4   fdZ;de6d e j                   d!e d"eg ee4   f   dee7   f
d#Z<de$dejt                  ddfd$Z=y)%    N)	dataclass)AnyCallableDictOptional)parse)Group)escape)Text)LinkCollector)PackageFinder)get_default_environment)DistributionVersion)SelectionPreferences)
PipSession)WINDOWS) get_best_invocation_for_this_pip#get_best_invocation_for_this_python)adjacent_tmp_filecheck_path_ownerreplace)
ensure_dirz%Y-%m-%dT%H:%M:%SZkeyreturnc                 l    | j                         }t        j                  |      j                         }|S N)encodehashlibsha224	hexdigest)r   	key_bytesnames      c/var/www/html/Resume-Scraper/venv/lib/python3.12/site-packages/pip/_internal/self_outdated_check.py_get_statefile_namer$   %   s)    

I>>)$..0DK    c                       e Zd ZdeddfdZedefd       Zdej                  dee   fdZ	dedej                  ddfd	Z
y)
SelfCheckState	cache_dirr   Nc                 Z   i | _         d | _        |rut        j                  j	                  |dt        | j                              | _        	 t        | j                  d      5 }t        j                  |      | _         d d d        y y # 1 sw Y   y xY w# t        t        t        f$ r Y y w xY w)N	selfcheckzutf-8)encoding)_state_statefile_pathospathjoinr$   r   openjsonloadOSError
ValueErrorKeyError)selfr(   	statefiles      r#   __init__zSelfCheckState.__init__,   s    &(# #%77<<;(;DHH(E$D $..A 7Y"&))I"6DK7 7 
7 7Z2  s0   B "B=B BB B B*)B*c                 "    t         j                  S r   )sysprefix)r7   s    r#   r   zSelfCheckState.key=   s    zzr%   current_timec                    | j                   syd| j                   vryd| j                   vryd}t        j                  j                  | j                   d   t              }||z
  j	                         }||kD  ry| j                   d   S )z7Check if we have a not-outdated version loaded already.N
last_checkpypi_versioni:	 )r,   datetimestrptime	_DATE_FMTtotal_seconds)r7   r=   seven_days_in_secondsr?   seconds_since_last_checks        r#   getzSelfCheckState.getA   s    {{t{{*, 0 &&//L0I9U
$0:$=#L#L#N #&;;{{>**r%   r@   c                 P   | j                   sy t        t        j                  j	                  | j                               sy t        t        j                  j	                  | j                                | j                  |j                  t              |d}t        j                  |dd      }t        | j                         5 }|j                  |j                                d d d        	 t        j                  | j                          y # 1 sw Y   +xY w# t         $ r Y y w xY w)N)r   r?   r@   T),:)	sort_keys
separators)r-   r   r.   r/   dirnamer   r   strftimerC   r2   dumpsr   writer   r   r"   r4   )r7   r@   r=   statetextfs         r#   setzSelfCheckState.setV   s    ##  0D0D EF 	277??4#7#789
 88&//	:(
 zz%4JGt334 	#GGDKKM"	#	 AFFD001	# 	#  		s    D, D D	D%$D%)__name__
__module____qualname__strr9   propertyr   rA   r   rG   rT    r%   r#   r'   r'   +   sm    # $ " S  + 1 1 +hsm +*   83D3D    r%   r'   c                   .    e Zd ZU eed<   eed<   defdZy)UpgradePromptoldnewr   c                    t         rt                d}n
t               }d}t        t	               t	        j
                  | d| j                   d| j                   d      t	        j
                  | dt        |       d            S )Nz -m pipz/[bold][[reset][blue]notice[reset][bold]][reset]z) A new release of pip is available: [red]z[reset] -> [green]z[reset]z To update, run: [green]z install --upgrade pip)	r   r   r   r	   r   from_markupr]   r^   r
   )r7   pip_cmdnotices      r#   __rich__zUpgradePrompt.__rich__~   s    <>?wGG68GBF( z!3DHH:WF (  /**@B

 
	
r%   N)rU   rV   rW   rX   __annotations__r	   rc   rZ   r%   r#   r\   r\   y   s    	H	H
% 
r%   r\   pkgc                 ^    t               j                  |       }|duxr 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)re   dists     r#   was_installed_by_piprk      s0     #$55c:Dt7 77r%   sessionoptionsc                     t        j                  | |d      }t        dd      }t        j                  ||      }|j	                  d      j
                  }|y t        |j                        S )NT)rm   suppress_no_indexF)allow_yankedallow_all_prereleases)link_collectorselection_prefsrg   )r   creater   r   find_best_candidatebest_candidaterX   version)rl   rm   rr   rs   finderrv   s         r#   _get_current_remote_pip_versionry      sy     #))N +#O
 !!%'F //6EEN~%%&&r%   rQ   r=   local_versionget_remote_versionc                    | j                  |      }|1 |       }|t        j                  d       y | j                  ||       t	        |      }t        j                  d|       t        j                  d|       t        d      }t        j                  d|       |sy ||k  xr |j                  |j                  k7  }|rt        t        |      |      S y )NzNo remote pip version foundzRemote version of pip: %szLocal version of pip:  %srg   zWas pip installed by pip? %s)r]   r^   )	rG   loggerdebugrT   parse_versionrk   base_versionr\   rX   )rQ   r=   rz   r{   remote_version_strremote_versionpip_installed_by_piplocal_version_is_olders           r#   _self_version_check_logicr      s     <0!/1%LL67		$l3"#56N
LL,n=
LL,m</6
LL/1EF 	& 	F&&.*E*EE  ]!39KLLr%   c           
         t               j                  d      }|sy	 t        t        |j                        t
        j
                  j                         |j                  t        j                  t        | |            }|t        j                  d|       yy# t        $ r/ t        j                  d       t        j                  dd	       Y yw xY 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.
    rg   N)r(   )rQ   r=   rz   r{   z[present-rich] %sz6There was an error checking the latest version of pip.zSee below for errorT)exc_info)r   rh   r   r'   r(   rA   utcnowrw   	functoolspartialry   r}   warning	Exceptionr~   )rl   rm   installed_distupgrade_prompts       r#   pip_self_version_checkr      s     -.??FN;2 7+<+<=!**113(00(00/' 	
 %NN.? & ;OP*T:;s   A:B 5CC)>rA   r   r   r2   loggingoptparseos.pathr.   r;   dataclassesr   typingr   r   r   r   pip._vendor.packaging.versionr   r   pip._vendor.rich.consoler	   pip._vendor.rich.markupr
   pip._vendor.rich.textr   pip._internal.index.collectorr   "pip._internal.index.package_finderr   pip._internal.metadatar   pip._internal.metadata.baser   $pip._internal.models.selection_prefsr   pip._internal.network.sessionr   pip._internal.utils.compatr   pip._internal.utils.entrypointsr   r   pip._internal.utils.filesystemr   r   r   pip._internal.utils.miscr   rC   	getLoggerrU   r}   rX   r$   r'   r\   boolrk   Valuesry   r   r   rZ   r%   r#   <module>r      sO          
 ! 0 0 @ * * & 7 < : ; E 4 . X W / 	 
		8	$S S K K\ 
 
 
08c 8d 8''"*//'c]'8 ## '	
 !Xc]!23 mD;J ; ;T ;r%   