\dWdZddlZddlZddlZddlZddlZddlZ ddlZ[dZn #e $rdZYnwxYw ddl Z [ dZ n #e $rdZ YnwxYw ddl Z [ dZ n #e $rdZ YnwxYwejdkZdxZZejdkrddlZnerddlZerdndZeed oejd aeo eed Zd Zgd ZGddeZGddeZGddeZGddeZGddeZGdde Z!Gdde Z"dZ#dZ$efdZ%dudZ&d Z'd!Z(d"Z)dd#d$Z*dd#d%Z+eed&rdd#d'Z,nd(Z,dd#d)Z-dd#d*Z.dd#d+Z/d,Z0 dvd-Z1dde/ddfd.Z2eej3d/rd0Z4d1Z5nd2Z4d3Z5d4Z6d5Z7ej8ejej9ej:hej;koej<ej=vo ejej>vZ?dwdd6d7Z@e?e@_Ad8ZBe/fd9ZCd:ZDd;ZEd<ZFd=ZG dxd?ZH dyd@ZIdAeHdBgdCdfiZJereHdDgdEdfeJdF<eIgdGdfeJdH<e r eHdIgdJdfeJdK<e r eHdLgdMdfeJdN<dOZKdzdQZLdRZM d{dSZNdTZOdUZP dzdVZQdWZRdXZSdYZTddZd[ZUd\geUgdCfd]geTgdGfd^ZVer d_d`geUgdEfeVdF<e r dadbgeUgdJfeVdK<e r dcddgeUgdMfeVdN<deZWd|ddZdfZXeedgrNeYdhejZdidjZ[dke[j\_dle[j]_dme[j^_dnZ_n+er)eYdhejZdidjZ[doZ_d|dpZ`d}drZadsZbejcejdzdfdtZedS)~zUtility functions for copying and archiving files and directory trees. XXX The functions here don't copy the resource fork or other metadata on Mac. NTFntposixiisendfilelinux _fcopyfilez%.COM;.EXE;.BAT;.CMD;.VBS;.JS;.WS;.MSC) copyfileobjcopyfilecopymodecopystatcopycopy2copytreemovermtreeErrorSpecialFileError ExecError make_archiveget_archive_formatsregister_archive_formatunregister_archive_formatget_unpack_formatsregister_unpack_formatunregister_unpack_formatunpack_archiveignore_patternschownwhichget_terminal_size SameFileErrorceZdZdS)rN)__name__ __module__ __qualname__4J:\tools\MySQL Workbench 8.0 CE\python\Lib\shutil.pyrr=sDr&rceZdZdZdS)r z5Raised when source and destination are the same file.Nr"r#r$__doc__r%r&r'r r @s????r&r ceZdZdZdS)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'rrCs;;;;r&rceZdZdZdS)rz+Raised when a command could not be executedNr)r%r&r'rrGs5555r&rceZdZdZdS) ReadErrorz%Raised when an archive cannot be readNr)r%r&r'r.r.Js////r&r.ceZdZdZdS) RegistryErrorzVRaised when a registry operation with the archiving and unpacking registries failsNr)r%r&r'r0r0Ms&&&&r&r0ceZdZdZdS)_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'r2r2Qsr&r2c |}|}n!#t$r}t|d}~wwxYw tj|||dS#t $rN}|j|_|j|_|j tj tj hvrt||dd}~wwxYw)zhCopy a regular file content or metadata by using high-performance fcopyfile(3) syscall (macOS). N) fileno Exceptionr2rrOSErrornamefilename filename2errnoEINVALENOTSUP)fsrcfdstflagsinfdoutfderrs r'_fastcopy_fcopyfilerCVs%{{}}  %%%$$$%  ue,,,,,    y   9u}5 5 5#C(( (4   s-(+ A AA  A%% B=/A B88B=c |}|}n!#t$r}t|d}~wwxYw tt j|jd}n#t$rd}YnwxYwtj dkrt|d}d} t j ||||}|dkrdS||z }n#t$r}|j |_ |j |_|jtjkrdat||jtjkr|d|dkr3t j|dtjdkrt||d}~wwxYw) zCopy data from one regular mmap-like fd to another by using high-performance sendfile(2) syscall. This should work on Linux >= 2.6.33 only. Niili@rTF)r4r5r2maxosfstatst_sizer6sysmaxsizeminrr7r8r9r:ENOTSOCK_USE_CP_SENDFILEENOSPClseekSEEK_CUR)r=r>r@rArB blocksizeoffsetsents r'_fastcopy_sendfilerTjs%{{}}  %%%$$$%.88   {W 7++ F ;udFI>>D,qyy dNFF/   9CL ICMyEN**$) ',,,yEL((t#{{rxq"+>>!CC',,,I' s?(+ A AA  'A55 BB+C E0BE++E0c@|j}|j}tt|5} ||}|snJ||kr8|d|5}||dddn #1swxYwYn ||X ddddS#1swxYwYdS)zreadinto()/memoryview() based variant of copyfileobj(). *fsrc* must support readinto() method and both files must be open in binary mode. TN)readintowrite memoryview bytearray)r=r>length fsrc_readinto fdst_writemvnsmvs r'_copyfileobj_readintor`s: MMJ If%% & & "  b!!A VV$sJJsOOO$$$$$$$$$$$$$$$ 2                   s5 B A-! B-A1 1B4A1 5BBBch|st}|j}|j} ||}|sdS||)z=copy data from file-like object fsrc to file-like object fdstTN) COPY_BUFSIZEreadrW)r=r>rZ fsrc_readr\bufs r'rrsP  IJi  E 3 r&ct|tjrpttjdrV tj|tj|S#t$rYdSwxYwttjdr2 tj||S#t$rYdSwxYwtj tj |tj tj |kS)NsamestatFsamefile) isinstancerFDirEntryhasattrpathrgstatr6rhnormcaseabspathsrcdsts r' _samefilerss#r{##(D(D 7##CHHJJ == =   55 rw ## 7##C-- -   55  G  RW__S11 2 2 G  RW__S11 2 2 34s$AA:: BB&C CCct|tjr|ntj|SN)rirFrjrmfns r'_statrxs-"2r{33 D277999Dr&ct|tjr|ntj|Sru)rirFrj is_symlinkrlislinkrvs r'_islinkr|s3(R[99 Q2==???rw~~b?Q?QQr&follow_symlinksc Dtjd||t||r#td||d}t ||gD]\}} t |}tj|j r5t|tj r|j n|}td|ztr |dkr|j}x#t"$rYwxYw|s8t%|r)tjtj||nt+|d5} t+|d5}t,rF t/||t0j|cdddcdddS#t4$rYnwxYwt6r; t9|||cdddcdddS#t4$rYnOwxYwtrD|dkr>t;||t=|t>|cdddcdddStA||dddn #1swxYwYnE#tB$r8} tj "|stGd|| d} ~ wwxYwdddn #1swxYwY|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: )$rIauditrsr format enumeraterxrmS_ISFIFOst_moderirFrjrlr_WINDOWSrHr6r|symlinkreadlinkopen_HAS_FCOPYFILErCr_COPYFILE_DATAr2rMrTr`rKrbrIsADirectoryErrorexistsFileNotFoundError) rqrrr~ file_sizeirwstr=r>es r'r r sIc***cP=DDS#NNOOOIC:&& ' '2 'rB }RZ(( D *2r{ ; ;CRWW&'='BCCC 'AFFJ     D  !ws||! 2;s##S)))) #t__  #t__,%#!/dE tjd||dddd |p.t|otj| }|r fd}n fd}t |tjr||}n|d||}tj |j }|d ||j |j f|t||| |d |||n#t$rYnwxYwt|d rr |d ||j|dS#t"$rF}d D]7}tt$|r |jt't$|krn8Yd}~dSd}~wwxYwdS)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)nsr~cdSrur%)rr~rs r'_nopzcopystat.._noparr&c0tt|Sru)getattrrF)r7rs r'lookupzcopystat..lookuphs2tT** *r&cTtt|}|tjvr|SSru)rrFsupports_follow_symlinks)r7rwrs r'rzcopystat..lookupms,T4((BR000 Kr&r}rmutimerst_flagschflags) EOPNOTSUPPr<)rIrr|rFrlr{rirjrmrr st_atime_ns st_mtime_nsrNotImplementedErrorrkrr6r:r) rqrrr~followrrmodewhyrBrs @r'r r SsBIc***T      JWS\\%IbgnnS6I6I JF  + + + + + +       #r{##9 XXfX - - VVF^^C 8 8 8 < # #DFF7OOCR^R^<    sC0000  wT6:::::        r:  FF9  c2; G G G G G G   .  5#&&39s8K8K+K+KEEEEEE s*3D DD,E F;FFctj|r=tj|tj|}t |||t ||||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. r})rFrlisdirjoinbasenamer r rqrrr~s r'r r sn w}}S7gll3 0 0 5 566 S#7777 S#7777 Jr&ctj|r=tj|tj|}t |||t ||||S)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". r})rFrlrrrr r rs r'r r sn w}}S7gll3 0 0 5 566 S#7777 S#7777 Jr&cfd}|S)zFunction that can be used as copytree() ignore parameter. Patterns is a sequence of glob-style patterns that are used to exclude filescg}D]*}|tj||+t|Sru)extendfnmatchfilterset)rlr ignored_namespatternpatternss r'_ignore_patternsz)ignore_patterns.._ignore_patternssJ  A AG  w!?!? @ @ @ @=!!!r&r%)rrs` r'rrs$ """"" r&c |)|tj|d|D}nt}tj||g} |tup|t u} |D]} | j|vr tj|| j} tj|| j} | r| n| } | }|r=tjdkr-| d}|j tj krd}|rtj | }|r)tj|| t|| | ntj|s|r| rt%|| |||||nC||| n6| rt%|| |||||n ||| #t&$r+}| |jdYd}~d}~wt,$r0}| | | t1|fYd}~d}~wwxYw t||nM#t,$r@}t3|dd%| ||t1|fYd}~nd}~wwxYw| rt'| |S)Ncg|] }|j Sr%r7).0xs r' z_copytree..s/H/H/H1/H/H/Hr&)exist_okrFr}rwinerror)rFfspathrmakedirsr r r7rlrrzrmst_reparse_tagIO_REPARSE_TAG_MOUNT_POINTrrr ris_dirrrrrr6appendstrr)entriesrqrrsymlinksignore copy_functionignore_dangling_symlinks dirs_exist_okrerrors use_srcentrysrcentrysrcnamedstnamesrcobjrzrlinktorBrs r' _copytreers= ry~~/H/H/H/H/HII  Km,,,, F E)B]d-BL,8,8 =M ) ) ',,sHM22',,sHM22)6w& 8!,,..J 'bgoo! e <<'4+JJJ!&J /W--7Jvw///VW(lKKKKK7>>&11!6N! ((7 (F!.0H!.0000& fg6666"" /(FM1=BBBB fg... ' ' ' MM#(1+ & & & & & & & & 8 8 8 MM7GSXX6 7 7 7 7 7 7 7 7 80c 000 3 D ) ) 1 MM3SXX. / / /0Fmm JsDB5G*;A-G** I4 H I'%III,, J666J11J6c tjd||tj|5}t |}dddn #1swxYwYt ||||||||S)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)rrqrrrrrrr)rIrrFscandirlistr) rqrrrrrrritrrs r'rrsPIc*** CCs)) W#3"-.F#0 2 2 22sAA A st_file_attributesc |d}tj|jo)|jtjzo|jtjk S#t$rYdSwxYwNFr})rmS_ISDIRrrFILE_ATTRIBUTE_REPARSE_POINTrrr6)entryrs r' _rmtree_isdirr:s E22BL,,K&)JJJ&$*II2K L   55 sAA A)(A)c tj|}tj|jp(|jtjzo|jtjkS#t$rYdSwxYw)NF) rFrrmS_ISLNKrrrrrr6)rlrs r'_rmtree_islinkrCsu $BL,,K&)JJJ&$*II L   55 sAA A&%A&cR |dS#t$rYdSwxYwr)rr6)rs r'rrLs= <<<66 6   55 s  &&c@tj|Sru)rFrlr{)rls r'rrRsw~~d###r&cF tj|5}t|}dddn #1swxYwYn:#t$r-|tj|t jg}YnwxYw|D]}|j}t|rs |rtdn=#t$r0|tjj |t jYvwxYwt|| tj |#t$r+|tj |t jYwxYw tj |dS#t$r,|tj |t jYdSwxYw)N%Cannot call rmtree on a symbolic link) rFrrr6rIexc_inforlrrzr{_rmtree_unsafeunlinkrmdir)rlonerror scandir_itrrfullnames r'rrVs Z   ':&&G ' ' ' ' ' ' ' ' ' ' ' ' ' ' '  D#,..111==:    = ##%%K""IJJJ K    #,..AAA  8W - - - - = (#### = = = 8S\^^<<<<< =0  000$ //////0s]>2 >6>6>4A54A5#B777C10C1D2EEE**2F F cd tj|5}t|}dddn #1swxYwYnG#t$r:}||_|tj|t jYd}~dSd}~wwxYw|D]}tj||j } | d}|ri | d} tj | j }nK#t$r+|tj|t jYwxYwn#t$rd}YnwxYw|r tj|j tj|} d} tj| tj| r|t'| || tj| d} tj|j |n#t$r+|tj|t jYnQwxYw td#t$r0|tjj|t jYnwxYw| stj| #| stj| wwxYw#t$r,|tj|t jYNwxYw tj|j |p#t$r,|tj|t jYwxYwdS)NFr}dir_fdTr)rFrrr6r8rIrrlrr7rrmrrrrO_RDONLYrgrG_rmtree_safe_fdcloserr{r) topfdrlrrrrBrrrorig_stdirfd dirfd_closeds r'rrus Z   '*:&&G ' ' ' ' ' ' ' ' ' ' ' ' ' ' '   D#,..111.=.=7<<ej11 \\%\88F #jjj??G!\'/::FFGBHh ???H     FFF   = ( BKFFF$ (w''%AAN'xAAAHHUOOO+/LHUZ>>>>>&HHH#GBHh GGGGGHN#*+1#2#22&NNN#GBGNHclnnMMMMMN(((((- ; ; ;3<>>::::: ;2 = %*U33333 = = = 8S\^^<<<<< =[.=.=s>2 >6>6> B/A==B0D2 /C992D.-D.2 EE(J 1AJ51G'&J'2HJHJ H//7I)&J(I))JJ 2KKK772L-,L-rc\tjd|||rd}n|d}trt|trt j|} t j||}n9#t$r,|t j|tj YdSwxYw t j |t j |}d}n9#t$r,|t j |tj YdSwxYw t j |t j|rwt||| t j|d}t j||n#t$$r+|t j|tj YnQwxYw t%d#t$$r0|t j j|tj YnwxYw|st j|dSdS#|st j|wwxYw|t)d  t+|rt%dn>#t$$r1|t j j|tj YdSwxYwt-||S) aRecursively delete a directory tree. If dir_fd is not None, it should be a file descriptor open to a directory; path will then be relative to that directory. dir_fd may not be implemented on your platform. If it is unavailable, using it will raise a NotImplementedError. 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.rmtreecdSrur%rs r'rzrmtree..onerrors Dr&Ncrur%r s r'rzrmtree..onerrors r&rFTrz#dir_fd unavailable on this platform)rIr_use_fd_functionsribytesrFfsdecoderr5rrrrlrgrGrrrr6r{rrr)rl ignore_errorsrrrfd fd_closeds r'rrs IotV,,,        .- dE " " %;t$$D htF333GG    GBHdCLNN 3 3 3 FF  r{6:::BII    GBGT3<>> 2 2 2 FF  w"66 BD'222<HRLLL $IHT&11111<<<GBHdCLNN;;;;;<B!"IJJJBBBGBGND#,..AAAAAB    9     %&KLL L d## GEFFF G    GBGND#,.. 9 9 9 FF dG,,,sA++2B! B!%#C 2C?>C?AH,E43H42F)&H(F))H-F<<7G63H5G66HH,I 7JJctj|}tjjtjjpdz}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' )rFrrlsepaltseprrstrip)rlrs r' _basenamersJ 9T??D '+-2 .C 7  DKK,, - --r&cjtjd|||}tj|rt ||rtj||dStj|t|}tj |rtd|z tj||n^#t$rPtj |r>tj |}tj||tj|ntj|rt!||rtd|d|dt#|sCtj|tjs:tj|r&tjdkrt-d|d |dt/|||d t1|n |||tj|YnwxYw|S) 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 existszCannot move a directory 'z' into itself 'z'.darwinz%Cannot move the non-empty directory 'z ': Lacking write permission to 'T)rr)rIrrFrlrrsrenamerrrrr6r{rrr _destinsrc _is_immutableaccessW_OKlistdirplatformPermissionErrorrr)rqrrrreal_dstrs r'rrs04ImS#&&&H w}}S K S#    Ic3    F7<<Ys^^44 7>>( # # K>IJJ J #x     7>>#   [%%F Jvx ( ( ( IcNNNN W]]3   #s## 3e(+SSS2333c"" 4Ic2733 48: 3 4LH44%o),ccc'3444 S(-" $ $ $ $ 3KKKK M#x ( ( ( IcNNN)* Os>CEH0/H0ctj|}tj|}|tjjs|tjjz }|tjjs|tjjz }||Sru)rFrlroendswithr startswithrps r'rrQs '//#  C '//#  C << $ $ rw{ << $ $ rw{ >>#  r&ct|}tjtjg}t |do|j|vS)Nr)rxrm UF_IMMUTABLE SF_IMMUTABLErkr)rqrimmutable_statess r'rrZs; sB)4+<= 2z " " Fr{6F'FFr&c|dS ddlm}n#t$rYdSwxYw ||}n#t$rd}YnwxYw||dSdS)z"Returns a gid, given a group name.Nr)getgrnam)grpr. ImportErrorKeyError)r7r.results r'_get_gidr4_ |t       tt$  ay 4  + ::c|dS ddlm}n#t$rYdSwxYw ||}n#t$rd}YnwxYw||dSdS)z"Returns an uid, given a user name.Nr)getpwnamr/)pwdr8r1r2)r7r8r3s r'_get_uidr:qr5r6gzipc |d} nRtr |dkrd} nBtr |dkrd} n2tr |dkrd} n"td|d dl} |rd | znd} |d z| z} t j| } | rMt j | s.|| d | |st j | || d ttfd}|s| | d| z}|}| t j||} |||||n#|wxYw|t j| } | 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. Nrr;gzbzip2bz2xzzCbad value for 'compress', or compression format not supported : {0}r..tar creating %szCreating tar archivecH|_|_|_|_|Sru)gidgnameuiduname)tarinforEgroupownerrGs r' _set_uid_gidz#_make_tarball.._set_uid_gids. ?GK!GM ?GK!GMr&zw|%sr)_ZLIB_SUPPORTED_BZ2_SUPPORTED_LZMA_SUPPORTED ValueErrorrtarfilerFrldirnamerinforr:r4rraddrro) base_namebase_dircompressverbosedry_runrKrJloggerroot_dirtar_compressionrR compress_ext archive_name archive_dirrLtararcnamerErGs `` @@r' _make_tarballrcs   =X// =H// =X--++16(+;+;== =NNN,4<3(("Lv% 4L'//,//K%27>>+66%   KK { 3 3 3 % K $ $ $ *+++ 5//C 5//C ll</)ABB  w||Hh77H  GGHglG ; ; ; IIKKKKCIIKKKKw|44 s F Fc8ddl}|dz} tj|} | rMtj| s.||d| |stj| ||d| ||se|| d|j5} tj |} | tj ||}tj |}| tj kr.| || ||d|tj |D]{\} }}| }| tj||}tj |}t|D]p}tj | |}tj ||} | || ||d|q|D]}tj | |}tj |}tj|rNtj ||} | || ||d|} dddn #1swxYwY|tj| } | 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.ziprCz#creating '%s' and adding '%s' to itw) compressionz adding '%s')zipfilerFrlrSrrTrZipFile ZIP_DEFLATEDnormpathrcurdirrWwalkrelpathsortedisfilero)rVrWrYrZr[rKrJr\rh zip_filenamer`zfrbdirpathdirnames filenames arcdirpathr7rls r' _make_zipfilerws NNNv%L'//),,K%27>>+66%   KK { 3 3 3 % K $ $ $  9 ( , , , = __\3)0)=?? =BDg&&x00G#7<<(;;w''11H")##7+++%KK x888020A0A = =,9$ '!#X!F!FJW--j99 "8,,99D7<<66D gll:t<zbzip2'ed tar-filebztar)rXr@zxz'ed tar-filexztarctdtD}||S)zReturns a list of supported formats for archiving and unarchiving. Each element of the returned sequence is a tuple (name, description) c(g|]\}}||dfS)r/r%)rr7registrys r'rz'get_archive_formats..s1)))~tXhqk")))r&)_ARCHIVE_FORMATSitemssortformatss r'rrs> ))%%'')))G LLNNN Nr&rcH|g}t|std|zt|ttfstd|D]@}t|ttfrt |dkrtdA|||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 TypeErrorrituplerlenr)r7function extra_args descriptionelements r'rr#s H  D7(BCCC j5$- 0 0=;<<<KK'E4=11 KS\\A5E5EIJJ J6F' KGTr&ct|=dSru)rrs r'rr8sr&c tjd|||| t|} n!#t$rt d|zdwxYw||||d} | d} | dD] \} } | | | < | t j}| d}d}|||rt j|}|| d<n`t j}|| d |t j |}|st j | | ||fi| }|,|| d |t j |n4#|-|| d |t j |wwxYw|S) 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)rZr[rKrJrr\zchanging into '%s'zchanging back to '%s') rIrrr2rQrFrlrgetcwddebugrlrochdir)rVrr\rWrYrZrKrJr[ format_inforfuncargvalsupport_root_dirsave_cwdr8s r'rr;s$I#Y(KKKK&v. KKK6?@@dJK!Fu..F q>DNSs 9"1~H  # ),,I!)F:  y{{H! 18<<< 22I #"""4 866v66  ! 4h??? HX     ! 4h??? HX     Os (A D;;1E,ctdtD}||S)zReturns a list of supported formats for unpacking. Each element of the returned sequence is a tuple (name, extensions, description) c6g|]\}}||d|dfS)rrr%)rr7rTs r'rz&get_unpack_formats..}s7(((JD$d1gtAw'(((r&)_UNPACK_FORMATSrrrs r'rrws> (($$&&(((G LLNNN Nr&ci}tD]\}}|dD]}|||<|D]"}||vrd}t||||fz#t|st ddS)z+Checks what gets registered as an unpacker.rz!%s is already registered for "%s"z*The registered function must be a callableN)rrr0rr) extensionsrrexisting_extensionsr7rText extensionmsgs r'_check_unpack_optionsrs%++--,, d7 , ,C'+  $ $ , HH + + +5Cy':9'E'G!GHH H , H  FDEEEFFr&cL|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)rr)r7rrrrs r'rrs:" *h ;;;&*kIODr&ct|=dS)z*Removes the pack format from the registry.N)rrs r'rrsr&ctj|}tj|stj|dSdS)z1Ensure that the parent directory of `path` existsN)rFrlrSrr)rlrSs r'_ensure_directoryrsKgood##G 7== ! ! Gr&cddl}||std|z||} |D]}|j}|dsd|vr#tjj |g| dR}|sPt|| dsf| |d5}t|d5}t||dddn #1swxYwYdddn #1swxYwY |dS#|wxYw)z+Unpack zip `filename` to `extract_dir` rNz%s is not a zip file/z..rr)rh is_zipfiler.riinfolistr8r(rFrlrsplitrr'rrr) r8 extract_dirrhryrTr7 targetpathsourcetargets r'_unpack_zipfilersNNN   h ' ';.9::: //( # #CLLNN 0 0D=Ds## tt||kDDJJsOODDDJ  j ) ) )==%% 0XXdC((0FZ..028///000000000000000000000000000000 0$  sUBE D%1D D%D D%D D% E%D) )E,D) -EErMcddl} ||}n #|j$rtd|zwxYw ||||dS#|wxYw)zAUnpack tar/tar.gz/tar.bz2/tar.xz `filename` to `extract_dir` rNz/%s is not a compressed or uncompressed tar filerM)rRrTarErrorr. extractallr)r8rrrRtarobjs r'_unpack_tarfilersNNNJh''  JJJ = HJJ JJ+f555  s9A**BrBre)raryz.tar.gzz.tgzz.tar.bz2z.tbz2z.tar.xzz.txzctD]+\}}|dD]}||r|ccS,dS)Nr)rrr')r8r7rTrs r'_find_unpack_formatrsh%++-- da  I  ++     4r&c|tjd||||tj}tj|}tj|}|i}nd|i}|i t |}n1#t $r$td|dwxYw|d}|||fit|d|dSt|}|"td|t |d}tt |d|z}|||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}'rr/zUnknown archive format '{0}') rIrrFrrrr2rQrdictrr.)r8rrr filter_kwargsrrrs r'rrso$I%xfEEEikk )K((Ky""H ~ !6*   U)&1KK U U U:AA&IIJJPT T U1~ X{LLd;q>&:&:LmLLLLL%X.. >:AA(KKLL Lv&q)of-a011MA X{--f-----s ! A//.Bstatvfs disk_usageusageztotal used freezTotal space in byteszUsed space in byteszFree space in bytesctj|}|j|jz}|j|jz}|j|jz |jz}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. )rFrf_bavailf_frsizef_blocksf_bfree_ntuple_diskusage)rlrfreetotaluseds r'rr6sV Z  {R[( bk) bj(BK7 d333r&c\tj|\}}||z }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)rlrrrs r'rrGs3 &t,, tt| d333r&ctjd|||||td|}|}|d}nHt|tr3t |}|"t d||d}nHt|ts3t|}|"t d|tj |||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}) rIrrQrirr: LookupErrorrintr4rFr)rluserrJ_user_groups r'rrRs IndD%000 | 8999 E F | D#  A =299$??@@ @ } s # #C% >3::5AABB BHT5&!!!!!r&PcH ttjd}n#ttf$rd}YnwxYw ttjd}n#ttf$rd}YnwxYw|dks|dkr tjt j}n1#tttf$rtj |}YnwxYw|dkr|j p|d}|dkr|j p|d}tj ||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. COLUMNSrLINESr)rrFenvironr2rQrrI __stdout__r4AttributeErrorr6 terminal_sizecolumnslines)fallbackrrsizes r'rrrsD(bj+,, j !BJw'(( j !!||uzz .'(=(=(?(?@@DD G4 . . .#H--DDD . a<<l1hqkG A::J-(1+E We, - --s/"88AA21A20B33+C! C!ctj|o4tj||otj| Sru)rFrlrr r)rwrs r' _access_checkrsD GNN2   &29R#6#6 &GMM"%%%'r&ctjrt|rSdSt t }|[tjdd}|9 tjd}n##ttf$rtj }YnwxYw|sdS|rFtj |}| tj tj}n3tj|}| tj}t jdkrtj}|rtj |}||vr|d|tjdpt*}d| tjD}|r d|D}t-fd |Drg}nfd |D}ng}t/}|D]u} tj| } | |vrP|| |D]8} tj| | } t| |r| ccS9vdS) 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_PATHwin32rPATHEXTcg|]}||Sr%r%rrs r'rzwhich..sJJJ3cJ3JJJr&c6g|]}tj|Sr%)rFfsencoders r'rzwhich..s";;;Cr{3'';;;r&c3K|]=}|V>dSru)lowerr'rrcmds r' zwhich..sADDSsyy{{##CIIKK00DDDDDDr&cg|]}|zSr%r%rs r'rzwhich..s2223S3Y222r&)rFrlrSrrirrgetconfstrrrQdefpathrrpathseprrIr#rlinsertgetenv_WIN_DEFAULT_PATHEXTanyrrnrUr) rrrl use_bytesrlpathext_sourcepathextfilesseendirnormdirthefiler7s ` r'rrs ws d # # Jt3&&I |z~~fd++ < "z),,"J/ " " "z " t&{4  zz"+bj1122{4  zz"*%% |w  )[((F    KK6 " " "9--E1EJJ."6"6rz"B"BJJJ  <;;7;;;G DDDDGDDD D D 3EEE2222'222EE 55D  '""3''$ HHW      w||C11 t,, KKKKK 4s/BB$#B$)r)F)FN)r;rrNNNN)rrNNNN)Nr)NNrrNNN)NN)r)fr*rFrIrmr collectionsr:zlibrNr1r?rOlzmarPr7rrrrbrkr#r(rMrr__all__r6rr rrr.r5r0r2rCrTr`rrsrxr|r r rr r r rrr stat_resultrrrrrrrsupports_dir_fdr supports_fdrrravoids_symlink_attacksrrrrr4r:rcrwrrrrrrrrrrrrrrrr namedtuplerrrrrrrrF_OKX_OKrr%r&r'r s    KKK OOOOOJJJ NNNNNKKK OOOOO 7d? 7gLLLL  III&5{{I 72z**Os|/F/Fw/O/O7775,77?        G   @@@@@E@@@;;;;;w;;;6666666600000000&&&&&I&&&     (>>>@.:&    444$EEERRR+/>>>>>@+/.....* 72{ 040   +/@@@@@D'+$(,"   7<@@@@D!&d%&+5.2.2.2.2` 72>/00$ $$$000>6=6=6=pgrw 28<'(<Z2>1<W ;; E-dE-E-E-E-E-R!2...$"'@@@@DGGG $$LM@DDDDDL;<@D7777~ m01%t- D!.1E0F 2D!:W,b*dCU;!.1F0G 3T!;W8!.1C0D 0$!8WHHHH*KL;?9999x   FFF$CG')JJJJ, <6:     (h-D EhZ 8 4!*F 3_b 2 4OG5!+W 5 3 5OG2!*F 3_b 0 2OG..d..........b 72y!4 NN<   . .w8IJJ&<#%:"%:" 4 4 4 4 4 NN<   . .w8IJJ444""""@+.+.+.+.b''' Gbg%DNNNNNNs-$..:AAAAA