/snap/core18/2999/usr/lib/python3.6/__pycache__
NameSizeModeActions
abc.cpython-36.pyc75150644editdlrm
aifc.cpython-36.pyc259430644editdlrm
antigravity.cpython-36.pyc7790644editdlrm
argparse.cpython-36.pyc604560644editdlrm
ast.cpython-36.pyc117040644editdlrm
asynchat.cpython-36.pyc68150644editdlrm
asyncore.cpython-36.pyc158380644editdlrm
base64.cpython-36.pyc170590644editdlrm
bdb.cpython-36.pyc170330644editdlrm
binhex.cpython-36.pyc120860644editdlrm
bisect.cpython-36.pyc26760644editdlrm
bz2.cpython-36.pyc112820644editdlrm
calendar.cpython-36.pyc258820644editdlrm
cgi.cpython-36.pyc284160644editdlrm
cgitb.cpython-36.pyc100800644editdlrm
chunk.cpython-36.pyc49000644editdlrm
cmd.cpython-36.pyc125750644editdlrm
code.cpython-36.pyc98360644editdlrm
codecs.cpython-36.pyc339000644editdlrm
codeop.cpython-36.pyc62700644editdlrm
colorsys.cpython-36.pyc33110644editdlrm
compileall.cpython-36.pyc82780644editdlrm
configparser.cpython-36.pyc452440644editdlrm
contextlib.cpython-36.pyc111580644editdlrm
copy.cpython-36.pyc70790644editdlrm
copyreg.cpython-36.pyc42440644editdlrm
cProfile.cpython-36.pyc42940644editdlrm
crypt.cpython-36.pyc22420644editdlrm
csv.cpython-36.pyc118550644editdlrm
datetime.cpython-36.pyc545110644editdlrm
decimal.cpython-36.pyc3510644editdlrm
difflib.cpython-36.pyc596420644editdlrm
dis.cpython-36.pyc141810644editdlrm
doctest.cpython-36.pyc755890644editdlrm
dummy_threading.cpython-36.pyc11020644editdlrm
enum.cpython-36.pyc234530644editdlrm
filecmp.cpython-36.pyc83050644editdlrm
fileinput.cpython-36.pyc131520644editdlrm
fnmatch.cpython-36.pyc28740644editdlrm
formatter.cpython-36.pyc175790644editdlrm
fractions.cpython-36.pyc184260644editdlrm
ftplib.cpython-36.pyc283570644editdlrm
functools.cpython-36.pyc240620644editdlrm
genericpath.cpython-36.pyc37260644editdlrm
getopt.cpython-36.pyc62170644editdlrm
getpass.cpython-36.pyc41770644editdlrm
gettext.cpython-36.pyc143060644editdlrm
glob.cpython-36.pyc42590644editdlrm
gzip.cpython-36.pyc162260644editdlrm
hashlib.cpython-36.pyc66920644editdlrm
heapq.cpython-36.pyc142920644editdlrm
hmac.cpython-36.pyc48360644editdlrm
imaplib.cpython-36.pyc421380644editdlrm
imghdr.cpython-36.pyc41500644editdlrm
imp.cpython-36.pyc96960644editdlrm
inspect.cpython-36.pyc797390644editdlrm
io.cpython-36.pyc33870644editdlrm
ipaddress.cpython-36.pyc623860644editdlrm
keyword.cpython-36.pyc17650644editdlrm
linecache.cpython-36.pyc37780644editdlrm
locale.cpython-36.pyc340300644editdlrm
lzma.cpython-36.pyc119920644editdlrm
macpath.cpython-36.pyc56410644editdlrm
macurl2path.cpython-36.pyc18670644editdlrm
mailbox.cpython-36.pyc637520644editdlrm
mailcap.cpython-36.pyc72090644editdlrm
mimetypes.cpython-36.pyc155530644editdlrm
modulefinder.cpython-36.pyc153660644editdlrm
netrc.cpython-36.pyc38360644editdlrm
nntplib.cpython-36.pyc337800644editdlrm
ntpath.cpython-36.pyc131900644editdlrm
nturl2path.cpython-36.pyc14990644editdlrm
numbers.cpython-36.pyc121420644editdlrm
opcode.cpython-36.pyc54130644editdlrm
operator.cpython-36.pyc139130644editdlrm
optparse.cpython-36.pyc480540644editdlrm
os.cpython-36.pyc296280644editdlrm
pathlib.cpython-36.pyc420070644editdlrm
pdb.cpython-36.pyc460940644editdlrm
pickle.cpython-36.pyc426910644editdlrm
pickletools.cpython-36.pyc660200644editdlrm
pipes.cpython-36.pyc78080644editdlrm
pkgutil.cpython-36.pyc162610644editdlrm
platform.cpython-36.pyc291970644editdlrm
plistlib.cpython-36.pyc280550644editdlrm
poplib.cpython-36.pyc133290644editdlrm
posixpath.cpython-36.pyc104560644editdlrm
pprint.cpython-36.pyc158240644editdlrm
profile.cpython-36.pyc139010644editdlrm
pstats.cpython-36.pyc218570644editdlrm
pty.cpython-36.pyc38610644editdlrm
pyclbr.cpython-36.pyc83650644editdlrm
pydoc.cpython-36.pyc837750644editdlrm
py_compile.cpython-36.pyc65440644editdlrm
queue.cpython-36.pyc87550644editdlrm
quopri.cpython-36.pyc57730644editdlrm
random.cpython-36.pyc193300644editdlrm
re.cpython-36.pyc140580644editdlrm
reprlib.cpython-36.pyc54000644editdlrm
rlcompleter.cpython-36.pyc57800644editdlrm
runpy.cpython-36.pyc79820644editdlrm
sched.cpython-36.pyc65640644editdlrm
secrets.cpython-36.pyc21620644editdlrm
selectors.cpython-36.pyc176970644editdlrm
shelve.cpython-36.pyc94580644editdlrm
shlex.cpython-36.pyc69700644editdlrm
shutil.cpython-36.pyc307040644editdlrm
signal.cpython-36.pyc25150644editdlrm
site.cpython-36.pyc165600644editdlrm
sitecustomize.cpython-36.pyc2120644editdlrm
smtpd.cpython-36.pyc266830644editdlrm
smtplib.cpython-36.pyc353400644editdlrm
sndhdr.cpython-36.pyc69130644editdlrm
socket.cpython-36.pyc220130644editdlrm
socketserver.cpython-36.pyc242500644editdlrm
sre_compile.cpython-36.pyc102780644editdlrm
sre_constants.cpython-36.pyc59720644editdlrm
sre_parse.cpython-36.pyc203580644editdlrm
ssl.cpython-36.pyc369390644editdlrm
stat.cpython-36.pyc38510644editdlrm
statistics.cpython-36.pyc181740644editdlrm
string.cpython-36.pyc79640644editdlrm
stringprep.cpython-36.pyc100300644editdlrm
struct.cpython-36.pyc3120644editdlrm
subprocess.cpython-36.pyc354850644editdlrm
sunau.cpython-36.pyc169380644editdlrm
symbol.cpython-36.pyc25170644editdlrm
symtable.cpython-36.pyc104280644editdlrm
sysconfig.cpython-36.pyc159160644editdlrm
tabnanny.cpython-36.pyc69750644editdlrm
tarfile.cpython-36.pyc630850644editdlrm
telnetlib.cpython-36.pyc180970644editdlrm
tempfile.cpython-36.pyc253090644editdlrm
textwrap.cpython-36.pyc136840644editdlrm
this.cpython-36.pyc12650644editdlrm
threading.cpython-36.pyc372340644editdlrm
timeit.cpython-36.pyc116030644editdlrm
token.cpython-36.pyc33200644editdlrm
tokenize.cpython-36.pyc186470644editdlrm
trace.cpython-36.pyc194950644editdlrm
traceback.cpython-36.pyc196460644editdlrm
tracemalloc.cpython-36.pyc172290644editdlrm
tty.cpython-36.pyc10720644editdlrm
turtle.cpython-36.pyc1317510644editdlrm
types.cpython-36.pyc82010644editdlrm
typing.cpython-36.pyc733060644editdlrm
uu.cpython-36.pyc34980644editdlrm
uuid.cpython-36.pyc209180644editdlrm
warnings.cpython-36.pyc132580644editdlrm
wave.cpython-36.pyc178850644editdlrm
weakref.cpython-36.pyc191430644editdlrm
webbrowser.cpython-36.pyc157970644editdlrm
xdrlib.cpython-36.pyc83020644editdlrm
zipapp.cpython-36.pyc55340644editdlrm
zipfile.cpython-36.pyc497280644editdlrm
_bootlocale.cpython-36.pyc9800644editdlrm
_collections_abc.cpython-36.pyc287970644editdlrm
_compat_pickle.cpython-36.pyc65660644editdlrm
_compression.cpython-36.pyc41040644editdlrm
_dummy_thread.cpython-36.pyc48510644editdlrm
_markupbase.cpython-36.pyc79910644editdlrm
_osx_support.cpython-36.pyc96840644editdlrm
_pydecimal.cpython-36.pyc1634020644editdlrm
_pyio.cpython-36.pyc713860644editdlrm
_sitebuiltins.cpython-36.pyc34350644editdlrm
_strptime.cpython-36.pyc159630644editdlrm
_sysconfigdata_m_linux_x86_64-linux-gnu.cpython-36.pyc187790644editdlrm
_threading_local.cpython-36.pyc64250644editdlrm
_weakrefset.cpython-36.pyc78280644editdlrm
__future__.cpython-36.pyc41670644editdlrm
__phello__.foo.cpython-36.pyc1190644editdlrm
Edit: /snap/core18/2999/usr/lib/python3.6/__pycache__/shutil.cpython-36.pyc (30704B)
3 Nqi\A@sdZddlZddlZddlZddlZddlZddlZyddlZ[dZWne k r^dZYnXyddl Z [ dZ Wne k rdZ YnXyddl Z [ dZ Wne k rdZ YnXyddlmZWne k rdZYnXyddlmZWne k r dZYnXddd d d d d ddddddddddddddddddgZGd ddeZGd!ddeZGd"ddeZGd#ddeZGd$d%d%eZGd&d'd'eZdd*dZd+d,Zdd-d.dZdd-d/d Zeed0rdd-d1d2Z nd3d2Z dd-d4d Z!dd-d5d Z"dd-d6d Z#d7dZ$dde#dfd8d Z%d9d:Z&d;d<Z'ej(ejej)ej*hej+ko~ej,ej-ko~ejej.kZ/dd=dZ0e/e0_1d>d?Z2e#fd@dZ3dAdBZ4dCdDZ5dEdFZ6ddHdIZ7ddJdKZ8dLe7dgdNfiZ9ere7dgdOfe9dP<e8gdQfe9dR<e re7dgdTfe9dU<e r0e7dgdWfe9dX<dYdZ:dd[dZ;d\dZd_d`Z?ddadZ@dbdZAdcddZBdedfZCdgdhZDdigeDgdNfdjgeCgdQfdkZEerdldmgeDgdOfeEdP<e rdndogeDgdTfeEdU<e rdpdqgeDgdWfeEdX<drdsZFddtdZGeedurPejHdvejIdwdxZJdyeJjK_dzeJjL_d{eJjM_d|dvZNn2ejOd}krddlPZPejHdvejIdwdxZJd~dvZNdddZQdddZRejSejTBdfddZUdS)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. NTF)getpwnam)getgrnam copyfileobjcopyfilecopymodecopystatcopycopy2copytreemovermtreeErrorSpecialFileError ExecError make_archiveget_archive_formatsregister_archive_formatunregister_archive_formatget_unpack_formatsregister_unpack_formatunregister_unpack_formatunpack_archiveignore_patternschownwhichget_terminal_size SameFileErrorc@s eZdZdS)r N)__name__ __module__ __qualname__r r /usr/lib/python3.6/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$icCs$x|j|}|sP|j|qWdS)z=copy data from file-like object fsrc to file-like object fdstN)readwrite)fsrcfdstZlengthZbufr r r!rLs  c CsXttjdr0ytjj||Stk r.dSXtjjtjj|tjjtjj|kS)NsamefileF)hasattrospathr*OSErrornormcaseabspath)srcdstr r r! _samefileTs r3)follow_symlinkscCst||rtdj||xL||gD]@}ytj|}Wntk rJYq$Xtj|jr$td|q$W| rtj j |rtj tj ||n6t |d&}t |d}t||WdQRXWdQRX|S)zCopy 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 piperbwbN)r3rformatr,statr.S_ISFIFOst_moderr-islinksymlinkreadlinkopenr)r1r2r4fnstr(r)r r r!r`s    cCsz| r>tjj|r>tjj|r>ttdr8tjtj}}q\dSnttdrXtjtj}}ndS||}||tj|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. lchmodNchmod) r,r-r;r+lstatrAr8rBS_IMODEr:)r1r2r4Z stat_funcZ chmod_funcr@r r r!r}s   listxattrcCsytj||d}Wn4tk rF}z|jtjtjfkr8dSd}~XnXxn|D]f}y&tj|||d}tj||||dWqNtk r}z|jtjtjtjfkrWYdd}~XqNXqNWdS)zCopy extended filesystem attributes from `src` to `dst`. Overwrite existing attributes. If `follow_symlinks` is false, symlinks won't be followed. )r4N) r,rEr.errnoENOTSUPZENODATAgetxattrsetxattrZEPERM)r1r2r4namesenamevaluer r r! _copyxattrs  rNcOsdS)Nr )argskwargsr r r!rNsc s6ddddd|p,tjj|o*tjj| }|r@fdd}n fdd}|d||d }tj|j}|d ||j|jf|dy|d |||d Wntk rYnXt |d r$y|d ||j |d WnPt k r"}z2x*dD] }t t |r|j t t |krPqWWYdd}~XnXt|||d dS)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 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. N)nsr4cWsdS)Nr )rQr4rOr r r!_nopszcopystat.._nopcs tt|S)N)getattrr,)rL)rRr r!lookupszcopystat..lookupcstt|}|tjkr|SS)N)rSr,supports_follow_symlinks)rLr?)rRr r!rTs  r8)r4utimerBst_flagsZchflags EOPNOTSUPPrG)rXrG)r,r-r;r8rDr: st_atime_ns st_mtime_nsNotImplementedErrorr+rWr.rFrSrN) r1r2r4ZfollowrTr@modewhyerrr )rRr!rs,      cCsBtjj|r"tjj|tjj|}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. )r4)r,r-isdirjoinbasenamerr)r1r2r4r r r!rs cCsBtjj|r"tjj|tjj|}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". )r4)r,r-r_r`rarr)r1r2r4r r r!r s 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}xD]}|jtj||q Wt|S)N)extendfnmatchfilterset)r-rJ ignored_namespattern)patternsr r!_ignore_patternss z)ignore_patterns.._ignore_patternsr )rhrir )rhr!r s cCstj|}|dk r|||}nt}tj|g}xB|D]8} | |krJq:tjj|| } tjj|| } ytjj| rtj| } |rtj| | t | | | dn 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)r4rZwinerror)r,listdirremakedirsr-r`r;r=r<rexistsr_r r rbrOr.appendstrrS)r1r2symlinksignore copy_functionZignore_dangling_symlinksrJrferrorsrLZsrcnameZdstnamelinktor^r]r r r!r sL$           *&c$CsLytjj|rtdWn(tk r@|tjj|tjdSXg}ytj|}Wn&tk rz|tj|tjYnXx|D]}tjj||}ytj|j }Wntk rd}YnXt j |rt ||qytj |Wqtk r |tj |tjYqXqWytj|Wn(tk rF|tj|tjYnXdS)Nz%Cannot call rmtree on a symbolic linkr)r,r-r;r.sysexc_inforjr`rCr:r8S_ISDIR_rmtree_unsafeunlinkrmdir)r-onerrorrJrLfullnamer\r r r!rwqs6      rwc 0Csg}ytj|}Wn:tk rL}z||_|tj|tjWYdd}~XnXx|D]x}tjj||}ytj||dd}|j }Wntk rd}YnXtj |rytj |tj |d} Wn&tk r|tj |tjYnXztjj |tj| rJt| ||ytj||dWn(tk rF|tj|tjYnXn8y tdWn*tk r|tjj|tjYnXWdtj| XqVytj||dWqVtk r|tj|tjYqVXqVWdS)NF)dir_fdr4r)r|z%Cannot call rmtree on a symbolic link)r,rjr.filenamertrur-r`r8r:rvr>O_RDONLYsamestatfstat_rmtree_safe_fdryr;closerx) topfdr-rzrJr^rLr{orig_str\dirfdr r r!rsD$     rc!Cs^|rdd}n|dkrdd}trPt|tr8tj|}ytj|}Wn&tk rl|tj|tjdSXytj |tj }Wn&tk r|tj|tjdSXztj j |tj |rt|||ytj|Wn(tk r|tj|tjYnXn8y tdWn*tk r<|tj j|tjYnXWdtj|Xn t||SdS)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. cWsdS)Nr )rOr r r!rzszrmtree..onerrorNcWsdS)Nr )rOr r r!rzsz%Cannot call rmtree on a symbolic link)_use_fd_functions isinstancebytesr,fsdecoderC Exceptionrtrur>r~r-rrrryr.r;rrw)r- ignore_errorsrzrfdr r r!r s<      cCs&tjjtjjpd}tjj|j|S)N)r,r-sepaltseprarstrip)r-rr r r! _basenamesrc Cs|}tjj|rTt||r*tj||dStjj|t|}tjj|rTtd|ytj||Wnt k rtjj |rtj |}tj ||tj |nTtjj|rt||rtd||ft|||ddt|n|||tj |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_r3renamer`rrlr r.r;r=r<rx _destinsrcr r )r1r2rqZreal_dstrsr r r!r s2              cCsVtjj|}tjj|}|jtjjs2|tjj7}|jtjjsL|tjj7}|j|S)N)r,r-r0endswithr startswith)r1r2r r r!r8s    rc CsNtdks|dkrdSy t|}Wntk r8d}YnX|dk rJ|dSdS)z"Returns a gid, given a group name.N)rKeyError)rLresultr r r!_get_gidAs  rc CsNtdks|dkrdSy t|}Wntk r8d}YnX|dk rJ|dSdS)z"Returns an uid, given a user name.Nr)rr)rLrr r r!_get_uidMs  rgzipc s"|dkrd}nDtr |dkr d}n2tr2|dkr2d}n trD|dkrDd}ntdj|d dl} |rfd |nd} |d | } tjj| } | rtjj |  r|dk r|j d | |stj | |dk r|j d t t fdd} |s| j| d|}z|j|| dWd|jX| 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. NrrZgzbzip2bz2xzzCbad value for 'compress', or compression format not supported : {0}r.z.tarz creating %szCreating tar archivecs,dk r|_|_dk r(|_|_|S)N)gidZgnameuiduname)Ztarinfo)rgroupownerrr r! _set_uid_gidsz#_make_tarball.._set_uid_gidzw|%s)rd)_ZLIB_SUPPORTED_BZ2_SUPPORTED_LZMA_SUPPORTED ValueErrorr7tarfiler,r-dirnamerlinforkrrr>addr) base_namebase_dircompressverbosedry_runrrloggerZtar_compressionrZ compress_extZ archive_name archive_dirrtarr )rrrrr! _make_tarballYs<          rc Cs|ddl}|d}tjj|}|rPtjj| rP|dk rB|jd||sPtj||dk rf|jd|||sx|j|d|jd}tjj |} | tj kr|j | | |dk r|jd| xtj |D]\} } } xFt | D]:} tjj tjj| | } |j | | |dk r|jd| qWxT| D]L} tjj tjj| | } tjj| r|j | | |dk r|jd| qWqWWdQRX|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. rNz.zipz creating %sz#creating '%s' and adding '%s' to itw)Z compressionz adding '%s')zipfiler,r-rrlrrkZipFileZ ZIP_DEFLATEDnormpathcurdirr'walksortedr`isfile)rrrrrrZ zip_filenamerZzfr-dirpathZdirnames filenamesrLr r r! _make_zipfiles@             rrrzuncompressed tar filezgzip'ed tar-fileZgztarzZIP fileziprzbzip2'ed tar-fileZbztarrzxz'ed tar-fileZxztarcCsddtjD}|j|S)zReturns a list of supported formats for archiving and unarchiving. Each element of the returned sequence is a tuple (name, description) cSsg|]\}}||dfqS)rr ).0rLregistryr r r! sz'get_archive_formats..)_ARCHIVE_FORMATSitemssort)formatsr r r!rs rcCsz|dkr g}t|s td|t|ttfs6tdx0|D](}t|ttf s\t|dkr|dk r$|jd|tjj|}|s>tj||dkrLtj}||d} y t|} Wn tk rt d|YnX| d} x| dD]\} }|| | <qW|dkr|| d<|| d <z| ||f| }Wd|dk r|dk r|jd | tj| 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')rrzunknown archive format '%s'rrrrzchanging back to '%s') r,getcwddebugr-r0chdirrrrr)rr7Zroot_dirrrrrrrZsave_cwdrP format_infofuncargvalr}r r r!rs6        cCsddtjD}|j|S)zReturns a list of supported formats for unpacking. Each element of the returned sequence is a tuple (name, extensions, description) cSs"g|]\}}||d|dfqS)rr )rrLrr r r!r6sz&get_unpack_formats..)_UNPACK_FORMATSrr)rr r r!r0s c Csvi}x.tjD]"\}}x|dD] }|||<q WqWx,|D]$}||kr:d}t||||fq:Wt|srtddS)z+Checks what gets registered as an unpacker.rz!%s is already registered for "%s"z*The registered function must be a callableN)rrr$rr) extensionsrrZexisting_extensionsrLrext extensionmsgr r r!_check_unpack_options;s rcCs,|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)rr)rLrrrrr r r!rMs cCs t|=dS)z*Removes the pack format from the registry.N)r)rLr r r!rcscCs&tjj|}tjj|s"tj|dS)z1Ensure that the parent directory of `path` existsN)r,r-rr_rk)r-rr r r!_ensure_directorygs  rc Csddl}|j|std||j|}zx|jD]}|j}|jds4d|krRq4tjj |f|j d}|spq4t ||j ds4|j |j}t|d}z|j|Wd|j~Xq4WWd|jXdS)z+Unpack zip `filename` to `extract_dir` rNz%s is not a zip file/z..r6)rZ is_zipfiler#rZinfolistr}rr,r-r`splitrrr&r>r'r) r} extract_dirrrrrLtargetdatafr r r!_unpack_zipfilems*       rcCsXddl}y|j|}Wn"|jk r8td|YnXz|j|Wd|jXdS)zAUnpack tar/tar.gz/tar.bz2/tar.xz `filename` to `extract_dir` rNz/%s is not a compressed or uncompressed tar file)rr>ZTarErrorr#Z extractallr)r}rrZtarobjr r r!_unpack_tarfilesrz.tarz.zip)rrz.tar.gzz.tgzz.tar.bz2z.tbz2z.tar.xzz.txzcCs:x4tjD](\}}x|dD]}|j|r|SqWq WdS)Nr)rrr)r}rLrrr r r!_find_unpack_formats   rc Cs|dkrtj}|dk rhy t|}Wn"tk rFtdj|YnX|d}|||ft|dnHt|}|dkrtdj|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}'rrzUnknown archive format '{0}') r,rrrrr7dictrr#)r}rr7rrrPr r r!rs  statvfs disk_usageZusageztotal used freezTotal space in byteszUsed space in byteszFree space in bytescCs@tj|}|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-r@freetotalusedr r r!rs    ntcCs"tj|\}}||}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. )rZ _getdiskusager)r-rrrr r r!rscCs|dkr|dkrtd|}|}|dkr.d}n(t|trVt|}|dkrVtdj||dkrdd}n(t|tst|}|dkrtdj|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. Nzuser and/or group must be setrzno such user: {!r}zno such group: {!r}r) rrrnr LookupErrorr7intrr,r)r-userrZ_userZ_groupr r r!rs"  PcCsyttjd}Wnttfk r.d}YnXyttjd}Wnttfk r^d}YnX|dksp|dkrytjtjj}Wn$t tt fk rtj |}YnX|dkr|j }|dkr|j }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. ZCOLUMNSrZLINES)rr,environrrrrt __stdout__filenoAttributeErrorr. terminal_sizecolumnslines)Zfallbackrrsizer r r!rs$  c s"dd}tjjr&||r"SdS|dkr>tjjdtj}|sFdS|jtj}tj dkrtj |krt|j dtj tjjddjtj}t fd d |Drg}q‡fd d |D}ng}t }xT|D]L}tjj|}||kr|j|x(|D] } tjj|| } || |r| SqWqWdS) 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&tjj|o$tj||o$tjj| S)N)r,r-rlaccessr_)r?r\r r r! _access_checkXszwhich.._access_checkNPATHZwin32rZPATHEXTrc3s |]}jj|jVqdS)N)lowerr)rr)cmdr r! uszwhich..csg|] }|qSr r )rr)r r r!rxszwhich..)r,r-rrgetdefpathrpathseprtplatformrinsertanyrer/rr`) r r\r-rZpathextZfilesseendirZnormdirZthefilerLr )r r!rKs8            @)r)FN)rrrNNN)rrN)rN)rr)rr)rr)Nr)NNrrNNN)Nr)NN)NNrr)r)Vr"r,rtr8rc collectionsrFzlibr ImportErrorrrZlzmarpwdrZgrpr__all__r.r rrrr#rr$rr3rrr+rNrrr rr rwrr>rxrysupports_dir_fdrj supports_fdrUrr Zavoids_symlink_attacksrr rrrrrrrrrrrrrrrrrrrrrm namedtuplerrrrrrLrrrF_OKX_OKrr r r r!s          :  Y!,   5 8    @ -     6  "        %        -