usr/lib/python2.7/site-packages/pip/download.pyo000064400000062326147205235710015562 0ustar00 abc @@sddlmZddlZddlZddlZddlZddlZddlZddl Z ddl Z ddl Z ddl Z ddl Z ddlZyddlZeZWnek reZnXddlmZddlmZddlZddlmZmZddlmZddlm Z m!Z!m"Z"m#Z#m$Z$m%Z%m&Z&m'Z'm(Z(m)Z)ddl*m+Z+dd l,m-Z-dd l.m/Z/dd l0m1Z1dd l2m3Z3dd l4m5Z5m6Z6ddl7m8Z8ddl9m:Z:ddl;m<Z<m=Z=ddl>m?Z?m@Z@ddlAmBZBmCZCddlDmEZEmFZFddlGmHZHddlImJZJddl;mKZKddlLmMZMddlNmOZOddlPmQZQddlRmSZSdddddd d!d"d#d$d%d&d'g ZTejUeVZWd(ZXd)eBfd*YZYd+e?fd,YZZd-eOfd.YZ[d/e@fd0YZ\d1e<j]fd2YZ^ddd3Z`e jad4e jbZce jad5e jbZdd6Zed7Zfd8Zgd9Zhd:Zid;Zjd<Zkd=Zld>Zmd?Znd@ZodAZpddddBZqdddCZrdDZsdEeSjtfdFYZudedddGZvdHZwdIZxdJZydKZzdS(Li(tabsolute_importN(tparse(trequest(tInstallationErrort HashMismatch(tPyPI( tsplitexttrmtreet format_sizet display_patht backup_dirtask_path_existst unpack_filetARCHIVE_EXTENSIONStconsumetcall_subprocess(t auto_decode(tcheck_path_owner(t indent_log(tSETUPTOOLS_SHIM(tlibc_ver(tDownloadProgressBartDownloadProgressSpinner(twrite_delete_marker_file(tvcs(trequeststsix(t BaseAdaptert HTTPAdapter(tAuthBaset HTTPBasicAuth(tCONTENT_CHUNK_SIZEtResponse(tget_netrc_auth(tCaseInsensitiveDict(turllib3(tCacheControlAdapter(t FileCache(t LockError(t xmlrpc_clienttget_file_contenttis_urlt url_to_patht path_to_urltis_archive_filetunpack_vcs_linktunpack_file_urlt is_vcs_urlt is_file_urltunpack_http_urlt unpack_urltparse_content_dispositiontsanitize_content_filenamec C@siidd6tjd6d6tjd6itjd6d6}|dddkrjtj|dd`ttidcS@s|dS(Ni((RC((s0/usr/lib/python2.7/site-packages/pip/download.pyRDdREtlibtlibcRBtdarwintmacOStsystemtreleasetcpuiitopenssl_versions9{data[installer][name]}/{data[installer][version]} {json}tdatatjsont separatorst,t:t sort_keys(ii(RRRS(R5t __version__tplatformtpython_versiontpython_implementationtsystpypy_version_infot releaseleveltjointstrt startswitht pip._vendorRBtdicttfiltertziptlinux_distributionRtmac_verRKt setdefaultRLtmachinetHAS_TLSt version_infotssltOPENSSL_VERSIONtformatRPtdumpstTrue(RORZRCRBt distro_infosRH((s0/usr/lib/python2.7/site-packages/pip/download.pyt user_agent@sT  -$ "%    tMultiDomainBasicAuthcB@s/eZedZdZdZdZRS(cC@s||_i|_dS(N(t promptingt passwords(tselfRq((s0/usr/lib/python2.7/site-packages/pip/download.pyt__init__s cC@s.tj|j}|jjddd}tj|d |f|d|_|jj|d\}}|dkr|j |j\}}n|dkr|dkrt |j}|r|nd\}}n|s|r||f|j||jddS|dfSdS(NRuiiRS(NN(R{tsplitR~(RsRztuserinfo((s0/usr/lib/python2.7/site-packages/pip/download.pyRs    (t__name__t __module__RmRtRRR(((s0/usr/lib/python2.7/site-packages/pip/download.pyRps  ! "tLocalFSAdaptercB@s)eZddddddZdZRS(c C@st|j}t}d|_|j|_ytj|} Wn%tk rg} d|_| |_n}Xtj j | j dt } t j|dpd} ti| d6| jd6| d6|_t|d |_|jj|_|S( Niitusegmtis text/plains Content-TypesContent-Lengths Last-Modifiedtrb(R*RyR RtoststattOSErrorRtemailtutilst formatdatetst_mtimeRmt mimetypest guess_typeR"tst_sizetheaderstopentclose( RsRtstreamttimeouttverifytcerttproxiestpathnameRtstatstexctmodifiedt content_type((s0/usr/lib/python2.7/site-packages/pip/download.pyRs$      cC@sdS(N((Rs((s0/usr/lib/python2.7/site-packages/pip/download.pyRsN(RRR~RR(((s0/usr/lib/python2.7/site-packages/pip/download.pyRs  t SafeFileCachecB@s2eZdZdZdZdZdZRS(sw A file based cache which is safe to use even when the target directory may not be accessible or writable. cO@sKtt|j||t|jsGtjd|jd|_ndS(NsThe directory '%s' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.(tsuperRRtRt directorytloggertwarningR~(RstargsR((s0/usr/lib/python2.7/site-packages/pip/download.pyRts  cO@sQ|jdkrdSytt|j||SWntttfk rLnXdS(N(RR~RRR}R&RtIOError(RsRR((s0/usr/lib/python2.7/site-packages/pip/download.pyR}s cO@sQ|jdkrdSytt|j||SWntttfk rLnXdS(N(RR~RRtsetR&RR(RsRR((s0/usr/lib/python2.7/site-packages/pip/download.pyRs cO@sQ|jdkrdSytt|j||SWntttfk rLnXdS(N(RR~RRtdeleteR&RR(RsRR((s0/usr/lib/python2.7/site-packages/pip/download.pyR)s (RRt__doc__RtR}RR(((s0/usr/lib/python2.7/site-packages/pip/download.pyRs   tInsecureHTTPAdaptercB@seZdZRS(cC@sd|_d|_dS(Nt CERT_NONE(t cert_reqsR~tca_certs(RstconnRyRR((s0/usr/lib/python2.7/site-packages/pip/download.pyt cert_verify9s (RRR(((s0/usr/lib/python2.7/site-packages/pip/download.pyR7st PipSessioncB@s eZdZdZdZRS(c O@s5|jdd}|jdd}|jdg}tt|j||t|jds    *  s^(http|https|file):s /*([a-z])\|cC@sId|krtS|jdddj}|ddddgtjkS(s)Returns true if the name looks like a URLRSiiRthttpsRtftp(tFalseRRRt all_schemes(R6R((s0/usr/lib/python2.7/site-packages/pip/download.pyR)s cC@sHtj|\}}}}}|r1d|}ntj||}|S(s( Convert a file: URL to a path. s\\(Rwturlsplitturllib_requestt url2pathname(Ryt_RzR((s0/usr/lib/python2.7/site-packages/pip/download.pyR*s  cC@s=tjjtjj|}tjdtj|}|S(sh Convert a path to a file: URL. The path will be made absolute and have quoted path parts. sfile:(RRtnormpathtabspathRwturljoinRt pathname2url(RRy((s0/usr/lib/python2.7/site-packages/pip/download.pyR+scC@s*t|dj}|tkr&tStS(s9Return True if `name` is a considered as an archive file.i(RRR RmR(R6text((s0/usr/lib/python2.7/site-packages/pip/download.pyR,s cC@st|}|j|dS(N(t_get_used_vcs_backendtunpack(tlinktlocationt vcs_backend((s0/usr/lib/python2.7/site-packages/pip/download.pyR-s cC@s=x6tjD]+}|j|jkr ||j}|Sq WdS(N(RtbackendsRtschemesRy(RtbackendR((s0/usr/lib/python2.7/site-packages/pip/download.pyRscC@stt|S(N(tboolR(R((s0/usr/lib/python2.7/site-packages/pip/download.pyR/scC@s|jjjdS(Nsfile:(RyRR^(R((s0/usr/lib/python2.7/site-packages/pip/download.pyR0scC@st|j}tjj|S(sReturn whether a file:// Link points to a directory. ``link`` must not have any other scheme but file://. Call is_file_url() first. (R*turl_without_fragmentRRtisdir(Rt link_path((s0/usr/lib/python2.7/site-packages/pip/download.pyt is_dir_urlscO@s|S(N((titerableRR((s0/usr/lib/python2.7/site-packages/pip/download.pyt_progress_indicatorsc @sytjd}Wn tttfk r9d}nXtdt}tjt j krjt}n9|ryt}n*|d krt }n|st }nt}|j }fd}fd} t } |jtjkr|} n |j} |rM|r.tjd| t|td |j} qvtjd | tj} n)|rftjd | ntjd | tjd || | |tt} |r|j| n t| dS(Nscontent-lengthit from_cachei(ic3@sry,x%jj|dtD] }|VqWWn?tk rmx/trijj|}|saPn|Vq?WnXdS(Ntdecode_content(RRRtAttributeErrorRmR(t chunk_sizetchunk(R(s0/usr/lib/python2.7/site-packages/pip/download.pyt resp_reads     c3@s'x |D]}j||VqWdS(N(twrite(tchunksR (t content_file(s0/usr/lib/python2.7/site-packages/pip/download.pytwritten_chunks;s  sDownloading %s (%s)tmaxsDownloading %ssUsing cached %ssDownloading from URL %si@(tintRt ValueErrortKeyErrorRtgetattrRRtgetEffectiveLeveltloggingtINFORmtshow_urlRRzRRtinfoRRtiterRtdebugRtcheck_against_chunksR( RRRthashest total_lengtht cached_respt show_progressRR Rtprogress_indicatorRytdownloaded_chunks((RRs0/usr/lib/python2.7/site-packages/pip/download.pyt _download_urlsL       %    cC@s,t}tjj||j}tjj|rtdt|d }|dkr^t}q|dkrt j dt|tj |q|dkrt |}t j dt|t|t j||q|dkrtjdqn|r(t j||t jd t|ndS( Ns8The file %s exists. (i)gnore, (w)ipe, (b)ackup, (a)aborttitwtbtas Deleting %ssBacking up %s to %sisSaved %s(R%R&R'R((RmRRR\tfilenametexistsR R RRRtremoveR tshutiltmoveRYtexittcopyR(R)RRR/tdownload_locationRvt dest_file((s0/usr/lib/python2.7/site-packages/pip/download.pyt _copy_fileas.        c C@s|dkrtdntjdd}d}|rNt|||}n|rp|}tj|d}nt||||\}}t|||||r| rt |||n|st j |nt |dS(Ns@unpack_http_url() missing 1 required keyword argument: 'session's-unpackspip-i( R~Rttempfiletmkdtempt_check_download_dirRRt_download_http_urlR R2RtunlinkR( RRt download_dirRRttemp_dirtalready_downloaded_patht from_pathR((s0/usr/lib/python2.7/site-packages/pip/download.pyR1|s,    cC@st|j}t|rjtjj|r:t|ntj||dt |rft j dndS|r|j |nd}|rt|||}n|r|}n|}tj|d}t|||||r| rt|||ndS(sUnpack link into location. If download_dir is provided and link points to a file, make a copy of the link file inside download_dir. tsymlinkss*Link is a directory, ignoring download_dirNi(R*RRRRRRR,tcopytreeRmRRtcheck_against_pathR~R5RRR R2(RRR8RRR:R;R((s0/usr/lib/python2.7/site-packages/pip/download.pyR.s,     c C@stjj|rt|nd}tjg}|jd|jt||jd|d|g7}tj d|t t |d|dt WdQXtjj |tj|d }tj d ||t||d dd ddS( sCopy distribution files in `link_path` to `location`. Invoked when user requests to install a local directory. E.g.: pip install . pip install ~/dev/git-repos/python-prompt-toolkit ssetup.pys-ctsdists --dist-dirsRunning setup.py sdist for %stcwdt show_stdoutNisUnpacking sdist %s into %sRR(RRRRRYt executableRRRRRRRR\tlistdirR R~(RRtsetup_pyt sdist_argsR?((s0/usr/lib/python2.7/site-packages/pip/download.pyt_copy_dist_from_dirs     "tPipXmlrpcTransportcB@s&eZdZedZedZRS(sRProvide a `xmlrpclib.Transport` implementation via a `PipSession` object. cC@s;tjj||tj|}|j|_||_dS(N(R't TransportRtRwRxRt_schemet_session(Rst index_urlRt use_datetimet index_parts((s0/usr/lib/python2.7/site-packages/pip/download.pyRts c C@s|j||dddf}tj|}yXidd6}|jj|d|d|dt}|j||_|j |j SWn2t j k r} t jd| jj|nXdS(Nstext/xmls Content-TypeRORRsHTTP error %s while getting %s(RIR~RwR|RJtpostRmRtverbosetparse_responseRRt HTTPErrorRtcriticalRvR( RsRthandlert request_bodyROtpartsRyRRvR((s0/usr/lib/python2.7/site-packages/pip/download.pyRs   (RRRRRtR(((s0/usr/lib/python2.7/site-packages/pip/download.pyRGs cC@st|rt||nVt|rAt|||d|n1|dkrYt}nt||||d||rt|ndS(svUnpack link. If link is a VCS link: if only_download, export into download_dir and ignore location else unpack into location for other types of link: - unpack into location - if download_dir, copy the file into download_dir - if only_download, mark location for deletion :param hashes: A Hashes object, one of whose embedded hashes must match, or HashMismatch will be raised. If the Hashes is empty, no matches are required, and unhashable types of requirements (like VCS ones, which would ordinarily raise HashUnsupported) are allowed. RN(R/R-R0R.R~RR1R(RRR8t only_downloadRR((s0/usr/lib/python2.7/site-packages/pip/download.pyR2s    cC@stjj|S(sJ Sanitize the "filename" value from a Content-Disposition header. (RRtbasename(R)((s0/usr/lib/python2.7/site-packages/pip/download.pyR4<scC@sCtj|\}}|jd}|r9t|}n|pB|S(s Parse the "filename" value from a Content-Disposition header, and return the default filename if the result is empty. R)(tcgit parse_headerR}R4(tcontent_dispositiontdefault_filenamet_typetparamsR)((s0/usr/lib/python2.7/site-packages/pip/download.pyR3Ds c C@s|jjddd}y0|j|didd6dt}|jWn2tjk r}}tjd|j j |nX|j jd d }|j }|j jd } | rt | |}nt|d} | stj|} | r|| 7}qn| rI|j|jkrItjj|jd} | rI|| 7}qIntjj||} t| d } t||| |Wd QX| |fS(s6Download link url into temp_dir using provided sessiont#iiRtidentitysAccept-EncodingRsHTTP error %s while getting %ss content-typeREscontent-dispositiontwbN(RyRR}RmRRRQRRRRvRRR)R3RRtguess_extensionRRR\RR$( RRR9Rt target_urlRRRR)RZRt file_pathR((s0/usr/lib/python2.7/site-packages/pip/download.pyR6Ss:   cC@stjj||j}tjj|rtjd||ry|j|Wqtk rtj d|tj |dSXn|SdS(s Check download_dir for previously downloaded file with correct hash If a correct file is found return its path else None sFile was already downloaded %ss;Previously-downloaded file %s has bad hash. Re-downloading.N( RRR\R)R*RRR>RRR7R~(RR8Rt download_path((s0/usr/lib/python2.7/site-packages/pip/download.pyR5s  ({t __future__RRXt email.utilsRRRPRRRRVtreR,RYR3RiRmRgt ImportErrorRtpip._vendor.six.moves.urllibRRwRRR5tpip.exceptionsRRt pip.modelsRt pip.utilsRRRR R R R R RRtpip.utils.encodingRtpip.utils.filesystemRtpip.utils.loggingRtpip.utils.setuptools_buildRtpip.utils.glibcRt pip.utils.uiRRt pip.locationsRtpip.vcsRR_RRtpip._vendor.requests.adaptersRRtpip._vendor.requests.authRRtpip._vendor.requests.modelsRR tpip._vendor.requests.utilsR!tpip._vendor.requests.structuresR"R#tpip._vendor.cachecontrolR$tpip._vendor.cachecontrol.cachesR%tpip._vendor.lockfileR&tpip._vendor.six.movesR't__all__t getLoggerRRRoRpRRRtSessionRR~R(tcompiletIRRR)R*R+R,R-RR/R0RRR$R2R1R.RFRHRGR2R4R3R6R5(((s0/usr/lib/python2.7/site-packages/pip/download.pyts                 F    BR!BH)         ` &0 $'   8