Your IP : 13.58.53.112


Current Path : /opt/alt/python35/lib/python3.5/site-packages/setuptools/__pycache__/
Upload File :
Current File : //opt/alt/python35/lib/python3.5/site-packages/setuptools/__pycache__/package_index.cpython-35.pyc



�Re#��
@s�dZddlZddlZddlZddlZddlZddlZddlZddlZddl	m
Z
yddlmZWn"e
k
r�ddlmZYnXddlmZddlmZmZmZmZddlZddlmZmZmZmZmZmZmZmZm 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.ej/d�Z0ej/dej1�Z2ej/d�Z3ej/dej1�j4Z5dj6�Z7ddddgZ8dZ9dZ:e:j;dej<dd�de�Z=dd�Z>dd�Z?dd �Z@dd!d�ZAdd"d#�ZBdd$d%�ZCdedd&d�ZDdd'd(�ZEd)d*�ZFej/d+ej1�ZGeFd,d-��ZHGd.d/�d/eI�ZJGd0d1�d1eJ�ZKGd2d�de�ZLej/d3�jMZNd4d5�ZOd6d7�ZPd8d9�ZQdd:d;�ZRd<d=�ZSGd>d?�d?eI�ZTGd@dA�dAejU�ZVejWjXdBdC�ZYeRe9�eY�ZYdDdE�ZZdFdG�Z[dS)Hz#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)�ssl_support)�log)�DistutilsError)�	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�z<setuptools/{setuptools.__version__} Python-urllib/{py_major}Zpy_major��
setuptoolscCs=ytj|�SWn%tk
r8td|f��YnXdS)Nz1Not a URL, existing file, or requirement spec: %r)r�parse�
ValueErrorr)�spec�r%��/builddir/build/BUILDROOT/alt-python35-setuptools-36.3.0-4.el8.x86_64/opt/alt/python35/lib/python3.5/site-packages/setuptools/package_index.py�parse_requirement_arg6s

r'cCs�|j�}d\}}}|jd�r�|jd�rR|dd�}d}n�|jdd�r�|dd�}|dd�}d}n`|jd
�r�|dd�}d}n8|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����r/i��)�lower�endswith�
startswith)�namer0�base�py_ver�platr%r%r&r?s$			c	Cs�tjj|�}|\}}}}}}tjj|jd�d�}|dkr�|dkr�tjj|jd�d�}d|kr�|jdd�\}}||fS)	N�/�zsourceforge.net�download��#������)rr"�urlparse�unquote�split)	�url�parts�scheme�server�path�
parameters�query�fragmentr4r%r%r&�egg_info_for_urlWsrIccs�t|�\}}xt|||�D]}|Vq%W|r�tj|�}|r�x.t||jd�|dt�D]}|VqqWdS)zEYield egg or source distribution objects that might be found at a URLr8�
precedenceN)rI�distros_for_location�EGG_FRAGMENT�matchr�groupr	)rA�metadatar4rH�distrMr%r%r&rbs	"cCs�|jd�r|dd�}|jd�rPd|krPtj|||�gS|jd�r�t|�\}}}|dk	r�t||||t|�SxDtD]<}|j|�r�|dt|��}t|||�Sq�WgS)z:Yield egg or source distribution objects based on basenamez.egg.zipNr,z.egg�-z.exer/)r1r
�
from_locationrrr�
EXTENSIONS�len)�location�basenamerOZwin_baser5�platform�extr%r%r&rKps
rKcCs"tt|�tjj|�|�S)zEYield possible egg or source distribution objects based on a filename)rKr�osrErV)�filenamerOr%r%r&�distros_for_filename�sr[ccs�|jd�}|r=tdd�|dd�D��r=dSxmtdt|�d�D]R}t||dj|d|��dj||d��d|d|d	|�VqWWdS)
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!
    rQcss!|]}tjd|�VqdS)z	py\d\.\d$N)�rerM)�.0�pr%r%r&�	<genexpr>�sz(interpret_distro_name.<locals>.<genexpr>r:Nr8�
py_versionrJrW)r@�any�rangerTr
�join)rUrVrOr`rJrWrBr^r%r%r&r�s* 5ccs�t�}|j}|dkrSxjtjj|j|�D]}||�|Vq7Wn8x5|D]-}||�}||krZ||�|VqZWdS)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		


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|krx:t	j|�D])}t
jj|t
|jd���VqwWqWxddD]\}|j|�}|d	kr�t	j||�}|r�t
jj|t
|jd���Vq�WdS)
zEFind rel="homepage" and rel="download" links in `page`, yielding URLs�,Zhomepager9r8�
<th>Home Page�<th>Download URLN)rurvr<)�REL�finditer�groupsrdr�str�stripr0r@�HREFrr"�urljoin�
htmldecoderN�find�search)rA�pagerM�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&�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__cCsRtjj|�d}|s#t�S|jj|�}|sBt�S||j��S)z5Construct a (possibly null) ContentChecker from a URLr8r<)rr"r>r��patternr��	groupdict)�clsrArHrMr%r%r&�from_urlszHashChecker.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�r\�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)Krz;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|_|o�tjo�|p�tj�}|r�tj|�|_ntjj|_dS)Nr7�|)rr�r1�	index_url�scanned_urls�fetched_urls�
package_pagesr\r�rcrrrM�allows�to_scanrZis_availableZfind_ca_bundleZ
opener_for�openerr�request�urlopen)r�r��hostsZ	ca_bundleZ
verify_sslro�kwZuse_sslr%r%r&r�$s!			'		zPackageIndex.__init__FcCs^||jkr|rdSd|j|<t|�sD|j|�dStt|��}|r|j|�sodS|jd|�|s�|s�||jkr�tt|j	|��dS|j|�s�d|j|<dS|j
d|�d|j|<d}|j|||�}|dkrdSd|j|j<d|j
jdd�j�kr]|j�dS|j}|j�}t|t�s�t|tjj�r�d	}n|j
jd
�p�d	}|j|d�}|j�xHtj|�D]7}	tjj|t|	jd���}
|j|
�q�W|j |j!�rZt"|d
d�dkrZ|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�ignorer8�codei�)$r��
URL_SCHEME�process_filename�listr�url_ok�debugr�rre�info�open_urlrA�headers�getr0�close�read�
isinstancerzr�error�	HTTPError�	get_param�decoder|rxr"r}r~rN�process_urlr2r��getattr�
process_index)r�rA�retrieve�dists�tmpl�fr4r�r�rM�linkr%r%r&r�9sP



!
		
$*zPackageIndex.process_urlcCs�tjj|�s&|jd|�dStjj|�r�|r�tjj|�}x6tj|�D]%}|jtjj||�d�qaWt	|�}|r�|j
d|�tt|j
|��dS)Nz
Not found: %sTz	Found: %s)rYrE�exists�warn�isdir�realpath�listdirr�rcr[r�r�rre)r��fn�nestedrE�itemr�r%r%r&r�ks#zPackageIndex.process_filenamecCs�t|�}|o*|jd�j�dk}|sR|jtjj|�d�rVdSd}|rut||��n|j||�dS)Nr8�fileTzN
Note: Bypassing %s (disallowed host; see http://bit.ly/1dg9ijs for details).
)	r�rNr0r�rr"r>rr�)r�rA�fatal�s�is_filer�r%r%r&r�{s!%zPackageIndex.url_okcCsEttjj|�}dd�|D�}ttj|j|��dS)Ncss@|]6}tj|�D] }|jd�r||fVqqdS)z	.egg-linkN)rYr�r1)r]rE�entryr%r%r&r_�sz.PackageIndex.scan_egg_links.<locals>.<genexpr>)�filterrYrEr�r��	itertools�starmap�
scan_egg_link)r��search_path�dirsZ	egg_linksr%r%r&�scan_egg_links�s	
zPackageIndex.scan_egg_linksc
Cs�ttjj||���(}ttdttj|���}WdQRXt	|�dkr\dS|\}}xQt
tjj||��D]4}tjj||�|_t|_
|j|�q�WdS)Nr:)�openrYrErcr�r�rrzr{rTrrUr
rJre)r�rEr�Z	raw_lines�linesZegg_pathZ
setup_pathrPr%r%r&r��s("	zPackageIndex.scan_egg_linkc

s�fdd�}xXtj|�D]G}y,|tjj|t|jd����Wq"tk
rhYq"Xq"W||�\}}|rxvt||�D]e}t	|�\}}	|j
d�r�|	r�|r�|d||f7}n
�j|��j|�q�Wt
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)Nr7r:r;r8rT)NN)r2r�r�rrr"r?rTr@rrr��
setdefaultr0r)r�rB�pkg�ver)r�r%r&�scan�s1"z(PackageIndex.process_index.<locals>.scanr8z.pyz
#egg=%s-%scSsd|jddd�S)Nz<a href="%s#md5=%s">%s</a>r8r r:)rN)�mr%r%r&�<lambda>�sz,PackageIndex.process_index.<locals>.<lambda>r�N)r|rxrr"r}r~rNr#r�rIr1�need_version_info�scan_url�PYPI_MD5�sub)
r�rAr�r�rMr�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�rAr%r%r&r��szPackageIndex.need_version_infocGsI|j|jkr5|r(|j||�|jd�|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�sK|j|j|jd�|jj|j�sm|j|�x3t|jj|jf��D]}|j|�q�WdS)Nr7)	r�r��unsafe_namer�r�rj�project_name�not_found_in_indexr�)r��requirementrAr%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��	installerrP)�	__class__r%r&r��s

zPackageIndex.obtaincCsf|j|jd|�|j�sb|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�rY�unlinkrr�r3rErV)r��checkerrZ�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�r2r�rr��append)r��urlsrAr%r%r&�add_find_linkss

zPackageIndex.add_find_linkscCs/|jr"tt|j|j��d|_dS)z7Scan urls scheduled for prescanning (e.g. --find-links)N)r�r�rr�)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_indexcCs�t|t�s�t|�}|ry|j|jd�||�}t|�\}}|jd�ru|j|||�}|Stj	j
|�r�|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.
        r8z.pyrUN)r�rr��
_download_urlrNrIr1�	gen_setuprYrEr�r'r��fetch_distribution)r�r$�tmpdirrC�foundr4rHr%r%r&r9 szPackageIndex.downloadc	s:�jd|�i�d}d�����fdd�}|rf�j��j|�||�}|r�|dk	r�|||�}|dkr��jdk	r��j�||�}|dkr�|r��j|�||�}|dkr�jd�rdp	d|�n#�jd|�|jd	|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�}x�||jD]�}|jtkre�re|�kr �jd|�d�|<q ||kr |jtks��r �j|j��|_tj	j
|j�r |Sq WdS)Nz&Skipping development or system egg: %sr8)rjrJrr�r
r9rU�download_locationrYrEr�)�req�envrP)�
develop_okr��skipped�sourcerr%r&r[s
"z-PackageIndex.fetch_distribution.<locals>.findz:No local packages or working download links found for %s%sza source distribution of r�zBest match: %srU)r�r�r�r�r��cloner)	r�r�r�
force_scanrr	Zlocal_indexrPrr%)r	r�r
rrr&rBs0!




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)rrU)r�r�rr
rrPr%r%r&�fetch�szPackageIndex.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��?}	|	jd|dj|djtjj|�df�WdQRX|S|rLtd	||f��ntd
��dS)NcSsg|]}|jr|�qSr%)�version)r]�dr%r%r&�
<listcomp>�s	z*PackageIndex.gen_setup.<locals>.<listcomp>r8r)�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.)rLrMrrNrTrYrErV�dirnamercZsetuptools.command.easy_installr�shutil�copy2r��writer�r�splitextr)
r�rZrHrrMr�rV�dstrr�r%r%r&r�s2	!"zPackageIndex.gen_setupi c
Cs�|jd|�d\}}zStj|�}|jt|��}t|tjj�rwt	d||j
|jf��|j�}d}|j}d	}	d|kr�t
|d�}
ttt|
��}	|j|||||	�t|d��w}xZ|j|�}|rK|j|�|j|�|d7}|j|||||	�q�Pq�W|j|||�WdQRX|SWd|r�|j�XdS)
NzDownloading %szCan't download %s: %s %srr8zcontent-lengthzContent-Length�wb)NNr<)r�r�r�r�rr�rr�r�rr�r��dl_blocksizer�maxr�int�
reporthookr�r�r�rr�r�)
r�rArZ�fpr�r�r��blocknum�bs�size�sizesr�r�r%r%r&�_download_to�s:	


zPackageIndex._download_tocCsdS)Nr%)r�rArZr Zblksizer"r%r%r&r�szPackageIndex.reporthookcCs�|jd�rt|�Syt||j�SWn�ttjfk
r�}zSdjdd�|jD��}|r�|j	||�nt
d||f��WYdd}~XnItjj
k
r�}z	|SWYdd}~Xntjjk
r8}z:|r
|j	||j�nt
d||jf��WYdd}~Xn�tjk
r�}z:|ri|j	||j�nt
d||jf��WYdd}~Xn`tjtjfk
r�}z4|r�|j	||�nt
d||f��WYdd}~XnXdS)Nzfile:� cSsg|]}t|��qSr%)rz)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)r2�
local_open�open_with_authr�r#r�
InvalidURLrcror�rrr�r��URLError�reason�
BadStatusLine�line�
HTTPException�socket)r�rA�warning�vr�r%r%r&r��s6
(%%zPackageIndex.open_urlcCsKt|�\}}|rLx7d|krH|jdd�jdd�}qWnd}|jd�rq|dd�}tjj||�}|dks�|jd	�r�|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:Tr/)rI�replacer1rYrErcr2�
_download_svn�
_download_git�_download_hgrr��url2pathnamer"r>r��_attempt_download)r�rCrArr3rHrZr%r%r&r
s$% zPackageIndex._download_urlcCs|j|d�dS)NT)r�)r�rAr%r%r&r�'szPackageIndex.scan_urlcCsK|j||�}d|jdd�j�krC|j|||�S|SdS)Nr�zcontent-typer�)r$r�r0�_download_html)r�rArZr�r%r%r&r<*szPackageIndex._attempt_downloadcCs�t|�}xT|D]L}|j�rtjd|�r^|j�tj|�|j||�SPqW|j�tj|�td|��dS)Nz <title>([^- ]+ - )?Revision \d+:zUnexpected HTML page found at )	r�r{r\r�r�rYr�r8r)r�rAr�rZr�r-r%r%r&r=1s




zPackageIndex._download_htmlcCsi|jdd�d}d}|j�jd�r8d|kr8tjj|�\}}}}}}	|r8|jd�r8d|d	d�kr8|d	d�jdd�\}}t|�\}
}|
r8d
|
kr�|
jd
d�\}}
d||
f}n
d|
}|}||||||	f}tjj|�}|jd
||�t	j
d|||f�|S)Nr;r8rr�zsvn:�@z//r7r:�:z --username=%s --password=%sz --username=z'Doing subversion checkout from %s to %szsvn checkout%s -q %s %s)r@r0r2rr"r>r�
urlunparser�rY�system)r�rArZ�credsrC�netlocrEr^�qr��auth�host�user�pwrBr%r%r&r8@s$!$,"
zPackageIndex._download_svncCs�tjj|�\}}}}}|jdd�d}|jdd�d}d}d|krw|jdd�\}}tjj||||df�}||fS)N�+r8r;rr>r�r<)rr"�urlsplitr@�rsplit�
urlunsplit)rA�
pop_prefixrCrCrErGr��revr%r%r&�_vcs_split_rev_from_urlUs!!z$PackageIndex._vcs_split_rev_from_urlcCs�|jdd�d}|j|dd�\}}|jd||�tjd||f�|dk	r�|jd|�tjd	||f�|S)
Nr;r8rrMTzDoing git clone from %s to %szgit clone --quiet %s %szChecking out %sz"(cd %s && git checkout --quiet %s))r@rOr�rYrA)r�rArZrNr%r%r&r9gs	zPackageIndex._download_gitcCs�|jdd�d}|j|dd�\}}|jd||�tjd||f�|dk	r�|jd|�tjd	||f�|S)
Nr;r8rrMTzDoing hg clone from %s to %szhg clone --quiet %s %szUpdating to %sz(cd %s && hg up -C -r %s >&-))r@rOr�rYrA)r�rArZrNr%r%r&r:ws	zPackageIndex._download_hgcGstj||�dS)N)rr�)r�r�ror%r%r&r��szPackageIndex.debugcGstj||�dS)N)rr�)r�r�ror%r%r&r��szPackageIndex.infocGstj||�dS)N)rr�)r�r�ror%r%r&r��szPackageIndex.warn)r�)'r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r9rrrrr$rr�rr�r<r=r8�staticmethodrOr9r:r�r�r�r%r%)r�r&r!sL2
+			#D
)$#z!&(#(\d+|x[\da-fA-F]+)|[\w.:-]+);?cCs6t|t�s|S|dkr,tj|�St|�S)N�)r�rr�unichr�chr)�cr%r%r&�uchr�s

rUcCs�|jd�}|jd�r:t|dd�d�}nL|jd�rbt|dd��}n$tjjjj||jd��}t|�S)Nr8z#xr:r*r;r)	rNr2rrrf�
html_entities�name2codepointr�rU)rM�whatr%r%r&�
decode_entity�s$rYcCs
tt|�S)z'Decode HTML entities in the given text.)�
entity_subrY)�textr%r%r&r~�sr~cs�fdd�}|S)Ncs��fdd�}|S)Ncs?tj�}tj��z�||�SWdtj|�XdS)N)r/�getdefaulttimeout�setdefaulttimeout)rorpZold_timeout)rq�timeoutr%r&�_socket_timeout�s

z@socket_timeout.<locals>._socket_timeout.<locals>._socket_timeoutr%)rqr_)r^)rqr&r_�sz'socket_timeout.<locals>._socket_timeoutr%)r^r_r%)r^r&�socket_timeout�sr`cCsItjj|�}|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�r7)rEZauth_sZ
auth_bytesZ
encoded_bytes�encodedr%r%r&�_encode_auth�s
rfc@s:eZdZdZdd�Zdd�Zdd�ZdS)	�
Credentialz:
    A username/password pair. Use like a namedtuple.
    cCs||_||_dS)N)�username�password)r�rhrir%r%r&r��s	zCredential.__init__ccs|jV|jVdS)N)rhri)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�rjrlr%r%r%r&rg�srgc@sFeZdZdd�Zedd��Zdd�Zdd�Zd	S)
�
PyPIConfigcCsrtjdddgd�}tjj||�tjjtjjd�d�}tjj	|�rn|j
|�dS)z%
        Load from ~/.pypirc
        rhri�
repositoryr��~z.pypircN)�dict�fromkeysr�RawConfigParserr�rYrErc�
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)rn)r�r{)r]�section)r�r%r&r�s	z2PyPIConfig.creds_by_repository.<locals>.<listcomp>)�sectionsrpr�_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)Nrnrhri)r�r{rg)r�rv�repor%r%r&rx�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)ry�itemsr2)r�rArn�credr%r%r&�find_credentialszPyPIConfig.find_credentialN)r�r�r�r��propertyryrxr}r%r%r%r&rm�s	rmcCs�tjj|�\}}}}}}|jd�rBtjd��|d
krct|�\}}	nd}|s�t�j|�}
|
r�t	|
�}|
j
|f}tjd|�|rdt
|�}||	||||f}tjj|�}
tjj|
�}|jd|�ntjj|�}|jd	t�||�}|r�tjj|j�\}}}}}}||kr�||	kr�||||||f}tjj|�|_|S)z4Open a urllib2 request, handling HTTP authenticationr?znonnumeric port: ''�http�httpsNz*Authenticating as %s for %s (from .pypirc)zBasic �
Authorizationz
User-Agent)rr�)rr"r>r1rr)rrmr}rzrhrr�rfr@r��Request�
add_header�
user_agentrA)rAr�rCrCrE�paramsrGr�rErFr|r�rBr�r�r�s2�h2�path2Zparam2Zquery2Zfrag2r%r%r&r(s6$'r(cCs|S)Nr%)rAr%r%r&�
fix_sf_url<sr�cCs�tjj|�\}}}}}}tjj|�}tjj|�rXtjj|�S|j	d�rNtjj
|�rNg}x�tj|�D]�}	tjj||	�}
|	dkr�t
|
d��}|j�}WdQRXPntjj
|
�r�|	d7}	|jdjd|	��q�Wd}
|
jd|d	d
j|��}d\}}nd\}}}ddi}tj|�}tjj|||||�S)z7Read a local path, with special support for directoriesr7z
index.html�rNz<a href="{name}">{name}</a>r3zB<html><head><title>{url}</title></head><body>{files}</body></html>rA�filesra���OK��Path not found�	Not foundzcontent-typez	text/html)r�r�)r�r�r�)rr"r>r�r;rYrE�isfiler�r1r�r�rcr�r�r��formatr�StringIOr�r�)rArCrDrE�paramrGr�rZr�r��filepathr�bodyr��status�messager�Zbody_streamr%r%r&r'@s,$!
!r')\r��sysrYr\rr/rcr�r��	functoolsr�urllib.parser�ImportError�urllib2Zsetuptools.externrZsetuptools.extern.six.movesrrrrr!�
pkg_resourcesr	r
rrr
rrrrrrrr�	distutilsr�distutils.errorsr�fnmatchrZsetuptools.py26compatrZsetuptools.py27compatrr�rL�Ir|r�rMr�r@rS�__all__Z_SOCKET_TIMEOUTZ_tmplr�rr�r'rrIrrKr[rrnrsrwr��objectr�r�rr�rZrUrYr~r`rfrgrrrmr�r�r(r�r'r%r%r%r&�<module>s~
"R			%	"
!��t&.

?>