B €/g^Þ£ã@s°dZddlZddlZddlZddlZddlZddlZyddlZ[dZWne k r^dZYnXyddl Z [ dZ Wne k rŠdZ YnXyddl Z [ dZ Wne k r¶dZ YnXyddlmZWne k ràdZYnXyddlmZWne k r dZYnXddd d d d d ddddddddddddddddddgZGd d„deƒZGd!d„deƒZGd"d„deƒZGd#d„deƒZGd$d%„d%eƒZGd&d'„d'eƒZdƒd)d„Zd*d+„Zdd,œd-d„Zdd,œd.d „Zeed/ƒrîdd,œd0d1„Z nd2d1„Z dd,œd3d „Z!dd,œd4d „Z"dd,œd5d „Z#d6d„Z$dde#dfd7d „Z%d8d9„Z&d:d;„Z'ej(ejej)ej*hej+ko~ej,ej-ko~ejej.kZ/d„d„Z2e#fd?d„Z3d@dA„Z4dBdC„Z5dDdE„Z6d…dGdH„Z7d†dIdJ„Z8dKe7dLgdMfiZ9ere7dNgdOfe9dP<e8gdQfe9dR<e re7dSgdTfe9dU<e r0e7dVgdWfe9dX<dYd„Z:d‡d[d„Z;d\d„Zd_d`„Z?d‰dad„Z@dbd„ZAdcdd„ZBdedf„ZCdgdh„ZDdigeDgdMfdjgeCgdQfdkœZEerÆdldmgeDgdOfeEdP<e ràdndogeDgdTfeEdU<e rúdpdqgeDgdWfeEdX<drds„ZFdŠdtd„ZGeeduƒrPe Hdv¡e Idwdx¡ZJdyeJjK_dzeJjL_d{eJjM_d|dv„ZNn2ejOd}kr‚ddlPZPe Hdv¡e Idwdx¡ZJd~dv„ZNd‹dd„ZQdŒdd„ZRejSejTBdfd‚d„ZUdS)z—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. éNTF)Ú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_patternsÚchownÚwhichÚget_terminal_sizeÚ SameFileErrorc@s eZdZdS)r N)Ú__name__Ú __module__Ú __qualname__©r r ú/usr/lib64/python3.7/shutil.pyr 7sc@seZdZdZdS)rz5Raised when source and destination are the same file.N)rrrÚ__doc__r r r r!r: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)rrrr"r r r r!r=sc@seZdZdZdS)rz+Raised when a command could not be executedN)rrrr"r r r r!rAsc@seZdZdZdS)Ú ReadErrorz%Raised when an archive cannot be readN)rrrr"r r r r!r#Dsr#c@seZdZdZdS)Ú RegistryErrorzVRaised when a registry operation with the archiving and unpacking registries failsN)rrrr"r r r r!r$Gsr$é@cCs$x| |¡}|sP| |¡qWdS)z=copy data from file-like object fsrc to file-like object fdstN)ÚreadÚwrite)ÚfsrcÚfdstÚlengthZbufr r r!rLs  cCsXttjdƒr0ytj ||¡Stk r.dSXtj tj |¡¡tj tj |¡¡kS)NÚsamefileF)ÚhasattrÚosÚpathr+ÚOSErrorÚnormcaseÚabspath)ÚsrcÚdstr r r!Ú _samefileTs r4)Úfollow_symlinksc CsÆt||ƒrtd ||¡ƒ‚xL||gD]@}yt |¡}Wntk rJYq$Xt |j¡r$td|ƒ‚q$W|sŒtj   |¡rŒt  t  |¡|¡n6t |dƒ&}t |dƒ}t||ƒWdQRXWdQRX|S)z«Copy data from src to dst. 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. z{!r} and {!r} are the same filez`%s` is a named pipeÚrbÚwbN)r4rÚformatr-Ústatr/ÚS_ISFIFOÚst_moderr.ÚislinkÚsymlinkÚreadlinkÚopenr)r2r3r5ÚfnÚstr(r)r r r!r`s    cCsx|s._nopcs tt|ˆƒS)N)Úgetattrr-)rM)rSr r!ÚlookupÀszcopystat..lookupcstt|ˆƒ}|tjkr|SˆS)N)rTr-Úsupports_follow_symlinks)rMr@)rSr r!rUÅs  r9)r5ÚutimerCÚst_flagsZchflags)Z EOPNOTSUPPrH)r-r.r<r9rEr;Ú st_atime_nsÚ st_mtime_nsrOÚNotImplementedErrorr,rXr/rGrT) r2r3r5ZfollowrUrAÚmodeÚwhyÚerrr )rSr!r®s,      cCsBtj |¡r"tj |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. )r5)r-r.ÚisdirÚjoinÚbasenamerr)r2r3r5r r r!rês cCsBtj |¡r"tj |tj |¡¡}t|||dt|||d|S)a1Copy 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". )r5)r-r.r_r`rarr)r2r3r5r r r!r üs cs‡fdd„}|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}xˆD]}| t ||¡¡q Wt|ƒS)N)ÚextendÚfnmatchÚfilterÚset)r.rKÚ ignored_namesÚpattern)Úpatternsr r!Ú_ignore_patternss z)ignore_patterns.._ignore_patternsr )rhrir )rhr!rs c Csât |¡}|dk r|||ƒ}ntƒ}t |¡g}x@|D]6} | |krJq:tj || ¡} tj || ¡} y tj | ¡rÜt | ¡} |r t | | ¡t | | | dn:tj  | ¡s²|r²w:tj  | ¡rÐt | | |||ƒn || | ƒn(tj  | ¡rút | | |||ƒn || | ƒWq:t k r:} z| | jd¡Wdd} ~ XYq:tk rp}z| | | t|ƒf¡Wdd}~XYq:Xq:Wyt ||ƒWnJtk rÎ}z*t|ddƒdkr¾| ||t|ƒf¡Wdd}~XYnX|rÞt |ƒ‚|S)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. N)r5rZwinerror)r-ÚlistdirreÚmakedirsr.r`r<r>r=rÚexistsr_r r rbrPr/ÚappendÚstrrT)r2r3ÚsymlinksÚignoreÚ copy_functionZignore_dangling_symlinksrKrfÚerrorsrMZsrcnameZdstnameÚlinktor^r]r r r!r sL$           *&c CsPy"t |¡}t|ƒ}WdQRXWn*tk rL|tj|t ¡ƒg}YnXxÄ|D]¼}|j}y|jdd}Wntk r†d}YnX|rØy| ¡ržtdƒ‚Wn*tk rÊ|tjj |t ¡ƒwTYnXt ||ƒqTyt  |¡WqTtk r|tj |t ¡ƒYqTXqTWyt  |¡Wn(tk rJ|tj |t ¡ƒYnXdS)NF)r5z%Cannot call rmtree on a symbolic link) r-ÚscandirÚlistr/ÚsysÚexc_infor.Úis_dirÚ is_symlinkr<Ú_rmtree_unsafeÚunlinkÚrmdir)r.ÚonerrorÚ scandir_itÚentriesÚentryÚfullnamerxr r r!rzts8      rzc Csþy"t |¡}t|ƒ}WdQRXWn:tk r\}z||_|tj|t ¡ƒdSd}~XYnXx˜|D]Ž}tj ||j ¡}y,|j dd}|r¦|j dd} t   | j ¡}Wntk rÀd}YnX|r¸ytj|j tj|d} Wn(tk r|tj|t ¡ƒYn®Xzžtj | t | ¡¡rnt| ||ƒytj|j |dWn(tk rj|tj|t ¡ƒYnXn8y tdƒ‚Wn*tk r¤|tjj|t ¡ƒYnXWdt | ¡Xqfytj|j |dWqftk rô|tj|t ¡ƒYqfXqfWdS)NF)r5)Údir_fdz%Cannot call rmtree on a symbolic link)r-rtrur/Úfilenamervrwr.r`rMrxr9ÚS_ISDIRr;r?ÚO_RDONLYÚsamestatÚfstatÚ_rmtree_safe_fdr|r<Úcloser{) Útopfdr.r}r~rr^r€rrxÚorig_stÚdirfdr r r!rˆ—sJ      rˆc Cs¤|rdd„}n|dkrdd„}trPt|tƒr8t |¡}yt |¡}Wn&tk rl|tj|t ¡ƒdSXyt  |tj ¡}Wn&tk r¦|tj|t ¡ƒdSXz˜tj   |t  |¡¡rt|||ƒyt |¡Wn(tk r|tj|t ¡ƒYnXn8y tdƒ‚Wn*tk r<|tj j|t ¡ƒYnXWdt |¡XnPytj  |¡rhtdƒ‚Wn*tk r”|tj j|t ¡ƒdSXt||ƒSdS)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 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. cWsdS)Nr )rPr r r!r}×szrmtree..onerrorNcWs‚dS)Nr )rPr r r!r}Úsz%Cannot call rmtree on a symbolic link)Ú_use_fd_functionsÚ isinstanceÚbytesr-ÚfsdecoderDÚ Exceptionrvrwr?r…r.r†r‡rˆr|r/r<r‰rz)r.Ú ignore_errorsr}r‹Úfdr r r!r ËsH       cCs&tjjtjjpd}tj | |¡¡S)NÚ)r-r.ÚsepÚaltsepraÚrstrip)r.r•r r r!Ú _basename sr˜c Cs|}tj |¡rTt||ƒr*t ||¡dStj |t|ƒ¡}tj |¡rTtd|ƒ‚yt ||¡Wn–t k rútj  |¡r¢t  |¡}t  ||¡t  |¡nTtj |¡rât||ƒrÈtd||fƒ‚t|||ddt|ƒn|||ƒt  |¡YnX|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. Nz$Destination path '%s' already existsz.Cannot move a directory '%s' into itself '%s'.T)rqro)r-r.r_r4Úrenamer`r˜rlr r/r<r>r=r{Ú _destinsrcr r )r2r3rqZreal_dstrsr r r!r s2              cCsVtj |¡}tj |¡}| tjj¡s2|tjj7}| tjj¡sL|tjj7}| |¡S)N)r-r.r1Úendswithr•Ú startswith)r2r3r r r!ršHs    ršcCsNtdks|dkrdSy t|ƒ}Wntk r8d}YnX|dk rJ|dSdS)z"Returns a gid, given a group name.Né)rÚKeyError)rMÚresultr r r!Ú_get_gidQs  r cCsNtdks|dkrdSy t|ƒ}Wntk r8d}YnX|dk rJ|dSdS)z"Returns an uid, given a user name.Nr)rrž)rMrŸr r r!Ú_get_uid]s  r¡Úgzipcs |dkrd}nDtr |dkr d}n2tr2|dkr2d}n trD|dkrDd}ntd |¡ƒ‚d dl} |rfd |nd} |d | } tj | ¡} | r´tj  | ¡s´|dk r¦|  d | ¡|s´t  | ¡|dk rÆ|  d ¡t ˆƒ‰t ˆƒ‰‡‡‡‡fdd„} |s|  | d|¡}z|j|| dWd| ¡X| S)aúCreate 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. Nr”r¢ZgzÚbzip2Úbz2ÚxzzCbad value for 'compress', or compression format not supported : {0}rÚ.z.tarz creating %szCreating tar archivecs,ˆdk rˆ|_ˆ|_ˆdk r(ˆ|_ˆ|_|S)N)ÚgidZgnameÚuidÚuname)Ztarinfo)r§ÚgroupÚownerr¨r r!Ú _set_uid_gid˜sz#_make_tarball.._set_uid_gidzw|%s)rd)Ú_ZLIB_SUPPORTEDÚ_BZ2_SUPPORTEDÚ_LZMA_SUPPORTEDÚ ValueErrorr8Útarfiler-r.ÚdirnamerlÚinforkr¡r r?Úaddr‰)Ú base_nameÚbase_dirÚcompressÚverboseÚdry_runr«rªÚloggerZtar_compressionr±Z compress_extZ archive_nameÚ archive_dirr¬Útarr )r§rªr«r¨r!Ú _make_tarballis<          r½c Cszddl}|d}tj |¡}|rNtj |¡sN|dk r@| d|¡|sNt |¡|dk rd| d||¡|sv|j|d|jdô}tj  |¡} | tj kr´|  | | ¡|dk r´| d| ¡x¶t  |¡D]¨\} } } xFt | ƒD]:} tj  tj | | ¡¡} |  | | ¡|dk rÔ| d| ¡qÔWxT| D]L} tj  tj | | ¡¡} tj | ¡r|  | | ¡|dk r| d| ¡qWqÀWWdQRX|S) z¦Create 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. rNz.zipz creating %sz#creating '%s' and adding '%s' to itÚw)Z compressionz adding '%s')Úzipfiler-r.r²rlr³rkÚZipFileZ ZIP_DEFLATEDÚnormpathÚcurdirr'ÚwalkÚsortedr`Úisfile)rµr¶r¸r¹rºr¿Z zip_filenamer»Zzfr.ÚdirpathZdirnamesÚ filenamesrMr r r!Ú _make_zipfileªs@             rÈr¼)r·Nzuncompressed tar file)r·r¢zgzip'ed tar-fileZgztarzZIP fileÚzip)r·r£zbzip2'ed tar-fileZbztar)r·r¥zxz'ed tar-fileZxztarcCsdd„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)rr )Ú.0rMÚregistryr r r!ú ìsz'get_archive_formats..)Ú_ARCHIVE_FORMATSÚitemsÚsort)Úformatsr r r!rçs r”cCsx|dkr g}t|ƒs td|ƒ‚t|ttfƒs6tdƒ‚x.|D]&}t|ttfƒrZt|ƒdkr|dk r$| d|¡tj |¡}|s>t |¡|dkrLtj}||dœ} y t|} Wn"tk r„t d|ƒd‚YnX| d} x| dD]\} }|| | <q˜W|dkrÄ|| d<|| d <z| ||f| Ž}Wd|dk rþ|dk rô| d | ¡t | ¡X|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. Nzchanging into '%s')r¹rºzunknown archive format '%s'rérÉr«rªzchanging back to '%s') r-ÚgetcwdÚdebugr.r1ÚchdirrÂrÍržr°)rµr8Zroot_dirr¶r¸r¹r«rªrºZsave_cwdrQÚ format_infoÚfuncÚargÚvalrƒr 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ÊrMr³r r r!rÌFsz&get_unpack_formats..)Ú_UNPACK_FORMATSrÎrÏ)rÐr r r!r@s c Csvi}x.t ¡D]"\}}x|dD] }|||<q WqWx,|D]$}||kr:d}t||||fƒ‚q:Wt|ƒsrtdƒ‚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$rÑrÒ) Ú extensionsrÕrÖZexisting_extensionsrMr³ÚextÚ extensionÚmsgr r r!Ú_check_unpack_optionsKs 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á)rMrârÕrÖr×r r r!r]s cCs t|=dS)z*Removes the pack format from the registry.N)rá)rMr r r!rsscCs&tj |¡}tj |¡s"t |¡dS)z1Ensure that the parent directory of `path` existsN)r-r.r²r_rk)r.r²r r r!Ú_ensure_directoryws  rçc CsÊddl}| |¡std|ƒ‚| |¡}z’xŒ| ¡D]€}|j}| d¡s4d|krRq4tjj |f|  d¡žŽ}|spq4t |ƒ|  d¡s4|  |j¡}t|dƒ}z| |¡Wd| ¡~Xq4WWd| ¡XdS)z+Unpack zip `filename` to `extract_dir` rNz%s is not a zip fileú/z..r7)r¿Z is_zipfiler#rÀZinfolistrƒrœr-r.r`Úsplitrçr›r&r?r'r‰) rƒÚ extract_dirr¿rÉr³rMÚtargetÚdataÚfr r r!Ú_unpack_zipfile}s*       rîcCsXddl}y| |¡}Wn"|jk r8td|ƒ‚YnXz| |¡Wd| ¡XdS)zAUnpack tar/tar.gz/tar.bz2/tar.xz `filename` to `extract_dir` rNz/%s is not a compressed or uncompressed tar file)r±r?ZTarErrorr#Z extractallr‰)rƒrêr±Ztarobjr r r!Ú_unpack_tarfileŸsrïz.tarz.zip)r¼rÉz.tar.gzz.tgzz.tar.bz2z.tbz2z.tar.xzz.txzcCs:x4t ¡D](\}}x|dD]}| |¡r|SqWq WdS)Nr)rárÎr›)rƒrMr³rär r r!Ú_find_unpack_format¾s   rðcCsÊ|dkrt ¡}t |¡}t |¡}|dk r~y t|}Wn$tk r\td |¡ƒd‚YnX|d}|||ft|dƒŽnHt|ƒ}|dkrœt d |¡ƒ‚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", "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. NzUnknown unpack format '{0}'rØrzUnknown archive format '{0}') r-rÙÚfspathráržr°r8Údictrðr#)rƒrêr8rÜrÝrQr r r!rÅs"    ÚstatvfsÚ disk_usageZusageztotal used freezTotal space in byteszUsed space in byteszFree space in bytescCs@t |¡}|j|j}|j|j}|j|j|j}t|||ƒS)zÖReturn 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-róÚf_bavailÚf_frsizeÚf_blocksÚf_bfreeÚ_ntuple_diskusage)r.rAÚfreeÚtotalÚusedr r r!rôõs    ÚntcCs"t |¡\}}||}t|||ƒS)z×Return 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ýZ _getdiskusagerù)r.rûrúrür r r!rôscCsž|dkr|dkrtdƒ‚|}|}|dkr.d}n(t|tƒrVt|ƒ}|dkrVtd |¡ƒ‚|dkrdd}n(t|tƒsŒt|ƒ}|dkrŒtd |¡ƒ‚t  |||¡dS)z¹Change 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. Nzuser and/or group must be setéÿÿÿÿzno such user: {!r}zno such group: {!r}) r°rŽrnr¡Ú LookupErrorr8Úintr r-r)r.ÚuserrªZ_userZ_groupr r r!rs"  ©éPéc CsÔyttjdƒ}Wnttfk r.d}YnXyttjdƒ}Wnttfk r^d}YnX|dksp|dkrÆyt tj ¡¡}Wn$t tt fk r¨t  |¡}YnX|dkr¸|j }|dkrÆ|j }t  ||f¡S)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. ZCOLUMNSrZLINES)rr-Úenvironržr°rrvÚ __stdout__ÚfilenoÚAttributeErrorr/Ú terminal_sizeÚcolumnsÚlines)Zfallbackr r Úsizer r r!r1s$  c s^dd„}tj ˆ¡r&|ˆ|ƒr"ˆSdS|dkrrtj dd¡}|dkrryt d¡}Wnttfk rptj}YnX|szdS|  tj ¡}t j dkrðtj |kr¨| dtj ¡tj dd ¡  tj ¡}t‡fd d „|Dƒƒr܈g}qö‡fd d „|Dƒ}nˆg}tƒ}x\|D]T}tj |¡}||kr| |¡x,|D]$} tj || ¡} || |ƒr,| Sq,WqWdS)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. cSs&tj |¡o$t ||¡o$tj |¡ S)N)r-r.rlÚaccessr_)r@r\r r r!Ú _access_checkkszwhich.._access_checkNÚPATHÚCS_PATHZwin32rZPATHEXTr”c3s |]}ˆ ¡ | ¡¡VqdS)N)Úlowerr›)rÊrã)Úcmdr r!ú ’szwhich..csg|] }ˆ|‘qSr r )rÊrã)rr r!rÌ•szwhich..)r-r.r²rÚgetÚconfstrrr°ÚdefpathréÚpathseprvÚplatformrÂÚinsertÚanyrer0r´r`) rr\r.rZpathextÚfilesÚseenÚdirZnormdirZthefilerMr )rr!r^sB             )r%)FN)r¢rrNNN)rrN)Nr”)NNrrNNN)Nr”)NN)NN)r)Vr"r-rvr9rcÚ collectionsrGÚzlibr­Ú ImportErrorr¤r®Zlzmar¯ÚpwdrZgrprÚ__all__r/r rrrr#r‘r$rr4rrr,rOrrr rr rzrˆr?r{r|Úsupports_dir_fdrtÚ supports_fdrVrr Zavoids_symlink_attacksr˜r ršr r¡r½rÈrÍrrrrrrærrrçrîrïrárðrrmÚ namedtuplerùrûrürúrôrMrýrrÚF_OKÚX_OKrr r r r!Úsþ          <  Y#/   = 8    @ -     6  "        (        -