ok

Mini Shell

Direktori : /opt/alt/python36/lib/python3.6/site-packages/pip/_vendor/distlib/_backport/
Upload File :
Current File : //opt/alt/python36/lib/python3.6/site-packages/pip/_vendor/distlib/_backport/shutil.pyc

�
Bu�_c@sNdZddlZddlZddlZddlmZddlZyddlmZWn!e	k
r}ddl
mZnXddlZddlm
Z
yddlZeZWne	k
r�eZnXyddlmZWne	k
r�dZnXyddlmZWne	k
r%dZnXd	d
ddd
ddddddddddddddddgZdefd��YZdefd��YZdefd ��YZd!efd"��YZd#efd$��YZyeWne k
r�dZnXdXd'�Z!d(�Z"d)�Z#d*�Z$d+�Z%d,�Z&d-�Z'd.�Z(ede'ed/�Z)edd0�Z*d1�Z+d2�Z,d3�Z-d4�Z.d5�Z/d6d7d7dddd8�Z0eed9�Z1d7d7dd:�Z2ie0dYgd<fd=6e0dZgd?fd@6e0d[gdAfdB6e2gdCfdD6Z3erAe0d\gd?fe3d@<ndE�Z4ddFdG�Z5dH�Z6ddd7d7ddddI�Z7dJ�Z8dK�Z9ddFdL�Z:dM�Z;dN�Z<dO�Z=dP�Z>idQdRge>gd<fd=6dSge>gdAfdB6dTge=gdCfdD6Z?er2dUge>gd?fe?d@<ndV�Z@dddW�ZAdS(]s�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.

i����N(tabspath(tCallablei(ttarfile(tgetpwnam(tgetgrnamtcopyfileobjtcopyfiletcopymodetcopystattcopytcopy2tcopytreetmovetrmtreetErrortSpecialFileErrort	ExecErrortmake_archivetget_archive_formatstregister_archive_formattunregister_archive_formattget_unpack_formatstregister_unpack_formattunregister_unpack_formattunpack_archivetignore_patternscBseZRS((t__name__t
__module__(((sU/opt/alt/python36/lib/python3.6/site-packages/pip/_vendor/distlib/_backport/shutil.pyR/scBseZdZRS(s|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)(RRt__doc__(((sU/opt/alt/python36/lib/python3.6/site-packages/pip/_vendor/distlib/_backport/shutil.pyR2scBseZdZRS(s+Raised when a command could not be executed(RRR(((sU/opt/alt/python36/lib/python3.6/site-packages/pip/_vendor/distlib/_backport/shutil.pyR6st	ReadErrorcBseZdZRS(s%Raised when an archive cannot be read(RRR(((sU/opt/alt/python36/lib/python3.6/site-packages/pip/_vendor/distlib/_backport/shutil.pyR9st
RegistryErrorcBseZdZRS(sVRaised when a registry operation with the archiving
    and unpacking registries fails(RRR(((sU/opt/alt/python36/lib/python3.6/site-packages/pip/_vendor/distlib/_backport/shutil.pyR<siicCs0x)|j|�}|sPn|j|�qdS(s=copy data from file-like object fsrc to file-like object fdstN(treadtwrite(tfsrctfdsttlengthtbuf((sU/opt/alt/python36/lib/python3.6/site-packages/pip/_vendor/distlib/_backport/shutil.pyRFs
cCs{ttjd�rAytjj||�SWqAtk
r=tSXntjjtjj|��tjjtjj|��kS(Ntsamefile(thasattrtostpathR%tOSErrortFalsetnormcaseR(tsrctdst((sU/opt/alt/python36/lib/python3.6/site-packages/pip/_vendor/distlib/_backport/shutil.pyt	_samefileNs
cCs�t||�r(td||f��nx`||gD]R}ytj|�}Wntk
raq5Xtj|j�r5td|��q5q5Wt|d��,}t|d��}t	||�WdQXWdQXdS(sCopy data from src to dsts`%s` and `%s` are the same files`%s` is a named pipetrbtwbN(
R.RR'tstatR)tS_ISFIFOtst_modeRtopenR(R,R-tfntstR!R"((sU/opt/alt/python36/lib/python3.6/site-packages/pip/_vendor/distlib/_backport/shutil.pyRZs
cCsGttd�rCtj|�}tj|j�}tj||�ndS(sCopy mode bits from src to dsttchmodN(R&R'R1tS_IMODER3R7(R,R-R6tmode((sU/opt/alt/python36/lib/python3.6/site-packages/pip/_vendor/distlib/_backport/shutil.pyRnscCs�tj|�}tj|j�}ttd�rOtj||j|jf�nttd�rqtj||�nttd�r�t|d�r�ytj	||j
�Wq�tk
r�}ttd�s�|jtj
kr��q�q�XndS(sCCopy all stat info (mode bits, atime, mtime, flags) from src to dsttutimeR7tchflagstst_flagst
EOPNOTSUPPN(R'R1R8R3R&R:tst_atimetst_mtimeR7R;R<R)terrnoR=(R,R-R6R9twhy((sU/opt/alt/python36/lib/python3.6/site-packages/pip/_vendor/distlib/_backport/shutil.pyRuscCsTtjj|�r6tjj|tjj|��}nt||�t||�dS(sVCopy data and mode bits ("cp src dst").

    The destination may be a directory.

    N(R'R(tisdirtjointbasenameRR(R,R-((sU/opt/alt/python36/lib/python3.6/site-packages/pip/_vendor/distlib/_backport/shutil.pyR	�s$
cCsTtjj|�r6tjj|tjj|��}nt||�t||�dS(s]Copy data and all stat info ("cp -p src dst").

    The destination may be a directory.

    N(R'R(RBRCRDRR(R,R-((sU/opt/alt/python36/lib/python3.6/site-packages/pip/_vendor/distlib/_backport/shutil.pyR
�s$
cs�fd�}|S(s�Function 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]}|jtj||��q
Wt|�S(N(textendtfnmatchtfiltertset(R(tnamest
ignored_namestpattern(tpatterns(sU/opt/alt/python36/lib/python3.6/site-packages/pip/_vendor/distlib/_backport/shutil.pyt_ignore_patterns�s
((RLRM((RLsU/opt/alt/python36/lib/python3.6/site-packages/pip/_vendor/distlib/_backport/shutil.pyR�scCs
tj|�}|dk	r-|||�}n	t�}tj|�g}xG|D]?}	|	|krhqPntjj||	�}
tjj||	�}y�tjj|
�r�tj|
�}|r�tj	||�q6tjj
|�r�|r�wPn||
|�n8tjj|
�r)t|
||||�n
||
|�WqPt
k
r`}
|j|
jd�qPtk
r�}|j|
|t|�f�qPXqPWyt||�WnMtk
r�}tdk	r�t|t�r�q�|j||t|�f�nX|r	t
|��ndS(s�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.

    iN(R'tlistdirtNoneRHtmakedirsR(RCtislinktreadlinktsymlinktexistsRBRRREtargstEnvironmentErrortappendtstrRR)tWindowsErrort
isinstance(R,R-tsymlinkstignoret
copy_functiontignore_dangling_symlinksRIRJterrorstnametsrcnametdstnametlinktoterrRA((sU/opt/alt/python36/lib/python3.6/site-packages/pip/_vendor/distlib/_backport/shutil.pyR�sD$	

$ cCs�|rd�}n|dkr*d�}ny%tjj|�rNtd��nWn.tk
r|tjj|tj��dSXg}ytj|�}Wn-tjk
r�|tj|tj��nXx�|D]�}tjj	||�}ytj
|�j}Wntjk
rd}nXtj
|�r@t|||�q�ytj|�Wq�tjk
r�|tj|tj��q�Xq�Wytj|�Wn-tjk
r�|tj|tj��nXdS(s�Recursively delete a directory tree.

    If ignore_errors is set, errors are ignored; otherwise, if onerror
    is set, it is called to handle the error with arguments (func,
    path, exc_info) where func is os.listdir, os.remove, or os.rmdir;
    path is the argument to that function that caused it to fail; and
    exc_info is a tuple returned by sys.exc_info().  If ignore_errors
    is false and onerror is None, an exception is raised.

    cWsdS(N((RU((sU/opt/alt/python36/lib/python3.6/site-packages/pip/_vendor/distlib/_backport/shutil.pytonerrorscWs�dS(N((RU((sU/opt/alt/python36/lib/python3.6/site-packages/pip/_vendor/distlib/_backport/shutil.pyRess%Cannot call rmtree on a symbolic linkNi(ROR'R(RQR)tsystexc_infoRNterrorRCtlstatR3R1tS_ISDIRR
tremovetrmdir(R(t
ignore_errorsReRIR`tfullnameR9((sU/opt/alt/python36/lib/python3.6/site-packages/pip/_vendor/distlib/_backport/shutil.pyR
�s>


!cCstjj|jtjj��S(N(R'R(RDtrstriptsep(R(((sU/opt/alt/python36/lib/python3.6/site-packages/pip/_vendor/distlib/_backport/shutil.pyt	_basename*scCs|}tjj|�r~t||�r;tj||�dStjj|t|��}tjj|�r~td|��q~nytj||�Wn�t	k
rtjj|�r�t
||�r�td||f��nt||dt�t
|�qt||�tj|�nXdS(s�Recursively move a file or directory to another location. This is
    similar to the Unix "mv" command.

    If the destination is a directory or a symlink to a directory, the source
    is moved inside the directory. The destination path must not already
    exist.

    If the destination already exists but is not a directory, it may be
    overwritten depending on os.rename() semantics.

    If the destination is on our current filesystem, then rename() is used.
    Otherwise, src is copied to the destination and then removed.
    A lot more could be done here...  A look at a mv.c shows a lot of
    the issues this implementation glosses over.

    Ns$Destination path '%s' already existss.Cannot move a directory '%s' into itself '%s'.R[(R'R(RBR.trenameRCRqRTRR)t
_destinsrcRtTrueR
R
tunlink(R,R-treal_dst((sU/opt/alt/python36/lib/python3.6/site-packages/pip/_vendor/distlib/_backport/shutil.pyR/s$


cCsut|�}t|�}|jtjj�s@|tjj7}n|jtjj�sh|tjj7}n|j|�S(N(RtendswithR'R(Rpt
startswith(R,R-((sU/opt/alt/python36/lib/python3.6/site-packages/pip/_vendor/distlib/_backport/shutil.pyRsWscCs^tdks|dkrdSyt|�}Wntk
rEd}nX|dk	rZ|dSdS(s"Returns a gid, given a group name.iN(RROtKeyError(R`tresult((sU/opt/alt/python36/lib/python3.6/site-packages/pip/_vendor/distlib/_backport/shutil.pyt_get_gid`s

cCs^tdks|dkrdSyt|�}Wntk
rEd}nX|dk	rZ|dSdS(s"Returns an uid, given a user name.iN(RRORy(R`Rz((sU/opt/alt/python36/lib/python3.6/site-packages/pip/_vendor/distlib/_backport/shutil.pyt_get_uidls

tgzipics|idd6dd6}idd6}	tr>d|d<d|	d<n|dk	rn||	krntdj|���n|d	|	j|d�}
tjj|
�}tjj|�s�|dk	r�|j	d
|�n|s�tj
|�q�n|dk	r|j	d�nt���t�������fd�}|sxt
j|
d
||�}
z|
j|d|�Wd|
j�Xn|
S(s�Create a (possibly compressed) tar file from all the files under
    'base_dir'.

    'compress' must be "gzip" (the default), "bzip2", or None.

    'owner' and 'group' can be used to define an owner and a group for the
    archive that is being built. If not provided, the current owner and group
    will be used.

    The output tar file will be named 'base_name' +  ".tar", possibly plus
    the appropriate compression extension (".gz", or ".bz2").

    Returns the output filename.
    tgzR}ts.gztbz2tbzip2s.bz2sCbad value for 'compress', or compression format not supported : {0}s.tarscreating %ssCreating tar archivecsF�dk	r!�|_�|_n�dk	rB�|_�|_n|S(N(ROtgidtgnametuidtuname(ttarinfo(R�tgrouptownerR�(sU/opt/alt/python36/lib/python3.6/site-packages/pip/_vendor/distlib/_backport/shutil.pyt_set_uid_gid�s		sw|%sRGN(ROt_BZ2_SUPPORTEDt
ValueErrortformattgetR'R(tdirnameRTtinfoRPR|R{RR4taddtclose(t	base_nametbase_dirtcompresstverbosetdry_runR�R�tloggerttar_compressiontcompress_exttarchive_nametarchive_dirR�ttar((R�R�R�R�sU/opt/alt/python36/lib/python3.6/site-packages/pip/_vendor/distlib/_backport/shutil.pyt
_make_tarballxs4


		cCs}|rd}nd}ddlm}ddlm}y |d|||gd|�Wn!|k
rxtd�|�nXdS(	Ns-rs-rqi����(tDistutilsExecError(tspawntzipR�skunable to create zip file '%s': could neither import the 'zipfile' module nor find a standalone zip utility(tdistutils.errorsR�tdistutils.spawnR�R(R�tzip_filenameR�R�t
zipoptionsR�R�((sU/opt/alt/python36/lib/python3.6/site-packages/pip/_vendor/distlib/_backport/shutil.pyt_call_external_zip�s	 
	cCs�|d}tjj|�}tjj|�sf|dk	rM|jd|�n|sftj|�qfnyddl}Wntk
r�d}nX|dkr�t	||||�n�|dk	r�|jd||�n|s�|j
|dd|j�}x�tj|�D]�\}	}
}xs|D]k}tjj
tjj|	|��}
tjj|
�r|j|
|
�|dk	r�|jd|
�q�qqWqW|j�n|S(	smCreate a zip file from all the files under 'base_dir'.

    The output zip file will be named 'base_name' + ".zip".  Uses either the
    "zipfile" Python module (if available) or the InfoZIP "zip" utility
    (if installed and found on the default search path).  If neither tool is
    available, raises ExecError.  Returns the name of the output zip
    file.
    s.zipscreating %si����Ns#creating '%s' and adding '%s' to ittwtcompressionsadding '%s'(R'R(R�RTROR�RPtzipfiletImportErrorR�tZipFiletZIP_DEFLATEDtwalktnormpathRCtisfileR R�(R�R�R�R�R�R�R�R�R�tdirpathtdirnamest	filenamesR`R(((sU/opt/alt/python36/lib/python3.6/site-packages/pip/_vendor/distlib/_backport/shutil.pyt
_make_zipfile�s8	


	

!
R�sgzip'ed tar-filetgztarR�sbzip2'ed tar-filetbztarsuncompressed tar fileR�sZIP fileR�cCs=gtj�D]\}}||df^q
}|j�|S(s�Returns a list of supported formats for archiving and unarchiving.

    Each element of the returned sequence is a tuple (name, description)
    i(t_ARCHIVE_FORMATStitemstsort(R`tregistrytformats((sU/opt/alt/python36/lib/python3.6/site-packages/pip/_vendor/distlib/_backport/shutil.pyRs,
RcCs�|dkrg}nt|t�s7td|��nt|ttf�s[td��nxE|D]=}t|ttf�s�t|�dkrbtd��qbqbW|||ft|<dS(suRegisters 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.
    sThe %s object is not callables!extra_args needs to be a sequenceis+extra_args elements are : (arg_name, value)N(RORZRt	TypeErrorttupletlisttlenR�(R`tfunctiont
extra_argstdescriptiontelement((sU/opt/alt/python36/lib/python3.6/site-packages/pip/_vendor/distlib/_backport/shutil.pyRs		
(cCst|=dS(N(R�(R`((sU/opt/alt/python36/lib/python3.6/site-packages/pip/_vendor/distlib/_backport/shutil.pyR sc	Csktj�}	|d
k	rb|d
k	r7|jd|�ntjj|�}|sbtj|�qbn|d
krztj}ni|d6|d6}
yt|}Wn!t	k
r�t
d|��nX|d}x"|dD]\}
}||
|
<q�W|dkr||
d<||
d	<nz||||
�}Wd
|d
k	rf|d
k	rV|jd|	�ntj|	�nX|S(s�Create an archive file (eg. zip or tar).

    'base_name' is the name of the file to create, minus any format-specific
    extension; 'format' is the archive format: one of "zip", "tar", "bztar"
    or "gztar".

    'root_dir' is a directory that will be the root directory of the
    archive; ie. we typically chdir into 'root_dir' before creating the
    archive.  'base_dir' is the directory where we start archiving from;
    ie. 'base_dir' will be the common prefix of all files and
    directories in the archive.  'root_dir' and 'base_dir' both default
    to the current directory.  Returns the name of the archive file.

    'owner' and 'group' are used when creating a tar archive. By default,
    uses the current owner and group.
    schanging into '%s'R�R�sunknown archive format '%s'iiR�R�R�Nschanging back to '%s'(R'tgetcwdROtdebugR(RtchdirtcurdirR�RyR�(R�R�troot_dirR�R�R�R�R�R�tsave_cwdtkwargstformat_infotfunctargtvaltfilename((sU/opt/alt/python36/lib/python3.6/site-packages/pip/_vendor/distlib/_backport/shutil.pyR#s6



cCsDgtj�D]#\}}||d|df^q
}|j�|S(s�Returns a list of supported formats for unpacking.

    Each element of the returned sequence is a tuple
    (name, extensions, description)
    ii(t_UNPACK_FORMATSR�R�(R`R�R�((sU/opt/alt/python36/lib/python3.6/site-packages/pip/_vendor/distlib/_backport/shutil.pyRZs3
c	Cs�i}x9tj�D]+\}}x|dD]}|||<q*WqWx=|D]5}||krId}t||||f��qIqIWt|t�s�td��ndS(s+Checks what gets registered as an unpacker.is!%s is already registered for "%s"s*The registered function must be a callableN(R�R�RRZRR�(	t
extensionsR�R�texisting_extensionsR`R�textt	extensiontmsg((sU/opt/alt/python36/lib/python3.6/site-packages/pip/_vendor/distlib/_backport/shutil.pyt_check_unpack_optionses
	cCs?|dkrg}nt|||�||||ft|<dS(sMRegisters 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(ROR�R�(R`R�R�R�R�((sU/opt/alt/python36/lib/python3.6/site-packages/pip/_vendor/distlib/_backport/shutil.pyRws	cCst|=dS(s*Removes the pack format from the registry.N(R�(R`((sU/opt/alt/python36/lib/python3.6/site-packages/pip/_vendor/distlib/_backport/shutil.pyR�scCs8tjj|�}tjj|�s4tj|�ndS(s1Ensure that the parent directory of `path` existsN(R'R(R�RBRP(R(R�((sU/opt/alt/python36/lib/python3.6/site-packages/pip/_vendor/distlib/_backport/shutil.pyt_ensure_directory�sc	CsAyddl}Wntk
r/td��nX|j|�sRtd|��n|j|�}z�x�|j�D]�}|j}|jd�sqd|kr�qqntj	j
||jd��}|s�qqnt|�|j
d�sq|j|j�}t|d�}z|j|�Wd|j�~XqqqqWWd|j�XdS(s+Unpack zip `filename` to `extract_dir`
    i����Ns/zlib not supported, cannot unpack this archive.s%s is not a zip filet/s..R0(R�R�Rt
is_zipfileR�tinfolistR�RxR'R(RCtsplitR�RwRR4R R�(	R�textract_dirR�R�R�R`ttargettdatatf((sU/opt/alt/python36/lib/python3.6/site-packages/pip/_vendor/distlib/_backport/shutil.pyt_unpack_zipfile�s0
	

cCs]ytj|�}Wn$tjk
r9td|��nXz|j|�Wd|j�XdS(s:Unpack tar/tar.gz/tar.bz2 `filename` to `extract_dir`
    s/%s is not a compressed or uncompressed tar fileN(RR4tTarErrorRt
extractallR�(R�R�ttarobj((sU/opt/alt/python36/lib/python3.6/site-packages/pip/_vendor/distlib/_backport/shutil.pyt_unpack_tarfile�ss.tar.gzs.tgzs.tars.zips.bz2cCsIxBtj�D]4\}}x%|dD]}|j|�r$|Sq$Wq
WdS(Ni(R�R�RwRO(R�R`R�R�((sU/opt/alt/python36/lib/python3.6/site-packages/pip/_vendor/distlib/_backport/shutil.pyt_find_unpack_format�s
cCs�|dkrtj�}n|dk	r�yt|}Wn&tk
r]tdj|���nX|d}|||t|d��nbt|�}|dkr�t	dj|���nt|d}tt|d�}||||�dS(s�Unpack an archive.

    `filename` is the name of the archive.

    `extract_dir` is the name of the target directory, where the archive
    is unpacked. If not provided, the current working directory is used.

    `format` is the archive format: one of "zip", "tar", or "gztar". Or any
    other registered format. If not provided, unpack_archive will use the
    filename extension and see if an unpacker was registered for that
    extension.

    In case none is found, a ValueError is raised.
    sUnknown unpack format '{0}'iisUnknown archive format '{0}'N(
ROR'R�R�RyR�R�tdictR�R(R�R�R�R�R�R�((sU/opt/alt/python36/lib/python3.6/site-packages/pip/_vendor/distlib/_backport/shutil.pyR�s

i@(scompresssgzip(scompresssbzip2(scompressN(scompresssbzip2(BRR'RfR1tos.pathRRFtcollections.abcRR�tcollectionsR@RRR�RtR�R*tpwdRROtgrpRt__all__RVRRRRt	ExceptionRRYt	NameErrorRR.RRRR	R
RRR
RqRRsR{R|R�R�R�R�RRRRRR�RRR�R�R�R�R�R(((sU/opt/alt/python36/lib/python3.6/site-packages/pip/_vendor/distlib/_backport/shutil.pyt<module>
s�







	

								Q1		(					=/		
		6					%	
	

Zerion Mini Shell 1.0