Your IP : 18.223.239.65


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

3

9��fŜ�@s�dZddlZddlZddlZddlZddlZddlZddlZddlZddl	Z	ddl
mZddlm
Z
ddlmZmZmZmZddlZddlmZmZmZmZmZmZmZmZmZmZmZm Z m!Z!ddlm"Z"ddl#m$Z$dd	l%m&Z&dd
l'm(Z(ddl)m*Z*ddl+m,Z,dd
l-m.Z.ej/d�Z0ej/dej1�Z2ej/d�Z3ej/dej1�j4Z5dj6�Z7ddddgZ8dZ9dZ:e:j;ej<dd�ed�Z=dd�Z>dd�Z?dd�Z@dEd d�ZAdFd!d"�ZBdGd#d$�ZCdedfd%d�ZDdHd&d'�ZEd(d)�ZFej/d*ej1�ZGeFd+d,��ZHGd-d.�d.eI�ZJGd/d0�d0eJ�ZKGd1d�de�ZLej/d2�jMZNd3d4�ZOd5d6�ZPdId7d8�ZQd9d:�ZRGd;d<�d<eI�ZSGd=d>�d>ejT�ZUejVjWfd?d@�ZXeQe9�eX�ZXdAdB�ZYdCdD�ZZdS)Jz#PyPI and direct package downloading�N)�wraps)�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)�unescape)�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&�#/usr/lib/python3.6/package_index.py�parse_requirement_arg3s

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�
Zwin32z	.win32-py���z.win-amd64.exe�z	win-amd64z
.win-amd64-py�)NNNi����i�i�������i�i�i��i����r/i��)�lower�endswith�
startswith)�namer0�base�py_verZplatr&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�pathZ
parameters�query�fragmentr4r&r&r'�egg_info_for_urlTsrGccsdt|�\}}xt|||�D]
}|VqW|r`tj|�}|r`x$t||jd�|td�D]
}|VqRWdS)zEYield egg or source distribution objects that might be found at a URLr7)�
precedenceN)rG�distros_for_location�EGG_FRAGMENT�matchr�groupr)r@�metadatar4rF�distrKr&r&r'r_s

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.whlr7)�location�project_name�versionrHz.exer/)
r1r	Z
from_locationrZ
is_compatiblerQrRrrrr
�
EXTENSIONS�len)rP�basenamerMZwheelZwin_baser5�platformZextr&r&r'rIms.



rIcCstt|�tjj|�|�S)zEYield possible egg or source distribution objects based on a filename)rIr�osrDrU)�filenamerMr&r&r'�distros_for_filename�srYc
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!
    rOcss|]}tjd|�VqdS)z	py\d\.\d$N)�rerK)�.0�pr&r&r'�	<genexpr>�sz(interpret_distro_name.<locals>.<genexpr>r9Nr7)�
py_versionrHrV)r?�any�rangerTr	�join)rPrUrMr^rHrVrAr\r&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�addrZmoves�filterfalse�__contains__)�iterable�key�seenZseen_add�element�kr&r&r'�unique_everseen�s
rkcst���fdd��}|S)zs
    Wrap a function returning an iterable such that the resulting iterable
    only ever yields unique items.
    cst�||��S)N)rk)�args�kwargs)�funcr&r'�wrapper�szunique_values.<locals>.wrapper)r)rnror&)rnr'�
unique_values�srpz3<([^>]*\srel\s{0,10}=\s{0,10}['"]?([^'" >]+)[^>]*)>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�,Zhomepager8r7�
<th>Home Page�<th>Download URLN)rrrsr;)�REL�finditer�groupsrbr�str�stripr0r?�HREFrr#�urljoin�
htmldecoderL�find�search)r@�pagerK�tagZrelZrels�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 URLr7r;)rr#r=r��patternr}�	groupdict)�clsr@rFrKr&r&r'�from_urlszHashChecker.from_urlcCs|jj|�dS)N)r��update)r�r�r&r&r'r�szHashChecker.feedcCs|jj�|jkS)N)r�Z	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�rZ�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.org/simple/�*NTcOs�tj|f|�|�|dd|jd��|_i|_i|_i|_tjdj	t
t|���j|_
g|_|ortjor|prtj�}|r�tj|�|_n
tjj|_dS)Nr6�|)r
r�r1�	index_url�scanned_urls�fetched_urls�
package_pagesrZr�rarrrK�allows�to_scanrZis_availableZfind_ca_bundleZ
opener_for�openerr�request�urlopen)r�r�ZhostsZ	ca_bundleZ
verify_sslrl�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�ignorer7�codei�)$r��
URL_SCHEME�process_filename�listr�url_ok�debugr�rrc�info�open_urlr@�headers�getr0�close�read�
isinstancerwr�error�	HTTPErrorZ	get_param�decoderyrur#rzr{rL�process_urlr2r��getattr�
process_index)r�r@Zretrieve�dists�tmpl�fr4r~r�rK�linkr&r&r'r�AsP





 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)rWrD�exists�warn�isdir�realpath�listdirr�rarYr�r�rrc)r��fn�nestedrD�itemr�r&r&r'r�tszPackageIndex.process_filenamecCsbt|�}|o|jd�j�dk}|s8|jtjj|�d�r<dSd}|rRt||��n|j||�dS)Nr7�fileTzN
Note: Bypassing %s (disallowed host; see http://bit.ly/2hrImnY for details).
)	r�rLr0r�rr#r=rr�)r�r@Zfatal�s�is_filer�r&r&r'r��szPackageIndex.url_okcCs2ttjj|�}dd�|D�}ttj|j|��dS)Ncss0|](}tj|�D]}|jd�r||fVqqdS)z	.egg-linkN)rWr�r1)r[rD�entryr&r&r'r]�sz.PackageIndex.scan_egg_links.<locals>.<genexpr>)�filterrWrDr�r��	itertools�starmap�
scan_egg_link)r�Zsearch_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)Nr9)�openrWrDrar�r�rrwrxrTrrPrrHrc)r�rDr�Z	raw_lines�linesZegg_pathZ
setup_pathrNr&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)Nr6r9r:r7rT)NN)r2r�r�rrr#r>rTr?rrr��
setdefaultr0r)r�rA�pkg�ver)r�r&r'�scan�s"z(PackageIndex.process_index.<locals>.scanr7z.pyz
#egg=%s-%scSsd|jddd�S)Nz<a href="%s#md5=%s">%s</a>r7r!r9)rL)�mr&r&r'�<lambda>�sz,PackageIndex.process_index.<locals>.<lambda>r�N)ryrurr#rzr{rLr$r�rGr1�need_version_info�scan_url�PYPI_MD5�sub)
r�r@r~r�rKr�r��new_urlr4�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�r@r&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�rlr&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)Nr6)	r�r��unsafe_namer�r�rgrQ�not_found_in_indexr�)r��requirementr@r&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�rgr��superr�obtain)r�r�Z	installerrN)�	__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�rW�unlinkrr�r3rDrU)r��checkerrX�tfpr&r&r'�
check_hash�s

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�r2r�rr��append)r�Zurlsr@r&r&r'�add_find_links
s



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?))rgr�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.
        r7z.pyrPN)r�rr��
_download_urlrLrGr1�	gen_setuprWrDr�r(r��fetch_distribution)r�r%�tmpdirrB�foundr4rFr&r&r'r8,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: %sr7)rgrHrr�rr8rP�download_locationrWrDr�)Zreq�envrNZtest�loc)�
develop_okr��skipped�sourcer�r&r'r|fs z-PackageIndex.fetch_distribution.<locals>.findz:No local packages or working download links found for %s%sza source distribution of r�zBest match: %s)rP)N)r�r�r�r�r��cloner�)	r�r�r��
force_scanr�r�Zlocal_indexrNr|r&)r�r�r�r�r�r'r�Ns0




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)r�rP)r�r�r�rr�rNr&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&)rR)r[�dr&r&r'�
<listcomp>�sz*PackageIndex.gen_setup.<locals>.<listcomp>r7r)�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.)rJrKrrLrTrWrDrU�dirnameraZsetuptools.command.easy_installr�shutilZcopy2r��writerQrR�splitextr)
r�rXrFr�rKr�rU�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 %srr7zcontent-lengthzContent-Length�wbr;)r�r�r�r�r�rr�r�rr�r��dl_blocksizer�maxr�int�
reporthookr�r�r�r	r�r�)r�r@rX�fpr�r��blocknumZbs�sizeZsizesr�r�r&r&r'�_download_to�s:





zPackageIndex._download_tocCsdS)Nr&)r�r@rXrZblksizerr&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&)rw)r[�argr&r&r'r�sz)PackageIndex.open_url.<locals>.<listcomp>z%s %szDownload error for %s: %sz;%s returned a bad status line. The server might be down, %s)r2�
local_open�open_with_authr�r$r�
InvalidURLrarlr�rrr�r�ZURLError�reasonZ
BadStatusLine�lineZ
HTTPException�socket)r�r@Zwarning�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�r9Tr/)rG�replacer1rWrDrar2�
_download_svn�
_download_git�_download_hgrr��url2pathnamer#r=r��_attempt_download)r�rBr@r�r3rFrXr&r&r'r�s$


zPackageIndex._download_urlcCs|j|d�dS)NT)r�)r�r@r&r&r'r�9szPackageIndex.scan_urlcCs6|j||�}d|jdd�j�kr.|j|||�S|SdS)Nr�zcontent-typer�)rr�r0�_download_html)r�r@rXr�r&r&r'r(<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�rxrZr}r�rWr�r$r)r�r@r�rXr�rr&r&r'r)Cs


zPackageIndex._download_htmlcCs|jdd�d}g}|j�jd�r�d|kr�tjj|�\}}}}}}	|r�|jd�r�d|dd�kr�|dd�jdd�\}}tjj|�\}
}|
r�d	|
kr�|
jd	d�\}}
d
|d|
g}n
d
|
g}|}||||||	f}tjj|�}|jd||�t	j
d
dg|d||g�|S)Nr:r7rzsvn:�@z//r6r9�:z--username=z--password=z'Doing subversion checkout from %s to %sr!�checkoutz-q)r?r0r2rr#r=�	splituser�
urlunparser��
subprocess�
check_call)r�r@rXZcredsrB�netlocrDr\�qr��auth�host�userZpwrAr&r&r'r$Rs$ 
zPackageIndex._download_svncCsptjj|�\}}}}}|jdd�d}|jdd�d}d}d|krR|jdd�\}}tjj||||df�}||fS)N�+r7r:rr*r�r;)rr#Zurlsplitr?�rsplitZ
urlunsplit)r@�
pop_prefixrBr1rDrEr��revr&r&r'�_vcs_split_rev_from_urlgsz$PackageIndex._vcs_split_rev_from_urlcCsr|jdd�d}|j|dd�\}}|jd||�tjddd	||g�|dk	rn|jd
|�tjdd|dd	|g�|S)
Nr:r7rT)r8zDoing git clone from %s to %sr"rz--quietzChecking out %sz-Cr,)r?r:r�r/r0)r�r@rXr9r&r&r'r%yszPackageIndex._download_gitc	Csv|jdd�d}|j|dd�\}}|jd||�tjddd	||g�|dk	rr|jd
|�tjdd|dd
d|dg�|S)Nr:r7rT)r8zDoing hg clone from %s to %sZhgrz--quietzUpdating to %sz--cwdZupz-Cz-rz-q)r?r:r�r/r0)r�r@rXr9r&r&r'r&�szPackageIndex._download_hgcGstj|f|��dS)N)rr�)r�r�rlr&r&r'r��szPackageIndex.debugcGstj|f|��dS)N)rr�)r�r�rlr&r&r'r��szPackageIndex.infocGstj|f|��dS)N)rr�)r�r�rlr&r&r'r��szPackageIndex.warn�r�)r�r;NT)F)F)F)N)N)FFFN)FF)N)F)(r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r8r�rr�r
rrr�r�r�r(r)r$�staticmethodr:r%r&r�r�r��
__classcell__r&r&)r�r'r)sL

3



+
		
#
J

)$
#

z!&(#(\d+|x[\da-fA-F]+)|[\w.:-]+);?cCs|jd�}t|�S)Nr7)rLr)rKZwhatr&r&r'�
decode_entity�s
r>cCs
tt|�S)z'Decode HTML entities in the given text.)�
entity_subr>)�textr&r&r'r{�sr{cs�fdd�}|S)Ncs��fdd�}|S)Ncs.tj�}tj��z
�||�Stj|�XdS)N)rZgetdefaulttimeoutZsetdefaulttimeout)rlrmZold_timeout)rn�timeoutr&r'�_socket_timeout�s


z@socket_timeout.<locals>._socket_timeout.<locals>._socket_timeoutr&)rnrB)rA)rnr'rB�sz'socket_timeout.<locals>._socket_timeoutr&)rArBr&)rAr'�socket_timeout�srCcCs2tjj|�}|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�base64Zencodestringr�r#)r3Zauth_sZ
auth_bytesZ
encoded_bytesZencodedr&r&r'�_encode_auth�s

rGc@s(eZdZdZdd�Zdd�Zdd�ZdS)	�
Credentialz:
    A username/password pair. Use like a namedtuple.
    cCs||_||_dS)N)�username�password)r�rIrJr&r&r'r��szCredential.__init__ccs|jV|jVdS)N)rIrJ)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�rKrMr&r&r&r'rH�srHc@s0eZdZdd�Zedd��Zdd�Zdd�Zd	S)
�
PyPIConfigcCsPtjdddgd�}tjj||�tjjtjjd�d�}tjj	|�rL|j
|�dS)z%
        Load from ~/.pypirc
        rIrJ�
repositoryr��~z.pypircN)�dict�fromkeysr�RawConfigParserr�rWrDra�
expanduserr�r�)r�ZdefaultsZrcr&r&r'r��s
zPyPIConfig.__init__cs&�fdd��j�D�}tt�j|��S)Ncs g|]}�j|d�j�r|�qS)rO)r�rx)r[�section)r�r&r'r�sz2PyPIConfig.creds_by_repository.<locals>.<listcomp>)ZsectionsrQr�_get_repo_cred)r�Zsections_with_repositoriesr&)r�r'�creds_by_repository�szPyPIConfig.creds_by_repositorycCs6|j|d�j�}|t|j|d�j�|j|d�j��fS)NrOrIrJ)r�rxrH)r�rUZrepor&r&r'rV�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)rW�itemsr2)r�r@rO�credr&r&r'�find_credential�s
zPyPIConfig.find_credentialN)r�r�r�r��propertyrWrVrZr&r&r&r'rN�s	rNcCs:tjj|�\}}}}}}|jd�r,tjd��|d
krFtjj|�\}}	nd}|s~t�j|�}
|
r~t	|
�}|
j
|f}tjd|��|r�dt
|�}||	||||f}tjj|�}
tjj|
�}|jd|�ntjj|�}|jd	t�||�}|�r6tjj|j�\}}}}}}||k�r6||	k�r6||||||f}tjj|�|_|S)z4Open a urllib2 request, handling HTTP authenticationr+znonnumeric port: ''�http�httpsN�*Authenticating as %s for %s (from .pypirc)zBasic Z
Authorizationz
User-Agent)r\r])r^)rr#r=r1rrr-rNrZrwrIrr�rGr.r�ZRequestZ
add_header�
user_agentr@)r@r�rBr1rDZparamsrEr�r3r4rYr�rAr�r�r�s2Zh2Zpath2Zparam2Zquery2Zfrag2r&r&r'r	s6


rcCs|S)Nr&)r@r&r&r'�
fix_sf_url:srac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 directoriesr6z
index.html�rNz<a href="{name}">{name}</a>)r3zB<html><head><title>{url}</title></head><body>{files}</body></html>rD)r@�files���OK��Path not found�	Not foundzcontent-typez	text/html)rdre)rfrgrh)rr#r=r�r'rWrD�isfiler�r1r�r�rar�r�r��formatr�StringIOr�r�)r@rBrCrDZparamrEr�rXrcr��filepathrZbodyr�Zstatus�messager�Zbody_streamr&r&r'r>s,


r)N)N)N)N)r )[r�r/�sysrWrZrrrFr�r��	functoolsrZsetuptools.externrZsetuptools.extern.six.movesrrrrr"Z
pkg_resourcesrr	r
rrr
rrrrrrrrZ	distutilsrZdistutils.errorsrZfnmatchrZsetuptools.py27compatrZsetuptools.py33compatrZsetuptools.wheelrr�rJ�Iryr�rKr�r?rS�__all__Z_SOCKET_TIMEOUTZ_tmplrjrRr_r(rrGrrIrYrrkrprtr��objectr�r�rr�r?r>r{rCrGrHrSrNr�r�rrarr&r&r&r'�<module>s|<
	

!
"

!z
&.

?>