a  zeD* @sddlmZddlZddlZddlZddlZddlZddlZddlZddl Z ddl m Z ddl m Z mZmZeeZdaGdddeZGdd d eZGd d d eZGd d d eZGdddeZGdddeZedee jeiZzNz ddlZWne yddl!ZYn0eeej"<eeej#<eeej$<[Wne e%fyRYn0ddZ&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___/opt/bitninja-python-dojo/embedded/lib/python3.9/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|}ntj|j|||}tj|}tj|sXt |tj |sjd}n | ||}|rt |d}| |jWdn1s0Y|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.get)N)__name__ __module__ __qualname__rrr' __classcell__rrrrrs rc@seZdZddZdS) ResourceBasecCs||_||_dSN)rname)rrr.rrrrHszResourceBase.__init__N)r(r)r*rrrrrr,Gsr,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. FcCs |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_streamUszResource.as_streamcCstdurtat|Sr-)cacherr'r1rrr file_path^szResource.file_pathcCs |j|Sr-)r get_bytesr1rrrr"eszResource.bytescCs |j|Sr-)rget_sizer1rrrsizeisz Resource.sizeN) r(r)r*__doc__ is_containerr2rr4r"r7rrrrr/Ms   r/c@seZdZdZeddZdS)ResourceContainerTcCs |j|Sr-)r get_resourcesr1rrr resourcesqszResourceContainer.resourcesN)r(r)r*r9rr<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)r?r@cCs.||_t|dd|_tjt|dd|_dS)N __loader____file__)modulegetattrloaderr r rr)rrDrrrrszResourceFinder.__init__cCs tj|Sr-)r r realpathrr rrr _adjust_pathszResourceFinder._adjust_pathcCsBt|trd}nd}||}|d|jtjj|}||S)N//r) isinstancer"splitinsertrr r r rI)r resource_nameseppartsr$rrr _make_paths   zResourceFinder._make_pathcCs tj|Sr-)r r rrHrrr_findszResourceFinder._findcCs d|jfSr-)r rrrrrrszResourceFinder.get_cache_infocCsD||}||sd}n&||r0t||}n t||}||_|Sr-)rRrS _is_directoryr:r/r )rrOr r$rrrfinds     zResourceFinder.findcCs t|jdSNrb)r r rTrrrr0szResourceFinder.get_streamcCs8t|jd}|WdS1s*0YdSrW)r r read)rrr&rrrr5szResourceFinder.get_bytescCstj|jSr-)r r getsizerTrrrr6szResourceFinder.get_sizecs*fddtfddt|jDS)Ncs|dko|j S)N __pycache__)endswithskipped_extensions)r&r1rralloweds z-ResourceFinder.get_resources..allowedcsg|]}|r|qSrr).0r&)r^rr z0ResourceFinder.get_resources..)setr listdirr rTr)r^rrr;s zResourceFinder.get_resourcescCs ||jSr-)rUr rTrrrr9szResourceFinder.is_containerccs||}|dur|g}|r|d}|V|jr|j}|jD]>}|sL|}nd||g}||}|jrv||q>|Vq>qdS)NrrK)rVpopr9r.r<r append)rrOrtodornamer.new_namechildrrriterators      zResourceFinder.iteratorN)r(r)r*r8sysplatform startswithr]rrIrRrSrrVr0r5r6r;r9 staticmethodr r rrUrjrrrrr=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|_n t j ||_t |j|_ dS)Nr_files) r rorrFarchivelen prefix_lenhasattrrp zipimport_zip_directory_cachesortedindex)rrDrqrrrrs   zZipResourceFinder.__init__cCs|Sr-rrHrrrrIszZipResourceFinder._adjust_pathcCs||jd}||jvrd}nV|r:|dtjkr:|tj}t|j|}z|j||}Wntyrd}Yn0|st d||j j nt d||j j |S)NTFz_find failed: %r %rz_find worked: %r %r) rsrpr rPbisectrxrm IndexErrorloggerdebugrFr#)rr r$irrrrSs    zZipResourceFinder._findcCs&|jj}|jdt|d}||fS)Nr)rFrqr rr)rrr#r rrrrsz ZipResourceFinder.get_cache_infocCs|j|jSr-)rFget_datar rTrrrr5szZipResourceFinder.get_bytescCst||Sr-)ioBytesIOr5rTrrrr0szZipResourceFinder.get_streamcCs|j|jd}|j|dS)N)r rsrprrrrr6szZipResourceFinder.get_sizecCs|j|jd}|r,|dtjkr,|tj7}t|}t}t|j|}|t|jkr|j||shq|j||d}| | tjdd|d7}qH|S)Nryrr) r rsr rPrrrbrzrxrmaddrM)rrr plenr$r~srrrr;s  zZipResourceFinder.get_resourcescCsh||jd}|r*|dtjkr*|tj7}t|j|}z|j||}Wntybd}Yn0|S)NryF)rsr rPrzrxrmr{)rr r~r$rrrrUs   zZipResourceFinder._is_directory)r(r)r*r8rrIrSrr5r0r6r;rUr+rrrrros rocCs|tt|<dSr-)_finder_registrytype)rF finder_makerrrrregister_finder2srcCs|tvrt|}nv|tjvr$t|tj|}t|dd}|durJtdt|dd}tt|}|durxtd|||}|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 packagerAzUnable to locate finder for %r) _finder_cacherkmodules __import__rErrr'r)packager$rDr rFrrrrr9s      r __dummy__cCsRd}t|tj|}tt|}|rNt}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. NrC) pkgutil get_importerrkpath_importer_cacher'rr _dummy_moduler r r rBrA)r r$rFrrDrrrfinder_for_pathUs  r)- __future__rrzrloggingr rrktypesrurCrutilrrr getLoggerr(r|r3robjectr,r/r:r=ror zipimporterr_frozen_importlib_externalZ_fi ImportError_frozen_importlibSourceFileLoader FileFinderSourcelessFileLoaderAttributeErrorrrr ModuleTyper rrrrrrsJ   ,!ZO