/usr/lib/python3.10/__pycache__
NameSizeModeActions
abc.cpython-310.pyc67510644editdlrm
aifc.cpython-310.pyc246850644editdlrm
antigravity.cpython-310.pyc8220644editdlrm
argparse.cpython-310.pyc635390644editdlrm
ast.cpython-310.pyc557390644editdlrm
asynchat.cpython-310.pyc70250644editdlrm
asyncore.cpython-310.pyc160020644editdlrm
base64.cpython-310.pyc171620644editdlrm
bdb.cpython-310.pyc258320644editdlrm
binhex.cpython-310.pyc128700644editdlrm
bisect.cpython-310.pyc25880644editdlrm
bz2.cpython-310.pyc108700644editdlrm
calendar.cpython-310.pyc263030644editdlrm
cgi.cpython-310.pyc267230644editdlrm
cgitb.cpython-310.pyc99980644editdlrm
chunk.cpython-310.pyc48600644editdlrm
cmd.cpython-310.pyc127070644editdlrm
code.cpython-310.pyc99570644editdlrm
codecs.cpython-310.pyc332190644editdlrm
codeop.cpython-310.pyc55950644editdlrm
colorsys.cpython-310.pyc32650644editdlrm
compileall.cpython-310.pyc127330644editdlrm
configparser.cpython-310.pyc454580644editdlrm
contextlib.cpython-310.pyc208950644editdlrm
contextvars.cpython-310.pyc2460644editdlrm
copy.cpython-310.pyc69960644editdlrm
copyreg.cpython-310.pyc46830644editdlrm
cProfile.cpython-310.pyc51130644editdlrm
crypt.cpython-310.pyc35500644editdlrm
csv.cpython-310.pyc117980644editdlrm
dataclasses.cpython-310.pyc265780644editdlrm
datetime.cpython-310.pyc565330644editdlrm
decimal.cpython-310.pyc3620644editdlrm
difflib.cpython-310.pyc589050644editdlrm
dis.cpython-310.pyc156560644editdlrm
doctest.cpython-310.pyc761750644editdlrm
enum.cpython-310.pyc260630644editdlrm
filecmp.cpython-310.pyc87490644editdlrm
fileinput.cpython-310.pyc140720644editdlrm
fnmatch.cpython-310.pyc42440644editdlrm
fractions.cpython-310.pyc186000644editdlrm
ftplib.cpython-310.pyc290340644editdlrm
functools.cpython-310.pyc283350644editdlrm
genericpath.cpython-310.pyc39070644editdlrm
getopt.cpython-310.pyc63390644editdlrm
getpass.cpython-310.pyc42100644editdlrm
gettext.cpython-310.pyc182210644editdlrm
glob.cpython-310.pyc58520644editdlrm
graphlib.cpython-310.pyc76160644editdlrm
gzip.cpython-310.pyc185460644editdlrm
hashlib.cpython-310.pyc68450644editdlrm
heapq.cpython-310.pyc138650644editdlrm
hmac.cpython-310.pyc69730644editdlrm
imaplib.cpython-310.pyc423120644editdlrm
imghdr.cpython-310.pyc39050644editdlrm
imp.cpython-310.pyc97860644editdlrm
inspect.cpython-310.pyc851530644editdlrm
io.cpython-310.pyc36630644editdlrm
ipaddress.cpython-310.pyc626700644editdlrm
keyword.cpython-310.pyc9270644editdlrm
linecache.cpython-310.pyc41420644editdlrm
locale.cpython-310.pyc461540644editdlrm
lzma.cpython-310.pyc121000644editdlrm
mailbox.cpython-310.pyc600910644editdlrm
mailcap.cpython-310.pyc73200644editdlrm
mimetypes.cpython-310.pyc176190644editdlrm
modulefinder.cpython-310.pyc161660644editdlrm
netrc.cpython-310.pyc39330644editdlrm
nntplib.cpython-310.pyc316230644editdlrm
ntpath.cpython-310.pyc147040644editdlrm
nturl2path.cpython-310.pyc17470644editdlrm
numbers.cpython-310.pyc118660644editdlrm
opcode.cpython-310.pyc54470644editdlrm
operator.cpython-310.pyc135080644editdlrm
optparse.cpython-310.pyc477540644editdlrm
os.cpython-310.pyc315990644editdlrm
pathlib.cpython-310.pyc420520644editdlrm
pdb.cpython-310.pyc474400644editdlrm
pickle.cpython-310.pyc468820644editdlrm
pickletools.cpython-310.pyc677600644editdlrm
pipes.cpython-310.pyc77690644editdlrm
pkgutil.cpython-310.pyc183610644editdlrm
platform.cpython-310.pyc274290644editdlrm
plistlib.cpython-310.pyc237650644editdlrm
poplib.cpython-310.pyc135730644editdlrm
posixpath.cpython-310.pyc105600644editdlrm
pprint.cpython-310.pyc178750644editdlrm
profile.cpython-310.pyc143910644editdlrm
pstats.cpython-310.pyc236210644editdlrm
pty.cpython-310.pyc41430644editdlrm
pyclbr.cpython-310.pyc97750644editdlrm
pydoc.cpython-310.pyc856450644editdlrm
py_compile.cpython-310.pyc73390644editdlrm
queue.cpython-310.pyc107920644editdlrm
quopri.cpython-310.pyc57940644editdlrm
random.cpython-310.pyc227480644editdlrm
re.cpython-310.pyc142270644editdlrm
reprlib.cpython-310.pyc52500644editdlrm
rlcompleter.cpython-310.pyc59540644editdlrm
runpy.cpython-310.pyc94110644editdlrm
sched.cpython-310.pyc61150644editdlrm
secrets.cpython-310.pyc21750644editdlrm
selectors.cpython-310.pyc171050644editdlrm
shelve.cpython-310.pyc94920644editdlrm
shlex.cpython-310.pyc77820644editdlrm
shutil.cpython-310.pyc385360644editdlrm
signal.cpython-310.pyc29350644editdlrm
site.cpython-310.pyc179220644editdlrm
sitecustomize.cpython-310.pyc2250644editdlrm
smtpd.cpython-310.pyc261470644editdlrm
smtplib.cpython-310.pyc357660644editdlrm
sndhdr.cpython-310.pyc69620644editdlrm
socket.cpython-310.pyc289630644editdlrm
socketserver.cpython-310.pyc253470644editdlrm
sre_compile.cpython-310.pyc151940644editdlrm
sre_constants.cpython-310.pyc63570644editdlrm
sre_parse.cpython-310.pyc217550644editdlrm
ssl.cpython-310.pyc452710644editdlrm
stat.cpython-310.pyc42730644editdlrm
statistics.cpython-310.pyc370510644editdlrm
string.cpython-310.pyc71020644editdlrm
stringprep.cpython-310.pyc170750644editdlrm
struct.cpython-310.pyc3070644editdlrm
subprocess.cpython-310.pyc447410644editdlrm
sunau.cpython-310.pyc164820644editdlrm
symtable.cpython-310.pyc128350644editdlrm
sysconfig.cpython-310.pyc181510644editdlrm
tabnanny.cpython-310.pyc69500644editdlrm
tarfile.cpython-310.pyc715780644editdlrm
telnetlib.cpython-310.pyc185060644editdlrm
tempfile.cpython-310.pyc273390644editdlrm
textwrap.cpython-310.pyc138120644editdlrm
this.cpython-310.pyc12640644editdlrm
threading.cpython-310.pyc449690644editdlrm
timeit.cpython-310.pyc117690644editdlrm
token.cpython-310.pyc27380644editdlrm
tokenize.cpython-310.pyc171940644editdlrm
trace.cpython-310.pyc198700644editdlrm
traceback.cpython-310.pyc217120644editdlrm
tracemalloc.cpython-310.pyc175250644editdlrm
tty.cpython-310.pyc10790644editdlrm
turtle.cpython-310.pyc1288570644editdlrm
types.cpython-310.pyc95250644editdlrm
typing.cpython-310.pyc852770644editdlrm
uu.cpython-310.pyc38670644editdlrm
uuid.cpython-310.pyc224980644editdlrm
warnings.cpython-310.pyc136460644editdlrm
wave.cpython-310.pyc175940644editdlrm
weakref.cpython-310.pyc203430644editdlrm
webbrowser.cpython-310.pyc174630644editdlrm
xdrlib.cpython-310.pyc78800644editdlrm
zipapp.cpython-310.pyc60130644editdlrm
zipfile.cpython-310.pyc618450644editdlrm
zipimport.cpython-310.pyc170330644editdlrm
_aix_support.cpython-310.pyc28790644editdlrm
_bootsubprocess.cpython-310.pyc22940644editdlrm
_collections_abc.cpython-310.pyc329250644editdlrm
_compat_pickle.cpython-310.pyc58720644editdlrm
_compression.cpython-310.pyc45120644editdlrm
_distutils_system_mod.cpython-310.pyc54220644editdlrm
_markupbase.cpython-310.pyc75720644editdlrm
_osx_support.cpython-310.pyc115350644editdlrm
_pydecimal.cpython-310.pyc1577360644editdlrm
_pyio.cpython-310.pyc736540644editdlrm
_py_abc.cpython-310.pyc46830644editdlrm
_sitebuiltins.cpython-310.pyc35470644editdlrm
_strptime.cpython-310.pyc159450644editdlrm
_sysconfigdata__linux_x86_64-linux-gnu.cpython-310.pyc353850644editdlrm
_sysconfigdata__x86_64-linux-gnu.cpython-310.pyc353790644editdlrm
_threading_local.cpython-310.pyc65390644editdlrm
_weakrefset.cpython-310.pyc76080644editdlrm
__future__.cpython-310.pyc41310644editdlrm
__phello__.foo.cpython-310.pyc1300644editdlrm
Edit: /usr/lib/python3.10/__pycache__/shutil.cpython-310.pyc (38536B)
o 9j,@s.dZddlZddlZddlZddlZddlZddlZz ddlZ[dZWn e y.dZYnwz ddl Z [ dZ Wn e yCdZ Ynwz ddl Z [ dZ Wn e yXdZ YnwejdkZdZZejdkrlddlZnerrddlZervdndZeed oejd aeoeed Zd Zgd ZGdddeZGdddeZGdddeZGdddeZGdddeZGddde Z!Gddde Z"ddZ#ddZ$efd d!Z%dd"d#Z&d$d%Z'd&d'Z(d(d)Z)dd*d+d,Z*dd*d-d.Z+eed/rdd*d0d1Z,nd2d1Z,dd*d3d4Z-dd*d5d6Z.dd*d7d8Z/d9d:Z0 dd;d<Z1dde/ddfd=d>Z2eej3d?r@d@dAZ4dBdCZ5ndDdAZ4dEdCZ5dFdGZ6dHdIZ7ej8ejej9ej:hej;kojejvZ?ddJdKZ@e?e@_AdLdMZBe/fdNdOZCdPdQZDdRdSZEdTdUZFdVdWZG  ddYdZZH  dd[d\ZId]eHd^gd_dfiZJereHd`gdadfeJdb<eIgdcdfeJdd<e reHdegdfdfeJdg<e reHdhgdidfeJdj<dkdlZKddndoZLdpdqZM  ddrdsZNdtduZOdvdwZP  mddxdyZQdzd{ZRd|d}ZSd~dZTddddZUdgeUgd_fdgeTgdcfdZVer"ddgeUgdafeVdb<e r/ddgeUgdffeVdg<e rrc@r%)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)Nr&r#r#r#r$rAr(rc@r%)rz+Raised when a command could not be executedNr&r#r#r#r$rEr(rc@r%) ReadErrorz%Raised when an archive cannot be readNr&r#r#r#r$r)Hr(r)c@r%) RegistryErrorzVRaised when a registry operation with the archiving and unpacking registries failsNr&r#r#r#r$r*Kr(r*c@r%)_GiveupOnFastCopyzuRaised as a signal to fallback on using raw read()/write() file copy when fast-copy functions fail to do so. Nr&r#r#r#r$r+Or(r+c Csz |}|}Wnty}zt|d}~wwz t|||WdStyI}z|j|_|j|_|j t j t j hvrBt||dd}~ww)zhCopy a regular file content or metadata by using high-performance fcopyfile(3) syscall (macOS). N) fileno Exceptionr+rrOSErrornamefilename filename2errnoEINVALENOTSUP)fsrcfdstflagsinfdoutfderrr#r#r$_fastcopy_fcopyfileTs" r;c Cs$z |}|}Wnty}zt|d}~wwz tt|jd}Wn ty1d}Ynwtj dkr= 2.6.33 only. Niili@rTF)r,r-r+maxosfstatst_sizer.sysmaxsizeminrr/r0r1r2ENOTSOCK_USE_CP_SENDFILEENOSPClseekSEEK_CUR)r5r6r8r9r: blocksizeoffsetsentr#r#r$_fastcopy_sendfilehsF      rKc Cs|j}|j}tt|6} ||}|sn%||kr5|d| }||Wdn1s/wYn||qWddS1sEwYdS)zreadinto()/memoryview() based variant of copyfileobj(). *fsrc* must support readinto() method and both files must be open in binary mode. TN)readintowrite memoryview bytearray)r5r6length fsrc_readinto fdst_writemvnsmvr#r#r$_copyfileobj_readintos  "rVcCs0|st}|j}|j} ||}|sdS||q )z=copy data from file-like object fsrc to file-like object fdstTN) COPY_BUFSIZEreadrM)r5r6rP fsrc_readrRbufr#r#r$rsrcCst|tjr$ttjdr$z tj|t|WSty#YdSwttjdr=ztj||WSty<YdSwtj tj |tj tj |kS)NsamestatFsamefile) isinstancer=DirEntryhasattrpathr[statr.r\normcaseabspathsrcdstr#r#r$ _samefiles   rgcCst|tjr |St|SN)r]r=r^rafnr#r#r$_statsrkcCs t|tjr |Stj|Srh)r]r=r^ is_symlinkr`islinkrir#r#r$_islinks rnfollow_symlinksc Cs:td||t||rtd||d}t||gD]4\}}zt|}Wn ty/Yqwt |j rGt |t j r?|jn|}td|trP|dkrP|j}q|sbt|rbt t |||St|d}zt|du}trzt||tj|WWdWWdStyYnDwtrzt|||WWdWWdStyYn!wtr|dkrt||t|t|WdWWdSt ||Wdn1swYWnt!y } zt j"|st#d|| d} ~ wwWd|S1swY|S) zCopy data from src to dst in the most efficient way possible. If follow_symlinks is not set and src is a symbolic link, a new symlink will be created instead of copying the file it points to. zshutil.copyfilez{!r} and {!r} are the same filerz`%s` is a named piperbwbNzDirectory does not exist: )$r@auditrgrformat enumeraterkr.raS_ISFIFOst_moder]r=r^r`r_WINDOWSr?rnsymlinkreadlinkopen_HAS_FCOPYFILEr;r_COPYFILE_DATAr+rDrKrVrBrWrIsADirectoryErrorexistsFileNotFoundError) rerfrp file_sizeirjstr5r6er#r#r$rsv       "          rcCsntd|||s"t|r"tj|r"ttdr tjtj}}ndSt tj }}||}||t |j dS)zCopy mode bits from src to dst. If follow_symlinks is not set, symlinks aren't followed if and only if both `src` and `dst` are symlinks. If `lchmod` isn't available (e.g. Linux) this method does nothing. zshutil.copymodelchmodN)r@rsrnr=r`rmr_lstatrrkchmodraS_IMODErw)rerfrp stat_func chmod_funcrr#r#r$r s  r listxattrc Csz tj||d}Wnty(}z|jtjtjtjfvrWYd}~dSd}~ww|D]5}ztj|||d}tj||||dWq+ty`}z|jtj tjtjtjfvrVWYd}~q+d}~wwdS)zCopy extended filesystem attributes from `src` to `dst`. Overwrite existing attributes. If `follow_symlinks` is false, symlinks won't be followed. roN) r=rr.r2r4ENODATAr3getxattrsetxattrEPERM)rerfrpnamesrr/valuer#r#r$ _copyxattr6s*  rcOdSrhr#)argskwargsr#r#r$rNc sXtd||ddddd|pt|otj| }|r%fdd}nfdd}t|tjr8|j|d }n|d ||d }t |j }|d ||j |j f|dt |||d z |d |||d Wn tynYnwt|d rz |d||j|d WdSty}zdD]}tt|r|jtt|krnqWYd}~dSd}~wwdS)aCopy file metadata Copy the permission bits, last access time, last modification time, and flags from `src` to `dst`. On Linux, copystat() also copies the "extended attributes" where possible. The file contents, owner, and group are unaffected. `src` and `dst` are path-like objects or path names given as strings. If the optional flag `follow_symlinks` is not set, symlinks aren't followed if and only if both `src` and `dst` are symlinks. zshutil.copystatN)nsrpcWrrhr#)rrprr#r#r$_nop_rzcopystat.._nopcs tt|Srh)getattrr=r/rr#r$lookupf zcopystat..lookupcstt|}|tjvr |SSrh)rr=supports_follow_symlinks)r/rjrr#r$rks  rorautimerst_flagschflags) EOPNOTSUPPr4)r@rsrnr=r`rmr]r^rarrw st_atime_ns st_mtime_nsrNotImplementedErrorr_rr.r2r) rerfrpfollowrrmodewhyr:r#rr$r Qs@       r cCBtj|rtj|tj|}t|||dt|||d|S)a3Copy data and mode bits ("cp src dst"). Return the file's destination. The destination may be a directory. If follow_symlinks is false, symlinks won't be followed. This resembles GNU's "cp -P src dst". If source and destination are the same file, a SameFileError will be raised. ro)r=r`isdirjoinbasenamerr rerfrpr#r#r$r s r cCr)a0Copy data and metadata. Return the file's destination. Metadata is copied with copystat(). Please see the copystat function for more information. The destination may be a directory. If follow_symlinks is false, symlinks won't be followed. This resembles GNU's "cp -P src dst". ro)r=r`rrrrr rr#r#r$r s r csfdd}|S)zFunction 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|Srh)extendfnmatchfilterset)r`r ignored_namespatternpatternsr#r$_ignore_patternssz)ignore_patterns.._ignore_patternsr#)rrr#rr$rs rc Cs2|dur|t|dd|D}nt}tj||dg} |tup%|tu} |D]} | j|vr0q(tj|| j} tj|| j} | rD| n| }zf| }|r`tjdkr`| j dd}|j t j kr`d}|rt | }|rxt|| t|| | dn3tj|s|rWq(| rt|| |||||n||| n| rt|| |||||n||| Wq(ty}z| |jdWYd}~q(d}~wty}z| | | t|fWYd}~q(d}~wwzt||Wn&ty}zt|dddur| ||t|fWYd}~nd}~ww| rt| |S) NcSsg|]}|jqSr#r).0xr#r#r$ sz_copytree..)exist_okrFrorwinerror)r=fspathrmakedirsr r r/r`rrlrast_reparse_tagIO_REPARSE_TAG_MOUNT_POINTrzryr ris_dirr rrrr.appendstrr)entriesrerfsymlinksignore copy_functionignore_dangling_symlinks dirs_exist_okrerrors use_srcentrysrcentrysrcnamedstnamesrcobjrlrlinktor:rr#r#r$ _copytreesl           rc CsXtd||t| }t|}Wdn1swYt||||||||dS)a'Recursively copy a directory tree and return the destination directory. 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. If dirs_exist_ok is false (the default) and `dst` already exists, a `FileExistsError` is raised. If `dirs_exist_ok` is true, the copying operation will continue if it encounters existing directories, and files within the `dst` tree will be overwritten by corresponding files from the `src` tree. zshutil.copytreeN)rrerfrrrrr)r@rsr=scandirlistr) rerfrrrrritrrr#r#r$r s(   r st_file_attributescCsJz|jdd}t|jo|jtj@o|jtjk WSty$YdSwNFro)raS_ISDIRrwrFILE_ATTRIBUTE_REPARSE_POINTrrr.)entryrr#r#r$ _rmtree_isdir8s     rcCsFzt|}t|jp|jtj@o|jtjkWSt y"YdSw)NF) r=rraS_ISLNKrwrrrrr.)r`rr#r#r$_rmtree_islinkAs     rcCs$z|jddWStyYdSwr)rr.)rr#r#r$rJs  cCs tj|Srh)r=r`rm)r`r#r#r$rPrc Cs*zt| }t|}Wdn1swYWnty/|tj|tg}Ynw|D]F}|j}t|r_z |rDtdWntyX|tjj |tYq2wt ||q2zt |Wq2tyx|tj |tYq2wzt |WdSty|tj |tYdSw)N%Cannot call rmtree on a symbolic link) r=rrr.r@exc_infor`rrlrm_rmtree_unsafeunlinkrmdir)r`onerror scandir_itrrfullnamer#r#r$rTs>       rc CsDzt| }t|}Wdn1swYWnty:}z||_|tj|tWYd}~dSd}~ww|D]}tj||j }z|j dd}Wn tyZd}Yn$w|r~z|j dd} t | j }Wnty}|tj|tYq=w|rztj|j tj|d} d} Wnty|tj|tYq=wzUtj| t| rt| ||zt| d} tj|j |dWn*ty|tj|tYnwztdty|tjj|tYnwW| st| q=| st| wwz tj|j |dWq=ty|tj|tYq=wdS)NFro)dir_fdTr)r=rrr.r0r@rr`rr/rrarrwrr{O_RDONLYr[r>_rmtree_safe_fdcloserrmr) topfdr`rrrr:rrrorig_stdirfd dirfd_closedr#r#r$rssz            rc Cstd||r dd}n|durdd}trt|tr!t|}zt|}Wnty;|tj|t YdSwz t |tj }d}WntyZ|tj |t YdSwzUtj |t|rt|||zt|d}t|Wn*ty|tj|t Ynwztdty|tj j|t YnwW|st|dSdS|st|wwz t|rtdWnty|tj j|t YdSwt||S) aRecursively 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 platform and implementation dependent; 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. z shutil.rmtreecWrrhr#rr#r#r$rrzrmtree..onerrorNcWsrhr#rr#r#r$rsFTr)r@rs_use_fd_functionsr]bytesr=fsdecoderr-rr{rr`r[r>rrrr.rmrr)r` ignore_errorsrrfd fd_closedr#r#r$rsf             rcCs0t|}tjjtjjp d}tj||S)aHA basename() variant which first strips the trailing slash, if present. Thus we always get the last component of the path, even for directories. path: Union[PathLike, str] e.g. >>> os.path.basename('/bar/foo') 'foo' >>> os.path.basename('/bar/foo/') '' >>> _basename('/bar/foo/') 'foo' )r=rr`sepaltseprrstrip)r`rr#r#r$ _basenames rc CsNtd|||}tj|r1t||rt||dStj|t|}tj |r1t d|z t||W|St ytj |rZt |}t||t|Y|Stj|rt||rmt d||ft|st|tjst|rtjdkrtd||ft|||ddt|Y|S|||t|Y|Sw) a+Recursively move a file or directory to another location. This is similar to the Unix "mv" command. Return the file or directory's destination. 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. Symlinks are recreated under the new name if os.rename() fails because of cross filesystem renames. The optional `copy_function` argument is a callable that will be used to copy the source or it will be delegated to `copytree`. By default, copy2() is used, but any function that supports the same signature (like copy()) can be used. A lot more could be done here... A look at a mv.c shows a lot of the issues this implementation glosses over. z shutil.moveNz$Destination path '%s' already existsz.Cannot move a directory '%s' into itself '%s'.darwinzKCannot move the non-empty directory '%s': Lacking write permission to '%s'.T)rr)r@rsr=r`rrgrenamerrrrr.rmrzryr _destinsrc _is_immutableaccessW_OKlistdirplatformPermissionErrorr r)rerfrreal_dstrr#r#r$rsR              rcCsVtj|}tj|}|tjjs|tjj7}|tjjs&|tjj7}||Srh)r=r`rcendswithr startswithrdr#r#r$rHs     rcCs(t|}tjtjg}t|do|j|vS)Nr)rkra UF_IMMUTABLE SF_IMMUTABLEr_r)rerimmutable_statesr#r#r$rQs rcCj|durdSzddlm}Wn tyYdSwz||}Wn ty*d}Ynw|dur3|dSdS)z"Returns a gid, given a group name.Nr)getgrnam)grpr ImportErrorKeyError)r/rresultr#r#r$_get_gidV   rcCr)z"Returns an uid, given a user name.Nr)getpwnamr )pwdrr r )r/rr r#r#r$_get_uidhrrgzipc sV|durd} n"tr|dkrd} ntr|dkrd} ntr"|dkr"d} ntd|d dl} |r3d | nd} |d | } tj| } | rZtj | sZ|durS| d | |sZt | |durc| d t t fdd}|s| | d| }|}|durtj||}z|j|||dW|n|w|durtj| } | S)aCreate a (possibly compressed) tar file from all the files under 'base_dir'. 'compress' must be "gzip" (the default), "bzip2", "xz", 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", ".bz2", or ".xz"). Returns the output filename. Nrrgzbzip2bz2xzzCbad value for 'compress', or compression format not supported : {0}r..tar creating %szCreating tar archivecs,dur |_|_dur|_|_|Srh)gidgnameuiduname)tarinforgroupownerrr#r$ _set_uid_gidsz#_make_tarball.._set_uid_gidzw|%sr)_ZLIB_SUPPORTED_BZ2_SUPPORTED_LZMA_SUPPORTED ValueErrorrttarfiler=r`dirnamerinforrrr{raddrrc) base_namebase_dircompressverbosedry_runr"r!loggerroot_dirtar_compressionr) compress_ext archive_name archive_dirr#tararcnamer#r r$ _make_tarballzsH          r:cCsddl}|d} tj|} | r'tj| s'|dur |d| |s't| |dur2|d| ||s|j| d|jd} tj |} |durOtj ||}tj |}| tj krj| || |durj|d|t |D]l\} }}| }|durtj||}tj |}t|D] }tj | |}tj ||} | || |dur|d|q|D],}tj | |}tj |}tj|rtj ||} | || |dur|d|qqoWdn1swY|durtj| } | S) zCreate a zip file from all the files under 'base_dir'. The output zip file will be named 'base_name' + ".zip". Returns the name of the output zip file. rN.ziprz#creating '%s' and adding '%s' to itw) compressionz adding '%s')zipfiler=r`r*rr+rZipFile ZIP_DEFLATEDnormpathrcurdirrMwalkrelpathsortedisfilerc)r-r.r0r1r2r"r!r3r> zip_filenamer7zfr9dirpathdirnames filenames arcdirpathr/r`r#r#r$ _make_zipfilesh                 rMr8)r/Nzuncompressed tar file)r/rzgzip'ed tar-filegztarzZIP filezip)r/rzbzip2'ed tar-filebztar)r/rzxz'ed tar-filexztarcCddtD}||S)zReturns a list of supported formats for archiving and unarchiving. Each element of the returned sequence is a tuple (name, description) cSsg|] \}}||dfqS)r r#)rr/registryr#r#r$rsz'get_archive_formats..)_ARCHIVE_FORMATSitemssortformatsr#r#r$rs rrcCsv|durg}t|std|t|ttfstd|D]}t|ttfr,t|dkr0tdq|||dft|<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)F)callable TypeErrorr]tuplerlenrT)r/function extra_args descriptionelementr#r#r$rs  rcCs t|=dSrh)rTrr#r#r$r/s rc  CsFtd||||zt|} Wntytd|dw||||d} | d} | dD]\} } | | | <q-|dur=tj}| d}d}|durn|rSt|}|| d<nt}|dura| d |tj |}|snt |z| ||fi| }W|dur|dur| d |t ||S|dur|dur| d |t |ww) aCreate 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", "gztar", "bztar", or "xztar". Or any other registered format. '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. zshutil.make_archivezunknown archive format '%s'N)r1r2r"r!rr3zchanging into '%s'zchanging back to '%s') r@rsrTr r(r=rBrgetcwddebugr`rcchdir)r-rtr3r.r0r1r"r!r2 format_inforfuncargvalsupport_root_dirsave_cwdr0r#r#r$r2sL            rcCrR)zReturns a list of supported formats for unpacking. Each element of the returned sequence is a tuple (name, extensions, description) cSs"g|] \}}||d|dfqS)rrbr#)rr/r+r#r#r$rts"z&get_unpack_formats..)_UNPACK_FORMATSrUrVrWr#r#r$rns rc Csji}tD]\}}|dD]}|||<qq|D]}||vr*d}t||||fqt|s3tddS)z+Checks what gets registered as an unpacker.rz!%s is already registered for "%s"z*The registered function must be a callableN)rlrUr*rYrZ) extensionsr]r^existing_extensionsr/r+ext extensionmsgr#r#r$_check_unpack_optionsys  rrcCs,|durg}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)rrrl)r/rmr]r^r_r#r#r$rs rcCs t|=dS)z*Removes the pack format from the registry.N)rlrr#r#r$rs rcCs*tj|}tj|st|dSdS)z1Ensure that the parent directory of `path` existsN)r=r`r*rr)r`r*r#r#r$_ensure_directorys  rsc Csddl}||std|||}zd|D]X}|j}|ds'd|vr(qtjj |g| dR}|s8qt || dsq| |d"}t |d }t||Wdn1s]wYWdn1slwYqW|dS|w)z+Unpack zip `filename` to `extract_dir` rNz%s is not a zip file/z..rrr)r> is_zipfiler)r?infolistr0rr=r`rsplitrsrr{rr) r0 extract_dirr>rOr+r/ targetpathsourcetargetr#r#r$_unpack_zipfiles2      r}r$cCs\ddl}z||}Wn|jytd|wz|j||dW|dS|w)zAUnpack tar/tar.gz/tar.bz2/tar.xz `filename` to `extract_dir` rNz/%s is not a compressed or uncompressed tar filer$)r)r{TarErrorr) extractallr)r0ryrr)tarobjr#r#r$_unpack_tarfilesrrr;)r8rOz.tar.gzz.tgzz.tar.bz2z.tbz2z.tar.xzz.txzcCs:tD]\}}|dD] }||r|Sq qdS)Nr)rlrUr)r0r/r+rpr#r#r$_find_unpack_formats   rcCstd||||durt}t|}t|}|dur!i}nd|i}|durTzt|}Wnty>td|dw|d}|||fit |d|dSt |}|durct d|t|d}t t|d|B}|||fi|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", "gztar", "bztar", or "xztar". 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. If `filter` is given, it is passed to the underlying extraction function. zshutil.unpack_archiveNrzUnknown unpack format '{0}'rar zUnknown archive format '{0}') r@rsr=rcrrlr r(rtdictrr))r0ryrtr filter_kwargsrfrgrr#r#r$rs,    " rstatvfs disk_usageusageztotal used freezTotal space in byteszUsed space in byteszFree space in bytescCs@t|}|j|j}|j|j}|j|j|j}t|||S)zReturn disk usage statistics about the given path. Returned value is a named tuple with attributes 'total', 'used' and 'free', which are the amount of total, used and free space, in bytes. )r=rf_bavailf_frsizef_blocksf_bfree_ntuple_diskusage)r`rfreetotalusedr#r#r$r-s    cCs"t|\}}||}t|||S)zReturn disk usage statistics about the given path. Returned values is a named tuple with attributes 'total', 'used' and 'free', which are the amount of total, used and free space, in bytes. )r _getdiskusager)r`rrrr#r#r$r>s cCstd||||dur|durtd|}|}|durd}nt|tr3t|}|dur3td||dur:d}nt|tsNt |}|durNtd|t |||dS)zChange owner user and group of the given path. user and group can be the uid/gid or the user/group names, and in that case, they are converted to their respective uid/gid. z shutil.chownNzuser and/or group must be setzno such user: {!r}zno such group: {!r}) r@rsr(r]rr LookupErrorrtintrr=r)r`userr!_user_groupr#r#r$rIs$  rPc Csz ttjd}Wn ttfyd}Ynwz ttjd}Wn ttfy-d}Ynw|dks6|dkr`z ttj}Wnt tt fyQt |}Ynw|dkrY|j }|dkr`|j }t ||fS)aGet the size of the terminal window. For each of the two dimensions, the environment variable, COLUMNS and LINES respectively, is checked. If the variable is defined and the value is a positive integer, it is used. When COLUMNS or LINES is not defined, which is the common case, the terminal connected to sys.__stdout__ is queried by invoking os.get_terminal_size. If the terminal size cannot be successfully queried, either because the system doesn't support querying, or because we are not connected to a terminal, the value given in fallback parameter is used. Fallback defaults to (80, 24) which is the default size used by many terminal emulators. The value returned is a named tuple of type os.terminal_size. COLUMNSrLINES)rr=environr r(rr@ __stdout__r,AttributeErrorr. terminal_sizecolumnslines)fallbackrrsizer#r#r$ris*rcCs&tj|ot||otj| Srh)r=r`rrr)rjrr#r#r$ _access_checks rc stjrt|r SdStt}|dur9tjdd}|dur9ztd}Wnt t fy8tj }Ynw|s=dS|rNt |}| t tj}n t|}| tj}tjdkrtj}|rht |}||vrr|d|tdpxt}dd| tjD}|rd d|D}tfd d |Drg}n fd d|D}ng}t}|D](} tj| } | |vr|| |D]} tj| | } t| |r| SqqdS) a3Given a command, mode, and a PATH string, return the path which conforms to the given mode on the PATH, or None if there is no such file. `mode` defaults to os.F_OK | os.X_OK. `path` defaults to the result of os.environ.get("PATH"), or can be overridden with a custom search path. NPATHCS_PATHwin32rPATHEXTcSsg|]}|r|qSr#r#rror#r#r$rzwhich..cSsg|]}t|qSr#)r=fsencoderr#r#r$rsc3s"|] }|VqdSrh)lowerrrcmdr#r$ s zwhich..csg|]}|qSr#r#rrr#r$rr)r=r`r*rr]rrgetconfstrrr(defpathrrxpathseprr@rrBinsertgetenv_WIN_DEFAULT_PATHEXTanyrrbr,r) rrr` use_bytesrBpathext_sourcepathextfilesseendirnormdirthefiler/r#rr$rs\             r)r)F)FN)rrrNNNN)rrNNNN)Nr)NNrrNNN)NN)r)fr'r=r@rar collectionsr2zlibr%r rr&lzmar'r/rxrrrWr_rrrDr|r__all__r.rrrrr)r-r*r+r;rKrVrrgrkrnrr rr r r rrr stat_resultrrrrr{rrsupports_dir_fdr supports_fdrrravoids_symlink_attacksrrrrrrr:rMrTrrrrrrrrrrsr}rrlrrr namedtuplerrrrrrrrF_OKX_OKrr#r#r#r$s>         @  @ B B 0  8   B B  F ?  <        1      1