o ƚReD* @s~ddlmZddlZddlZddlZddlZddlZddlZddlZddl Z ddl m Z ddl m Z mZmZeeZdaGdddeZGdd d eZGd d d eZGd d d eZGdddeZGdddeZedee jeiZz&zddlZWn e yddl!ZYnweeej"<eeej#<eeej$<[Wn e e%fyYnwddZ&iZ'ddZ(e)e*dZ+ddZ,dS))unicode_literalsN)DistlibException)cached_propertyget_cache_baseCachecs.eZdZdfdd ZddZddZZS) ResourceCacheNcs0|durtjttd}tt||dS)Nzresource-cache)ospathjoinrstrsuperr__init__)selfbase __class__/builddir/build/BUILDROOT/alt-python310-pip-21.3.1-3.el8.x86_64/opt/alt/python310/lib/python3.10/site-packages/pip/_vendor/distlib/resources.pyrszResourceCache.__init__cCsdS)z Is the cache stale for the given resource? :param resource: The :class:`Resource` being cached. :param path: The path of the resource in the cache. :return: True if the cache is stale. Trrresourcer rrris_stale"s zResourceCache.is_stalecCs|j|\}}|dur|}|Stj|j|||}tj|}tj|s-t |tj |s6d}n| ||}|rZt |d}| |jWd|S1sUwY|S)z Get a resource into the cache, :param resource: A :class:`Resource` instance. :return: The pathname of the resource in the cache. NTwb)finderget_cache_infor r r r prefix_to_dirdirnameisdirmakedirsexistsropenwritebytes)rrprefixr resultrstalefrrrget-s$       zResourceCache.getN)__name__ __module__ __qualname__rrr' __classcell__rrrrrs rc@seZdZddZdS) ResourceBasecCs||_||_dSr()rname)rrr.rrrrHs zResourceBase.__init__N)r)r*r+rrrrrr-Gs r-c@s@eZdZdZdZddZeddZeddZed d Z d S) Resourcez A class representing an in-package resource, such as a data file. This is not normally instantiated by user code, but rather by a :class:`ResourceFinder` which manages the resource. FcC |j|S)z Get the resource as a stream. This is not a property to make it obvious that it returns a new stream each time. )r get_streamrrrr as_streamUs zResource.as_streamcCstdurtat|Sr()cacherr'r2rrr file_path^s zResource.file_pathcCr0r()r get_bytesr2rrrr"e zResource.bytescCr0r()rget_sizer2rrrsizeir7z Resource.sizeN) r)r*r+__doc__ is_containerr3rr5r"r9rrrrr/Ms  r/c@seZdZdZeddZdS)ResourceContainerTcCr0r()r get_resourcesr2rrr resourcesqr7zResourceContainer.resourcesN)r)r*r+r;rr>rrrrr<nsr<c@seZdZdZejdrdZndZddZddZ d d Z d d Z d dZ ddZ ddZddZddZddZddZeejjZddZdS)ResourceFinderz4 Resource finder for file system resources. java).pyc.pyoz.class)rArBcCs.||_t|dd|_tjt|dd|_dS)N __loader____file__)modulegetattrloaderr r rr)rrFrrrrszResourceFinder.__init__cC tj|Sr()r r realpathrr rrr _adjust_path zResourceFinder._adjust_pathcCsBt|trd}nd}||}|d|jtjj|}||S)N//r) isinstancer"splitinsertrr r r rL)r resource_nameseppartsr$rrr _make_paths    zResourceFinder._make_pathcCrIr()r r rrKrrr_findrMzResourceFinder._findcCs d|jfSr()r rrrrrrs zResourceFinder.get_cache_infocCsF||}||sd}|S||rt||}nt||}||_|Sr()rVrW _is_directoryr<r/r )rrSr r$rrrfinds    zResourceFinder.findcCs t|jdSNrb)r r rXrrrr1rMzResourceFinder.get_streamcCs8t|jd }|WdS1swYdSr[)r r read)rrr&rrrr6s$zResourceFinder.get_bytescCstj|jSr()r r getsizerXrrrr8zResourceFinder.get_sizecs*fddtfddt|jDS)Ncs|dko |j S)N __pycache__)endswithskipped_extensions)r&r2rralloweds z-ResourceFinder.get_resources..allowedcsg|]}|r|qSrr).0r&)rcrr sz0ResourceFinder.get_resources..)setr listdirr rXr)rcrrr=s zResourceFinder.get_resourcescCs ||jSr()rYr rXrrrr;rMzResourceFinder.is_containerccs||}|durD|g}|rF|d}|V|jr@|j}|jD]}|s'|}nd||g}||}|jr<||q |Vq |sdSdSdS)NrrO)rZpopr;r.r>r append)rrSrtodornamer.new_namechildrrriterators(     zResourceFinder.iteratorN)r)r*r+r:sysplatform startswithrbrrLrVrWrrZr1r6r8r=r; staticmethodr r rrYrnrrrrr?vs$     r?cs`eZdZdZfddZddZddZdd Zd d Zd d Z ddZ ddZ ddZ Z S)ZipResourceFinderz6 Resource finder for resources in .zip files. csZtt|||jj}dt||_t|jdr|jj|_nt j ||_t |j|_ dS)Nr_files) r rsrrHarchivelen prefix_lenhasattrrt zipimport_zip_directory_cachesortedindex)rrFrurrrrs   zZipResourceFinder.__init__cCs|Sr(rrKrrrrLszZipResourceFinder._adjust_pathcCs||jd}||jvrd}n+|r|dtjkr|tj}t|j|}z |j||}Wn ty9d}Ynw|sGt d||j j |St d||j j |S)NTFz_find failed: %r %rz_find worked: %r %r) rwrtr rTbisectr|rq IndexErrorloggerdebugrHr#)rr r$irrrrWs    zZipResourceFinder._findcCs&|jj}|jdt|d}||fS)Nr)rHrur rv)rrr#r rrrrsz ZipResourceFinder.get_cache_infocCs|j|jSr()rHget_datar rXrrrr6r_zZipResourceFinder.get_bytescCst||Sr()ioBytesIOr6rXrrrr1zZipResourceFinder.get_streamcCs|j|jd}|j|dS)N)r rwrtrrrrr8szZipResourceFinder.get_sizecCs|j|jd}|r|dtjkr|tj7}t|}t}t|j|}|t|jkrV|j||s6 |S|j||d}| | tjdd|d7}|t|jks+|S)Nr}rr) r rwr rTrvrfr~r|rqaddrQ)rrr plenr$rsrrrr=s zZipResourceFinder.get_resourcescCsh||jd}|r|dtjkr|tj7}t|j|}z |j||}W|Sty3d}Y|Sw)Nr}F)rwr rTr~r|rqr)rr rr$rrrrYs  zZipResourceFinder._is_directory)r)r*r+r:rrLrWrr6r1r8r=rYr,rrrrrss  rscCs|tt|<dSr()_finder_registrytype)rH finder_makerrrrregister_finder2rrcCs|tvr t|}|S|tjvrt|tj|}t|dd}|dur&tdt|dd}tt|}|dur=td|||}|t|<|S)z Return a resource finder for a package. :param package: The name of the package. :return: A :class:`ResourceFinder` instance for the package. __path__Nz8You cannot get a finder for a module, only for a packagerCzUnable to locate finder for %r) _finder_cacheromodules __import__rGrrr'r)packager$rFr rHrrrrr9s      r __dummy__cCsRd}t|tj|}tt|}|r't}tj |d|_ ||_ ||}|S)z Return a resource finder for a path, which should represent a container. :param path: The path. :return: A :class:`ResourceFinder` instance for the path. NrE) pkgutil get_importerropath_importer_cacher'rr _dummy_moduler r r rDrC)r r$rHrrFrrrfinder_for_pathUs  r)- __future__rr~rloggingr rrotypesryrErutilrrr getLoggerr)rr4robjectr-r/r<r?rsr zipimporterr_frozen_importlib_externalZ_fi ImportError_frozen_importlibSourceFileLoader FileFinderSourcelessFileLoaderAttributeErrorrrr ModuleTyper rrrrrrsP   ,!ZO