1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
U
H=®d*ã    @sˆddlmZddlZddlZddlZddlZddlZddlZddlZddl    Z    ddl
Z
ddl m Z ddl mZmZmZmZe e¡ZdaGdd„deƒZGdd    „d    eƒZGd
d „d eƒZGd d „d eƒZGdd„deƒZGdd„deƒZedƒee
jeiZzFz ddl Z!Wne"k
r$ddl#Z!YnXeee!j$<eee!j%<[!Wne"e&fk
rXYnXdd„Z'iZ(dd„Z)e     *e+dƒ¡Z,dd„Z-dS)é)Úunicode_literalsNé)ÚDistlibException)Úcached_propertyÚget_cache_baseÚpath_to_cache_dirÚCachecs.eZdZd‡fdd„    Zdd„Zdd„Z‡ZS)    Ú ResourceCacheNcs0|dkrtj tƒtdƒ¡}tt|ƒ |¡dS)Nzresource-cache)ÚosÚpathÚjoinrÚstrÚsuperr    Ú__init__)ÚselfÚbase©Ú    __class__©úTD:\z\workplace\VsCode\pyvenv\venv\Lib\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.
        Tr©rÚresourcer rrrÚis_stale#s    zResourceCache.is_stalec    Cs |j |¡\}}|dkr|}n~tj |j| |¡|¡}tj |¡}tj |¡sXt     |¡tj 
|¡sjd}n |  ||¡}|rœt |dƒ}|  |j¡W5QRX|S)z¤
        Get a resource into the cache,
 
        :param resource: A :class:`Resource` instance.
        :return: The pathname of the resource in the cache.
        NTÚwb)ÚfinderÚget_cache_infor
r r rÚ prefix_to_dirÚdirnameÚisdirÚmakedirsÚexistsrÚopenÚwriteÚbytes)rrÚprefixr ÚresultrÚstaleÚfrrrÚget.s  
   zResourceCache.get)N)Ú__name__Ú
__module__Ú __qualname__rrr(Ú __classcell__rrrrr    s r    c@seZdZdd„ZdS)Ú ResourceBasecCs||_||_dS©N)rÚname)rrr/rrrrIszResourceBase.__init__N)r)r*r+rrrrrr-Hsr-c@s@eZdZdZdZdd„Zedd„ƒZedd„ƒZed    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_stream©rrrrÚ    as_streamVszResource.as_streamcCstdkrtƒat |¡Sr.)Úcacher    r(r2rrrÚ    file_path_szResource.file_pathcCs |j |¡Sr.)rÚ    get_bytesr2rrrr#fszResource.bytescCs |j |¡Sr.)rÚget_sizer2rrrÚsizejsz Resource.sizeN)
r)r*r+Ú__doc__Ú is_containerr3rr5r#r8rrrrr0Ns    
 
r0c@seZdZdZedd„ƒZdS)ÚResourceContainerTcCs |j |¡Sr.)rÚ get_resourcesr2rrrÚ    resourcesrszResourceContainer.resourcesN)r)r*r+r:rr=rrrrr;osr;c@s’eZdZdZej d¡rdZndZdd„Zdd„Z    d    d
„Z
d d „Z d d„Z dd„Z dd„Zdd„Zdd„Zdd„Zdd„ZeejjƒZdd„ZdS)ÚResourceFinderz4
    Resource finder for file system resources.
    Újava)ú.pycú.pyoz.class)r@rAcCs.||_t|ddƒ|_tj t|ddƒ¡|_dS)NÚ
__loader__Ú__file__Ú)ÚmoduleÚgetattrÚloaderr
r rr)rrErrrrszResourceFinder.__init__cCs tj |¡Sr.)r
r Úrealpath©rr rrrÚ _adjust_path†szResourceFinder._adjust_pathcCsBt|tƒrd}nd}| |¡}| d|j¡tjj|Ž}| |¡S)Nó/ú/r)    Ú
isinstancer#ÚsplitÚinsertrr
r r rJ)rÚ resource_nameÚsepÚpartsr%rrrÚ
_make_path‰s
 
 zResourceFinder._make_pathcCs tj |¡Sr.)r
r r rIrrrÚ_find•szResourceFinder._findcCs
d|jfSr.)r ©rrrrrr˜szResourceFinder.get_cache_infocCsD| |¡}| |¡sd}n&| |¡r0t||ƒ}n
t||ƒ}||_|Sr.)rSrTÚ _is_directoryr;r0r )rrPr r%rrrÚfind›s
 
 
 
zResourceFinder.findcCs t|jdƒS©NÚrb)r!r rUrrrr1§szResourceFinder.get_streamc
Cs,t|jdƒ}| ¡W5QR£SQRXdSrX)r!r Úread)rrr'rrrr6ªszResourceFinder.get_bytescCstj |j¡Sr.)r
r ÚgetsizerUrrrr7®szResourceFinder.get_sizecs*‡fdd„‰t‡fdd„t |j¡DƒƒS)Ncs|dko| ˆj¡ S)NÚ __pycache__)ÚendswithÚskipped_extensions)r'r2rrÚallowed²s
ÿz-ResourceFinder.get_resources.<locals>.allowedcsg|]}ˆ|ƒr|‘qSrr)Ú.0r')r_rrÚ
<listcomp>µsz0ResourceFinder.get_resources.<locals>.<listcomp>)Úsetr
Úlistdirr rUr)r_rrr<±s zResourceFinder.get_resourcescCs | |j¡Sr.)rVr rUrrrr:·szResourceFinder.is_containerccs„| |¡}|dk    r€|g}|r€| d¡}|V|jr|j}|jD]>}|sL|}nd ||g¡}| |¡}|jrv| |¡q>|Vq>qdS)NrrL)rWÚpopr:r/r=r Úappend)rrPrÚtodoÚrnamer/Únew_nameÚchildrrrÚiterator¼s 
 
 
 
 zResourceFinder.iteratorN)r)r*r+r9ÚsysÚplatformÚ
startswithr^rrJrSrTrrWr1r6r7r<r:Ú staticmethodr
r rrVrjrrrrr>ws"    r>cs`eZdZdZ‡fdd„Zdd„Zdd„Zdd    „Zd
d „Zd d „Z    dd„Z
dd„Z dd„Z ‡Z S)ÚZipResourceFinderz6
    Resource finder for resources in .zip files.
    csZtt|ƒ |¡|jj}dt|ƒ|_t|jdƒr>|jj|_n t    j
||_t |jƒ|_ dS)NrÚ_files) rrorrGÚarchiveÚlenÚ
prefix_lenÚhasattrrpÚ    zipimportÚ_zip_directory_cacheÚsortedÚindex)rrErqrrrrÕs   zZipResourceFinder.__init__cCs|Sr.rrIrrrrJàszZipResourceFinder._adjust_pathcCs¤||jd…}||jkrd}nX|r:|dtjkr:|tj}t |j|¡}z|j| |¡}Wntk
rtd}YnX|sŽt     d||j
j ¡nt     d||j
j ¡|S)NTéÿÿÿÿFz_find failed: %r %rz_find worked: %r %r) rsrpr
rQÚbisectrxrmÚ
IndexErrorÚloggerÚdebugrGr$)rr r%ÚirrrrTãs
 
 
zZipResourceFinder._findcCs&|jj}|jdt|ƒd…}||fS)Nr)rGrqr rr)rrr$r rrrrõsz ZipResourceFinder.get_cache_infocCs|j |j¡Sr.)rGÚget_datar rUrrrr6úszZipResourceFinder.get_bytescCst | |¡¡Sr.)ÚioÚBytesIOr6rUrrrr1ýszZipResourceFinder.get_streamcCs|j|jd…}|j|dS)Né)r rsrprrrrr7szZipResourceFinder.get_sizecCs |j|jd…}|r,|dtjkr,|tj7}t|ƒ}tƒ}t |j|¡}|t|jƒkrœ|j| |¡shqœ|j||d…}|     | 
tjd¡d¡|d7}qH|S)Nryrr) r rsr
rQrrrbrzrxrmÚaddrN)rrr Úplenr%r~Úsrrrr<s
 
zZipResourceFinder.get_resourcescCsj||jd…}|r*|dtjkr*|tj7}t |j|¡}z|j| |¡}Wntk
rdd}YnX|S)NryF)rsr
rQrzrxrmr{)rr r~r%rrrrVs
 
zZipResourceFinder._is_directory)r)r*r+r9rrJrTrr6r1r7r<rVr,rrrrroÑs rocCs|tt|ƒ<dSr.)Ú_finder_registryÚtype)rGÚ finder_makerrrrÚregister_finder0sr‰cCsŒ|tkrt|}nv|tjkr$t|ƒtj|}t|ddƒ}|dkrJtdƒ‚t|ddƒ}t t|ƒ¡}|dkrxtd|ƒ‚||ƒ}|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 packagerBzUnable to locate finder for %r)    Ú _finder_cacherkÚmodulesÚ
__import__rFrr†r(r‡)Úpackager%rEr rGrˆrrrr6s
 
 
   rÚ    __dummy__cCsRd}t |¡tj |¡}t t|ƒ¡}|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.
    NrD) ÚpkgutilÚ get_importerrkÚpath_importer_cacher(r†r‡Ú _dummy_moduler
r r rCrB)r r%rGrrErrrÚfinder_for_pathRs
 r”).Ú
__future__rrzr€Úloggingr
rÚshutilrkÚtypesrurDrÚutilrrrrÚ    getLoggerr)r|r4r    Úobjectr-r0r;r>ror‡Ú zipimporterr†Ú_frozen_importlib_externalZ_fiÚ ImportErrorÚ_frozen_importlibÚSourceFileLoaderÚ
FileFinderÚAttributeErrorr‰r‹rÚ
ModuleTyper r“r”rrrrÚ<module>sN  
,!ZNþ