Your IP : 3.133.124.80


Current Path : /opt/alt/python36/lib/python3.6/site-packages/setuptools/__pycache__/
Upload File :
Current File : //opt/alt/python36/lib/python3.6/site-packages/setuptools/__pycache__/package_index.cpython-36.pyc

3

K�Re;��@s�dZddlZddlZddlZddlZddlZddlZddlZddlZddl	m
Z
yddlmZWn e
k
r�ddlmZYnXddlmZddlmZmZmZmZddlZddlmZmZmZmZmZmZmZmZm Z m!Z!m"Z"m#Z#m$Z$ddlm%Z%dd	l&m'Z'dd
l(m)Z)ddl*m+Z+ddl,m-Z-dd
l.m/Z/ej0d�Z1ej0dej2�Z3ej0d�Z4ej0dej2�j5Z6dj7�Z8ddddgZ9dZ:dZ;e;j<ej=dd�ed�Z>dd�Z?dd�Z@dd�ZAdGd d�ZBdHd!d"�ZCdId#d$�ZDdedfd%d�ZEdJd&d'�ZFd(d)�ZGej0d*ej2�ZHeGd+d,��ZIGd-d.�d.eJ�ZKGd/d0�d0eK�ZLGd1d�de�ZMej0d2�jNZOd3d4�ZPd5d6�ZQd7d8�ZRdKd9d:�ZSd;d<�ZTGd=d>�d>eJ�ZUGd?d@�d@ejV�ZWejXjYfdAdB�ZZeSe:�eZ�ZZdCdD�Z[dEdF�Z\dS)Lz#PyPI and direct package downloading�N)�wraps)�	splituser)�six)�urllib�http_client�configparser�map)
�
CHECKOUT_DIST�Distribution�BINARY_DIST�normalize_path�SOURCE_DIST�Environment�find_distributions�	safe_name�safe_version�to_filename�Requirement�DEVELOP_DIST�EGG_DIST)�ssl_support)�log)�DistutilsError)�	translate)�get_all_headers)�Wheelz^egg=([-A-Za-z0-9_.+!]+)$zhref\s*=\s*['"]?([^'"> ]+)z�<a href="([^"#]+)">([^<]+)</a>
\s+\(<a (?:title="MD5 hash"
\s+)href="[^?]+\?:action=show_md5&amp;digest=([0-9a-f]{32})">md5</a>\)z([-+.a-z0-9]{2,}):z.tar.gz .tar.bz2 .tar .zip .tgz�PackageIndex�distros_for_url�parse_bdist_wininst�interpret_distro_name�z<setuptools/{setuptools.__version__} Python-urllib/{py_major}�)Zpy_major�
setuptoolscCs2y
tj|�Stk
r,td|f��YnXdS)Nz1Not a URL, existing file, or requirement spec: %r)r�parse�
ValueErrorr)�spec�r&��/builddir/build/BUILDROOT/alt-python36-setuptools-38.5.2-7.el8.x86_64/opt/alt/python36/lib/python3.6/site-packages/setuptools/package_index.py�parse_requirement_arg6s

r(cCs�|j�}d\}}}|jd�r�|jd�r8|dd�}d}nn|jdd�rb|dd�}|dd�}d}nD|jd
�r~|dd�}d}n(|jd
d�r�|dd�}|dd�}d}|||fS)z=Return (base,pyversion) or (None,None) for possible .exe nameNz.exez
.win32.exe�
�win32z	.win32-py���z.win-amd64.exe�z	win-amd64z
.win-amd64-py�)NNNi����i�i�������i�i�i��i����r0i��)�lower�endswith�
startswith)�namer1�base�py_ver�platr&r&r'r?s$



c	Csxtjj|�}|\}}}}}}tjj|jd�d�}|dkrX|dkrXtjj|jd�d�}d|krp|jdd�\}}||fS)	N�/�zsourceforge.net�download��#������)rr#�urlparse�unquote�split)	�url�parts�scheme�server�path�
parameters�query�fragmentr5r&r&r'�egg_info_for_urlWsrJccsdt|�\}}xt|||�D]
}|VqW|r`tj|�}|r`x$t||jd�|td�D]
}|VqRWdS)zEYield egg or source distribution objects that might be found at a URLr9)�
precedenceN)rJ�distros_for_location�EGG_FRAGMENT�matchr�groupr	)rB�metadatar5rI�distrNr&r&r'rbs

cCs�|jd�r|dd
�}|jd�r8d|kr8tj|||�gS|jd�rxd|krxt|�}|j�s^gSt||j|jtdd�gS|jd	�r�t|�\}}}|dk	r�t	||||t
|�Sx4tD],}|j|�r�|dt|��}t	|||�Sq�WgS)z:Yield egg or source distribution objects based on basenamez.egg.zipNr-z.egg�-z.whlr9)�location�project_name�versionrKz.exer0)
r2r
�
from_locationr�
is_compatiblerTrUrrrr�
EXTENSIONS�len)rS�basenamerP�wheelZwin_baser6�platform�extr&r&r'rLps.



rLcCstt|�tjj|�|�S)zEYield possible egg or source distribution objects based on a filename)rLr�osrFrZ)�filenamerPr&r&r'�distros_for_filename�sr`c
cs�|jd�}|r.tdd�|dd�D��r.dSxNtdt|�d�D]8}t||dj|d|��dj||d��|||d�VqBWdS)z�Generate alternative interpretations of a source distro name

    Note: if `location` is a filesystem filename, you should call
    ``pkg_resources.normalize_path()`` on it before passing it to this
    routine!
    rRcss|]}tjd|�VqdS)z	py\d\.\d$N)�rerN)�.0�pr&r&r'�	<genexpr>�sz(interpret_distro_name.<locals>.<genexpr>r;Nr9)�
py_versionrKr\)rA�any�rangerYr
�join)rSrZrPrerKr\rCrcr&r&r'r�s
 $ccsnt�}|j}|dkr>xTtjj|j|�D]}||�|Vq&Wn,x*|D]"}||�}||krD||�|VqDWdS)zHList unique elements, preserving order. Remember all elements ever seen.N)�set�addr�moves�filterfalse�__contains__)�iterable�key�seenZseen_add�element�kr&r&r'�unique_everseen�s
rscst���fdd��}|S)zs
    Wrap a function returning an iterable such that the resulting iterable
    only ever yields unique items.
    cst�||��S)N)rs)�args�kwargs)�funcr&r'�wrapper�szunique_values.<locals>.wrapper)r)rvrwr&)rvr'�
unique_values�srxz(<([^>]*\srel\s*=\s*['"]?([^'">]+)[^>]*)>ccs�xvtj|�D]h}|j�\}}tttj|j�jd���}d|ksFd|krx,t	j|�D]}t
jj|t
|jd���VqRWqWxHdD]@}|j|�}|d	kr~t	j||�}|r~t
jj|t
|jd���Vq~WdS)
zEFind rel="homepage" and rel="download" links in `page`, yielding URLs�,Zhomepager:r9�
<th>Home Page�<th>Download URLN)rzr{r=)�REL�finditer�groupsrir�str�stripr1rA�HREFrr#�urljoin�
htmldecoderO�find�search)rB�pagerN�tag�relZrels�posr&r&r'�find_external_links�s"

r�c@s(eZdZdZdd�Zdd�Zdd�ZdS)	�ContentCheckerzP
    A null content checker that defines the interface for checking content
    cCsdS)z3
        Feed a block of data to the hash.
        Nr&)�self�blockr&r&r'�feed�szContentChecker.feedcCsdS)zC
        Check the hash. Return False if validation fails.
        Tr&)r�r&r&r'�is_valid�szContentChecker.is_validcCsdS)zu
        Call reporter with information about the checker (hash name)
        substituted into the template.
        Nr&)r��reporter�templater&r&r'�reportszContentChecker.reportN)�__name__�
__module__�__qualname__�__doc__r�r�r�r&r&r&r'r��sr�c@sBeZdZejd�Zdd�Zedd��Zdd�Z	dd	�Z
d
d�ZdS)
�HashCheckerzK(?P<hash_name>sha1|sha224|sha384|sha256|sha512|md5)=(?P<expected>[a-f0-9]+)cCs||_tj|�|_||_dS)N)�	hash_name�hashlib�new�hash�expected)r�r�r�r&r&r'�__init__szHashChecker.__init__cCs>tjj|�d}|st�S|jj|�}|s0t�S|f|j��S)z5Construct a (possibly null) ContentChecker from a URLr9r=)rr#r?r��patternr��	groupdict)�clsrBrIrNr&r&r'�from_urlszHashChecker.from_urlcCs|jj|�dS)N)r��update)r�r�r&r&r'r�!szHashChecker.feedcCs|jj�|jkS)N)r��	hexdigestr�)r�r&r&r'r�$szHashChecker.is_validcCs||j}||�S)N)r�)r�r�r��msgr&r&r'r�'s
zHashChecker.reportN)r�r�r�ra�compiler�r��classmethodr�r�r�r�r&r&r&r'r�sr�cs<eZdZdZdKdd�ZdLd	d
�ZdMdd�ZdNd
d�Zdd�Zdd�Z	dd�Z
dd�ZdOdd�Zdd�Z
dP�fdd�	Zdd�Zdd �Zd!d"�Zd#d$�Zd%d&�ZdQd'd(�ZdRd)d*�Zd+d,�Zd-Zd.d/�Zd0d1�ZdSd2d3�Zd4d5�Zd6d7�Zd8d9�Zd:d;�Zd<d=�Ze dTd>d?��Z!d@dA�Z"dBdC�Z#dDdE�Z$dFdG�Z%dHdI�Z&�Z'S)Urz;A distribution index that scans web pages for download URLs�https://pypi.python.org/simple�*NTcOs�tj|f|�|�|dd|jd��|_i|_i|_i|_tjdj	t
t|���j|_
g|_|ortjor|prtj�}|r�tj|�|_n
tjj|_dS)Nr8�|)rr�r2�	index_url�scanned_urls�fetched_urls�
package_pagesrar�rhrrrN�allows�to_scanrZis_availableZfind_ca_bundleZ
opener_for�openerr�request�urlopen)r�r��hostsZ	ca_bundleZ
verify_sslrt�kwZuse_sslr&r&r'r�/szPackageIndex.__init__FcCs�||jkr|rdSd|j|<t|�s4|j|�dStt|��}|r^|j|�sRdS|jd|�|sr|sr||jkr�tt|j	|��dS|j|�s�d|j|<dS|j
d|�d|j|<d}|j|||�}|dkr�dSd|j|j<d|j
jdd�j�k�r|j�dS|j}|j�}t|t��sRt|tjj��r4d	}n|j
jd
��pDd	}|j|d�}|j�x6tj|�D](}	tjj|t|	jd���}
|j|
��qfW|j |j!��r�t"|d
d�dk�r�|j#||�}dS)z<Evaluate a URL as a possible download, and maybe retrieve itNTzFound link: %sz
Reading %sz<Download error on %s: %%s -- Some packages may not be found!�htmlzcontent-type�zlatin-1�charset�ignorer9�codei�)$r��
URL_SCHEME�process_filename�listr�url_ok�debugr�rrj�info�open_urlrB�headers�getr1�close�read�
isinstancerr�error�	HTTPError�	get_param�decoder�r}r#r�r�rO�process_urlr3r��getattr�
process_index)r�rB�retrieve�dists�tmpl�fr5r�r�rN�linkr&r&r'r�DsP





 zPackageIndex.process_urlcCs�tjj|�s|jd|�dStjj|�rd|rdtjj|�}x(tj|�D]}|jtjj||�d�qFWt	|�}|r�|j
d|�tt|j
|��dS)Nz
Not found: %sTz	Found: %s)r^rF�exists�warn�isdir�realpath�listdirr�rhr`r�r�rrj)r��fn�nestedrF�itemr�r&r&r'r�wszPackageIndex.process_filenamecCsbt|�}|o|jd�j�dk}|s8|jtjj|�d�r<dSd}|rRt||��n|j||�dS)Nr9�fileTzN
Note: Bypassing %s (disallowed host; see http://bit.ly/2hrImnY for details).
)	r�rOr1r�rr#r?rr�)r�rB�fatal�s�is_filer�r&r&r'r��szPackageIndex.url_okcCs2ttjj|�}dd�|D�}ttj|j|��dS)Ncss0|](}tj|�D]}|jd�r||fVqqdS)z	.egg-linkN)r^r�r2)rbrF�entryr&r&r'rd�sz.PackageIndex.scan_egg_links.<locals>.<genexpr>)�filterr^rFr�r��	itertools�starmap�
scan_egg_link)r��search_path�dirsZ	egg_linksr&r&r'�scan_egg_links�szPackageIndex.scan_egg_linksc
Cs�ttjj||���}ttdttj|���}WdQRXt	|�dkrDdS|\}}x>t
tjj||��D](}tjj|f|��|_t|_
|j|�q`WdS)Nr;)�openr^rFrhr�r�rrr�rYrrSr
rKrj)r�rFr�Z	raw_lines�linesZegg_pathZ
setup_pathrQr&r&r'r��s zPackageIndex.scan_egg_linkc

s��fdd�}xHtj|�D]:}y |tjj|t|jd����Wqtk
rPYqXqW||�\}}|r�xXt||�D]J}t	|�\}}	|j
d�r�|	r�|r�|d||f7}n
�j|��j|�qrWt
jdd�|�SdSd	S)
z#Process the contents of a PyPI pagecs�|j�j�r�tttjj|t�j�d�jd���}t|�dkr�d|dkr�t	|d�}t
|d�}d�jj|j
�i�|<t|�t|�fSdS)Nr8r;r<r9rT)NN)r3r�r�rrr#r@rYrArrr��
setdefaultr1r)r�rC�pkg�ver)r�r&r'�scan�s"z(PackageIndex.process_index.<locals>.scanr9z.pyz
#egg=%s-%scSsd|jddd�S)Nz<a href="%s#md5=%s">%s</a>r9r!r;)rO)�mr&r&r'�<lambda>�sz,PackageIndex.process_index.<locals>.<lambda>r�N)r�r}rr#r�r�rOr$r�rJr2�need_version_info�scan_url�PYPI_MD5�sub)
r�rBr�r�rNr�r��new_urlr5�fragr&)r�r'r��s$ 

zPackageIndex.process_indexcCs|jd|�dS)NzPPage at %s links to .py file(s) without version info; an index scan is required.)�scan_all)r�rBr&r&r'r��szPackageIndex.need_version_infocGs:|j|jkr*|r |j|f|��|jd�|j|j�dS)Nz6Scanning index of all packages (this may take a while))r�r�r�r�r�)r�r�rtr&r&r'r��szPackageIndex.scan_allcCs~|j|j|jd�|jj|j�s:|j|j|jd�|jj|j�sR|j|�x&t|jj|jf��D]}|j|�qhWdS)Nr8)	r�r��unsafe_namer�r�rorT�not_found_in_indexr�)r��requirementrBr&r&r'�
find_packages�s
zPackageIndex.find_packagescsR|j�|j|�x,||jD]}||kr.|S|jd||�qWtt|�j||�S)Nz%s does not match %s)�prescanr�ror��superr�obtain)r�r��	installerrQ)�	__class__r&r'r��s
zPackageIndex.obtaincCsL|j|jd|�|j�sH|j�tj|�td|jjtj	j
|�f��dS)z-
        checker is a ContentChecker
        zValidating %%s checksum for %sz7%s validation failed for %s; possible download problem?N)r�r�r�r�r^�unlinkrr�r4rFrZ)r��checkerr_�tfpr&r&r'�
check_hashs

zPackageIndex.check_hashcCsTxN|D]F}|jdks4t|�s4|jd�s4tt|��r@|j|�q|jj|�qWdS)z;Add `urls` to the list that will be prescanned for searchesNzfile:)r�r�r3r�rr��append)r��urlsrBr&r&r'�add_find_linkss



zPackageIndex.add_find_linkscCs"|jrtt|j|j��d|_dS)z7Scan urls scheduled for prescanning (e.g. --find-links)N)r�r�rr�)r�r&r&r'r�szPackageIndex.prescancCs<||jr|jd}}n|jd}}|||j�|j�dS)Nz#Couldn't retrieve index page for %rz3Couldn't find index page for %r (maybe misspelled?))ror�r�r�r�)r�r��methr�r&r&r'r�%s
zPackageIndex.not_found_in_indexcCs~t|t�sjt|�}|rR|j|jd�||�}t|�\}}|jd�rN|j|||�}|Stj	j
|�rb|St|�}t|j
||�dd�S)aLocate and/or download `spec` to `tmpdir`, returning a local path

        `spec` may be a ``Requirement`` object, or a string containing a URL,
        an existing local filename, or a project/version requirement spec
        (i.e. the string form of a ``Requirement`` object).  If it is the URL
        of a .py file with an unambiguous ``#egg=name-version`` tag (i.e., one
        that escapes ``-`` as ``_`` throughout), a trivial ``setup.py`` is
        automatically created alongside the downloaded file.

        If `spec` is a ``Requirement`` object or a string containing a
        project/version requirement spec, this method returns the location of
        a matching distribution (possibly after downloading it to `tmpdir`).
        If `spec` is a locally existing file or directory name, it is simply
        returned unchanged.  If `spec` is a URL, it is downloaded to a subpath
        of `tmpdir`, and the local filename is returned.  Various errors may be
        raised if a problem occurs during downloading.
        r9z.pyrSN)r�rr��
_download_urlrOrJr2�	gen_setupr^rFr�r(r��fetch_distribution)r�r%�tmpdirrD�foundr5rIr&r&r'r:/s

zPackageIndex.downloadc	s��jd|�i�d}d
�����fdd�	}|rH�j��j|�||�}|r`|dk	r`|||�}|dkr��jdk	rz�j�||�}|dkr�|r��j|�||�}|dkrˆjd�r�dp�d|�n�jd|�|j|jd	�SdS)a|Obtain a distribution suitable for fulfilling `requirement`

        `requirement` must be a ``pkg_resources.Requirement`` instance.
        If necessary, or if the `force_scan` flag is set, the requirement is
        searched for in the (online) package index as well as the locally
        installed packages.  If a distribution matching `requirement` is found,
        the returned distribution's ``location`` is the value you would have
        gotten from calling the ``download()`` method with the matching
        distribution's URL or filename.  If no matching distribution is found,
        ``None`` is returned.

        If the `source` flag is set, only source distributions and source
        checkout links will be considered.  Unless the `develop_ok` flag is
        set, development and system eggs (i.e., those using the ``.egg-info``
        format) will be ignored.
        zSearching for %sNcs�|dkr�}x�||jD]t}|jtkrJ�rJ|�kr�jd|�d�|<q||ko`|jtkp`�}|r�j|j��}||_tj	j
|j�r|SqWdS)Nz&Skipping development or system egg: %sr9)rorKrr�r
r:rS�download_locationr^rFr�)�req�envrQ�test�loc)�
develop_okr��skipped�sourcer	r&r'r�is z-PackageIndex.fetch_distribution.<locals>.findz:No local packages or working download links found for %s%sza source distribution of r�zBest match: %s)rS)N)r�r�r�r�r��cloner)	r�r�r	�
force_scanrrZlocal_indexrQr�r&)rr�rrr	r'rQs0




zPackageIndex.fetch_distributioncCs"|j||||�}|dk	r|jSdS)a3Obtain a file suitable for fulfilling `requirement`

        DEPRECATED; use the ``fetch_distribution()`` method now instead.  For
        backward compatibility, this routine is identical but returns the
        ``location`` of the downloaded distribution instead of a distribution
        object.
        N)rrS)r�r�r	rrrQr&r&r'�fetch�szPackageIndex.fetchc

Cs�tj|�}|r*dd�t||jd�d�D�p,g}t|�dkr�tjj|�}tjj|�|kr�tjj	||�}ddl
m}|||�s�tj
||�|}ttjj	|d�d��2}	|	jd|dj|djtjj|�df�WdQRX|S|r�td	||f��ntd
��dS)NcSsg|]}|jr|�qSr&)rU)rb�dr&r&r'�
<listcomp>�sz*PackageIndex.gen_setup.<locals>.<listcomp>r9r)�samefilezsetup.py�wzIfrom setuptools import setup
setup(name=%r, version=%r, py_modules=[%r])
z�Can't unambiguously interpret project/version identifier %r; any dashes in the name or version should be escaped using underscores. %rzpCan't process plain .py files without an '#egg=name-version' suffix to enable automatic setup script generation.)rMrNrrOrYr^rFrZ�dirnamerhZsetuptools.command.easy_installr�shutil�copy2r��writerTrU�splitextr)
r�r_rIr	rNr�rZ�dstrr�r&r&r'r�s2

 zPackageIndex.gen_setupi cCs|jd|�d}z�tj|�}|j|�}t|tjj�rJtd||j	|j
f��|j�}d}|j}d}d|kr�t|d�}	t
tt|	��}|j|||||�t|d��Z}
xD|j|�}|r�|j|�|
j|�|d7}|j|||||�q�Pq�W|j|||
�WdQRX|S|�r|j�XdS)	NzDownloading %szCan't download %s: %s %srr9zcontent-lengthzContent-Length�wbr=)r�r�r�r�r�rr�r�rr�r��dl_blocksizer�maxr�int�
reporthookr�r�r�rrr�)r�rBr_�fpr�r��blocknum�bs�size�sizesrr�r&r&r'�_download_to�s:





zPackageIndex._download_tocCsdS)Nr&)r�rBr_r&Zblksizer(r&r&r'r$�szPackageIndex.reporthookcCs�|jd�rt|�Syt||j�Sttjfk
r�}z>djdd�|jD��}|r^|j	||�nt
d||f��WYdd}~X�ntjj
k
r�}z|Sd}~Xn�tjjk
r�}z,|r�|j	||j�nt
d||jf��WYdd}~Xn�tjk
�r8}z.|�r|j	||j�nt
d||jf��WYdd}~XnPtjtjfk
�r�}z*|�rf|j	||�nt
d||f��WYdd}~XnXdS)Nzfile:� cSsg|]}t|��qSr&)r)rb�argr&r&r'rsz)PackageIndex.open_url.<locals>.<listcomp>z%s %szDownload error for %s: %sz;%s returned a bad status line. The server might be down, %s)r3�
local_open�open_with_authr�r$r�
InvalidURLrhrtr�rrr�r��URLError�reason�
BadStatusLine�line�
HTTPException�socket)r�rB�warning�vr�r&r&r'r��s6
"zPackageIndex.open_urlcCs�t|�\}}|r4x&d|kr0|jdd�jdd�}qWnd}|jd�rN|dd�}tjj||�}|dksn|jd	�rz|j||�S|d
ks�|jd�r�|j||�S|jd�r�|j	||�S|d
kr�t
jjt
j
j|�d�S|j|d�|j||�SdS)Nz..�.�\�_Z__downloaded__z.egg.zipr-�svnzsvn+�gitzgit+zhg+r�r;Tr0)rJ�replacer2r^rFrhr3�
_download_svn�
_download_git�_download_hgrr��url2pathnamer#r?r��_attempt_download)r�rDrBr	r4rIr_r&r&r'rs$


zPackageIndex._download_urlcCs|j|d�dS)NT)r�)r�rBr&r&r'r�<szPackageIndex.scan_urlcCs6|j||�}d|jdd�j�kr.|j|||�S|SdS)Nr�zcontent-typer�)r*r�r1�_download_html)r�rBr_r�r&r&r'rB?szPackageIndex._attempt_downloadcCslt|�}x@|D]8}|j�rtjd|�rD|j�tj|�|j||�SPqW|j�tj|�td|��dS)Nz <title>([^- ]+ - )?Revision \d+:zUnexpected HTML page found at )	r�r�rar�r�r^r�r>r)r�rBr�r_r�r3r&r&r'rCFs


zPackageIndex._download_htmlcCs�|jdd�d}d}|j�jd�r�d|kr�tjj|�\}}}}}}	|r�|jd�r�d|d	d�kr�|d	d�jdd�\}}t|�\}
}|
r�d
|
kr�|
jd
d�\}}
d||
f}nd|
}|}||||||	f}tjj|�}|jd
||�t	j
d|||f�|S)Nr<r9rr�zsvn:�@z//r8r;�:z --username=%s --password=%sz --username=z'Doing subversion checkout from %s to %szsvn checkout%s -q %s %s)rAr1r3rr#r?r�
urlunparser�r^�system)r�rBr_�credsrD�netlocrFrc�qr��auth�host�user�pwrCr&r&r'r>Us$ zPackageIndex._download_svncCsptjj|�\}}}}}|jdd�d}|jdd�d}d}d|krR|jdd�\}}tjj||||df�}||fS)N�+r9r<rrDr�r=)rr#�urlsplitrA�rsplit�
urlunsplit)rB�
pop_prefixrDrIrFrHr��revr&r&r'�_vcs_split_rev_from_urljsz$PackageIndex._vcs_split_rev_from_urlcCsl|jdd�d}|j|dd�\}}|jd||�tjd||f�|dk	rh|jd|�tjd	||f�|S)
Nr<r9rT)rSzDoing git clone from %s to %szgit clone --quiet %s %szChecking out %sz"(cd %s && git checkout --quiet %s))rArUr�r^rG)r�rBr_rTr&r&r'r?|s
zPackageIndex._download_gitcCsl|jdd�d}|j|dd�\}}|jd||�tjd||f�|dk	rh|jd|�tjd	||f�|S)
Nr<r9rT)rSzDoing hg clone from %s to %szhg clone --quiet %s %szUpdating to %sz(cd %s && hg up -C -r %s -q))rArUr�r^rG)r�rBr_rTr&r&r'r@�s
zPackageIndex._download_hgcGstj|f|��dS)N)rr�)r�r�rtr&r&r'r��szPackageIndex.debugcGstj|f|��dS)N)rr�)r�r�rtr&r&r'r��szPackageIndex.infocGstj|f|��dS)N)rr�)r�r�rtr&r&r'r��szPackageIndex.warn�r�)r�rVNT)F)F)F)N)N)FFFN)FF)N)F)(r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�rrr�r�r:rrrr!r*r$r�rr�rBrCr>�staticmethodrUr?r@r�r�r��
__classcell__r&r&)r�r'r,sL

3



+
		
#
J

)$
#z!&(#(\d+|x[\da-fA-F]+)|[\w.:-]+);?cCs(t|t�s|S|dkr tj|�St|�S)N�)r�r#r�unichr�chr)�cr&r&r'�uchr�s


r]cCsd|jd�}|jd�r(t|dd�d�}n4|jd�rDt|dd��}ntjjjj||jd��}t|�S)Nr9z#xr;r+r<r)	rOr3r#rrk�
html_entities�name2codepointr�r])rN�whatr&r&r'�
decode_entity�s


racCs
tt|�S)z'Decode HTML entities in the given text.)�
entity_subra)�textr&r&r'r��sr�cs�fdd�}|S)Ncs��fdd�}|S)Ncs.tj�}tj��z
�||�Stj|�XdS)N)r5�getdefaulttimeout�setdefaulttimeout)rtruZold_timeout)rv�timeoutr&r'�_socket_timeout�s


z@socket_timeout.<locals>._socket_timeout.<locals>._socket_timeoutr&)rvrg)rf)rvr'rg�sz'socket_timeout.<locals>._socket_timeoutr&)rfrgr&)rfr'�socket_timeout�srhcCs2tjj|�}|j�}tj|�}|j�}|jdd�S)aq
    A function compatible with Python 2.3-3.3 that will encode
    auth from a URL suitable for an HTTP header.
    >>> str(_encode_auth('username%3Apassword'))
    'dXNlcm5hbWU6cGFzc3dvcmQ='

    Long auth strings should not cause a newline to be inserted.
    >>> long_auth = 'username:' + 'password'*10
    >>> chr(10) in str(_encode_auth(long_auth))
    False
    �
r�)rr#r@�encode�base64�encodestringr�r=)rKZauth_sZ
auth_bytesZ
encoded_bytes�encodedr&r&r'�_encode_auth�s

rnc@s(eZdZdZdd�Zdd�Zdd�ZdS)	�
Credentialz:
    A username/password pair. Use like a namedtuple.
    cCs||_||_dS)N)�username�password)r�rprqr&r&r'r��szCredential.__init__ccs|jV|jVdS)N)rprq)r�r&r&r'�__iter__�szCredential.__iter__cCsdt|�S)Nz%(username)s:%(password)s)�vars)r�r&r&r'�__str__�szCredential.__str__N)r�r�r�r�r�rrrtr&r&r&r'ro�sroc@s0eZdZdd�Zedd��Zdd�Zdd�Zd	S)
�
PyPIConfigcCsPtjdddgd�}tjj||�tjjtjjd�d�}tjj	|�rL|j
|�dS)z%
        Load from ~/.pypirc
        rprq�
repositoryr��~z.pypircN)�dict�fromkeysr�RawConfigParserr�r^rFrh�
expanduserr�r�)r��defaults�rcr&r&r'r��s
zPyPIConfig.__init__cs&�fdd��j�D�}tt�j|��S)Ncs g|]}�j|d�j�r|�qS)rv)r�r�)rb�section)r�r&r'r	sz2PyPIConfig.creds_by_repository.<locals>.<listcomp>)�sectionsrxr�_get_repo_cred)r�Zsections_with_repositoriesr&)r�r'�creds_by_repositoryszPyPIConfig.creds_by_repositorycCs6|j|d�j�}|t|j|d�j�|j|d�j��fS)Nrvrprq)r�r�ro)r�r~�repor&r&r'r�szPyPIConfig._get_repo_credcCs*x$|jj�D]\}}|j|�r|SqWdS)z�
        If the URL indicated appears to be a repository defined in this
        config, return the credential for that repository.
        N)r��itemsr3)r�rBrv�credr&r&r'�find_credentials
zPyPIConfig.find_credentialN)r�r�r�r��propertyr�r�r�r&r&r&r'ru�s	rucCs6tjj|�\}}}}}}|jd�r,tjd��|d
krBt|�\}}	nd}|szt�j|�}
|
rzt	|
�}|
j
|f}tjd|��|r�dt
|�}||	||||f}tjj|�}
tjj|
�}|jd|�ntjj|�}|jd	t�||�}|�r2tjj|j�\}}}}}}||k�r2||	k�r2||||||f}tjj|�|_|S)z4Open a urllib2 request, handling HTTP authenticationrEznonnumeric port: ''�http�httpsN�*Authenticating as %s for %s (from .pypirc)zBasic �
Authorizationz
User-Agent)r�r�)r�)rr#r?r2rr/rrur�rrprr�rnrFr��Request�
add_header�
user_agentrB)rBr�rDrIrF�paramsrHr�rKrLr�r�rCr�r�r%�s2�h2�path2Zparam2Zquery2Zfrag2r&r&r'r. s6


r.cCs|S)Nr&)rBr&r&r'�
fix_sf_urlQsr�cCstjj|�\}}}}}}tjj|�}tjj|�r<tjj|�S|j	d�r�tjj
|�r�g}x�tj|�D]b}	tjj||	�}
|	dkr�t
|
d��}|j�}WdQRXPntjj
|
�r�|	d7}	|jdj|	d��qbWd}
|
j|dj|�d	�}d\}}n
d\}}}ddi}tj|�}tjj|||||�S)z7Read a local path, with special support for directoriesr8z
index.html�rNz<a href="{name}">{name}</a>)r4zB<html><head><title>{url}</title></head><body>{files}</body></html>ri)rB�files���OK��Path not found�	Not foundzcontent-typez	text/html)r�r�)r�r�r�)rr#r?r�rAr^rF�isfiler�r2r�r�rhr�r�r�formatr�StringIOr�r�)rBrDrErF�paramrHr�r_r�r��filepathr%�bodyr��status�messager�Zbody_streamr&r&r'r-Us,


r-)N)N)N)N)r )]r��sysr^rarr5rkr�r��	functoolsr�urllib.parser�ImportError�urllib2Zsetuptools.externrZsetuptools.extern.six.movesrrrrr"�
pkg_resourcesr	r
rrr
rrrrrrrrr�	distutilsr�distutils.errorsr�fnmatchrZsetuptools.py27compatrZsetuptools.wheelrr�rM�Ir�r�rNr�rArX�__all__Z_SOCKET_TIMEOUTZ_tmplr�rUr�r(rrJrrLr`rrsrxr|r��objectr�r�rr�rbr]rar�rhrnrorzrur�r�r.r�r-r&r&r&r'�<module>s�<
	

!
"

!
&.

?>