Viewing File: /opt/alt/python35/lib/python3.5/site-packages/pip/_internal/__pycache__/cache.cpython-35.pyc



t_/@sdZddlZddlZddlZddlZddlmZmZddlm	Z	ddl
mZddlm
Z
ddlmZddlmZmZdd	lmZdd
lmZerddlmZmZmZmZmZddlmZdd
lmZej e!Z"ddZ#Gddde$Z%Gddde%Z&Gddde&Z'Gddde$Z(Gddde%Z)dS)zCache Management
N)interpreter_nameinterpreter_version)canonicalize_name)InvalidWheelFilename)Link)Wheel)
TempDirectory
tempdir_kinds)MYPY_CHECK_RUNNING)path_to_url)OptionalSetListAnyDict)Tag)
FormatControlcCs=tj|dddddd}tj|jdjS)	z'Return a stable sha224 of a dictionary.	sort_keysT
separators,:ensure_asciiascii)rr)jsondumpshashlibsha224encode	hexdigest)dsr!/builddir/build/BUILDROOT/alt-python35-pip-20.2.4-1.el7.x86_64/opt/alt/python35/lib/python3.5/site-packages/pip/_internal/cache.py
_hash_dicts!r#cspeZdZdZfddZddZddZdd	Zd
dZdd
Z	ddZ
S)CacheaAn abstract class - provides cache directories for data from links


        :param cache_dir: The root of the cache.
        :param format_control: An object of FormatControl class to limit
            binaries being read from the cache.
        :param allowed_formats: which formats of files the cache should store.
            ('binary' and 'source' are the only allowed values)
    cstt|j|s2tjj|s2t|p;d|_||_||_	ddh}|j	j
||ks}tdS)Nsourcebinary)superr$__init__ospathisabsAssertionError	cache_dirformat_controlallowed_formatsunion)selfr-r.r/_valid_formats)	__class__r!r"r(/s		zCache.__init__cCs|jg}|jdk	rL|jdk	rL|jdj|j|jgdj|}tj|jj}|dd|dd|dd|ddg}|S)zGet parts of part that must be os.path.joined with cache_dir

        Legacy cache key (pip < 20) for compatibility with older caches.
        N=#)	url_without_fragment	hash_namehashappendjoinrrrr)r1link	key_partskey_urlhashedpartsr!r!r"_get_cache_path_parts_legacy:s
":z"Cache._get_cache_path_parts_legacycCsd|ji}|jdk	r=|jdk	r=|j||j<|jrS|j|d<t|d<t|d<t|}|dd|dd|dd|ddg}|S)	zEGet parts of part that must be os.path.joined with cache_dir
        urlNsubdirectoryrrr6r7r8)r9r:r;subdirectory_fragmentrrr#)r1r>r?rArBr!r!r"_get_cache_path_partsVs	


:zCache._get_cache_path_partsc	Cs|jp|p|}|r"gS|jj|}|jj|sJgSg}|j|}tjj|rx*tj	|D]}|j
||fqW|j|}tjj|rx*tj	|D]}|j
||fqW|S)N)r-r.get_allowed_formatsr/intersectionget_path_for_linkr)r*isdirlistdirr<get_path_for_link_legacy)	r1r>canonical_package_name
can_not_cacheformats
candidatesr*	candidatelegacy_pathr!r!r"_get_candidatesys&
		zCache._get_candidatescCs
tdS)N)NotImplementedError)r1r>r!r!r"rMszCache.get_path_for_link_legacycCs
tdS)z>Return a directory to store cached items in for link.
        N)rU)r1r>r!r!r"rJszCache.get_path_for_linkcCs
tdS)zaReturns a link to a cached item if it exists, otherwise returns the
        passed link.
        N)rU)r1r>package_namesupported_tagsr!r!r"gets
z	Cache.get)__name__
__module____qualname____doc__r(rCrGrTrMrJrXr!r!)r3r"r$$s	#r$csLeZdZdZfddZddZddZdd	ZS)
SimpleWheelCachez+A cache of wheels for future installs.
    cs#tt|j||dhdS)Nr&)r'r]r()r1r-r.)r3r!r"r(szSimpleWheelCache.__init__cCs7|j|}|jsttjj|jd|S)Nwheels)rCr-r,r)r*r=)r1r>rBr!r!r"rMsz)SimpleWheelCache.get_path_for_link_legacycCs7|j|}|jsttjj|jd|S)aReturn a directory to store cached wheels for link

        Because there are M wheels for any one sdist, we provide a directory
        to cache them in, and then consult that directory when looking up
        cache hits.

        We only insert things into the cache if they have plausible version
        numbers, so that we don't contaminate the cache with things that were
        not unique. E.g. ./package might have dozens of installs done for it
        and build a version of 0.0...and if we built and cached a wheel, we'd
        end up using the same wheel even if the source has been edited.

        :param link: The link of the sdist for which this will cache wheels.
        r^)rGr-r,r)r*r=)r1r>rBr!r!r"rJsz"SimpleWheelCache.get_path_for_linkc
Csg}|s|St|}x|j||D]\}}yt|}Wntk
rbw/YnXt|j|krtjd|||q/|j|sq/|j|j	|||fq/W|s|St
|\}	}}ttt
jj||S)NzWIgnoring cached wheel %s for %s as it does not match the expected distribution name %s.)rrTrrnameloggerdebug	supportedr<support_index_minminrrr)r*r=)
r1r>rVrWrQrN
wheel_name	wheel_dirwheel_r!r!r"rXs2	

zSimpleWheelCache.get)rYrZr[r\r(rMrJrXr!r!)r3r"r]s
r]cs(eZdZdZfddZS)EphemWheelCachezGA SimpleWheelCache that creates it's own temporary cache directory
    cs>tdtjdd|_tt|j|jj|dS)Nkindglobally_managedT)rr	EPHEM_WHEEL_CACHE	_temp_dirr'rir(r*)r1r.)r3r!r"r(s
	zEphemWheelCache.__init__)rYrZr[r\r(r!r!)r3r"risric@seZdZddZdS)
CacheEntrycCs||_||_dS)N)r>
persistent)r1r>ror!r!r"r(s	zCacheEntry.__init__N)rYrZr[r(r!r!r!r"rnsrncsdeZdZdZfddZddZddZdd	Zd
dZdd
Z	S)
WheelCachezWraps EphemWheelCache and SimpleWheelCache into a single Cache

    This Cache allows for gracefully degradation, using the ephem wheel cache
    when a certain link is not found in the simple wheel cache first.
    csDtt|j||dht|||_t||_dS)Nr&)r'rpr(r]_wheel_cacheri_ephem_cache)r1r-r.)r3r!r"r(szWheelCache.__init__cCs|jj|S)N)rqrM)r1r>r!r!r"rM'sz#WheelCache.get_path_for_link_legacycCs|jj|S)N)rqrJ)r1r>r!r!r"rJ+szWheelCache.get_path_for_linkcCs|jj|S)N)rrrJ)r1r>r!r!r"get_ephem_path_for_link/sz"WheelCache.get_ephem_path_for_linkcCs,|j|||}|dkr%|S|jS)N)get_cache_entryr>)r1r>rVrWcache_entryr!r!r"rX3szWheelCache.getcCs~|jjd|d|d|}||k	r=t|ddS|jjd|d|d|}||k	rzt|ddSdS)zReturns a CacheEntry with a link to a cached item if it exists or
        None. The cache entry indicates if the item was found in the persistent
        or ephemeral cache.
        r>rVrWroTFN)rqrXrnrr)r1r>rVrWretvalr!r!r"rt?s		zWheelCache.get_cache_entry)
rYrZr[r\r(rMrJrsrXrtr!r!)r3r"rpsrp)*r\rrloggingr)pip._vendor.packaging.tagsrrZpip._vendor.packaging.utilsrpip._internal.exceptionsrpip._internal.models.linkrpip._internal.models.wheelrpip._internal.utils.temp_dirrr	pip._internal.utils.typingr
pip._internal.utils.urlsrtypingrr
rrrr#pip._internal.models.format_controlr	getLoggerrYr`r#objectr$r]rirnrpr!r!r!r"<module>s.(R
Back to Directory File Manager