Viewing File: /opt/alt/python35/lib/python3.5/site-packages/pip/_internal/utils/unpacking.pyc

ó
“tÆ_c@@sÛdZddlmZddlZddlZddlZddlZddlZddlZddl	m
Z
ddlmZm
Z
mZmZddlmZddlmZerñddlmZmZmZmZmZdd	lmZnejeƒZee
ZyddlZee7ZWne k
rDej!d
ƒnXyddl"Z"ee7ZWne k
rej!dƒnXd„Z#d
„Z$d„Z%d„Z&d„Z'd„Z(e)d„Z*d„Z+dd„Z-dS(sUtilities related archives.
i(tabsolute_importN(tInstallationError(tBZ2_EXTENSIONStTAR_EXTENSIONSt
XZ_EXTENSIONStZIP_EXTENSIONS(t
ensure_dir(tMYPY_CHECK_RUNNING(tIterabletListtOptionaltTexttUnion(tZipInfosbz2 module is not availableslzma module is not availablecC@s tjdƒ}tj|ƒ|S(sBGet the current umask which involves having to set it temporarily.i(tostumask(tmask((sN/opt/alt/python35/lib/python3.5/site-packages/pip/_internal/utils/unpacking.pyt
current_umask/s
cC@s”|jdƒjdƒ}d|krjd|krN|jdƒ|jdƒksZd|krj|jddƒSd|kr†|jddƒS|dgSdS(Nt/s\it(tlstriptfindtsplit(tpath((sN/opt/alt/python35/lib/python3.5/site-packages/pip/_internal/utils/unpacking.pytsplit_leading_dir7s*cC@s\d}xO|D]G}t|ƒ\}}|s/tS|dkrD|}q
||kr
tSq
WtS(syReturns true if all the paths have the same leading path name
    (i.e., everything is in one subdirectory in an archive)N(tNoneRtFalsetTrue(tpathst
common_prefixRtprefixtrest((sN/opt/alt/python35/lib/python3.5/site-packages/pip/_internal/utils/unpacking.pythas_leading_dirGs
	cC@sFtjj|ƒ}tjj|ƒ}tjj||gƒ}||kS(sL
    Return true if the absolute path of target is within the directory
    (RRtabspathtcommonprefix(t	directoryttargett
abs_directoryt
abs_targetR((sN/opt/alt/python35/lib/python3.5/site-packages/pip/_internal/utils/unpacking.pytis_within_directoryWscC@s tj|dtƒ@dBƒdS(sx
    Make file present at path have execute for user/group/world
    (chmod +x) is no-op on windows per python docs
    iÿiIN(RtchmodR(R((sN/opt/alt/python35/lib/python3.5/site-packages/pip/_internal/utils/unpacking.pyt2set_extracted_file_to_default_mode_plus_executablecscC@s0|jd?}t|o,tj|ƒo,|d@ƒS(NiiI(t
external_attrtbooltstattS_ISREG(tinfotmode((sN/opt/alt/python35/lib/python3.5/site-packages/pip/_internal/utils/unpacking.pytzip_item_is_executablels
c

C@sŒt|ƒt|dƒ}zatj|dtƒ}t|jƒƒoF|}x-|jƒD]}|j}|}|r„t	|ƒd}nt
jj||ƒ}t
jj
|ƒ}	t||ƒsÞd}
t|
j|||ƒƒ‚n|jdƒsü|jdƒr	t|ƒqVt|	ƒ|j|ƒ}z,t|dƒ}tj||ƒWdQXWd|jƒt|ƒrtt|ƒnXqVWWd|jƒXdS(	sŸ
    Unzip the file (with path `filename`) to the destination `location`.  All
    files are written based on system defaults and umask (i.e. permissions are
    not preserved), except that regular file members with any execute
    permissions (user, group, or world) have "chmod +x" applied after being
    written. Note that for windows, any execute changes using os.chmod are
    no-ops per the python docs.
    trbt
allowZip64isQThe zip file ({}) has a file ({}) trying to install outside target directory ({})Rs\twbN(RtopentzipfiletZipFileRR tnamelisttinfolisttfilenameRRRtjointdirnameR'RtformattendswithtshutiltcopyfileobjtcloseR0R)(
R9tlocationtflattentzipfptziptleadingR.tnametfntdirtmessagetfptdestfp((sN/opt/alt/python35/lib/python3.5/site-packages/pip/_internal/utils/unpacking.pyt
unzip_filets4

	


c	C@s»t|ƒ|jƒjdƒs4|jƒjdƒr=d}np|jƒjtƒr[d}nR|jƒjtƒryd}n4|jƒjdƒr—d}ntjd|ƒd	}tj||ƒ}zêt	g|j
ƒD]}|j^qÒƒ}x»|j
ƒD]­}|j}|rt|ƒd
}nt
jj||ƒ}t||ƒsgd}t|j|||ƒƒ‚n|jƒr€t|ƒq÷|jƒrÕy|j||ƒWq¤tk
rÑ}	tjd||j|	ƒq÷q¤Xq÷y|j|ƒ}
Wn5ttfk
r}	tjd||j|	ƒq÷nXtt
jj|ƒƒ|
dk	sHt‚t|d
ƒ}tj|
|ƒWdQX|
jƒ|j ||ƒ|j!d@r÷t"|ƒq÷q÷WWd|jƒXdS(sŸ
    Untar the file (with path `filename`) to the destination `location`.
    All files are written based on system defaults and umask (i.e. permissions
    are not preserved), except that regular file members with any execute
    permissions (user, group, or world) have "chmod +x" applied after being
    written.  Note that for windows, any execute changes using os.chmod are
    no-ops per the python docs.
    s.gzs.tgzsr:gzsr:bz2sr:xzs.tartrs-Cannot determine compression type for file %ssr:*isQThe tar file ({}) has a file ({}) trying to install outside target directory ({})s/In the tar file %s the member %s is invalid: %sR3NiI(#RtlowerR=RRtloggertwarningttarfileR4R t
getmembersRFRRRR:R'RR<tisdirtissymt_extract_membert	ExceptiontextractfiletKeyErrortAttributeErrorR;RtAssertionErrorR>R?R@tutimeR/R)(R9RAR/ttartmemberRERGRRItexcRJRK((sN/opt/alt/python35/lib/python3.5/site-packages/pip/_internal/utils/unpacking.pyt
untar_file£sf

*				
%	



c	C@sÙtjj|ƒ}|dksB|jƒjtƒsBtj|ƒrbt||d|jdƒƒns|dksšt	j
|ƒsš|jƒjttt
ƒrªt||ƒn+tjd|||ƒtdj|ƒƒ‚dS(Nsapplication/zipRBs.whlsapplication/x-gzipsZCannot unpack file %s (downloaded from %s, content-type: %s); cannot detect archive formats%Cannot determine archive format of {}(RRtrealpathRNR=RR5t
is_zipfileRLRQt
is_tarfileRRRR_ROtcriticalRR<(R9RAtcontent_type((sN/opt/alt/python35/lib/python3.5/site-packages/pip/_internal/utils/unpacking.pytunpack_fileös$
(.t__doc__t
__future__RtloggingRR>R,RQR5tpip._internal.exceptionsRtpip._internal.utils.filetypesRRRRtpip._internal.utils.miscRtpip._internal.utils.typingRttypingRR	R
RRR
t	getLoggert__name__ROtSUPPORTED_EXTENSIONStbz2tImportErrortdebugtlzmaRRR R'R)R0RRLR_RRe(((sN/opt/alt/python35/lib/python3.5/site-packages/pip/_internal/utils/unpacking.pyt<module>sF"(


							/	V
Back to Directory File Manager