HEX
Server: Apache
System: Linux scp1.abinfocom.com 5.4.0-216-generic #236-Ubuntu SMP Fri Apr 11 19:53:21 UTC 2025 x86_64
User: confeduphaar (1010)
PHP: 8.1.33
Disabled: exec,passthru,shell_exec,system
Upload Files
File: //usr/lib/python3/dist-packages/setuptools/__pycache__/package_index.cpython-38.pyc
U

tD7h���@s�dZddlZddlZddlZddlZddlZddlZddlZddlZddl	Z	ddl
Z
ddlmZddl
mZddlmZmZmZmZddlZddlmZmZmZmZmZmZmZmZmZmZm Z m!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/e0Z1e�2d�Z3e�2dej4�Z5e�2d�Z6e�2dej4�j7Z8d�9�Z:ddddgZ;dZ<dZ=e=j>dj>ej?�ed�Z@dd�ZAdd�ZBdd�ZCdGd d�ZDdHd!d"�ZEdId#d$�ZFdedfd%d�ZGdJd&d'�ZHd(d)�ZIe�2d*ej4�ZJeId+d,��ZKGd-d.�d.�ZLGd/d0�d0eL�ZMGd1d�de�ZNe�2d2�jOZPd3d4�ZQd5d6�ZRdKd7d8�ZSd9d:�ZTGd;d<�d<�ZUGd=d>�d>ejV�ZWejXjYfd?d@�ZZdAdB�Z[eSe<�eZ�ZZdCdD�Z\dEdF�Z]dS)Lz#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>\n\s+\(<a (?:title="MD5 hash"\n\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}z{}.{})Zpy_major�
setuptoolscCs4zt�|�WStk
r.td|f��YnXdS)Nz1Not a URL, existing file, or requirement spec: %r)r�parse�
ValueErrorr)�spec�r&�:/usr/lib/python3/dist-packages/setuptools/package_index.py�parse_requirement_arg6s�r(cCs�|��}d\}}}|�d�r�|�d�r8|dd�}d}nn|�dd�rb|d	d
�}|dd�}d}nD|�d�r~|dd�}d
}n(|�dd�r�|d	d
�}|dd�}d
}|||fS)z=Return (base,pyversion) or (None,None) for possible .exe name)NNN�.exez
.win32.exeNi����Zwin32z	.win32-pyi�i�������z.win-amd64.exei�z	win-amd64z
.win-amd64-pyi��)�lower�endswith�
startswith)�namer+�base�py_verZplatr&r&r'r?s$



c	Csxtj�|�}|\}}}}}}tj�|�d�d�}|dkrX|dkrXtj�|�d�d�}d|krp|�dd�\}}||fS)N�/���zsourceforge.net�download����#�)rr#�urlparse�unquote�split)	�url�parts�scheme�server�pathZ
parameters�query�fragmentr/r&r&r'�egg_info_for_urlWsrAccs\t|�\}}t|||�D]
}|Vq|rXt�|�}|rXt||�d�|td�D]
}|VqLdS)zEYield egg or source distribution objects that might be found at a URLr6)�
precedenceN)rA�distros_for_location�EGG_FRAGMENT�matchr �groupr	)r:�metadatar/r@�distrEr&r&r'rbs
�
cCs�|�d�r|dd�}|�d�r8d|kr8t�|||�gS|�d�rxd|krxt|�}|��s^gSt||j|jtdd�gS|�d	�r�t|�\}}}|dk	r�t	||||t
|�StD]0}|�|�r�|dt|��}t	|||�Sq�gS)
z:Yield egg or source distribution objects based on basename�.egg.zipNr*z.egg�-z.whlr6)�location�project_name�versionrBr))
r,r
Z
from_locationrZ
is_compatiblerLrMrrr r�
EXTENSIONS�len)rK�basenamerGZwheelZwin_baser0�platformZextr&r&r'rCps<
�
�
rCcCstt|�tj�|�|�S)zEYield possible egg or source distribution objects based on a filename)rCr�osr>rP)�filenamerGr&r&r'�distros_for_filename�s

�rTc
cs||�d�}|s,tdd�|dd�D��r,dStdt|�d�D]8}t||d�|d|��d�||d��|||d�Vq>dS)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!
    rJcss|]}t�d|�VqdS)z	py\d\.\d$N)�rerE)�.0�pr&r&r'�	<genexpr>�sz(interpret_distro_name.<locals>.<genexpr>�Nr6)�
py_versionrBrQ)r9�any�rangerOr
�join)rKrPrGrZrBrQr;rWr&r&r'r �s
�ccsft�}|j}|dkr:tj�|j|�D]}||�|Vq$n(|D]"}||�}||kr>||�|Vq>dS)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
rgcst���fdd��}|S)zs
    Wrap a function returning an iterable such that the resulting iterable
    only ever yields unique items.
    cst�||��S�N)rg)�args�kwargs��funcr&r'�wrapper�szunique_values.<locals>.wrapperr)rlrmr&rkr'�
unique_values�srnz3<([^>]*\srel\s{0,10}=\s{0,10}['"]?([^'" >]+)[^>]*)>c	cs�t�|�D]d}|��\}}tttj|���d���}d|ksDd|kr
t	�|�D]}t
j�|t
|�d���VqNq
dD]@}|�|�}|dkrtt	�||�}|rtt
j�|t
|�d���VqtdS)zEFind rel="homepage" and rel="download" links in `page`, yielding URLs�,Zhomepager3r6)z
<th>Home Pagez<th>Download URLr2N)�REL�finditer�groupsr^r�str�stripr+r9�HREFrr#�urljoin�
htmldecoderF�find�search)r:�pagerE�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@sBeZdZe�d�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||_t�|�|_||_dSrh)�	hash_name�hashlib�new�hash�expected)r�r�r�r&r&r'�__init__szHashChecker.__init__cCs>tj�|�d}|st�S|j�|�}|s0t�S|f|���S)z5Construct a (possibly null) ContentChecker from a URLr2)rr#r7r~�patternry�	groupdict)�clsr:r@rEr&r&r'�from_urlszHashChecker.from_urlcCs|j�|�dSrh)r��updaterr&r&r'r�!szHashChecker.feedcCs|j��|jkSrh)r�Z	hexdigestr�r�r&r&r'r�$szHashChecker.is_validcCs||j}||�Srh)r�)r�r�r��msgr&r&r'r�'s
zHashChecker.reportN)r�r�r�rU�compiler�r��classmethodr�r�r�r�r&r&r&r'r�s�

r�csReZdZdZdNdd�ZdOd	d
�ZdPdd�ZdQd
d�Zdd�Zdd�Z	dd�Z
dd�ZdRdd�Zdd�Z
dS�fdd�	Zdd�Zdd �Zd!d"�Zd#d$�Zd%d&�ZdTd'd(�ZdUd)d*�Zd+d,�Zd-Zd.d/�Zd0d1�ZdVd2d3�Zed4d5��Zd6d7�Zed8d9��Zd:d;�Zd<d=�Z d>d?�Z!d@dA�Z"dBdC�Z#dDdE�Z$edFdG��Z%dHdI�Z&dJdK�Z'dLdM�Z(�Z)S)Wrz;A distribution index that scans web pages for download URLs�https://pypi.org/simple/��*NTcOs�tj|f|�|�|dd|�d��|_i|_i|_i|_t�d�	t
t|���j|_
g|_|ortjor|prt��}|r�t�|�|_n
tjj|_dS)Nr1�|)rr�r,�	index_url�scanned_urls�fetched_urls�
package_pagesrUr�r]rrrE�allows�to_scanrZis_availableZfind_ca_bundleZ
opener_for�openerr�request�urlopen)r�r�ZhostsZ	ca_bundleZ
verify_sslri�kwZuse_sslr&r&r'r�/s�
�zPackageIndex.__init__FcCs�||jkr|sdSd|j|<t|�s2|�|�dStt|��}|r\|�|�sPdS|�d|�|sn|rn||jkr�tt|j	|��dS|�|�s�d|j|<dS|�
d|�d|j|<d}|�|||�}|dkr�dSd|j|j<d|j
�dd���k�r|��dS|j}|��}t|t��sNt|tjj��r0d	}n|j
�d
��p@d	}|�|d�}|��t�|�D](}	tj�|t|	�d���}
|�|
��q`|� |j!��r�t"|d
d�dk�r�|�#||�}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!�html�content-type�zlatin-1�charset�ignorer6�code�)$r��
URL_SCHEME�process_filename�listr�url_ok�debugr�rr_�info�open_urlr:�headers�getr+�close�read�
isinstancersr�error�	HTTPErrorZ	get_param�decoderurqr#rvrwrF�process_urlr-r��getattr�
process_index)r�r:Zretrieve�dists�tmpl�fr/rzr�rE�linkr&r&r'r�DsP





 zPackageIndex.process_urlcCs�tj�|�s|�d|�dStj�|�r^|s^tj�|�}t�|�D]}|�tj�||�d�qBt	|�}|r�|�
d|�tt|j
|��dS)Nz
Not found: %sTz	Found: %s)rRr>�exists�warn�isdir�realpath�listdirr�r]rTr�r�rr_)r��fn�nestedr>�itemr�r&r&r'r�wszPackageIndex.process_filenamecCsbt|�}|o|�d���dk}|s8|�tj�|�d�r<dSd}|rRt||��n|�||�dS)Nr6�fileTzN
Note: Bypassing %s (disallowed host; see http://bit.ly/2hrImnY for details).
)	r�rFr+r�rr#r7rr�)r�r:Zfatal�s�is_filer�r&r&r'r��s�zPackageIndex.url_okcCs2ttjj|�}dd�|D�}tt�|j|��dS)Ncss0|](}t�|�D]}|�d�r||fVqqdS)z	.egg-linkN)rRr�r,)rVr>�entryr&r&r'rX�s

�z.PackageIndex.scan_egg_links.<locals>.<genexpr>)�filterrRr>r�r��	itertools�starmap�
scan_egg_link)r��search_path�dirsZ	egg_linksr&r&r'�scan_egg_links�s
�zPackageIndex.scan_egg_linksc	Cs�ttj�||���}ttdttj|���}W5QRXt	|�dkrDdS|\}}t
tj�||��D](}tjj|f|��|_t|_
|�|�q^dS)NrY)�openrRr>r]r�r�rrsrtrOrrKr
rBr_)r�r>r�Z	raw_lines�linesZegg_pathZ
setup_pathrHr&r&r'r��s zPackageIndex.scan_egg_linkc
	s��fdd�}t�|�D]:}z |tj�|t|�d����Wqtk
rNYqXq||�\}}|r�t||�D]H}t	|�\}}	|�
d�r�|	s�|r�|d||f7}n
��|���|�qlt
�dd�|�SdSd	S)
z#Process the contents of a PyPI pagecs�|��j�r�tttjj|t�j�d��d���}t|�dkr�d|dkr�t	|d�}t
|d�}d�j�|�
�i�|<t|�t|�fSdS)Nr1rYr5r6rT)NN)r-r�r�rrr#r8rOr9rrr��
setdefaultr+r)r�r;�pkg�verr�r&r'�scan�s�z(PackageIndex.process_index.<locals>.scanr6�.pyz
#egg=%s-%scSsd|�ddd�S)Nz<a href="%s#md5=%s">%s</a>r6�rY)rF)�mr&r&r'�<lambda>��z,PackageIndex.process_index.<locals>.<lambda>r�N)rurqrr#rvrwrFr$r}rAr,�need_version_info�scan_url�PYPI_MD5�sub)
r�r:rzr�rEr�r��new_urlr/�fragr&r�r'r��s( 
�zPackageIndex.process_indexcCs|�d|�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��s�zPackageIndex.need_version_infocGs:|j|jkr*|r |j|f|��|�d�|�|j�dS)Nz6Scanning index of all packages (this may take a while))r�r�r�r�r��r�r�rir&r&r'r��s�zPackageIndex.scan_allcCsz|�|j|jd�|j�|j�s:|�|j|jd�|j�|j�sR|�|�t|j�|jd��D]}|�|�qfdS)Nr1r&)	r�r��unsafe_namer�r�rcrL�not_found_in_indexr�)r��requirementr:r&r&r'�
find_packages�s
zPackageIndex.find_packagescsR|��|�|�||jD]"}||kr0|S|�d||�qtt|��||�S)Nz%s does not match %s)�prescanr�rcr��superr�obtain)r�r�Z	installerrH��	__class__r&r'r��s
zPackageIndex.obtaincCsL|�|jd|�|��sH|��t�|�td|jjtj	�
|�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�rR�unlinkrr�r.r>rP)r��checkerrS�tfpr&r&r'�
check_hashs�
��zPackageIndex.check_hashcCsN|D]D}|jdks0t|�r0|�d�s0tt|��r<|�|�q|j�|�qdS)z;Add `urls` to the list that will be prescanned for searchesN�file:)r�r�r-r�rr��append)r�Zurlsr:r&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�|��dS)Nz#Couldn't retrieve index page for %rz3Couldn't find index page for %r (maybe misspelled?))rcr�r�r�r�)r�r��methr�r&r&r'r�%s
�zPackageIndex.not_found_in_indexcCsvt|t�sbt|�}|rJ|�||�}t|�\}}|�d�rF|�|||�}|Stj�	|�rZ|St
|�}t|�||�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�rKN)
r�rr��
_download_urlrAr,�	gen_setuprRr>r�r(r��fetch_distribution)r�r%�tmpdirr<�foundr/r@r&r&r'r3/s

zPackageIndex.downloadc	s���d|�i�d}d
�����fdd�	}|rH�����|�||�}|s^|dk	r^|||�}|dkr��jdk	rx���||�}|dkr�|s���|�||�}|dkr���d�r�dp�d|�n��d|�|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�}||jD]v}|jtkrF�sF|�kr��d|�d�|<q||ko\|jtkp\�}|r��|j��}||_tj	�
|j�r|SqdS)Nz&Skipping development or system egg: %sr6)rcrBrr�r
r3rK�download_locationrRr>r�)Zreq�envrHZtestZloc��
develop_okr�Zskipped�sourcerr&r'rxis&��z-PackageIndex.fetch_distribution.<locals>.findz:No local packages or working download links found for %s%sza source distribution of r�zBest match: %s)rK)N)r�r�r�r�r��cloner)	r�r�r�
force_scanrrZlocal_indexrHrxr&rr'rQs2




�zPackageIndex.fetch_distributioncCs"|�||||�}|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)rrK)r�r�rr	rrHr&r&r'�fetch�szPackageIndex.fetchc
	Cs�t�|�}|r*dd�t||�d�d�D�p,g}t|�dkr�tj�|�}tj�|�|kr�tj�	||�}ddl
m}|||�s�t�
||�|}ttj�	|d�d��2}	|	�d|dj|djtj�|�df�W5QRX|S|r�td	||f��ntd
��dS)NcSsg|]}|jr|�qSr&)rM)rV�dr&r&r'�
<listcomp>�s�z*PackageIndex.gen_setup.<locals>.<listcomp>r6r)�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.)rDrEr rFrOrRr>rP�dirnamer]Zsetuptools.command.easy_installr
�shutilZcopy2r��writerLrM�splitextr)
r�rSr@rrEr�rPZdstr
r�r&r&r'r��sB

��
������zPackageIndex.gen_setupi c	Cs|�d|�d}z�t�|�}|�|�}t|tjj�rJt	d||j
|jf��|��}d}|j}d}d|kr�t
|d�}	ttt|	��}|�|||||�t|d��V}
|�|�}|r�|�|�|
�|�|d7}|�|||||�q�q�q�|�|||
�W5QRX|W�S|�r|��XdS)	NzDownloading %szCan't download %s: %s %srr2zcontent-lengthzContent-Length�wbr6)r�r�r�r�r�r�rr�r�rr�r��dl_blocksizer�maxr�int�
reporthookr�r�r�rr�)r�r:rS�fpr�r��blocknumZbs�sizeZsizesr�r�r&r&r'�_download_to�s:

�



zPackageIndex._download_tocCsdSrhr&)r�r:rSrZblksizerr&r&r'r�szPackageIndex.reporthookc
Cs�|�d�rt|�Szt||j�WSttjfk
r�}z<d�dd�|jD��}|r`|�	||�nt
d||f��W5d}~XY�ntjj
k
r�}z|WY�Sd}~XYn�tjjk
�r�}z*|r�|�	||j�nt
d||jf��W5d}~XYn�tjk
�rF}z,|�r$|�	||j�nt
d||jf��W5d}~XYnPtjtjfk
�r�}z(|�rt|�	||�nt
d||f��W5d}~XYnXdS)Nr�� cSsg|]}t|��qSr&)rs)rV�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)r-�
local_open�open_with_authr�r$r�
InvalidURLr]rir�rrr�r�ZURLError�reasonZ
BadStatusLine�lineZ
HTTPException�socket)r�r:Zwarning�vr�r&r&r'r��s>
"����zPackageIndex.open_urlcCsxt|�\}}|r0d|kr4|�dd��dd�}qnd}|�d�rJ|dd�}tj�||�}|�t|��sttd	|����|S)
aB
        >>> import pathlib
        >>> du = PackageIndex._resolve_download_filename
        >>> root = getfixture('tmp_path')
        >>> url = 'https://files.pythonhosted.org/packages/a9/5a/0db.../setuptools-78.1.0.tar.gz'
        >>> str(pathlib.Path(du(url, root)).relative_to(root))
        'setuptools-78.1.0.tar.gz'

        Ensures the target is always in tmpdir.

        >>> url = 'https://anyhost/%2fhome%2fuser%2f.ssh%2fauthorized_keys'
        >>> du(url, root)
        Traceback (most recent call last):
        ...
        ValueError: Invalid filename...
        z..�.�\�_Z__downloaded__rINr*zInvalid filename )	rA�replacer,rRr>r]r-rsr$)r:rr.r@rSr&r&r'�_resolve_download_filenames
z'PackageIndex._resolve_download_filenamecCs$|�||�}|�||�p"|�||�S)z2
        Determine the download filename.
        )r)�
_download_vcs�_download_other)r�r:rrSr&r&r'r�CszPackageIndex._download_urlcCsLtj�|�j}|�d�\}}}tddgdgt|��}tt|h|@�d�S)a

        >>> rvcs = PackageIndex._resolve_vcs
        >>> rvcs('git+http://foo/bar')
        'git'
        >>> rvcs('hg+https://foo/bar')
        'hg'
        >>> rvcs('git:myhost')
        'git'
        >>> rvcs('hg:myhost')
        >>> rvcs('http://foo/bar')
        �+�svn�git�hgN)	rr#�urlsplitr<�	partitionr^�bool�next�iter)r:r<�pre�sep�postZallowedr&r&r'�_resolve_vcsJs
zPackageIndex._resolve_vcsc
Cs�|�|�}|sdS|dkr&|�||�S|�d�\}}}|�|�\}}|�d|�d|�d|���t�|dd||g�t|d|d	d|g|d
|ddd|d
gd�}|dk	r�|�d|���t�||�|S)Nr-r5zDoing z clone from z to rz--quietz-C�checkoutz--cwdZupz-r�-q)r.r/z
Checking out )r8�
_download_svnr1�_vcs_split_rev_from_urlr��
subprocess�
check_call�dict)r�r:Z
spec_filenameZvcsrSr'�revZco_commandsr&r&r'r*]s"
�zPackageIndex._download_vcscCsDtj�|�j}|dkr,tj�tj�|�j�S|�|d�|�	||�S)Nr�T)
rr#r0r<r��url2pathnamer7r>r��_attempt_download)r�r:rSr<r&r&r'r+ts
zPackageIndex._download_othercCs|�|d�dS)NT)r�r�r&r&r'r�|szPackageIndex.scan_urlcCs6|�||�}d|�dd���kr.|�|||�S|SdS)Nr�r�r�)rr�r+�_download_html)r�r:rSr�r&r&r'rBszPackageIndex._attempt_downloadcCsnt|�}|D]>}|��rt�d|�rF|��t�|�|�||�SqLq|��t�|�td|��dS)Nz <title>([^- ]+ - )?Revision \d+:zUnexpected HTML page found at )	r�rtrUryr�rRr�r;r)r�r:r�rSr�r"r&r&r'rC�s

zPackageIndex._download_htmlcCs t�dt�|�dd�d}g}|���d�r�d|kr�tj�|�\}}}}}}	|s�|�d�r�d|d	d�kr�|d	d��dd�\}}t	|�\}
}|
r�d
|
kr�|
�d
d�\}}
|�
d|d|
g�n|�
d|
g�|}||||||	f}tj�|�}|�d
||�dddg|||g}t
�|�|S)Nz"SVN download support is deprecatedr5r6rzsvn:�@z//r1rY�:z
--usernamez
--passwordz'Doing subversion checkout from %s to %sr-r9r:)�warningsr��UserWarningr9r+r-rr#r7�
_splituser�extend�
urlunparser�r=r>)r�r:rSZcredsr<�netlocr>rW�qr��auth�host�userZpwr;�cmdr&r&r'r;�s(
zPackageIndex._download_svncCsttj�|�}|j�dd�d}|j�d�\}}}|�d�\}}}|rL||fn|df\}}	|j||dd��	�}
|
|	fS)	a�
        Given a possible VCS URL, return a clean URL and resolved revision if any.

        >>> vsrfu = PackageIndex._vcs_split_rev_from_url
        >>> vsrfu('git+https://github.com/pypa/setuptools@v69.0.0#egg-info=setuptools')
        ('https://github.com/pypa/setuptools', 'v69.0.0')
        >>> vsrfu('git+https://github.com/pypa/setuptools#egg-info=setuptools')
        ('https://github.com/pypa/setuptools', None)
        >>> vsrfu('http://foo/bar')
        ('http://foo/bar', None)
        r,r6r2r5rDNr�)r<r>r@)
rr#r0r<r9r>r1�
rpartition�_replaceZgeturl)r:r;Zclean_schemeZno_fragment_pathr'r5r6r7Z
clean_pathr@Zresolvedr&r&r'r<�s
�
z$PackageIndex._vcs_split_rev_from_urlcGstj|f|��dSrh)rr�r�r&r&r'r��szPackageIndex.debugcGstj|f|��dSrh)rr�r�r&r&r'r��szPackageIndex.infocGstj|f|��dSrh)rr�r�r&r&r'r��szPackageIndex.warn)r�r�NT)F)F)F)N)N)FFFN)FF)N)*r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r3rr
r�rrrr��staticmethodr)r�r8r*r+r�rBrCr;r<r�r�r��
__classcell__r&r&r�r'r,s`�

3



+
		
#�
L

)$
#
#

z!&(#(\d+|x[\da-fA-F]+)|[\w.:-]+);?cCs|�d�}t|�S)Nr)rFr)rEZwhatr&r&r'�
decode_entity�s
rUcCs
tt|�S)a
    Decode HTML entities in the given text.

    >>> htmldecode(
    ...     'https://../package_name-0.1.2.tar.gz'
    ...     '?tokena=A&amp;tokenb=B">package_name-0.1.2.tar.gz')
    'https://../package_name-0.1.2.tar.gz?tokena=A&tokenb=B">package_name-0.1.2.tar.gz'
    )�
entity_subrU)�textr&r&r'rw�s	rwcs�fdd�}|S)Ncs��fdd�}|S)Nc	s2t��}t���z�||�W�St�|�XdSrh)r#ZgetdefaulttimeoutZsetdefaulttimeout)rirjZold_timeout)rl�timeoutr&r'�_socket_timeout�s

z@socket_timeout.<locals>._socket_timeout.<locals>._socket_timeoutr&)rlrY�rXrkr'rY�sz'socket_timeout.<locals>._socket_timeoutr&)rXrYr&rZr'�socket_timeout�sr[cCs2tj�|�}|��}t�|�}|��}|�dd�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#r8�encode�base64Z	b64encoder�r()rMZauth_sZ
auth_bytesZ
encoded_bytesZencodedr&r&r'�_encode_auth�s

r_c@s(eZdZdZdd�Zdd�Zdd�ZdS)	�
Credentialz:
    A username/password pair. Use like a namedtuple.
    cCs||_||_dSrh��username�password)r�rbrcr&r&r'r�szCredential.__init__ccs|jV|jVdSrhrar�r&r&r'�__iter__szCredential.__iter__cCsdt|�S)Nz%(username)s:%(password)s)�varsr�r&r&r'�__str__szCredential.__str__N)r�r�r�r�r�rdrfr&r&r&r'r`sr`c@s0eZdZdd�Zedd��Zdd�Zdd�Zd	S)
�
PyPIConfigcCsPt�dddgd�}tj�||�tj�tj�d�d�}tj�	|�rL|�
|�dS)z%
        Load from ~/.pypirc
        rbrc�
repositoryr��~z.pypircN)r?�fromkeysr�RawConfigParserr�rRr>r]�
expanduserr�r�)r��defaultsZrcr&r&r'r�$s
zPyPIConfig.__init__cs&�fdd����D�}tt�j|��S)Ncs g|]}��|d���r|�qS)rh)r�rt)rV�sectionr�r&r'r1s�z2PyPIConfig.creds_by_repository.<locals>.<listcomp>)Zsectionsr?r�_get_repo_cred)r�Zsections_with_repositoriesr&r�r'�creds_by_repository/s
�zPyPIConfig.creds_by_repositorycCs6|�|d���}|t|�|d���|�|d����fS)Nrhrbrc)r�rtr`)r�rnZrepor&r&r'ro8s
�zPyPIConfig._get_repo_credcCs*|j��D]\}}|�|�r
|Sq
dS)z�
        If the URL indicated appears to be a repository defined in this
        config, return the credential for that repository.
        N)rp�itemsr-)r�r:rh�credr&r&r'�find_credential?s
zPyPIConfig.find_credentialN)r�r�r�r��propertyrprorsr&r&r&r'rg#s

rgcCs:tj�|�}|\}}}}}}|�d�r0t�d��|dkrFt|�\}	}
nd}	|	s~t��|�}|r~t	|�}	|j
|f}tjd	|��|	r�dt
|	�}	||
||||f}
tj�|
�}tj�|�}|�d|	�ntj�|�}|�dt�||�}|	�r6tj�|j�\}}}}}}||k�r6||
k�r6||||||f}
tj�|
�|_|S)
z4Open a urllib2 request, handling HTTP authenticationrEznonnumeric port: '')ZhttpZhttpsN�*Authenticating as %s for %s (from .pypirc)zBasic Z
Authorizationz
User-Agent)ru)rr#r7r,rr rHrgrsrsrbrr�r_rJr�ZRequestZ
add_header�
user_agentr:)r:r�Zparsedr<rKr>Zparamsr?r�rMZaddressrrr�r;r�r�r�s2Zh2Zpath2Zparam2Zquery2Zfrag2r&r&r'rIs8


rcCs |�d�\}}}|r|nd|fS)zNsplituser('user[:passwd]@host[:port]')
    --> 'user[:passwd]', 'host[:port]'.rDN)rQ)rNrOZdelimr&r&r'rHxsrHcCs|Srhr&)r:r&r&r'�
fix_sf_url�srxc
Cstj�|�\}}}}}}tj�|�}tj�|�r<tj�|�S|�	d�r�tj�
|�r�g}t�|�D]d}	tj�||	�}
|	dkr�t
|
d��}|��}W5QRXq�ntj�
|
�r�|	d7}	|�dj|	d��q`d}
|
j|d�|�d�}d	\}}n
d
\}}}ddi}t�|�}tj�|||||�S)
z7Read a local path, with special support for directoriesr1z
index.html�rz<a href="{name}">{name}</a>)r.zB<html><head><title>{url}</title></head><body>{files}</body></html>r\)r:�files)��ZOK)r�zPath not foundz	Not foundr�z	text/html)rr#r7r�rArRr>�isfiler�r,r�r�r]r�r�r��formatr�StringIOr�r�)r:r<r=r>Zparamr?r�rSrzr��filepathrZbodyr�Zstatus�messager�Zbody_streamr&r&r'r�s.�


r)N)N)N)N)r!)^r��sysr=rRrUrr#r^r�r�rF�	functoolsrZsetuptools.externrZsetuptools.extern.six.movesrrrrr"Z
pkg_resourcesr	r
rrr
rrrrrrrrrZ	distutilsrZdistutils.errorsrZfnmatchrZsetuptools.py27compatrZsetuptools.py33compatrZsetuptools.wheelr�typeZ
__metaclass__r�rD�Irur�rEr�r9rN�__all__Z_SOCKET_TIMEOUTZ_tmplr}�version_inforvr(rrArrCrTr rgrnrpr}r~r�rr�rVrUrwr[r_r`rkrgr�r�rrHrxrr&r&r&r'�<module>s�<
��
�	

!
�
$


!2
&/