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
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
U
H=®dkdã@s4dZddlZddlZddlZddlmZddlZzddlmZWn e    k
r`ddl
mZYnXddl Z ddl m Z zddlZdZWne    k
rždZYnXzdd    lmZWne    k
rÈdZYnXzdd
lmZWne    k
ròdZYnXd d d ddddddddddddddddddgZGd d„deƒZGd!d„deƒZGd"d„deƒZGd#d$„d$eƒZGd%d&„d&eƒZzeWnek
r”dZYnXded(d „Zd)d*„Zd+d „Z d,d „Z!d-d„Z"d.d„Z#d/d„Z$d0d„Z%dde$dfd1d„Z&dfd2d„Z'd3d4„Z(d5d„Z)d6d7„Z*d8d9„Z+d:d;„Z,dgd=d>„Z-dhd?d@„Z.didAdB„Z/e-dCgdDfe-dEgdFfe-dGgdHfe/gdIfdJœZ0er|e-dEgdFfe0dK<dLd„Z1djdNd„Z2dOd„Z3dkdPd„Z4dQd„Z5dRdS„Z6dldTd„Z7dUd„Z8dVdW„Z9dXdY„Z:dZd[„Z;d\d]ge;gdDfd^ge;gdHfd_ge:gdIfd`œZ<erdage;gdFfe<dK<dbdc„Z=dmddd„Z>dS)nz—Utility functions for copying and archiving files and directory trees.
 
XXX The functions here don't copy the resource fork or other metadata on Mac.
 
éN)Úabspath)ÚCallableé)ÚtarfileTF)Úgetpwnam)ÚgetgrnamÚ copyfileobjÚcopyfileÚcopymodeÚcopystatÚcopyÚcopy2ÚcopytreeÚmoveÚrmtreeÚErrorÚSpecialFileErrorÚ    ExecErrorÚ make_archiveÚget_archive_formatsÚregister_archive_formatÚunregister_archive_formatÚget_unpack_formatsÚregister_unpack_formatÚunregister_unpack_formatÚunpack_archiveÚignore_patternsc@s eZdZdS)rN)Ú__name__Ú
__module__Ú __qualname__©r r ú[D:\z\workplace\VsCode\pyvenv\venv\Lib\site-packages\pip/_vendor/distlib/_backport/shutil.pyr/sc@seZdZdZdS)rz|Raised when trying to do a kind of operation (e.g. copying) which is
    not supported on a special file (e.g. a named pipe)N©rrrÚ__doc__r r r r!r2sc@seZdZdZdS)rz+Raised when a command could not be executedNr"r r r r!r6sc@seZdZdZdS)Ú    ReadErrorz%Raised when an archive cannot be readNr"r r r r!r$9sr$c@seZdZdZdS)Ú RegistryErrorzVRaised when a registry operation with the archiving
    and unpacking registries failsNr"r r r r!r%<sr%é@cCs | |¡}|sq| |¡qdS)z=copy data from file-like object fsrc to file-like object fdstN)ÚreadÚwrite)ÚfsrcÚfdstÚlengthÚbufr r r!rFs
cCs\ttjdƒr4ztj ||¡WStk
r2YdSXtj tj |¡¡tj tj |¡¡kS)NÚsamefileF)ÚhasattrÚosÚpathr-ÚOSErrorÚnormcaser©ÚsrcÚdstr r r!Ú    _samefileNs ÿr6c
Csžt||ƒrtd||fƒ‚||fD]@}zt |¡}Wntk
rHYq"Xt |j¡r"td|ƒ‚q"t|dƒ&}t|dƒ}t    ||ƒW5QRXW5QRXdS)zCopy data from src to dstz`%s` and `%s` are the same filez`%s` is a named pipeÚrbÚwbN)
r6rr/Ústatr1ÚS_ISFIFOÚst_moderÚopenr)r4r5ÚfnÚstr)r*r r r!r    Zs
    cCs0ttdƒr,t |¡}t |j¡}t ||¡dS)zCopy mode bits from src to dstÚchmodN)r.r/r9ÚS_IMODEr;r?)r4r5r>Úmoder r r!r
ns
 
 c
Cs°t |¡}t |j¡}ttdƒr4t ||j|jf¡ttdƒrJt ||¡ttdƒr¬t|dƒr¬zt     ||j
¡Wn:t k
rª}ztt dƒr˜|j t j krš‚W5d}~XYnXdS)zCCopy all stat info (mode bits, atime, mtime, flags) from src to dstÚutimer?ÚchflagsÚst_flagsÚ
EOPNOTSUPPN)r/r9r@r;r.rBÚst_atimeÚst_mtimer?rCrDr1ÚerrnorE)r4r5r>rAÚwhyr r r!r us
 
 
 
 
ÿcCs:tj |¡r"tj |tj |¡¡}t||ƒt||ƒdS)zVCopy data and mode bits ("cp src dst").
 
    The destination may be a directory.
 
    N)r/r0ÚisdirÚjoinÚbasenamer    r
r3r r r!r …s 
cCs:tj |¡r"tj |tj |¡¡}t||ƒt||ƒdS)z]Copy data and all stat info ("cp -p src dst").
 
    The destination may be a directory.
 
    N)r/r0rJrKrLr    r r3r r r!r s 
cs‡fdd„}|S)zFunction that can be used as copytree() ignore parameter.
 
    Patterns is a sequence of glob-style patterns
    that are used to exclude filescs(g}ˆD]}| t ||¡¡qt|ƒS©N)ÚextendÚfnmatchÚfilterÚset)r0ÚnamesÚ ignored_namesÚpattern©Úpatternsr r!Ú_ignore_patterns sz)ignore_patterns.<locals>._ignore_patternsr )rVrWr rUr!r›s c Cs¶t |¡}|dk    r|||ƒ}ntƒ}t |¡g}|D]
}    |    |krFq6tj ||    ¡}
tj ||    ¡} zttj |
¡r¬t |
¡} |rŒt | | ¡qÔtj     | ¡s |r Wq6||
| ƒn(tj 
|
¡rÊt |
| |||ƒn
||
| ƒWq6t k
r
} z|  | jd¡W5d} ~ XYq6tk
r@}z| |
| t|ƒf¡W5d}~XYq6Xq6zt||ƒWnPtk
r¢}z0tdk    r~t|tƒr~n|  ||t|ƒf¡W5d}~XYnX|r²t |ƒ‚dS)aüRecursively copy a directory tree.
 
    The destination directory must not already exist.
    If exception(s) occur, an Error is raised with a list of reasons.
 
    If the optional symlinks flag is true, symbolic links in the
    source tree result in symbolic links in the destination tree; if
    it is false, the contents of the files pointed to by symbolic
    links are copied. If the file pointed by the symlink doesn't
    exist, an exception will be added in the list of errors raised in
    an Error exception at the end of the copy process.
 
    You can set the optional ignore_dangling_symlinks flag to true if you
    want to silence this exception. Notice that this has no effect on
    platforms that don't support os.symlink.
 
    The optional ignore argument is a callable. If given, it
    is called with the `src` parameter, which is the directory
    being visited by copytree(), and `names` which is the list of
    `src` contents, as returned by os.listdir():
 
        callable(src, names) -> ignored_names
 
    Since copytree() is called recursively, the callable will be
    called once for each directory that is copied. It returns a
    list of names relative to the `src` directory that should
    not be copied.
 
    The optional copy_function argument is a callable that will be used
    to copy each file. It will be called with the source path and the
    destination path as arguments. By default, copy2() is used, but any
    function that supports the same signature (like copy()) can be used.
 
    Nr)r/ÚlistdirrQÚmakedirsr0rKÚislinkÚreadlinkÚsymlinkÚexistsrJrrrNÚargsÚEnvironmentErrorÚappendÚstrr r1Ú WindowsErrorÚ
isinstance)r4r5ÚsymlinksÚignoreÚ copy_functionÚignore_dangling_symlinksrRrSÚerrorsÚnameÚsrcnameÚdstnameÚlinktoÚerrrIr r r!r§sD$
 
 
 
   (&c    Csr|rdd„}n|dkrdd„}ztj |¡r4tdƒ‚Wn*tk
r`|tjj|t ¡ƒYdSXg}zt |¡}Wn(tjk
rœ|tj|t ¡ƒYnX|D]}tj ||¡}zt     |¡j
}Wntjk
rÞd}YnXt   |¡røt |||ƒq¢zt |¡Wq¢tjk
r0|tj|t ¡ƒYq¢Xq¢zt |¡Wn*tjk
rl|tj|t ¡ƒYnXdS)aÁRecursively delete a directory tree.
 
    If ignore_errors is set, errors are ignored; otherwise, if onerror
    is set, it is called to handle the error with arguments (func,
    path, exc_info) where func is os.listdir, os.remove, or os.rmdir;
    path is the argument to that function that caused it to fail; and
    exc_info is a tuple returned by sys.exc_info().  If ignore_errors
    is false and onerror is None, an exception is raised.
 
    cWsdSrMr ©r^r r r!Úonerrorszrmtree.<locals>.onerrorNcWs‚dSrMr rnr r r!rosz%Cannot call rmtree on a symbolic linkr)r/r0rZr1ÚsysÚexc_inforXÚerrorrKÚlstatr;r9ÚS_ISDIRrÚremoveÚrmdir)r0Ú ignore_errorsrorRriÚfullnamerAr r r!rùs> 
 
 
cCstj | tjj¡¡SrM)r/r0rLÚrstripÚsep)r0r r r!Ú    _basename*sr{cCsÐ|}tj |¡rTt||ƒr*t ||¡dStj |t|ƒ¡}tj |¡rTtd|ƒ‚zt ||¡Wnft    k
rÊtj |¡r²t
||ƒrštd||fƒ‚t ||ddt |ƒnt ||ƒt |¡YnXdS)a“Recursively move a file or directory to another location. This is
    similar to the Unix "mv" command.
 
    If the destination is a directory or a symlink to a directory, the source
    is moved inside the directory. The destination path must not already
    exist.
 
    If the destination already exists but is not a directory, it may be
    overwritten depending on os.rename() semantics.
 
    If the destination is on our current filesystem, then rename() is used.
    Otherwise, src is copied to the destination and then removed.
    A lot more could be done here...  A look at a mv.c shows a lot of
    the issues this implementation glosses over.
 
    Nz$Destination path '%s' already existsz.Cannot move a directory '%s' into itself '%s'.T)rd)r/r0rJr6ÚrenamerKr{r]rr1Ú
_destinsrcrrr Úunlink)r4r5Úreal_dstr r r!r/s$ 
 
 
 
cCsNt|ƒ}t|ƒ}| tjj¡s*|tjj7}| tjj¡sD|tjj7}| |¡SrM)rÚendswithr/r0rzÚ
startswithr3r r r!r}Ws  r}cCsNtdks|dkrdSz t|ƒ}Wntk
r8d}YnX|dk    rJ|dSdS)z"Returns a gid, given a group name.Né)rÚKeyError©riÚresultr r r!Ú_get_gid`s 
r†cCsNtdks|dkrdSz t|ƒ}Wntk
r8d}YnX|dk    rJ|dSdS)z"Returns an uid, given a user name.Nr‚)rrƒr„r r r!Ú_get_uidls 
r‡Úgzipcsdddœ}ddi}    tr&d|d<d|    d<|d    k    rD||    krDtd
 |¡ƒ‚|d |     |d¡}
tj |
¡} tj | ¡s’|d    k    r„| d | ¡|s’t     | ¡|d    k    r¤| d ¡t
ˆƒ‰t ˆƒ‰‡‡‡‡fdd„} |süt   |
d||¡} z| j|| dW5|  ¡X|
S)aíCreate a (possibly compressed) tar file from all the files under
    'base_dir'.
 
    'compress' must be "gzip" (the default), "bzip2", or None.
 
    'owner' and 'group' can be used to define an owner and a group for the
    archive that is being built. If not provided, the current owner and group
    will be used.
 
    The output tar file will be named 'base_name' +  ".tar", possibly plus
    the appropriate compression extension (".gz", or ".bz2").
 
    Returns the output filename.
    ÚgzÚ)rˆNrˆz.gzÚbz2Úbzip2ú.bz2NzCbad value for 'compress', or compression format not supported : {0}ú.tarú creating %szCreating tar archivecs,ˆdk    rˆ|_ˆ|_ˆdk    r(ˆ|_ˆ|_|SrM)ÚgidÚgnameÚuidÚuname)Útarinfo©rÚgroupÚownerr’r r!Ú _set_uid_gid¤sz#_make_tarball.<locals>._set_uid_gidzw|%s)rP)Ú_BZ2_SUPPORTEDÚ
ValueErrorÚformatÚgetr/r0Údirnamer]ÚinforYr‡r†rr<ÚcloseÚadd)Ú    base_nameÚbase_dirÚcompressÚverboseÚdry_runr—r–ÚloggerÚtar_compressionÚ compress_extÚ archive_nameÚ archive_dirr˜Útarr r•r!Ú _make_tarballxs6
ÿ   
 
    
r¬cCsd|r
d}nd}ddlm}ddlm}z|d|||g|dWn |k
r^tdƒ|‚YnXdS)    Nz-rz-rqr)ÚDistutilsExecError)ÚspawnÚzip)r¥zkunable to create zip file '%s': could neither import the 'zipfile' module nor find a standalone zip utility)Údistutils.errorsr­Údistutils.spawnr®r)r¢Ú zip_filenamer¤r¥Ú
zipoptionsr­r®r r r!Ú_call_external_zip¶s  þr´cCs|d}tj |¡}tj |¡sB|dk    r4| d|¡|sBt |¡z ddl}Wntk
rfd}YnX|dkr€t||||ƒn˜|dk    r–| d||¡|s|j    |d|j
d}t  |¡D]V\}    }
} | D]F} tj  tj  |    | ¡¡} tj | ¡rÆ| | | ¡|dk    rÆ| d| ¡qÆq¸| ¡|S)    amCreate a zip file from all the files under 'base_dir'.
 
    The output zip file will be named 'base_name' + ".zip".  Uses either the
    "zipfile" Python module (if available) or the InfoZIP "zip" utility
    (if installed and found on the default search path).  If neither tool is
    available, raises ExecError.  Returns the name of the output zip
    file.
    ú.zipNrrz#creating '%s' and adding '%s' to itÚw)Ú compressionz adding '%s')r/r0rr]ržrYÚzipfileÚ ImportErrorr´ÚZipFileÚ ZIP_DEFLATEDÚwalkÚnormpathrKÚisfiler(rŸ)r¡r¢r¤r¥r¦r²rªr¸r¯ÚdirpathÚdirnamesÚ    filenamesrir0r r r!Ú _make_zipfileÇs>       
 
ÿÿ  rÂ)r£rˆzgzip'ed tar-file)r£rŒzbzip2'ed tar-file)r£Nzuncompressed tar filezZIP file)ÚgztarÚbztarr«r¯rÄcCsdd„t ¡Dƒ}| ¡|S)z‘Returns a list of supported formats for archiving and unarchiving.
 
    Each element of the returned sequence is a tuple (name, description)
    cSsg|]\}}||df‘qS)r‚r )Ú.0riÚregistryr r r!Ú
<listcomp>sz'get_archive_formats.<locals>.<listcomp>)Ú_ARCHIVE_FORMATSÚitemsÚsort©Úformatsr r r!rs
ÿrŠcCsv|dkr g}t|tƒs"td|ƒ‚t|ttfƒs8tdƒ‚|D]&}t|ttfƒrZt|ƒdkr<tdƒ‚q<|||ft|<dS)auRegisters an archive format.
 
    name is the name of the format. function is the callable that will be
    used to create archives. If provided, extra_args is a sequence of
    (name, value) tuples that will be passed as arguments to the callable.
    description can be provided to describe the format, and will be returned
    by the get_archive_formats() function.
    NzThe %s object is not callablez!extra_args needs to be a sequencer‚z+extra_args elements are : (arg_name, value))rcrÚ    TypeErrorÚtupleÚlistÚlenrÈ)riÚfunctionÚ
extra_argsÚ descriptionÚelementr r r!r s    
 
cCs
t|=dSrM)rÈ©rir r r!r sc    
Csþt ¡}    |dk    r>|dk    r$| d|¡tj |¡}|s>t |¡|dkrLtj}||dœ}
z t|} Wn tk
r‚t    d|ƒ‚YnX| d} | dD]\} }||
| <q”|dkr¾||
d<||
d    <z| ||f|
Ž}W5|dk    rø|dk    rî| d
|    ¡t |    ¡X|S) aêCreate an archive file (eg. zip or tar).
 
    'base_name' is the name of the file to create, minus any format-specific
    extension; 'format' is the archive format: one of "zip", "tar", "bztar"
    or "gztar".
 
    'root_dir' is a directory that will be the root directory of the
    archive; ie. we typically chdir into 'root_dir' before creating the
    archive.  'base_dir' is the directory where we start archiving from;
    ie. 'base_dir' will be the common prefix of all files and
    directories in the archive.  'root_dir' and 'base_dir' both default
    to the current directory.  Returns the name of the archive file.
 
    'owner' and 'group' are used when creating a tar archive. By default,
    uses the current owner and group.
    Nzchanging into '%s')r¥r¦zunknown archive format '%s'rrr¯r—r–zchanging back to '%s')
r/ÚgetcwdÚdebugr0rÚchdirÚcurdirrÈrƒrš)r¡r›Úroot_dirr¢r¤r¥r—r–r¦Úsave_cwdÚkwargsÚ format_infoÚfuncÚargÚvalÚfilenamer r r!r#s6  
 
 
  cCsdd„t ¡Dƒ}| ¡|S)z‘Returns a list of supported formats for unpacking.
 
    Each element of the returned sequence is a tuple
    (name, extensions, description)
    cSs"g|]\}}||d|df‘qS)rér )rÅriržr r r!rÇ`sz&get_unpack_formats.<locals>.<listcomp>)Ú_UNPACK_FORMATSrÉrÊrËr r r!rZs
ÿc    Csli}t ¡D]\}}|dD] }|||<qq |D]$}||kr0d}t||||fƒ‚q0t|tƒshtdƒ‚dS)z+Checks what gets registered as an unpacker.rz!%s is already registered for "%s"z*The registered function must be a callableN)rãrÉr%rcrrÍ)    Ú
extensionsrÑrÒÚexisting_extensionsriržÚextÚ    extensionÚmsgr r r!Ú_check_unpack_optionses  ÿ
 
récCs,|dkr g}t|||ƒ||||ft|<dS)aMRegisters an unpack format.
 
    `name` is the name of the format. `extensions` is a list of extensions
    corresponding to the format.
 
    `function` is the callable that will be
    used to unpack archives. The callable will receive archives to unpack.
    If it's unable to handle an archive, it needs to raise a ReadError
    exception.
 
    If provided, `extra_args` is a sequence of
    (name, value) tuples that will be passed as arguments to the callable.
    description can be provided to describe the format, and will be returned
    by the get_unpack_formats() function.
    N)rérã)rirärÑrÒrÓr r r!rws cCs
t|=dS)z*Removes the pack format from the registry.N)rãrÕr r r!rscCs&tj |¡}tj |¡s"t |¡dS)z1Ensure that the parent directory of `path` existsN)r/r0rrJrY)r0rr r r!Ú_ensure_directory‘s  rêc        Csèz ddl}Wntk
r(tdƒ‚YnX| |¡s@td|ƒ‚| |¡}zŽ| ¡D]€}|j}| d¡sTd|krrqTt    j
j |f|  d¡žŽ}|sqTt |ƒ| d¡sT| |j¡}t|dƒ}z| |¡W5| ¡~XqTW5| ¡XdS)z+Unpack zip `filename` to `extract_dir`
    rNz/zlib not supported, cannot unpack this archive.z%s is not a zip fileú/z..r8)r¸r¹r$Ú
is_zipfilerºrŸÚinfolistrárr/r0rKÚsplitrêr€r'r<r()    ráÚ extract_dirr¸r¯ržriÚtargetÚdataÚfr r r!Ú_unpack_zipfile—s0 
 
 
 
 
rócCsPzt |¡}Wn"tjk
r0td|ƒ‚YnXz| |¡W5| ¡XdS)z:Unpack tar/tar.gz/tar.bz2 `filename` to `extract_dir`
    z/%s is not a compressed or uncompressed tar fileN)rr<ÚTarErrorr$rŸÚ
extractall)rárïÚtarobjr r r!Ú_unpack_tarfile¼sÿ
r÷z.tar.gzz.tgzrŽrµ)rÃr«r¯rcCs:t ¡D],\}}|dD]}| |¡r|SqqdS)Nr)rãrÉr€)ráriržrçr r r!Ú_find_unpack_formatÓs
 
røcCs´|dkrt ¡}|dk    rhz t|}Wn"tk
rFtd |¡ƒ‚YnX|d}|||ft|dƒŽnHt|ƒ}|dkr†td |¡ƒ‚t|d}tt|dƒ}|||f|ŽdS)aöUnpack an archive.
 
    `filename` is the name of the archive.
 
    `extract_dir` is the name of the target directory, where the archive
    is unpacked. If not provided, the current working directory is used.
 
    `format` is the archive format: one of "zip", "tar", or "gztar". Or any
    other registered format. If not provided, unpack_archive will use the
    filename extension and see if an unpacker was registered for that
    extension.
 
    In case none is found, a ValueError is raised.
    NzUnknown unpack format '{0}'rr‚zUnknown archive format '{0}')    r/rÖrãrƒršr›Údictrør$)rárïr›rÝrÞrÜr r r!rÚs  )r&)FN)rˆrrNNN)FF)rrN)NrŠ)NNrrNNN)NrŠ)NN)?r#r/rpr9Úos.pathrrOÚcollections.abcrr¹Ú collectionsrHrŠrr‹r™ÚpwdrÚgrprÚ__all__r_rrrr$Ú    Exceptionr%rbÚ    NameErrorrr6r    r
r r r rrrr{rr}r†r‡r¬r´rÂrÈrrrrrrérrrêrór÷rãrørr r r r!Ú<module>sÞ  
 
 
 û
 
    ÿ
R
1(      ÿ
>
 
0
 
 
üÿ
 
ÿ
7 ÿ
%  ýÿ