OwlCyberSecurity - MANAGER
Edit File: locators.cpython-310.pyc
o ����ƚRe������������������������@���s0��d�dl�Z�d�dlmZ�d�dlZd�dlZd�dlZd�dlZd�dlZzd�dlZW�n �e y1���d�dl ZY�nw�d�dlZddlm Z �ddlmZmZmZmZmZmZmZmZmZmZmZmZmZmZ�ddlmZm Z m!Z!�ddl"m#Z#m$Z$�ddl%m&Z&m'Z'm(Z(m)Z)m*Z*m+Z+m,Z,m-Z-�dd l.m/Z/m0Z0�dd l1m2Z2m3Z3�e�4e5�Z6e�7d�Z8e�7dej9�Z:e�7d �Z;dZ<d,dd�Z=G�dd��de�Z>G�dd��de?�Z@G�dd��de@�ZAG�dd��de@�ZBG�dd��de?�ZCG�dd��de@�ZDG�dd��de@�ZEG�dd ��d e@�ZFG�d!d"��d"e@�ZGG�d#d$��d$e@�ZHeHeF��eDd%d&d'�d(d)�ZIeIjJZJG�d*d+��d+e?�ZKdS�)-�����N)�BytesIO����)�DistlibException)�urljoin�urlparse� urlunparse�url2pathname�pathname2url�queue�quote�unescape�build_opener�HTTPRedirectHandler� text_type�Request� HTTPError�URLError)�Distribution�DistributionPath� make_dist)�Metadata�MetadataInvalidError)�cached_property�ensure_slash�split_filename�get_project_data�parse_requirement�parse_name_and_version�ServerProxy�normalize_name)� get_scheme�UnsupportedVersionError)�Wheel� is_compatiblez^(\w+)=([a-f0-9]+)z;\s*charset\s*=\s*(.*)\s*$ztext/html|application/x(ht)?mlzhttps://pypi.org/pypic�����������������C���s:���|�du�rt�}�t|�dd�}z |���W�|d����S�|d����w�)z� Return all distribution names known by an index. :param url: The URL of the index. :return: A list of all known distribution names. N�������@��timeout�close)� DEFAULT_INDEXr���� list_packages)�url�client��r,�����/builddir/build/BUILDROOT/alt-python310-pip-21.3.1-3.el8.x86_64/opt/alt/python310/lib/python3.10/site-packages/pip/_vendor/distlib/locators.py�get_all_distribution_names)���s���r.���c�������������������@���s$���e�Zd�ZdZdd��Ze�Z�ZZdS�)�RedirectHandlerzE A class to work around a bug in some Python 3.2.x releases. c����������� ������C���s����d�}dD�]}||v�r||�}�nq|d�u�rd�S�t�|�}|jdkr7t|���|�}t|d�r3|�||��n|||<�t�|�|||||�S�)N)�location�uri���replace_header)r����schemer����get_full_url�hasattrr3����BaseRedirectHandler�http_error_302) �self�req�fp�code�msg�headers�newurl�key�urlpartsr,���r,���r-���r8���@���s"���� �zRedirectHandler.http_error_302N)�__name__� __module__�__qualname__�__doc__r8����http_error_301�http_error_303�http_error_307r,���r,���r,���r-���r/���7���s����r/���c�������������������@���s����e�Zd�ZdZdZdZdZdZed�Zd)dd �Z d d��Z dd ��Zdd��Zdd��Z dd��Zee e�Zdd��Zdd��Zdd��Zdd��Zdd��Zdd��Zd d!��Zd"d#��Zd$d%��Zd*d'd(�ZdS�)+�LocatorzG A base class for locators - things that locate distributions. )z.tar.gzz.tar.bz2z.tarz.zipz.tgzz.tbz)z.eggz.exe�.whl)z.pdfN)rJ����defaultc�����������������C���s,���i�|�_�||�_tt���|�_d|�_t���|�_dS�)a^�� Initialise an instance. :param scheme: Because locators look for most recent versions, they need to know the version scheme to use. This specifies the current PEP-recommended scheme - use ``'legacy'`` if you need to support existing distributions on PyPI. N) �_cacher4���r ���r/����opener�matcherr ����Queue�errors)r9���r4���r,���r,���r-����__init__f���s ���zLocator.__init__c�����������������C���sX���g�}|�j����s*z |�j��d�}|�|��W�n�|�j�jy���Y�qw�|�j�����|�j����r|S�)z8 Return any errors which have occurred. F)rP����empty�get�append�Empty� task_done)r9����result�er,���r,���r-���� get_errorsy���s��� � �zLocator.get_errorsc�����������������C���s���|������dS�)z> Clear any errors which may have been logged. N)rY����r9���r,���r,���r-����clear_errors����s���zLocator.clear_errorsc�����������������C���s���|�j�����d�S��N)rL����clearrZ���r,���r,���r-����clear_cache����s���zLocator.clear_cachec�����������������C���s���|�j�S�r\�����_schemerZ���r,���r,���r-����_get_scheme����s���zLocator._get_schemec�����������������C���s ���||�_�d�S�r\���r_���)r9����valuer,���r,���r-����_set_scheme����s��� zLocator._set_schemec�����������������C�������t�d��)a=�� For a given project, get a dictionary mapping available versions to Distribution instances. This should be implemented in subclasses. If called from a locate() request, self.matcher will be set to a matcher for the requirement to satisfy, otherwise it will be None. � Please implement in the subclass��NotImplementedError)r9����namer,���r,���r-����_get_project����s��� zLocator._get_projectc�����������������C���rd���)�J Return all the distribution names known to this locator. re���rf���rZ���r,���r,���r-����get_distribution_names��������zLocator.get_distribution_namesc�����������������C���sP���|�j�du�r|��|�}|S�||�j�v�r|�j�|�}|S�|�����|��|�}||�j�|<�|S�)z� For a given project, get a dictionary mapping available versions to Distribution instances. This calls _get_project to do all the work, and just implements a caching layer on top. N)rL���ri���r[���)r9���rh���rW���r,���r,���r-����get_project����s��� � � zLocator.get_projectc�����������������C���s^���t�|�}t�|j�}d}|�d�}|�|�j�}|r!tt|�|�j�}|j dkd|j v�||||fS�)zu Give an url a score which can be used to choose preferred URLs for a given project release. TrJ����httpszpypi.org)r���� posixpath�basename�path�endswith�downloadable_extensionsr#���r"���� wheel_tagsr4����netloc)r9���r*����trp���� compatible�is_wheelZis_downloadabler,���r,���r-���� score_url����s��� �zLocator.score_urlc�����������������C���sT���|}|r(|���|�}|���|�}||kr|}||kr!t�d||��|S�t�d||��|S�)a{�� Choose one of two URLs where both are candidates for distribution archives for the same version of a distribution (for example, .tar.gz vs. zip). The current implementation favours https:// URLs over http://, archives from PyPI over those from other locations, wheel compatibility (if a wheel) and then the archive name. zNot replacing %r with %rzReplacing %r with %r)ry����logger�debug)r9����url1�url2rW����s1�s2r,���r,���r-���� prefer_url����s��� �zLocator.prefer_urlc�����������������C���s ���t�||�S�)zZ Attempt to split a filename in project name, version and Python version. )r���)r9����filename�project_namer,���r,���r-���r�������s��� zLocator.split_filenamec�����������������C���s��dd��}d}t�|�\}}}}} } | ����d�rt�d|| ��t�| �}|r,|���\}} nd\}} |}|r@|d�dkr@|dd��}|�d �r�z>t |�}t ||�j�sWt�d |��n+|du�r^d}n||j|�}|r�|j|j |jt||||| df�d �dd��|jD���d�}W�nr�ty��}�zt�d|��W�Y�d}~n_d}~ww�|�|�j�s�t�d|��nMt�|��}}|�jD�]B}|�|�r�|dt|����}|��||�}|s�t�d|��n!|\}}}|r�|||�r�|||t||||| df�d�}|r�||d<��nq�|�r|�r| |d|�<�|S�)a�� See if a URL is a candidate for a download URL for a project (the URL has typically been scraped from an HTML page). If it is, a dictionary is returned with keys "name", "version", "filename" and "url"; otherwise, None is returned. c�����������������S���s���t�|��t�|�kS�r\���)r���)Zname1Zname2r,���r,���r-����same_project����s���z:Locator.convert_url_to_download_info.<locals>.same_projectNzegg=z %s: version hint in fragment: %r)NN����/rJ���zWheel not compatible: %sTr2���z, c�����������������S���s"���g�|�] }d���t|dd�����qS�)�.����N)�join�list)�.0�vr,���r,���r-���� <listcomp>��s���"�z8Locator.convert_url_to_download_info.<locals>.<listcomp>)rh����versionr����r*����python-versionzinvalid path for wheel: %szNot downloadable: %sz No match for project/version: %s)rh���r����r����r*���r����� %s_digest)r����lower� startswithrz���r{����HASHER_HASH�match�groupsrr���r"���r#���rt���rh���r����r����r���r�����pyver� Exception�warningrs���ro���rp����lenr���)r9���r*���r����r����rW���r4���ru���rq����params�query�frag�m�algo�digestZorigpath�wheel�includerX���r�����extrv���rh���r����r����r,���r,���r-����convert_url_to_download_info����s~���� ���� �� ���z$Locator.convert_url_to_download_infoc�����������������C���sj���d}d|v�r|d�}dD�]}||v�r|||�f}�nq|s3dD�]}d|�}||v�r2|||�f}�|S�q|S�)z� Get a digest from a dictionary by looking at a "digests" dictionary or keys of the form 'algo_digest'. Returns a 2-tuple (algo, digest) if found, else None. Currently looks only for SHA256, then MD5. N�digests)�sha256�md5r����r,���)r9����inforW���r����r����r@���r,���r,���r-����_get_digest1��s"�����zLocator._get_digestc����������� ������C���s����|��d�}|��d�}||v�r||�}|j}nt|||�jd�}|j}|��|��|_}|d�}||d�|<�|j|d�krN|��|j|�|_|d��|t ���� |��|�|_|||<�dS�)z� Update a result dictionary (the final result from _get_project) with a dictionary for a specific version, which typically holds information gleaned from a filename or URL for an archive for the distribution. rh���r�����r4���r*���r�����urlsN)�pop�metadatar���r4���r����r����� source_urlr����� setdefault�set�add�locator) r9���rW���r����rh���r�����dist�mdr����r*���r,���r,���r-����_update_version_dataH��s��� zLocator._update_version_dataFc�������������� ���C���sr��d}t�|�}|du�rtd|���t|�j�}|�|j��|�_}t�d|t|�j ��|�� |j�}t|�dkr�g�}|j } |D�]+} | dv�rBq;z|�| �sIn|sP| | �jsU|�| ��W�q;�tyf���t�d|| ��Y�q;w�t|�dkrtt||jd�}|r�t�d |��|d �}||�}|r�|jr�|j|_|�di���|t���|_i�}|�di��} |jD�]}|| v�r�| |�||<�q�||_d|�_|S�) a�� Find the most recent distribution which matches the given requirement. :param requirement: A requirement of the form 'foo (1.0)' or perhaps 'foo (>= 1.0, < 2.0, != 1.3)' :param prereleases: If ``True``, allow pre-release versions to be located. Otherwise, pre-release versions are not returned. :return: A :class:`Distribution` instance, or ``None`` if no such distribution could be located. NzNot a valid requirement: %rzmatcher: %s (%s)r�����r����r����zerror matching %s with %rr���)r@���zsorted list: %sr����r����r����)r���r���r ���r4���rN����requirementrz���r{����typerB���rm���rh���r����Z version_classr����� is_prereleaserT���r����r�����sortedr@����extrasrS���r����� download_urlsr����)r9���r�����prereleasesrW����rr4���rN����versions�slistZvcls�kr�����d�sdr*���r,���r,���r-����locate_��sV��� �� �zLocator.locate)rK���)F)rB���rC���rD���rE����source_extensions�binary_extensions�excluded_extensionsrt���rs���rQ���rY���r[���r^���ra���rc����propertyr4���ri���rk���rm���ry���r����r���r����r����r����r����r,���r,���r,���r-���rI���V���s0���� JrI���c������������������������0���e�Zd�ZdZ��fdd�Zdd��Zdd��Z���ZS�)�PyPIRPCLocatorz� This locator uses XML-RPC to locate distributions. It therefore cannot be used with simple mirrors (that only mirror file content). c��������������������s.���t�t|��jdi�|���||�_t|dd�|�_dS�)z� Initialise an instance. :param url: The URL to use for XML-RPC. :param kwargs: Passed to the superclass constructor. r$���r%���Nr,���)�superr����rQ����base_urlr���r+����r9���r*����kwargs�� __class__r,���r-���rQ������s���zPyPIRPCLocator.__init__c�����������������C���s���t�|�j����S��rj���)r����r+���r)���rZ���r,���r,���r-���rk������s���z%PyPIRPCLocator.get_distribution_namesc�����������������C���s���i�i�d�}|�j��|d�}|D�]o}|�j��||�}|�j��||�}t|�jd�}|d�|_|d�|_|�d�|_ |�dg��|_ |�d�|_t|�}|r}|d �} | d �|_ |��| �|_|�|_|||<�|D�]} | d �} |��| �}|d��|t����| ��||d�| <�q_q|S�) Nr����Tr����rh���r�����license�keywords�summaryr���r*���r����r����)r+���Zpackage_releasesZrelease_urlsZrelease_datar���r4���rh���r����rS���r����r����r����r���r����r����r����r����r����r����r����)r9���rh���rW���r����r����r�����datar����r����r����r*���r����r,���r,���r-���ri������s2��� �zPyPIRPCLocator._get_project�rB���rC���rD���rE���rQ���rk���ri���� __classcell__r,���r,���r����r-���r�������s ����r����c�����������������������r����)�PyPIJSONLocatorzw This locator uses PyPI's JSON interface. It's very limited in functionality and probably not worth using. c��������������������s$���t�t|��jdi�|���t|�|�_d�S�)Nr,���)r����r����rQ���r���r����r����r����r,���r-���rQ������s���zPyPIJSONLocator.__init__c�����������������C���rd����rj���zNot available from this locatorrf���rZ���r,���r,���r-���rk������rl���z&PyPIJSONLocator.get_distribution_namesc�������������� ���C���s���i�i�d�}t�|�jdt|���}z�|�j�|�}|������}t�|�}t |�j d�}|d�}|d�|_|d�|_|� d�|_|� dg��|_|� d �|_t|�}|�|_|d �} |||j<�|d �D�]*} | d�}|j�|��|��| �|j|<�|d ��|jt����|��|��| �|d�|<�q\|d ����D�]N\}}||jkr�q�t |�j d�} |j| _|| _t| �}|�|_|||<�|D�])} | d�}|j�|��|��| �|j|<�|d ��|t����|��|��| �|d�|<�q�q�W�|S��ty��}�z|�j�t|���t�d|��W�Y�d�}~|S�d�}~ww�)Nr����z%s/jsonr����r����rh���r����r����r����r����r����r*���r����ZreleaseszJSON fetch failed: %s) r���r����r���rM����open�read�decode�json�loadsr���r4���rh���r����rS���r����r����r����r���r����r����r����r����r����r����r�����itemsr����rP����putr���rz���� exception)r9���rh���rW���r*����respr����r����r����r����r����r����r�����infosZomd�odistrX���r,���r,���r-���ri������s^��� �����zPyPIJSONLocator._get_projectr����r,���r,���r����r-���r�������s ����r����c�������������������@���s`���e�Zd�ZdZe�dejejB�ejB��Z e�dejejB��Z dd��Ze�dej�Ze dd���Zd S�) �Pagez4 This class represents a scraped HTML page. z� (rel\s*=\s*(?:"(?P<rel1>[^"]*)"|'(?P<rel2>[^']*)'|(?P<rel3>[^>\s ]*))\s+)? href\s*=\s*(?:"(?P<url1>[^"]*)"|'(?P<url2>[^']*)'|(?P<url3>[^>\s ]*)) (\s+rel\s*=\s*(?:"(?P<rel4>[^"]*)"|'(?P<rel5>[^']*)'|(?P<rel6>[^>\s ]*)))? z!<base\s+href\s*=\s*['"]?([^'">]+)c�����������������C���s8���||�_�|�|�_|�_|�j�|�j��}|r|�d�|�_dS�dS�)zk Initialise an instance with the Unicode page contents and the URL they came from. r���N)r����r����r*����_base�search�group)r9���r����r*���r����r,���r,���r-���rQ��� ��s����z Page.__init__z[^a-z0-9$&+,/:;=?@.#%_\\|-]c�����������������C���s����dd��}t���}|�j�|�j�D�]E}|�d�}|d�p,|d�p,|d�p,|d�p,|d�p,|d �}|d �p8|d�p8|d�}t|�j|�}t|�}|�j� d d��|�}|� ||f��qt|dd��dd�}|S�)z� Return the URLs of all the links on a page together with information about their "rel" attribute, for determining which ones to treat as downloads and which ones to queue for further scraping. c�����������������S���s,���t�|��\}}}}}}t||t|�|||f�S�)zTidy up an URL.)r���r���r���)r*���r4���ru���rq���r����r����r����r,���r,���r-����clean4��s����zPage.links.<locals>.cleanr2���Zrel1Zrel2Zrel3Zrel4Zrel5Zrel6r|���r}���Zurl3c�����������������S���s���dt�|��d���S�)Nz%%%2xr���)�ordr����)r����r,���r,���r-����<lambda>B��s����zPage.links.<locals>.<lambda>c�����������������S���s���|�d�S�)Nr���r,���)rv���r,���r,���r-���r����F��s����T)r@����reverse)r�����_href�finditerr����� groupdictr���r����r���� _clean_re�subr����r����)r9���r����rW���r����r�����relr*���r,���r,���r-����links-��s$��� ���z Page.linksN)rB���rC���rD���rE����re�compile�I�S�Xr����r����rQ���r����r���r����r,���r,���r,���r-���r������s�����r����c�����������������������s����e�Zd�ZdZejdd��dd��d�Zd��fdd � Zd d��Zdd ��Z dd��Z e�dej �Zdd��Zdd��Zdd��Zdd��Zdd��Ze�d�Zdd��Z���ZS�)�SimpleScrapingLocatorz� A locator which scrapes HTML pages to locate downloads for a distribution. This runs multiple threads to do the I/O; performance is at least as good as pip's PackageFinder, which works in an analogous fashion. c�����������������C���s���t�jt|��d����S�)N)�fileobj)�gzip�GzipFiler���r������br,���r,���r-���r����T��s����zSimpleScrapingLocator.<lambda>c�����������������C���s���|�S�r\���r,���r����r,���r,���r-���r����U��s����)�deflater�����noneN� ���c��������������������sp���t�t|��jdi�|���t|�|�_||�_i�|�_t��|�_t � ��|�_t��|�_d|�_ ||�_t���|�_t���|�_d|�_dS�)a��� Initialise an instance. :param url: The root URL to use for scraping. :param timeout: The timeout, in seconds, to be applied to requests. This defaults to ``None`` (no timeout specified). :param num_workers: The number of worker threads you want to do I/O, This defaults to 10. :param kwargs: Passed to the superclass. FNr,���)r����r����rQ���r���r����r&����_page_cacher�����_seenr ���rO���� _to_fetch� _bad_hosts�skip_externals�num_workers� threading�RLock�_lock�_gplock�platform_check)r9���r*���r&���r��r����r����r,���r-���rQ���X��s��� zSimpleScrapingLocator.__init__c�����������������C���sF���g�|�_�t|�j�D�]}tj|�jd�}|�d��|����|�j��|��qdS�)z� Threads are created only when get_project is called, and terminate before it returns. They are there primarily to parallelise I/O (i.e. fetching web pages). )�targetTN) �_threads�ranger��r���Thread�_fetch� setDaemon�startrT���)r9����irv���r,���r,���r-����_prepare_threadss��s��� �z&SimpleScrapingLocator._prepare_threadsc�����������������C���s6���|�j�D�]}|�j�d��q|�j�D�]}|����qg�|�_�dS�)zu Tell all the threads to terminate (by sending a sentinel value) and wait for them to do so. N)r��r��r����r����)r9���rv���r,���r,���r-���� _wait_threads���s ��� z#SimpleScrapingLocator._wait_threadsc�������������� ���C���s����i�i�d�}|�j��F�||�_||�_t|�jdt|���}|�j����|�j����|�� ���zt �d|��|�j� |��|�j����W�|�����n|�����w�|�`W�d�����|S�1�sQw���Y��|S�)Nr����z%s/zQueueing %s)r ��rW���r����r���r����r���r��r]���r���r��rz���r{���r��r����r����r��)r9���rh���rW���r*���r,���r,���r-���ri������s$��� ��z"SimpleScrapingLocator._get_projectz<\b(linux_(i\d86|x86_64|arm\w+)|win(32|_amd64)|macosx_?\d+)\bc�����������������C���s���|�j��|�S�)zD Does an URL refer to a platform-specific download? )�platform_dependentr����)r9���r*���r,���r,���r-����_is_platform_dependent���s���z,SimpleScrapingLocator._is_platform_dependentc�����������������C���sp���|�j�r|��|�rd}n|��||�j�}t�d||��|r6|�j��|��|�j|��W�d����|S�1�s1w���Y��|S�)a%�� See if an URL is a suitable download for a project. If it is, register information in the result dictionary (for _get_project) about the specific version it's for. Note that the return value isn't actually used other than as a boolean value. Nzprocess_download: %s -> %s) r ��r��r����r����rz���r{���r��r����rW���)r9���r*���r����r,���r,���r-����_process_download���s��� ��z'SimpleScrapingLocator._process_downloadc����������� ������C���s����t�|�\}}}}}}|�|�j|�j�|�j��rd}n>|�jr%|�|�j�s%d}n2|�|�j�s.d}n)|dvr5d}n"|dvr<d}n|��|�rDd}n|� dd�d�} | � ��dkrUd}nd}t�d ||||��|S�) z� Determine whether a link URL from a referring page and with a particular "rel" attribute should be queued for scraping. F)Zhomepage�download)�httprn����ftp�:r���r���� localhostTz#should_queue: %s (%s) from %s -> %s) r���rr���r����r����r����r��r����r����r���splitr����rz���r{���) r9����linkZreferrerr����r4���ru���rq����_rW����hostr,���r,���r-���� _should_queue���s.���� �z#SimpleScrapingLocator._should_queuec�������������� ���C���s�� �|�j����}zozM|rS|��|�}|du�rW�W�|�j�����q�|jD�]4\}}||�jvrRz!|�j�|��|��|�sG|��|||�rGt � d||��|�j��|��W�q�tyQ���Y�qw�qW�n�t yn�}�z|�j�t|���W�Y�d}~nd}~ww�W�|�j�����n|�j�����w�|s�dS�q)z� Get a URL to fetch from the work queue, get the HTML page, examine its links for download candidates and candidates for further scraping. This is a handy method to run in a thread. TNzQueueing %s from %s)r��rS����get_pagerV���r����r��r����r��r!��rz���r{���r����r���r����rP���r���)r9���r*����pager��r����rX���r,���r,���r-���r�����s@��� � ����� ����zSimpleScrapingLocator._fetchc�����������������C���s���t�|�\}}}}}}|dkrtj�t|��rtt|�d�}||�jv�r0|�j|�}t� d||��|S�|� dd�d�}d}||�jv�rHt� d||��|S�t|d d id�}z�zlt� d|��|�j j||�jd �} t� d|��| ���} | �dd�}t�|�r�| ���}| ���} | �d�}|r�|�j|�}|| �} d}t�|�}|r�|�d�}z| �|�} W�n�ty����| �d�} Y�nw�t| |�}||�j|<�W�ni�ty��}�z|jdkr�t�d||��W�Y�d}~nXd}~w�t �y �}�z&t�d||��|�j!��|�j�"|��W�d����n1�s�w���Y��W�Y�d}~n.d}~w�t#�y&�}�z t�d||��W�Y�d}~nd}~ww�W�||�j|<�|S�W�||�j|<�|S�W�||�j|<�|S�W�||�j|<�|S�||�j|<�w�)a�� Get the HTML for an URL, possibly from an in-memory cache. XXX TODO Note: this cache is never actually cleared. It's assumed that the data won't get stale over the lifetime of a locator instance (not necessarily true for the default_locator). �filez index.htmlzReturning %s from cache: %sr��r���r���NzSkipping %s due to bad host %szAccept-encoding�identity)r>���zFetching %sr%���z Fetched %szContent-Typer2���zContent-Encodingzutf-8zlatin-1i���zFetch failed: %s: %s)$r����osrq����isdirr���r���r���r���rz���r{���r��r��r���rM���r����r&���r����rS����HTML_CONTENT_TYPEr�����geturlr�����decoders�CHARSETr����r����r�����UnicodeErrorr����r���r<���r����r���r��r����r����)r9���r*���r4���ru���rq���r��rW���r ��r:���r����r>����content_typeZ final_urlr�����encoding�decoderr����rX���r,���r,���r-���r"�����s���� *� %� � � ������ � �� �� �zSimpleScrapingLocator.get_pagez<a href=[^>]*>([^<]+)<c�����������������C���sL���t���}|��|�j�}|std|�j���|�j�|j�D�] }|�|�d���q|S�)rj���zUnable to get %sr���) r����r"��r����r����_distname_rer����r����r����r����)r9���rW���r#��r����r,���r,���r-���rk���7��s���z,SimpleScrapingLocator.get_distribution_names)Nr����)rB���rC���rD���rE����zlib� decompressr*��rQ���r��r��ri���r����r����r����r��r��r��r!��r��r"��r0��rk���r����r,���r,���r����r-���r����J��s(����� �! ;r����c�����������������������s8���e�Zd�ZdZ��fdd�Zdd��Zdd��Zdd ��Z���ZS�) �DirectoryLocatorz? This class locates distributions in a directory tree. c��������������������sR���|��dd�|�_tt|��jdi�|���tj�|�}tj�|�s$t d|���||�_ dS�)a��� Initialise an instance. :param path: The root of the directory tree to search. :param kwargs: Passed to the superclass constructor, except for: * recursive - if True (the default), subdirectories are recursed into. If False, only the top-level directory is searched, � recursiveTzNot a directory: %rNr,���)r����r4��r����r3��rQ���r&��rq����abspathr'��r����base_dir)r9���rq���r����r����r,���r-���rQ���H��s��� zDirectoryLocator.__init__c�����������������C���s���|��|�j�S�)z� Should a filename be considered as a candidate for a distribution archive? As well as the filename, the directory which contains it is provided, though not used by the current implementation. )rr���rs���)r9���r�����parentr,���r,���r-����should_includeY��s���zDirectoryLocator.should_includec����������� ��� ���C���s����i�i�d�}t��|�j�D�];\}}}|D�]-}|��||�r?t�j�||�}tddtt�j�|��dddf�}|�� ||�}|r?|�� ||��q|�jsF�|S�q|S�)Nr����r$��r2���)r&���walkr6��r8��rq���r����r���r ���r5��r����r����r4��) r9���rh���rW����root�dirs�files�fnr*���r����r,���r,���r-���ri���a��s$��� ���zDirectoryLocator._get_projectc�������������� ���C���s����t���}t�|�j�D�]<\}}}|D�].}|��||�r>tj�||�}tddttj� |��dddf�}|�� |d�}|r>|�|d���q|�jsE�|S�q |S�)rj���r$��r2���Nrh���) r����r&��r9��r6��r8��rq���r����r���r ���r5��r����r����r4��)r9���rW���r:��r;��r<��r=��r*���r����r,���r,���r-���rk���q��s$������z'DirectoryLocator.get_distribution_names) rB���rC���rD���rE���rQ���r8��ri���rk���r����r,���r,���r����r-���r3��C��s����r3��c�������������������@���s ���e�Zd�ZdZdd��Zdd��ZdS�)�JSONLocatora�� This locator uses special extended metadata (not available on PyPI) and is the basis of performant dependency resolution in distlib. Other locators require archive downloads before dependencies can be determined! As you might imagine, that can be slow. c�����������������C���rd���r����rf���rZ���r,���r,���r-���rk������rl���z"JSONLocator.get_distribution_namesc�����������������C���s����i�i�d�}t�|�}|rk|�dg��D�]Y}|d�dks|d�dkr qt|d�|d�|�d d �|�jd�}|j}|d�|_d |v�rH|d �rHd|d �f|_|�di��|_|�di��|_|||j <�|d�� |j t����|d���q|S�)Nr����r<���ptype�sdistZ pyversion�sourcerh���r����r����zPlaceholder for summary)r����r4���r*���r����r�����requirements�exportsr����) r���rS���r���r4���r����r����r�����dependenciesrC��r����r����r����r����)r9���rh���rW���r����r����r����r����r,���r,���r-���ri������s*��� �� zJSONLocator._get_projectN)rB���rC���rD���rE���rk���ri���r,���r,���r,���r-���r>�����s����r>��c�����������������������s(���e�Zd�ZdZ��fdd�Zdd��Z���ZS�)�DistPathLocatorz� This locator finds installed distributions in a path. It can be useful for adding to an :class:`AggregatingLocator`. c��������������������s.���t�t|��jdi�|���t|t�sJ��||�_dS�)zs Initialise an instance. :param distpath: A :class:`DistributionPath` instance to search. Nr,���)r����rE��rQ���� isinstancer����distpath)r9���rG��r����r����r,���r-���rQ������s��� zDistPathLocator.__init__c�����������������C���sR���|�j��|�}|d�u�ri�i�d�}|S�|j|d|jt|jg�id|jtd�g�ii}|S�)Nr����r����r����)rG���get_distributionr����r����r����)r9���rh���r����rW���r,���r,���r-���ri������s��� ��zDistPathLocator._get_project)rB���rC���rD���rE���rQ���ri���r����r,���r,���r����r-���rE�����s���� rE��c�����������������������sR���e�Zd�ZdZ��fdd�Z��fdd�Zdd��Zeej j e�Z dd ��Zd d��Z���Z S�)�AggregatingLocatorzI This class allows you to chain and/or merge a list of locators. c��������������������s.���|��dd�|�_||�_tt|��jdi�|���dS�)a��� Initialise an instance. :param locators: The list of locators to search. :param kwargs: Passed to the superclass constructor, except for: * merge - if False (the default), the first successful search from any of the locators is returned. If True, the results from all locators are merged (this can be slow). �mergeFNr,���)r����rJ���locatorsr����rI��rQ���)r9���rK��r����r����r,���r-���rQ������s���zAggregatingLocator.__init__c��������������������s&���t�t|������|�jD�]}|����q d�S�r\���)r����rI��r^���rK���r9���r����r����r,���r-���r^������s��� �zAggregatingLocator.clear_cachec�����������������C���s���||�_�|�jD�]}||_qd�S�r\���)r`���rK��r4���)r9���rb���r����r,���r,���r-���rc������s��� �zAggregatingLocator._set_schemec�����������������C���s����i�}|�j�D�]o}|�|�}|rt|�jrT|�di��}|�di��}|�|��|�d�}|rE|rE|���D�]\}} ||v�r@||��| O��<�q/| ||<�q/|�d�} |rS| rS| �|��q|�jd�u�r\d}nd}|D�]}|�j�|�rld}�nq`|rt|}�|S�q|S�)Nr����r����TF)rK��rm���rJ��rS����updater����rN���r����)r9���rh���rW���r����r����r<��r����Zdfr����r�����dd�foundr,���r,���r-���ri������s@��� � ���zAggregatingLocator._get_projectc�������������� ���C���s8���t���}|�jD�]}z||���O�}W�q�ty���Y�qw�|S�r����)r����rK��rk���rg���)r9���rW���r����r,���r,���r-���rk�����s��� �z)AggregatingLocator.get_distribution_names)rB���rC���rD���rE���rQ���r^���rc���r����rI���r4����fgetri���rk���r����r,���r,���r����r-���rI�����s����,rI��zhttps://pypi.org/simple/r$���r%����legacyr����c�������������������@���sL���e�Zd�ZdZddd�Zdd��Zdd��Zd d ��Zdd��Zd d��Z ddd�Z dS�)�DependencyFinderz0 Locate dependencies for distributions. Nc�����������������C���s���|pt�|�_t|�jj�|�_dS�)zf Initialise an instance, using the specified locator to locate distributions. N)�default_locatorr����r ���r4���rL��r,���r,���r-���rQ���/��s��� zDependencyFinder.__init__c�����������������C���sr���t��d|��|j}||�j|<�||�j||jf<�|jD�]}t|�\}}t��d|||��|�j� |t ����||f��qdS�)z� Add a distribution to the finder. This will update internal information about who provides what. :param dist: The distribution to add. zadding distribution %szAdd to provided: %s, %s, %sN)rz���r{���r@���� dists_by_name�distsr�����providesr����providedr����r����r����)r9���r����rh����pr����r,���r,���r-����add_distribution7��s��� �z!DependencyFinder.add_distributionc�����������������C���sx���t��d|��|j}|�j|=�|�j||jf=�|jD�]"}t|�\}}t��d|||��|�j|�}|� ||f��|s9|�j|=�qdS�)z� Remove a distribution from the finder. This will update internal information about who provides what. :param dist: The distribution to remove. zremoving distribution %sz Remove from provided: %s, %s, %sN) rz���r{���r@���rT��rU��r����rV��r���rW���remove)r9���r����rh���rX��r�����sr,���r,���r-����remove_distributionF��s��� ��z$DependencyFinder.remove_distributionc�����������������C���s@���z |�j��|�}W�|S��ty���|���d�}|�j��|�}Y�|S�w�)z� Get a version matcher for a requirement. :param reqt: The requirement :type reqt: str :return: A version matcher (an instance of :class:`distlib.version.Matcher`). r���)r4���rN���r!���r��)r9����reqtrN���rh���r,���r,���r-����get_matcherX��s�����zDependencyFinder.get_matcherc����������� ��� ���C���st���|���|�}|j}t��}|�j}||v�r8||�D�]!\}}z|�|�}W�n�ty,���d}Y�nw�|r7|�|���|S�q|S�)z� Find the distributions which can fulfill a requirement. :param reqt: The requirement. :type reqt: str :return: A set of distribution which can fulfill the requirement. F)r^��r@���r����rW��r����r!���r����) r9���r]��rN���rh���rW���rW��r�����providerr����r,���r,���r-����find_providersh��s"��� � �zDependencyFinder.find_providersc����������� ������C���s����|�j�|�}t��}|D�]}|��|�}|�|j�s|�|��q |r.|�d||t|�f��d}|S�|��|��|�j�|=�|D�] }|�j��|t����|��q9|�� |��d}|S�)a��� Attempt to replace one provider with another. This is typically used when resolving dependencies from multiple sources, e.g. A requires (B >= 1.0) while C requires (B >= 1.1). For successful replacement, ``provider`` must meet all the requirements which ``other`` fulfills. :param provider: The provider we are trying to replace with. :param other: The provider we're trying to replace. :param problems: If False is returned, this will contain what problems prevented replacement. This is currently a tuple of the literal string 'cantreplace', ``provider``, ``other`` and the set of requirements that ``provider`` couldn't fulfill. :return: True if we can replace ``other`` with ``provider``, else False. ZcantreplaceFT) �reqtsr����r^��r����r����r����� frozensetr\��r����rY��) r9���r_���other�problemsZrlist� unmatchedr[��rN���rW���r,���r,���r-����try_to_replace���s(��� � � � zDependencyFinder.try_to_replaceFc�����������������C���s���i�|�_�i�|�_i�|�_i�|�_t|pg��}d|v�r#|�d��|tg�d��O�}t|t�r3|�}}t� d|��n|�j j||d��}}|du�rGtd|���t� d|��d|_ t��}t|g�}t|g�}|�rH|���}|j} | |�jvrr|��|��n|�j| �} | |kr�|��|| |��|j|jB�}|j}t��} |r�||v�r�d D�]}d |�}||v�r�| t|d|��O�} q�||B�| B�}|D�]�}|��|�}|�st� d|��|�j j||d�}|du�r�|s�|�j j|dd�}|du�r�t� d |��|�d|f��n.|j|j}}||f|�jvr�|�|��|�|��||v��r||v��r|�|��t� d|j��|D�]*}|j} | |�jv�r2|�j�|t����|���q|�j| �} | |k�rC|��|| |���qq�|s`t|�j����}|D�]}||v|_|j�rct� d|j���qQt� d|��||fS�)a��� Find a distribution and all distributions it depends on. :param requirement: The requirement specifying the distribution to find, or a Distribution instance. :param meta_extras: A list of meta extras such as :test:, :build: and so on. :param prereleases: If ``True``, allow pre-release versions to be returned - otherwise, don't return prereleases unless they're all that's available. Return a set of :class:`Distribution` instances and a set of problems. The distributions returned should be such that they have the :attr:`required` attribute set to ``True`` if they were from the ``requirement`` passed to ``find()``, and they have the :attr:`build_time_dependency` attribute set to ``True`` unless they are post-installation dependencies of the ``requirement``. The problems should be a tuple consisting of the string ``'unsatisfied'`` and the requirement which couldn't be satisfied by any distribution known to the locator. z:*:)z:test:z:build:z:dev:zpassed %s as requirement)r����NzUnable to locate %rz located %sT)�test�build�devz:%s:z%s_requireszNo providers found for %rzCannot satisfy %rZunsatisfiedzAdding %s to install_distsz#%s is a build-time dependency only.zfind done for %s)rW��rU��rT��ra��r����rZ��rF��r���rz���r{���r����r����r���� requestedr����r@���rY��rf��Zrun_requiresZ meta_requiresZbuild_requires�getattrr`��r����r����Zname_and_versionr�����valuesZbuild_time_dependency)r9���r����Zmeta_extrasr����r����r����rd���todoZ install_distsrh���rc��ZireqtsZsreqtsZereqtsr@���rX���Z all_reqtsr����� providersr_���nr����rX��rU��r,���r,���r-����find���s���� � � � ���3 ��zDependencyFinder.findr\���)NF)rB���rC���rD���rE���rQ���rY��r\��r^��r`��rf��rp��r,���r,���r,���r-���rR��*��s���� (rR��r\���)Lr�����ior���r�����loggingr&��ro���r����r���ImportErrorZdummy_threadingr1��r2���r����compatr���r���r���r���r ���r ���r���r���r ���r���r7���r���r���r���r���Zdatabaser���r���r���r����r���r����utilr���r���r���r���r���r���r���r���r����r ���r!���r����r"���r#���� getLoggerrB���rz���r����r����r����r+��r(��r(���r.���r/����objectrI���r����r����r����r����r3��r>��rE��rI��rS��r����rR��r,���r,���r,���r-����<module>���s`����@( ��G0E:�zA&[��