Warning: session_start(): Session cannot be started after headers have already been sent in /home/tvrreohg/public_html/manga.php on line 13
3 ÝPfEÇã@s@ddlZddlmZddlZddlZddlZddlZddlZy ddlZWne k rdddl ZYnXddl Z ddl m Z ddlmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZddlm Z m!Z!m"Z"ddl#m$Z$ddl%m&Z&m'Z'm(Z(m)Z)m*Z*m+Z+m,Z,m-Z-m.Z.dd l/m0Z0m1Z1dd l2m3Z3m4Z4ej5e6ƒZ7ej8d ƒZ9ej8d ej:ƒZ;ej8d ƒZGdd„deƒZ?Gdd„de@ƒZAGdd„deAƒZBGdd„deAƒZCGdd„de@ƒZDGdd„deAƒZEGdd„deAƒZFGdd „d eAƒZGGd!d"„d"eAƒZHGd#d$„d$eAƒZIeIeGƒeEd%d&d'�d(d)�ZJeJjKZKej8d*ƒZLGd+d,„d,e@ƒZMdS).éN)ÚBytesIOé)ÚDistlibException)ÚurljoinÚurlparseÚ urlunparseÚ url2pathnameÚ pathname2urlÚqueueÚquoteÚunescapeÚ string_typesÚ build_openerÚHTTPRedirectHandlerÚ text_typeÚRequestÚ HTTPErrorÚURLError)Ú DistributionÚDistributionPathÚ make_dist)ÚMetadata) Úcached_propertyÚparse_credentialsÚ 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.python.org/pypicCs |dkr t}t|dd�}|jƒS)z• Return all distribution names known by an index. :param url: The URL of the index. :return: A list of all known distribution names. Ng@)Útimeout)Ú DEFAULT_INDEXrÚ list_packages)ÚurlÚclient©r*ú/usr/lib/python3.6/locators.pyÚget_all_distribution_names)s r,c@s$eZdZdZdd„ZeZZZdS)ÚRedirectHandlerzE A class to work around a bug in some Python 3.2.x releases. c Cs„d}xdD]}||kr ||}Pq W|dkr0dSt|ƒ}|jdkrpt|jƒ|ƒ}t|dƒrh|j||ƒn|||<tj||||||ƒS)NÚlocationÚuriÚÚreplace_header)r.r/)rÚschemerZ get_full_urlÚhasattrr1ÚBaseRedirectHandlerÚhttp_error_302) ÚselfÚreqÚfpÚcodeÚmsgÚheadersZnewurlÚkeyZurlpartsr*r*r+r5=s   zRedirectHandler.http_error_302N)Ú__name__Ú __module__Ú __qualname__Ú__doc__r5Zhttp_error_301Zhttp_error_303Zhttp_error_307r*r*r*r+r-4sr-c@s¶eZdZdZd/Zd0Zd1Zd Zed2Zd3dd„Z dd„Z dd„Z dd„Z dd„Z dd„Zee eƒZdd„Zdd„Zdd„Zd d!„Zd"d#„Zd$d%„Zd&d'„Zd(d)„Zd*d+„Zd4d-d.„Zd S)5ÚLocatorzG A base class for locators - things that locate distributions. ú.tar.gzú.tar.bz2ú.tarú.zipú.tgzú.tbzú.eggú.exeú.whlú.pdfNÚdefaultcCs,i|_||_ttƒƒ|_d|_tjƒ|_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) Ú_cacher2rr-ÚopenerÚmatcherr ÚQueueÚerrors)r6r2r*r*r+Ú__init__cs  zLocator.__init__c CsXg}xN|jjƒsRy|jjdƒ}|j|ƒWn|jjk rDwYnX|jjƒqW|S)z8 Return any errors which have occurred. F)rQÚemptyÚgetÚappendZEmptyÚ task_done)r6ÚresultÚer*r*r+Ú get_errorsvs  zLocator.get_errorscCs |jƒdS)z> Clear any errors which may have been logged. N)rY)r6r*r*r+Ú clear_errors„szLocator.clear_errorscCs|jjƒdS)N)rMÚclear)r6r*r*r+Ú clear_cache‹szLocator.clear_cachecCs|jS)N)Ú_scheme)r6r*r*r+Ú _get_schemeŽszLocator._get_schemecCs ||_dS)N)r])r6Úvaluer*r*r+Ú _set_scheme‘szLocator._set_schemecCs tdƒ‚dS)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. z Please implement in the subclassN)ÚNotImplementedError)r6Únamer*r*r+Ú _get_project–s zLocator._get_projectcCs tdƒ‚dS)zJ Return all the distribution names known to this locator. z Please implement in the subclassN)ra)r6r*r*r+Úget_distribution_names¢szLocator.get_distribution_namescCsL|jdkr|j|ƒ}n2||jkr,|j|}n|jƒ|j|ƒ}||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)rMrcrZ)r6rbrWr*r*r+Ú get_project¨s      zLocator.get_projectcCsPt|ƒ}tj|jƒ}d}|jdƒ}|r6tt|ƒ|jƒ}|jdkd|j k|||fS)zu Give an url a score which can be used to choose preferred URLs for a given project release. Tz.whlÚhttpszpypi.python.org) rÚ posixpathÚbasenameÚpathÚendswithr$r#Ú wheel_tagsr2Únetloc)r6r(ÚtrhZ compatibleZis_wheelr*r*r+Ú score_url¹s  zLocator.score_urlcCsR|}|rN|j|ƒ}|j|ƒ}||kr(|}||kr@tjd||ƒntjd||ƒ|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)rnÚloggerÚdebug)r6Úurl1Úurl2rWÚs1Ús2r*r*r+Ú prefer_urlÇs   zLocator.prefer_urlcCs t||ƒS)zZ Attempt to split a filename in project name, version and Python version. )r)r6ÚfilenameÚ project_namer*r*r+rÝszLocator.split_filenamecCsdd„}d}t|ƒ\}}}}} } | jƒjdƒr.same_projectNzegg=z %s: version hint in fragment: %rrú/z.whlTr0z, cSs"g|]}djt|dd…ƒƒ‘qS)Ú.éN)ÚjoinÚlist)Ú.0Úvr*r*r+ú sz8Locator.convert_url_to_download_info..)rbÚversionrvr(zpython-versionzinvalid path for wheel: %sz No match for project/version: %s)rbr�rvr(zpython-versionz %s_digest)NNéÿÿÿÿr‚)rÚlowerÚ startswithrorpÚ HASHER_HASHÚmatchÚgroupsrjr#r$rkrbr�rvrr|ÚpyverÚ ExceptionÚwarningÚdownloadable_extensionsrgrhÚlenr)r6r(rwrxrWr2rlriÚparamsÚqueryÚfragÚmÚalgoÚdigestZorigpathÚwheelÚincluderXrvZextrmrbr�rˆr*r*r+Úconvert_url_to_download_infoãsf            z$Locator.convert_url_to_download_infocCs4d}x*dD]"}d|}||kr |||f}Pq W|S)zØ Get a digest from a dictionary by looking at keys of the form 'algo_digest'. Returns a 2-tuple (algo, digest) if found, else None. Currently looks only for SHA256, then MD5. NÚsha256Úmd5z %s_digest)r–r—r*)r6ÚinforWr‘r<r*r*r+Ú _get_digest)s  zLocator._get_digestc Cs®|jdƒ}|jdƒ}||kr,||}|j}nt|||jd�}|j}|j|ƒ|_}|d}||d|<|j|dkrœ|j|j|ƒ|_|dj|t ƒƒj |ƒ||_ |||<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. rbr�)r2r(ÚdigestsÚurlsN) ÚpopÚmetadatarr2r™r’Ú source_urlruÚ setdefaultÚsetÚaddÚlocator) r6rWr˜rbr�ÚdistÚmdr’r(r*r*r+Ú_update_version_data9s   zLocator._update_version_dataFc Cs®d}t|ƒ}|dkr td|ƒ‚t|jƒ}|j|jƒ|_}tjd|t|ƒj ƒ|j |j ƒ}t |ƒdk�r8g}|j } x„|D]|} | d krˆqzyJ|j| ƒs¤tjd|| ƒn,|s´| | ƒj rÀ|j| ƒntjd| |j ƒWqztk rôtjd || ƒYqzXqzWt |ƒd k�rt||jd �}|�r8tjd |ƒ|d} || }|�r¤|j�rN|j|_|jdiƒj| tƒƒ|_i} |jdiƒ} x&|jD]}|| k�r~| || |<�q~W| |_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šz%s did not match %rz%skipping pre-release version %s of %szerror matching %s with %rr)r<zsorted list: %s)r›ršr‚)rrr!r2rOÚ requirementrorpÚtyper=rerbrŒZ version_classr†Z is_prereleaserUr‰rŠÚsortedr<ZextrasrTr Ú download_urlsrš)r6r¦Ú prereleasesrWÚrr2rOÚversionsZslistZvclsÚkr�ÚdZsdr(r*r*r+ÚlocatePsT            zLocator.locate)rBrCrDrErFrG)rHrIrJ)rK)rJ)rL)F)r=r>r?r@Úsource_extensionsÚbinary_extensionsÚexcluded_extensionsrkr‹rRrYrZr\r^r`Úpropertyr2rcrdrernrurr•r™r¥r¯r*r*r*r+rASs.   FrAcs0eZdZdZ‡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*tt|ƒjf|Ž||_t|dd�|_dS)z— Initialise an instance. :param url: The URL to use for XML-RPC. :param kwargs: Passed to the superclass constructor. g@)r%N)Úsuperr´rRÚbase_urlrr))r6r(Úkwargs)Ú __class__r*r+rR‘szPyPIRPCLocator.__init__cCst|jjƒƒS)zJ Return all the distribution names known to this locator. )r r)r')r6r*r*r+rdœsz%PyPIRPCLocator.get_distribution_namesc Csiidœ}|jj|dƒ}xê|D]â}|jj||ƒ}|jj||ƒ}t|jd�}|d|_|d|_|jdƒ|_ |jdgƒ|_ |jdƒ|_ t |ƒ}|r|d } | d |_ |j| ƒ|_||_|||<xB|D]:} | d } |j| ƒ} |d j|tƒƒj| ƒ| |d | <qÂWqW|S) N)r›ršT)r2rbr�ÚlicenseÚkeywordsÚsummaryrr(r›rš)r)Zpackage_releasesZ release_urlsZ release_datarr2rbr�rTr¹rºr»rržr™r’r¢rŸr r¡) r6rbrWr¬rr›Údatar�r£r˜r(r’r*r*r+rc¢s0           zPyPIRPCLocator._get_project)r=r>r?r@rRrdrcÚ __classcell__r*r*)r¸r+r´Œs r´cs0eZdZdZ‡fdd„Zdd„Zdd„Z‡ZS)ÚPyPIJSONLocatorzw This locator uses PyPI's JSON interface. It's very limited in functionality and probably not worth using. c s tt|ƒjf|Žt|ƒ|_dS)N)rµr¾rRrr¶)r6r(r·)r¸r*r+rRÁszPyPIJSONLocator.__init__cCs tdƒ‚dS)zJ Return all the distribution names known to this locator. zNot available from this locatorN)ra)r6r*r*r+rdÅsz&PyPIJSONLocator.get_distribution_namescCsiidœ}t|jdt|ƒƒ}�y°|jj|ƒ}|jƒjƒ}tj|ƒ}t |j d�}|d}|d|_ |d|_ |j dƒ|_|j dgƒ|_|j d ƒ|_t|ƒ}||_|d } |||j <x`|d D]T} | d }|jj|ƒ|j| ƒ|j|<|d j|j tƒƒj|ƒ|j| ƒ|d |<q¼Wx¸|d jƒD]¨\} } | |j k�r:�q"t |j d�} |j | _ | | _ t| ƒ}||_||| <x\| D]T} | d }|jj|ƒ|j| ƒ|j|<|d j| tƒƒj|ƒ|j| ƒ|d |<�qpW�q"WWn@tk �r}z"|jjt|ƒƒtjd|ƒWYdd}~XnX|S)N)r›ršz%s/json)r2r˜rbr�r¹rºr»r›r(ršZreleaseszJSON fetch failed: %s) rr¶r rNÚopenÚreadÚdecodeÚjsonÚloadsrr2rbr�rTr¹rºr»rr¢r©r¡r™ršrŸr Úitemsr‰rQÚputrroÚ exception)r6rbrWr(Úrespr¼r®r¤r£r›r˜r�ZinfosZomdÚodistrXr*r*r+rcËsT               " zPyPIJSONLocator._get_project)r=r>r?r@rRrdrcr½r*r*)r¸r+r¾¼s r¾c@s`eZdZdZejdejejBejBƒZ ejdejejBƒZ dd„Z ejdejƒZ e dd„ƒZd S) ÚPagez4 This class represents a scraped HTML page. zÝ (rel\s*=\s*(?:"(?P[^"]*)"|'(?P[^']*)'|(?P[^>\s ]*))\s+)? href\s*=\s*(?:"(?P[^"]*)"|'(?P[^']*)'|(?P[^>\s ]*)) (\s+rel\s*=\s*(?:"(?P[^"]*)"|'(?P[^']*)'|(?P[^>\s ]*)))? z!]+)cCs4||_||_|_|jj|jƒ}|r0|jdƒ|_dS)zk Initialise an instance with the Unicode page contents and the URL they came from. rN)r¼r¶r(Ú_baseÚsearchÚgroup)r6r¼r(r�r*r*r+rRs  z Page.__init__z[^a-z0-9$&+,/:;=?@.#%_\\|-]cCsÂdd„}tƒ}xœ|jj|jƒD]Š}|jdƒ}|dpZ|dpZ|dpZ|dpZ|dpZ|d }|d pr|d pr|d }t|j|ƒ}t|ƒ}|jj d d„|ƒ}|j ||fƒqWt |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. cSs,t|ƒ\}}}}}}t||t|ƒ|||fƒS)zTidy up an URL.)rrr )r(r2rlrir�rŽr�r*r*r+Úclean%s zPage.links..cleanr0Zrel1Zrel2Zrel3Zrel4Zrel5Zrel6rqrrZurl3cSsdt|jdƒƒS)Nz%%%2xr)ÚordrÌ)r�r*r*r+Ú3szPage.links..cSs|dS)Nrr*)rmr*r*r+rÏ7sT)r<Úreverse) r Ú_hrefÚfinditerr¼Ú groupdictrr¶r Ú _clean_reÚsubr¡r¨)r6rÍrWr†r®Úrelr(r*r*r+Úlinkss  z Page.linksN)r=r>r?r@ÚreÚcompileÚIÚSÚXrÑrÊrRrÔrr×r*r*r*r+rÉs rÉcs˜eZdZdZejdd„dd„dœZd‡fdd „ Zd d „Zd d „Z dd„Z e j de j ƒZdd„Zdd„Zdd„Zdd„Zdd„Ze j 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. cCstjttƒd�jƒS)N)Zfileobj)ÚgzipZGzipFilerr®rÀ)Úbr*r*r+rÏEszSimpleScrapingLocator.cCs|S)Nr*)rßr*r*r+rÏFs)ZdeflaterÞZnoneNé c sftt|ƒjf|Žt|ƒ|_||_i|_tƒ|_t j ƒ|_ tƒ|_ d|_ ||_tjƒ|_tjƒ|_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. FN)rµrÝrRrr¶r%Ú _page_cacher Ú_seenr rPÚ _to_fetchÚ _bad_hostsÚskip_externalsÚ num_workersÚ threadingÚRLockÚ_lockÚ_gplock)r6r(r%rær·)r¸r*r+rRIs    zSimpleScrapingLocator.__init__cCsJg|_x>t|jƒD]0}tj|jd�}|jdƒ|jƒ|jj|ƒqWdS)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çZThreadÚ_fetchZ setDaemonÚstartrU)r6Úirmr*r*r+Ú_prepare_threadscs  z&SimpleScrapingLocator._prepare_threadscCs>x|jD]}|jjdƒqWx|jD] }|jƒq$Wg|_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|)r6rmr*r*r+Ú _wait_threadsps    z#SimpleScrapingLocator._wait_threadscCs’iidœ}|j�x||_||_t|jdt|ƒƒ}|jjƒ|jjƒ|j ƒz&t j d|ƒ|j j |ƒ|j jƒWd|jƒX|`WdQRX|S)N)r›ršz%s/z Queueing %s)rêrWrwrr¶r râr[rárñrorprãrÅr|rò)r6rbrWr(r*r*r+rc}s      z"SimpleScrapingLocator._get_projectz<\b(linux-(i\d86|x86_64|arm\w+)|win(32|-amd64)|macosx-?\d+)\bcCs |jj|ƒS)zD Does an URL refer to a platform-specific download? )Úplatform_dependentrË)r6r(r*r*r+Ú_is_platform_dependent’sz,SimpleScrapingLocator._is_platform_dependentc CsT|j|ƒrd}n|j||jƒ}tjd||ƒ|rP|j�|j|j|ƒWdQRX|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•rwrorprér¥rW)r6r(r˜r*r*r+Ú_process_download˜s z'SimpleScrapingLocator._process_downloadc CsÆt|ƒ\}}}}}}|j|j|j|jƒr2d}n~|jrL|j|jƒ rLd}nd|j|jƒs^d}nR|d krld}nD|dkrzd}n6|j|ƒrŠd}n&|j ddƒd } | j ƒd kr¬d}nd }t j d ||||ƒ|S)z‘ Determine whether a link URL from a referring page and with a particular "rel" attribute should be queued for scraping. FÚhomepageÚdownloadÚhttprfÚftpú:rrZ localhostTz#should_queue: %s (%s) from %s -> %s)rör÷)rørfrù) rrjr°r±r²rår„r¶rôÚsplitrƒrorp) r6ÚlinkZreferrerrÖr2rlriÚ_rWÚhostr*r*r+Ú _should_queue¬s*     z#SimpleScrapingLocator._should_queuecCsÚxÔ|jjƒ}z²yz|r†|j|ƒ}|dkr(wx\|jD]R\}}||jkr0|jj|ƒ|j|ƒ r0|j|||ƒr0tj d||ƒ|jj |ƒq0WWn2t k rº}z|j j t |ƒƒWYdd}~XnXWd|jjƒX|sPqWdS)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. NzQueueing %s from %s)rãrTÚget_pager×râr¡rõrÿrorprÅr‰rQrrV)r6r(ÚpagerürÖrXr*r*r+rîÉs&     & zSimpleScrapingLocator._fetchcCsXt|ƒ\}}}}}}|dkr:tjjt|ƒƒr:tt|ƒdƒ}||jkr`|j|}tj d||ƒ�nô|j ddƒd}d}||j kr�tj d||ƒ�nÄt |d d id �}�z¤yâtj d |ƒ|j j||jd �} tj d|ƒ| jƒ} | jddƒ} tj| ƒ�r„| jƒ} | jƒ} | jdƒ}|�r"|j|}|| ƒ} d}tj| ƒ}|�r@|jdƒ}y| j|ƒ} Wn tk �rn| jdƒ} YnXt| | ƒ}||j| <Wn¼tk �rÄ}z |jdk�r´tjd||ƒWYdd}~Xn€t k �r}z2tjd||ƒ|j!�|j j"|ƒWdQRXWYdd}~Xn2t#k �rB}ztjd||ƒWYdd}~XnXWd||j|<X|S)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úrrNzSkipping %s due to bad host %szAccept-encodingZidentity)r;z Fetching %s)r%z Fetched %sz Content-Typer0zContent-Encodingzutf-8zlatin-1i”zFetch failed: %s: %s)$rÚosriÚisdirrrrrárorprûrärrNr¿r%r˜rTÚHTML_CONTENT_TYPEr†ZgeturlrÀÚdecodersÚCHARSETrËrÌrÁÚ UnicodeErrorrÉrr9rÆrrér¡r‰)r6r(r2rlrirýrWrþr7rÇr;Z content_typeZ final_urlr¼ÚencodingÚdecoderr�rXr*r*r+rçsZ              &$ zSimpleScrapingLocator.get_pagez]*>([^<]+)r?r@ÚzlibZ decompressrrRrñròrcrØrÙrÚrórôrõrÿrîrr rdr½r*r*)r¸r+rÝ;s"   ; rÝcs8eZdZdZ‡fdd„Zdd„Zdd„Zdd „Z‡ZS) ÚDirectoryLocatorz? This class locates distributions in a directory tree. c sN|jddƒ|_tt|ƒjf|Žtjj|ƒ}tjj|ƒsDt 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: %rN) rœrrµr rRrriÚabspathrrÚbase_dir)r6rir·)r¸r*r+rR5s    zDirectoryLocator.__init__cCs |j|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. )rjr‹)r6rvÚparentr*r*r+Úshould_includeFszDirectoryLocator.should_includec Cs–iidœ}x†tj|jƒD]v\}}}xb|D]Z}|j||ƒr(tjj||ƒ}tddttjj|ƒƒdddfƒ}|j ||ƒ}|r(|j ||ƒq(W|j sPqW|S)N)r›ršrr0) rÚwalkrrrir|rr rr•r¥r) r6rbrWÚrootÚdirsÚfilesÚfnr(r˜r*r*r+rcNs     zDirectoryLocator._get_projectc Cs”tƒ}xˆtj|jƒD]x\}}}xd|D]\}|j||ƒr$tjj||ƒ}tddttjj |ƒƒdddfƒ}|j |dƒ}|r$|j |dƒq$W|j sPqW|S)zJ Return all the distribution names known to this locator. rr0Nrb) r rrrrrir|rr rr•r¡r)r6rWrrrrr(r˜r*r*r+rd^s    z'DirectoryLocator.get_distribution_names) r=r>r?r@rRrrcrdr½r*r*)r¸r+r 0s  r c@s eZdZdZdd„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. cCs tdƒ‚dS)zJ Return all the distribution names known to this locator. zNot available from this locatorN)ra)r6r*r*r+rdxsz"JSONLocator.get_distribution_namescCsÞiidœ}t|ƒ}|rÚxÂ|jdgƒD]²}|ddks$|ddkrBq$t|d|d|jd d ƒ|jd �}|j}|d |_d |kr’|d r’d|d f|_|jdiƒ|_|jdiƒ|_|||j <|dj |j t ƒƒj |d ƒq$W|S)N)r›ršrZptypeZsdistZ pyversionÚsourcerbr�r»zPlaceholder for summary)r»r2r(r’r—Z requirementsÚexportsr›) rrTrr2r�ržr’Z dependenciesrr�rŸr r¡)r6rbrWr¼r˜r£r¤r*r*r+rc~s&    "zJSONLocator._get_projectN)r=r>r?r@rdrcr*r*r*r+rqsrcs(eZdZdZ‡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*tt|ƒjf|Žt|tƒs t‚||_dS)zs Initialise an instance. :param distpath: A :class:`DistributionPath` instance to search. N)rµrrRÚ isinstancerÚAssertionErrorÚdistpath)r6rr·)r¸r*r+rRœszDistPathLocator.__init__cCsP|jj|ƒ}|dkr iidœ}n,|j|d|jt|jgƒid|jtdgƒii}|S)N)r›ršr›rš)rZget_distributionr�r rž)r6rbr£rWr*r*r+rc¦s  zDistPathLocator._get_project)r=r>r?r@rRrcr½r*r*)r¸r+r—s rcsReZdZdZ‡fdd„Z‡fdd„Zdd„Zeej j eƒZ dd „Z d d „Z ‡Z S) ÚAggregatingLocatorzI This class allows you to chain and/or merge a list of locators. cs*|jddƒ|_||_tt|ƒjf|Ž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). ÚmergeFN)rœr ÚlocatorsrµrrR)r6r!r·)r¸r*r+rR·s zAggregatingLocator.__init__cs*tt|ƒjƒx|jD] }|jƒqWdS)N)rµrr\r!)r6r¢)r¸r*r+r\Çs zAggregatingLocator.clear_cachecCs ||_x|jD] }||_qWdS)N)r]r!r2)r6r_r¢r*r*r+r`Ìs zAggregatingLocator._set_schemec Csôi}xê|jD]à}|j|ƒ}|r |jr®|jdiƒ}|jdiƒ}|j|ƒ|jdƒ}|r�|r�x6|jƒD]*\}} ||kr„||| O<qb| ||<qbW|jdƒ} |rì| rì| j|ƒq |jdkr¾d} n$d} x|D]}|jj|ƒrÈd} PqÈW| r |}Pq W|S)Nr›ršTF)r!rer rTÚupdaterÄrOr†) r6rbrWr¢r®rršZdfr­rZddÚfoundr*r*r+rcÓs8           zAggregatingLocator._get_projectc Cs@tƒ}x4|jD]*}y||jƒO}Wqtk r6YqXqW|S)zJ Return all the distribution names known to this locator. )r r!rdra)r6rWr¢r*r*r+rdÿs  z)AggregatingLocator.get_distribution_names)r=r>r?r@rRr\r`r³rAr2Úfgetrcrdr½r*r*)r¸r+r³s  ,rzhttps://pypi.python.org/simple/g@)r%Úlegacy)r2z1(?P[\w-]+)\s*\(\s*(==\s*)?(?P[^)]+)\)$c@sLeZdZdZddd„Zdd„Zdd„Zd d „Zd d „Zd d„Z ddd„Z dS)ÚDependencyFinderz0 Locate dependencies for distributions. NcCs|pt|_t|jjƒ|_dS)zf Initialise an instance, using the specified locator to locate distributions. N)Údefault_locatorr¢r!r2)r6r¢r*r*r+rRs zDependencyFinder.__init__cCsvtjd|ƒ|j}||j|<||j||jf<xD|jD]:}t|ƒ\}}tjd|||ƒ|jj |t ƒƒj ||fƒq4WdS)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) rorpr<Ú dists_by_nameÚdistsr�ÚprovidesrÚprovidedrŸr r¡)r6r£rbÚpr�r*r*r+Úadd_distribution&s    z!DependencyFinder.add_distributioncCs|tjd|ƒ|j}|j|=|j||jf=xN|jD]D}t|ƒ\}}tjd|||ƒ|j|}|j ||fƒ|s0|j|=q0WdS)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) rorpr<r(r)r�r*rr+Úremove)r6r£rbr,r�Úsr*r*r+Úremove_distribution5s    z$DependencyFinder.remove_distributionc CsBy|jj|ƒ}Wn,tk r<|jƒd}|jj|ƒ}YnX|S)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)r2rOr"rû)r6ÚreqtrOrbr*r*r+Ú get_matcherGs  zDependencyFinder.get_matcherc Csv|j|ƒ}|j}tƒ}|j}||krrxL||D]@\}}y|j|ƒ}Wntk r\d}YnX|r.|j|ƒPq.W|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)r2r<r r+r†r"r¡) r6r1rOrbrWr+r�Úproviderr†r*r*r+Úfind_providersWs   zDependencyFinder.find_providersc Cs¦|j|}tƒ}x,|D]$}|j|ƒ}|j|jƒs|j|ƒqW|r^|jd||t|ƒfƒd}nD|j|ƒ|j|=x"|D]}|jj|tƒƒj|ƒqvW|j |ƒ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. Z cantreplaceFT) Úreqtsr r2r†r�r¡Ú frozensetr0rŸr-) r6r3ÚotherÚproblemsZrlistZ unmatchedr/rOrWr*r*r+Útry_to_replaceos"         zDependencyFinder.try_to_replaceFcCsi|_i|_i|_i|_t|p gƒ}d|krH|jdƒ|tdddgƒO}t|tƒrh|}}tj d|ƒn4|j j ||d�}}|dkr�t d|ƒ‚tj d |ƒd |_ tƒ}t|gƒ}t|gƒ}�xô|�r²|jƒ}|j} | |jkrê|j|ƒn"|j| } | |k�r |j|| |ƒ|j|jB} |j} tƒ} ||k�rbx2dD]*}d|}||k�r4| t|d|ƒO} �q4W| | B| B}�x>|D�]4}|j|ƒ}|�sNtj d|ƒ|j j ||d�}|dk�rÊ| �rÊ|j j |d d�}|dk�rðtj d|ƒ|jd|fƒn^|j|j}}||f|jk�r|j|ƒ|j|ƒ|| k�rN||k�rN|j|ƒtj d|jƒxZ|D]R}|j} | |jk�r‚|jj|tƒƒj|ƒn"|j| } | |k�rT|j|| |ƒ�qTW�qvWqÀWt|jjƒƒ}x.|D]&}||k|_|j�rÈtj d|jƒ�qÈWtj 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 %rZ unsatisfiedzAdding %s to install_distsz#%s is a build-time dependency only.zfind done for %s)r:r;r<)r+r)r(r5r r.rrrorpr¢r¯rZ requestedrœr<r-r9Z run_requiresZ meta_requiresZbuild_requiresÚgetattrr4r¡r�Zname_and_versionrŸÚvaluesZbuild_time_dependency)r6r¦Z meta_extrasrªr£rÈr8ZtodoZ install_distsrbr7ZireqtsZsreqtsZereqtsr<rXZ all_reqtsr«Z providersr3Únrr,r)r*r*r+Úfind—sŒ                                zDependencyFinder.find)N)NF) r=r>r?r@rRr-r0r2r4r9r@r*r*r*r+r&s (r&)N)NrÞÚiorrÂZloggingrrgrØrçÚ ImportErrorZdummy_threadingr r0rÚcompatrrrrr r r r r rrr4rrrrZdatabaserrrr�rÚutilrrrrrrrrr r�r!r"r“r#r$Z getLoggerr=rorÙr…rÚrrr&r,r-ÚobjectrAr´r¾rÉrÝr rrrr'r¯ZNAME_VERSION_REr&r*r*r*r+ÚsZ   D ,    ;0E:vA&[