Your IP : 18.191.171.136


Current Path : /opt/alt/python34/lib/python3.4/site-packages/setuptools/__pycache__/
Upload File :
Current File : //opt/alt/python34/lib/python3.4/site-packages/setuptools/__pycache__/package_index.cpython-34.pyc

�
M�Re
��@s�dZddlZddlZddlZddlZddlZddlZddlZddlm	Z	ddl
mZmZm
Z
mZmZmZmZmZmZmZmZmZmZddlmZddlmZddlmZddlmZm Z m!Z!m"Z"m#Z#m$Z$m%Z%m&Z&m'Z'm(Z(m)Z)m*Z*m+Z+m,Z,m-Z-dd	lm.Z.dd
l/m0Z0ddl1m2Z2ddl3m4Z4ej5d
�Z6ej5dej7�Z8ej5d�Z9ej5dej7�j:Z;dj<�Z=ddddgZ>dZ?dd�Z@dd�ZAddd�ZBddd�ZCddd�ZDdeddd�ZEdd d!�ZFd"d#�ZGej5d$ej7�ZHeGd%d&��ZId'ejJdd(�ed)�djJfZKGd*d+�d+eL�ZMGd,d-�d-eM�ZNGd.d�de�ZOej5d/�jPZQd0d1�ZRd2d3�ZSd4d5�ZTdd6d7�ZUd8d9�ZVGd:d;�d;eL�ZWGd<d=�d=e-j-�ZXejYd>d?�ZZeUe?�eZ�ZZd@dA�Z[dBdC�Z\dS)Dz#PyPI and direct package downloading�N)�wraps)
�
CHECKOUT_DIST�Distribution�BINARY_DIST�normalize_path�SOURCE_DIST�require�Environment�find_distributions�	safe_name�safe_version�to_filename�Requirement�DEVELOP_DIST)�ssl_support)�log)�DistutilsError)�urllib2�httplib�StringIO�	HTTPError�urlparse�
urlunparse�unquote�	splituser�url2pathname�name2codepoint�unichr�urljoin�urlsplit�
urlunsplit�ConfigParser)�filterfalse)�	translate)�strip_fragment)�get_all_headersz^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�cCs|j�}d\}}}|jd�r�|jd�rR|dd�}d}q�|jdd�r�|dd�}|dd�}d}q�|jd
�r�|dd�}d}q�|jd
d�r�|dd�}|dd�}d}q�n|||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����r2i��)�lower�endswith�
startswith)�namer3�base�py_ver�plat�r:�3/tmp/pip-l4uy7dan-build/setuptools/package_index.pyr(.s$			cCs�t|�\}}}}}}t|jd�d�}|dkrk|dkrkt|jd�d�}nd|kr�|jdd�\}}n||fS)	N�/�zsourceforge.net�download��#������)rr�split)�url�scheme�server�path�
parameters�query�fragmentr7r:r:r;�egg_info_for_urlFsrKccs�t|�\}}xt|||�D]}|Vq%W|r�tj|�}|r�x1t||jd�|dt�D]}|VqqWq�ndS)zEYield egg or source distribution objects that might be found at a URLr=�
precedenceN)rK�distros_for_location�EGG_FRAGMENT�matchr)�groupr)rD�metadatar7rJ�distrOr:r:r;r'Ns	"cCs�|jd�r"|dd�}n|jd�rSd|krStj|||�gS|jd�r�t|�\}}}|dk	r�t||||t|�SnxDtD]<}|j|�r�|dt|��}t|||�Sq�WgS)z:Yield egg or source distribution objects based on basenamez.egg.zipNr/z.egg�-z.exer2)r4r�
from_locationr(r)r�
EXTENSIONS�len)�location�basenamerQZwin_baser8�platform�extr:r:r;rMZs
rMcCs"tt|�tjj|�|�S)zEYield possible egg or source distribution objects based on a filename)rMr�osrGrX)�filenamerQr:r:r;�distros_for_filenameosr]c	cs�|jd�}|sdxLt|dd��D]1\}}t|�dkr,|jd�r,dSq,Wnxmtdt|�d�D]R}t||dj|d|��dj||d��d|d|d	|�Vq~WdS)
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!
    rSr?N�zpy2.r=�
py_versionrLrY)rC�	enumeraterVr5�ranger�join)	rWrXrQr_rLrY�parts�i�pr:r:r;r)vs#! 5ccs�t�}|j}|dkrMxgt|j|�D]}||�|Vq1Wn;x8|D]0}||�}||krT||�|VqTqTWdS)zHList unique elements, preserving order. Remember all elements ever seen.N)�set�addr"�__contains__)�iterable�key�seenZseen_add�element�kr:r:r;�unique_everseen�s		


rncs"t���fdd��}|S)zs
    Wrap a function returning an iterable such that the resulting iterable
    only ever yields unique items.
    cst�||��S)N)rn)�args�kwargs)�funcr:r;�wrapper�szunique_values.<locals>.wrapper)r)rqrrr:)rqr;�
unique_values�srsz(<([^>]*\srel\s*=\s*['"]?([^'">]+)[^>]*)>ccsx�tj|�D]�}|j�\}}tttj|j�jd���}d|ksgd|krx7t	j|�D]#}t
|t|jd���VqwWqqWxddD]\}|j
|�}|d	kr�t	j||�}|rt
|t|jd���Vqq�q�WdS)
zEFind rel="homepage" and rel="download" links in `page`, yielding URLs�,Zhomepager>r=�
<th>Home Page�<th>Download URLN)rurvrA)�REL�finditer�groupsrf�map�str�stripr3rC�HREFr�
htmldecoderP�find�search)rD�pagerO�tag�rel�rels�posr:r:r;�find_external_links�s'(
r�zPython-urllib/%s setuptools/%s��
setuptoolsc@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;�report�szContentChecker.reportN)�__name__�
__module__�__qualname__�__doc__r�r�r�r:r:r:r;r��sr�c@saeZdZejd�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__cCsLt|�d}|st�S|jj|�}|s<t�S||j��S)z5Construct a (possibly null) ContentChecker from a URLr=rA)rr��patternr��	groupdict)�clsrDrJrOr:r:r;�from_url�szHashChecker.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��re�compiler�r��classmethodr�r�r�r�r:r:r:r;r��s	r�cs�eZdZdZddJdddd�Zdd	d
�Zddd�Zdd
d�Zdd�Zdd�Z	dd�Z
dd�Zddd�Zdd�Z
d�fdd�Zdd�Zdd �Zd!d"�Zd#d$�Zd%d&�Zddddd'd(�Zddd)d*�Zd+d,�Zd-Zd.d/�Zd0d1�Zdd2d3�Zd4d5�Zd6d7�Zd8d9�Zd:d;�Zd<d=�Ze dd>d?��Z!d@dA�Z"dBdC�Z#dDdE�Z$dFdG�Z%dHdI�Z&�S)Kr&z;A distribution index that scans web pages for download URLszhttps://pypi.python.org/simple�*NTcOs�tj|||�|dd|jd��|_i|_i|_i|_tjdj	t
t|���j|_
g|_|r�tjr�|s�tj�r�tj|�|_ntj|_dS)Nr<�|)r	r�r4�	index_url�scanned_urls�fetched_urls�
package_pagesr�r�rbrzr#rO�allows�to_scanrZis_availableZfind_ca_bundleZ
opener_for�openerr�urlopen)r�r�ZhostsZ	ca_bundleZ
verify_sslro�kwr:r:r;r�	s!			'	!zPackageIndex.__init__Fc
CsU||jkr|rdSd|j|<t|�sD|j|�dStt|��}|r�|j|�sodS|jd|�n|s�|s�||jkr�tt|j	|��dS|j|�s�d|j|<dS|j
d|�d|j|<|j|d|�}|dkrdSd|j|j<d|j
jdd�j�krZ|j�dS|j}|j�}t|t�s�t|t�r�d	}n|j
jd
�p�d	}|j|d�}n|j�xBtj|�D]1}t|t|jd���}	|j|	�q�W|j|j�rQt|d
d�dkrQ|j ||�}ndS)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�ignorer=�codei�)!r��
URL_SCHEME�process_filename�listr'�url_ok�debugr�rzrg�info�open_urlrD�headers�getr3�close�read�
isinstancer{r�	get_param�decoder}rxrr~rP�process_urlr5r��getattr�
process_index)
r�rD�retrieve�dists�fr7r�r�rO�linkr:r:r;r�sN



!
		
*zPackageIndex.process_urlcCs�tjj|�s&|jd|�dStjj|�r�|r�tjj|�}x9tj|�D]%}|jtjj||�d�qaWnt	|�}|r�|j
d|�tt|j
|��ndS)Nz
Not found: %sTz	Found: %s)r[rG�exists�warn�isdir�realpath�listdirr�rbr]r�r�rzrg)r��fn�nestedrG�itemr�r:r:r;r�Hs&zPackageIndex.process_filenamecCs}t|�}|r-|jd�j�dksF|jt|�d�rJdSd}|rit||��n|j||�dS)Nr=�fileTzN
Note: Bypassing %s (disallowed host; see http://bit.ly/1dg9ijs for details).
)r�rPr3r�rrr�)r�rD�fatal�sr�r:r:r;r�Xs:zPackageIndex.url_okcCsfx_|D]W}tjj|�rx<tj|�D](}|jd�r/|j||�q/q/WqqWdS)Nz	.egg-link)r[rGr�r�r4�
scan_egg_link)r��search_pathr��entryr:r:r;�scan_egg_linkscs

zPackageIndex.scan_egg_linkscCs�dd�ttjttjj||���D�}t|�dkr�xXttjj||d��D]4}tjj||�|_	t
|_|j|�qfWndS)NcSsg|]}|r|�qSr:r:)�.0Z_fr:r:r;�
<listcomp>ks	z.PackageIndex.scan_egg_link.<locals>.<listcomp>r?r)
rzr{r|�openr[rGrbrVr
rWrrLrg)r�rGr��linesrRr:r:r;r�js"&	zPackageIndex.scan_egg_linkc

s�fdd�}xRtj|�D]A}y&|t|t|jd����Wq"tk
rbYq"Xq"W||�\}}|rxyt||�D]h}t|�\}}	|jd�r�|	r�|r�|d||f7}q��j	|�n�j
|�q�Wtjdd�|�SdSd	S)
z#Process the contents of a PyPI pagecs�|j�j�r�ttt|t�j�d�jd���}t|�dkr�d|dkr�t|d�}t|d�}d�j	j
|j�i�|<t|�t|�fSndS)Nr<r?r@r=rT)NN)
r5r�r�rzrrVrCrrr��
setdefaultr3r
)r�rc�pkg�ver)r�r:r;�scanus+"z(PackageIndex.process_index.<locals>.scanr=z.pyz
#egg=%s-%scSsd|jddd�S)Nz<a href="%s#md5=%s">%s</a>r=r�r?)rP)�mr:r:r;�<lambda>�sz,PackageIndex.process_index.<locals>.<lambda>r�N)
r}rxrr~rP�
ValueErrorr�rKr4�need_version_info�scan_url�PYPI_MD5�sub)
r�rDr�r�rOr�r��new_urlr7�fragr:)r�r;r�ss$&
	zPackageIndex.process_indexcCs|jd|�dS)NzPPage at %s links to .py file(s) without version info; an index scan is required.)�scan_all)r�rDr:r:r;r��szPackageIndex.need_version_infocGsO|j|jkr;|r+|j||�n|jd�n|j|j�dS)Nz6Scanning index of all packages (this may take a while))r�r�r�r�r�)r�r�ror:r:r;r��s
zPackageIndex.scan_allcCs�|j|j|jd�|jj|j�sN|j|j|jd�n|jj|j�ss|j|�nx3t|jj|jf��D]}|j|�q�WdS)Nr<)	r�r��unsafe_namer�r�rj�project_name�not_found_in_indexr�)r��requirementrDr:r:r;�
find_packages�s%zPackageIndex.find_packagescsk|j�|j|�x8||jD])}||kr;|S|jd||�q%Wtt|�j||�S)Nz%s does not match %s)�prescanr�rjr��superr&�obtain)r�r��	installerrR)�	__class__r:r;r��s

zPackageIndex.obtaincCsi|j|jd|�|j�se|j�tj|�td|jjtj	j
|�f��ndS)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�r6rGrX)r��checkerr\�tfpr:r:r;�
check_hash�s

zPackageIndex.check_hashcCsrxk|D]c}|jdksJt|�sJ|jd�sJtt|��rZ|j|�q|jj|�qWdS)z;Add `urls` to the list that will be prescanned for searchesNzfile:)r�r�r5r�r'r��append)r��urlsrDr:r:r;�add_find_links�s

zPackageIndex.add_find_linkscCs2|jr%tt|j|j��nd|_dS)z7Scan urls scheduled for prescanning (e.g. --find-links)N)r�r�rzr�)r�r:r:r;r��s	zPackageIndex.prescancCsN||jr |jd}}n|jd}}|||j�|j�dS)Nz#Couldn't retrieve index page for %rz3Couldn't find index page for %r (maybe misspelled?))rjr�r�r�r�)r�r��methr�r:r:r;r��s

zPackageIndex.not_found_in_indexcCs�t|t�s�t|�}|r||j|jd�||�}t|�\}}|jd�rx|j|||�}n|Stj	j
|�r�|Sytj|�}Wq�tk
r�t
d|f��Yq�Xnt|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.
        r=z.pyz1Not a URL, existing file, or requirement spec: %rrWN)r�rr��
_download_urlrPrKr4�	gen_setupr[rGr��parser�rr��fetch_distribution)r��spec�tmpdirrE�foundr7rJr:r:r;r>�s"
zPackageIndex.downloadc	sN�jd|�i�d}d����fdd�}|rf�j��j|�||�}n|dk	r�|p�|||�}n|dkr��jdk	r��j�||�}n|dkr�|r��j|�||�}n|dkr�jd�rdpd|�n/�jd|�|jd	�j|j|��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�}nx�||jD]q}|jtkrn�rn|�kr#�jd|�d�|<q#q#n||kr#|jtks��r#|Sq#WdS)Nz&Skipping development or system egg: %sr=)rjrLrr�r)�req�envrR)�
develop_okr��skipped�sourcer:r;r1s	
"z-PackageIndex.fetch_distribution.<locals>.findz2No local packages or download links found for %s%sza source distribution of r�zBest match: %srW)r�r�r�r�r��cloner>rW)	r�r�r�
force_scanr	rZlocal_indexrRrr:)rr�rr	r;rs.




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)rrW)r�r�rrr	rRr:r:r;�fetch[szPackageIndex.fetchc
Csbtj|�}|r=dd�t||jd�d�D�p@g}t|�dkr3tjj|�}tjj|�|kr�tjj	||�}ddl
m}|||�s�tj
||�|}q�nttjj	|d�d�}	|	jd|dj|djtjj|�df�|	j�|S|rRtd	||f��ntd
��dS)NcSsg|]}|jr|�qSr:)�version)r��dr:r:r;r�ks	z*PackageIndex.gen_setup.<locals>.<listcomp>r=r)�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.)rNrOr)rPrVr[rGrX�dirnamerbZsetuptools.command.easy_installr�shutil�copy2r��writer�r
�splitextr�r)
r�r\rJrrOr�rX�dstrr�r:r:r;r�hs4	
zPackageIndex.gen_setupi c
Cs�|jd|�d\}}}zItj|�}|jt|��}t|t�rwtd||j|j	f��n|j�}d}|j
}	d	}
d|kr�t|d�}tt
t|��}
|j||||	|
�nt|d�}xZ|j|	�}|rK|j|�|j|�|d7}|j||||	|
�q�Pq�W|j|||�|SWd|r~|j�n|r�|j�nXdS)
NzDownloading %szCan't download %s: %s %srr=zcontent-lengthzContent-Length�wb)NNNrA)r�r�r�r�r$r�rrr�r��dl_blocksizer%�maxrz�int�
reporthookr�r�r�rr�r�)
r�rDr\�fpr�r�r�r��blocknum�bs�sizeZsizesr�r:r:r;�_download_to�s>	



zPackageIndex._download_tocCsdS)Nr:)r�rDr\rZblksizerr:r:r;r�szPackageIndex.reporthookcCs�|jd�rt|�Syt||j�SWn�ttjfk
r�tj�d}dj	dd�|j
D��}|r�|j||�ntd||f��Yn.t
jk
r�tj�d}|SYnt
jk
r)tj�d}|r|j||j�ntd||jf��Yn�tjk
r�tj�d}|re|j||j�ntd||jf��YnTtjk
r�tj�d}|r�|j||�ntd||f��YnXdS)	Nzfile:r=� cSsg|]}t|��qSr:)r{)r��argr:r:r;r��s	z)PackageIndex.open_url.<locals>.<listcomp>z%s %szDownload error for %s: %sz;%s returned a bad status line. The server might be down, %s)r5�
local_open�open_with_authr�r�r�
InvalidURL�sys�exc_inforbror�rrr�URLError�reason�
BadStatusLine�line�
HTTPException)r�rD�warning�vr�r:r:r;r��s@
zPackageIndex.open_urlcCsBt|�\}}|rLx7d|krH|jdd�jdd�}qWnd}|jd�rt|dd�}ntjj||�}|dks�|jd	�r�|j||�S|d
ks�|jd�r�|j||�S|jd�r�|j	||�S|d
krt
t|�d�S|j|d�|j
||�SdS)Nz..�.�\�_Z__downloaded__z.egg.zipr/�svnzsvn+�gitzgit+zhg+r�r?Tr2)rK�replacer4r[rGrbr5�
_download_svn�
_download_git�_download_hgrrr��_attempt_download)r�rErDrr6rJr\r:r:r;r��s$%zPackageIndex._download_urlcCs|j|d�dS)NT)r�)r�rDr:r:r;r��szPackageIndex.scan_urlcCsK|j||�}d|jdd�j�krC|j|||�S|SdS)Nr�zcontent-typer�)r r�r3�_download_html)r�rDr\r�r:r:r;r8szPackageIndex._attempt_downloadcCs�t|�}xW|D]O}|j�rtjd|�r^|j�tj|�|j||�SPqqW|j�tj|�td|��dS)Nz <title>([^- ]+ - )?Revision \d+:zUnexpected HTML page found at )	r�r|r�r�r�r[r�r5r)r�rDr�r\r�r+r:r:r;r9	s




zPackageIndex._download_htmlcCs`|jdd�d}d}|j�jd�r/d|kr/t|�\}}}}}}	|r/|jd�r/d|d	d�kr/|d	d�jdd�\}}t|�\}
}|
r,d
|
kr�|
jd
d�\}}
d||
f}n
d|
}|}t||||||	f�}q,q/n|jd
||�tjd|||f�|S)Nr@r=rr�zsvn:�@z//r<r?�:z --username=%s --password=%sz --username=z'Doing subversion checkout from %s to %szsvn checkout%s -q %s %s)	rCr3r5rrrr�r[�system)r�rDr\�credsrE�netlocrGre�qr��auth�host�user�pwr:r:r;r5s"!,"
'zPackageIndex._download_svncCs�t|�\}}}}}|jdd�d}|jdd�d}d}d|krt|jdd�\}}nt||||df�}||fS)N�+r=r@rr:r�rA)rrC�rsplitr )rD�
pop_prefixrEr>rGrIr��revr:r:r;�_vcs_split_rev_from_url,sz$PackageIndex._vcs_split_rev_from_urlcCs�|jdd�d}|j|dd�\}}|jd||�tjd||f�|dk	r�|jd|�tjd	||f�n|S)
Nr@r=rrFTzDoing git clone from %s to %szgit clone --quiet %s %szChecking out %sz"(cd %s && git checkout --quiet %s))rCrHr�r[r<)r�rDr\rGr:r:r;r6>s	zPackageIndex._download_gitcCs�|jdd�d}|j|dd�\}}|jd||�tjd||f�|dk	r�|jd|�tjd	||f�n|S)
Nr@r=rrFTzDoing hg clone from %s to %szhg clone --quiet %s %szUpdating to %sz(cd %s && hg up -C -r %s >&-))rCrHr�r[r<)r�rDr\rGr:r:r;r7Ns	zPackageIndex._download_hgcGstj||�dS)N)rr�)r�r�ror:r:r;r�^szPackageIndex.debugcGstj||�dS)N)rr�)r�r�ror:r:r;r�aszPackageIndex.infocGstj||�dS)N)rr�)r�r�ror:r:r;r�dszPackageIndex.warn)r�)'r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r>rrr�rr rr�r�r�r8r9r5�staticmethodrHr6r7r�r�r�r:r:)r�r;r&sL
0	*		)A
*$(z!&(#(\d+|x[\da-fA-F]+)|[\w.:-]+);?cCs3t|t�s|S|dkr)t|�St|�S)N�)r�rr�chr)�cr:r:r;�uchrks

rMcCs�|jd�}|jd�r:t|dd�d�}nC|jd�rbt|dd��}ntj||jd��}t|�S)Nr=z#xr?r-r@r)rPr5rrr�rM)rO�whatr:r:r;�
decode_entityqsrOcCs
tt|�S)z'Decode HTML entities in the given text.)�
entity_subrO)�textr:r:r;r~{sr~cs�fdd�}|S)Ncs��fdd�}|S)Ncs?tj�}tj��z�||�SWdtj|�XdS)N)�socket�getdefaulttimeout�setdefaulttimeout)rorpZold_timeout)rq�timeoutr:r;�_socket_timeout�s

z@socket_timeout.<locals>._socket_timeout.<locals>._socket_timeoutr:)rqrV)rU)rqr;rV�sz'socket_timeout.<locals>._socket_timeoutr:)rUrVr:)rUr;�socket_timeouts	rWcCsCt|�}|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�)r�encode�base64�encodestringr�r4)r@Zauth_sZ
auth_bytesZ
encoded_bytes�encodedr:r:r;�_encode_auth�s
r]c@s:eZdZdZdd�Zdd�Zdd�ZdS)	�
Credentialz:
    A username/password pair. Use like a namedtuple.
    cCs||_||_dS)N)�username�password)r�r_r`r:r:r;r��s	zCredential.__init__ccs|jV|jVdS)N)r_r`)r�r:r:r;�__iter__�szCredential.__iter__cCsdt|�S)Nz%(username)s:%(password)s)�vars)r�r:r:r;�__str__�szCredential.__str__N)r�r�r�r�r�rarcr:r:r:r;r^�sr^c@sFeZdZdd�Zedd��Zdd�Zdd�Zd	S)
�
PyPIConfigcCsutjdddgd�}tjj||�tjjtjjd�d�}tjj|�rq|j	|�ndS)z%
        Load from ~/.pypirc
        r_r`�
repositoryr��~z.pypircN)
�dict�fromkeysr!r�r[rGrb�
expanduserr�r�)r��defaults�rcr:r:r;r��s
!zPyPIConfig.__init__cs5�fdd��j�D�}tt�j|��S)Ncs.g|]$}�j|d�j�r|�qS)re)r�r|)r��section)r�r:r;r��s	z2PyPIConfig.creds_by_repository.<locals>.<listcomp>)�sectionsrgrz�_get_repo_cred)r�Zsections_with_repositoriesr:)r�r;�creds_by_repository�szPyPIConfig.creds_by_repositorycCsO|j|d�j�}|t|j|d�j�|j|d�j��fS)Nrer_r`)r�r|r^)r�rl�repor:r:r;rn�szPyPIConfig._get_repo_credcCs7x0|jj�D]\}}|j|�r|SqWdS)z�
        If the URL indicated appears to be a repository defined in this
        config, return the credential for that repository.
        N)ro�itemsr5)r�rDre�credr:r:r;�find_credential�szPyPIConfig.find_credentialN)r�r�r�r��propertyrornrsr:r:r:r;rd�s	rdcCs�t|�\}}}}}}|jd�r?tjd��n|d
kr`t|�\}}	nd}|s�t�j|�}
|
r�t|
�}|
j|f}t	j
d|�q�n|rdt|�}t||	||||f�}t
j|�}
|
jd|�nt
j|�}
|
jd	t�||
�}|r�t|j�\}}}}}}||kr�||	kr�t||||||f�|_q�n|S)z4Open a urllib2 request, handling HTTP authenticationr;znonnumeric port: ''�http�httpsNz*Authenticating as %s for %s (from .pypirc)zBasic �
Authorizationz
User-Agent)zhttpzhttps)rr4rr%rrdrsr{r_rr�r]rr�Request�
add_header�
user_agentrD)rDr�rEr>rG�paramsrIr�r@rArrr�r��requestr�s2�h2Zpath2Zparam2Zquery2Zfrag2r:r:r;r$�s2!'r$cCs|S)Nr:)rDr:r:r;�
fix_sf_urlsrcCsut|�\}}}}}}t|�}tjj|�rItj|�S|jd�r=tjj|�r=g}x�tj	|�D]�}	|	dkr�t
tjj||	�d�}
|
j�}|
j
�Pn.tjjtjj||	��r�|	d7}	n|jd|	|	f�q�Wd|ddj|�}d\}}
nd\}}
}id
d6}t|||
|t|��S)z7Read a local path, with special support for directoriesr<z
index.html�rz<a href=%r>%s</a>z<html><head><title>%s</title>z</head><body>%s</body></html>rX���OK��Path not found�	Not foundz	text/htmlzcontent-type)r�zOK)r�r�r�)rrr[rG�isfilerr�r4r�r�r�rbr�r�r�rr)rDrErFrG�paramrIr�r\�filesr�r�body�status�messager�r:r:r;r#s*
!
!

r#)]r�r&r[r�rrRrZr��	functoolsr�
pkg_resourcesrrrrrrr	r
rrr
rrr�r�	distutilsr�distutils.errorsrZsetuptools.compatrrrrrrrrrrrrrr r!r"�fnmatchr#Zsetuptools.py26compatr$Zsetuptools.py27compatr%r�rN�Ir}r�rOr�rCrU�__all__Z_SOCKET_TIMEOUTr(rKr'rMr]r)rnrsrwr�r
rz�objectr�r�r&r�rPrMrOr~rWr]r^rdr�r$rr#r:r:r:r;�<module>spXd			"
'!��e
'+

?>