U ÀÒ.e‚lã@sæddlmZmZmZddlZddlZddlZddlZddlm Z m Z ddl m Z m Z mZGdd„deƒZGdd „d e ejeƒƒZGd d „d eƒZGd d „d eƒZdd„ZGdd„deƒZe d¡Zdd„Zdd„ZGdd„deƒZdS)é)Úabsolute_importÚdivisionÚprint_functionNé)Ú string_typesÚwith_metaclass)ÚVersionÚ LegacyVersionÚparsec@seZdZdZdS)ÚInvalidSpecifierzH An invalid specifier was found, users should refer to PEP 440. N)Ú__name__Ú __module__Ú __qualname__Ú__doc__©rrúD/usr/lib/python3.8/site-packages/pip/_vendor/packaging/specifiers.pyr sr c@s€eZdZejdd„ƒZejdd„ƒZejdd„ƒZejdd„ƒZej d d „ƒZ e j d d „ƒZ ejdd d„ƒZ ejddd„ƒZ d S)Ú BaseSpecifiercCsdS)zŽ Returns the str representation of this Specifier like object. This should be representative of the Specifier itself. Nr©ÚselfrrrÚ__str__szBaseSpecifier.__str__cCsdS)zF Returns a hash value for this Specifier like object. NrrrrrÚ__hash__szBaseSpecifier.__hash__cCsdS)zq Returns a boolean representing whether or not the two Specifier like objects are equal. Nr©rÚotherrrrÚ__eq__#szBaseSpecifier.__eq__cCsdS)zu Returns a boolean representing whether or not the two Specifier like objects are not equal. NrrrrrÚ__ne__*szBaseSpecifier.__ne__cCsdS)zg Returns whether or not pre-releases as a whole are allowed by this specifier. NrrrrrÚ prereleases1szBaseSpecifier.prereleasescCsdS)zd Sets whether or not pre-releases as a whole are allowed by this specifier. Nr©rÚvaluerrrr8sNcCsdS)zR Determines if the given item is contained within this specifier. Nr©rÚitemrrrrÚcontains?szBaseSpecifier.containscCsdS)z• Takes an iterable of items and filters them so that only items which are contained within this specifier are allowed in it. Nr)rÚiterablerrrrÚfilterEszBaseSpecifier.filter)N)N)r r rÚabcÚabstractmethodrrrrÚabstractpropertyrÚsetterr r"rrrrrs        rc@s eZdZiZd dd„Zdd„Zdd„Zd d „Zd d „Zd d„Z dd„Z dd„Z e dd„ƒZ e dd„ƒZe dd„ƒZejdd„ƒZdd„Zd!dd„Zd"dd„ZdS)#Ú_IndividualSpecifierÚNcCsF|j |¡}|std |¡ƒ‚| d¡ ¡| d¡ ¡f|_||_dS)NzInvalid specifier: '{0}'ÚoperatorÚversion)Ú_regexÚsearchr ÚformatÚgroupÚstripÚ_specÚ _prereleases)rÚspecrÚmatchrrrÚ__init__Qs  z_IndividualSpecifier.__init__cCs0|jdk rd |j¡nd}d |jjt|ƒ|¡S)Nú, prereleases={0!r}r(z<{0}({1!r}{2})>)r1r-rÚ __class__r Ústr©rZprerrrÚ__repr__[s ÿýz_IndividualSpecifier.__repr__cCs dj|jŽS)Nz{0}{1})r-r0rrrrrdsz_IndividualSpecifier.__str__cCs t|jƒS©N)Úhashr0rrrrrgsz_IndividualSpecifier.__hash__cCsPt|tƒr4z| |¡}WqDtk r0tYSXnt||jƒsDtS|j|jkSr:©Ú isinstancerr6r ÚNotImplementedr0rrrrrjs   z_IndividualSpecifier.__eq__cCsPt|tƒr4z| |¡}WqDtk r0tYSXnt||jƒsDtS|j|jkSr:r<rrrrrus   z_IndividualSpecifier.__ne__cCst|d |j|¡ƒS)Nz _compare_{0})Úgetattrr-Ú _operators)rÚoprrrÚ _get_operator€sz"_IndividualSpecifier._get_operatorcCst|ttfƒst|ƒ}|Sr:)r=r rr ©rr*rrrÚ_coerce_versionƒsz$_IndividualSpecifier._coerce_versioncCs |jdS)Nr©r0rrrrr)ˆsz_IndividualSpecifier.operatorcCs |jdS)NrrErrrrr*Œsz_IndividualSpecifier.versioncCs|jSr:©r1rrrrr�sz _IndividualSpecifier.prereleasescCs ||_dSr:rFrrrrr”scCs | |¡Sr:©r ©rrrrrÚ __contains__˜sz!_IndividualSpecifier.__contains__cCs:|dkr|j}| |¡}|jr&|s&dS| |j¡||jƒS©NF)rrDÚ is_prereleaserBr)r*rrrrr ›s   z_IndividualSpecifier.containsccs€d}g}d|dk r|ndi}|D]B}| |¡}|j|f|Žr |jrX|sX|jsX| |¡q d}|Vq |s||r||D] }|VqpdS)NFrT)rDr rKrÚappend)rr!rZyieldedÚfound_prereleasesÚkwr*Úparsed_versionrrrr"®s" ÿÿ z_IndividualSpecifier.filter)r(N)N)N)r r rr@r4r9rrrrrBrDÚpropertyr)r*rr&rIr r"rrrrr'Ms(         r'c@sveZdZdZe dedejejB¡Zdddddd d œZ d d „Z d d„Z dd„Z dd„Z dd„Zdd„Zdd„ZdS)ÚLegacySpecifieraÛ (?P(==|!=|<=|>=|<|>)) \s* (?P [^,;\s)]* # Since this is a "legacy" specifier, and the version # string can be just about anything, we match everything # except for whitespace, a semi-colon for marker support, # a closing paren since versions can be enclosed in # them, and a comma since it's a version separator. ) ú^\s*ú\s*$ÚequalÚ not_equalÚless_than_equalÚgreater_than_equalÚ less_thanÚ greater_than)ú==ú!=ú<=ú>=ú<ú>cCst|tƒstt|ƒƒ}|Sr:)r=r r7rCrrrrDès  zLegacySpecifier._coerce_versioncCs|| |¡kSr:©rD©rÚ prospectiver2rrrÚ_compare_equalíszLegacySpecifier._compare_equalcCs|| |¡kSr:r`rarrrÚ_compare_not_equalðsz"LegacySpecifier._compare_not_equalcCs|| |¡kSr:r`rarrrÚ_compare_less_than_equalósz(LegacySpecifier._compare_less_than_equalcCs|| |¡kSr:r`rarrrÚ_compare_greater_than_equalösz+LegacySpecifier._compare_greater_than_equalcCs|| |¡kSr:r`rarrrÚ_compare_less_thanùsz"LegacySpecifier._compare_less_thancCs|| |¡kSr:r`rarrrÚ_compare_greater_thanüsz%LegacySpecifier._compare_greater_thanN)r r rÚ _regex_strÚreÚcompileÚVERBOSEÚ IGNORECASEr+r@rDrcrdrerfrgrhrrrrrQÏs  ú rQcst ˆ¡‡fdd„ƒ}|S)Ncst|tƒsdSˆ|||ƒSrJ)r=rra©ÚfnrrÚwrappeds z)_require_version_compare..wrapped)Ú functoolsÚwraps)rorprrnrÚ_require_version_comparesrsc @s¸eZdZdZe dedejejB¡Zdddddd d d d œZ e d d„ƒZ e dd„ƒZ e dd„ƒZ e dd„ƒZe dd„ƒZe dd„ƒZe dd„ƒZdd„Zedd„ƒZejdd„ƒZd S)!Ú Specifiera (?P(~=|==|!=|<=|>=|<|>|===)) (?P (?: # The identity operators allow for an escape hatch that will # do an exact string match of the version you wish to install. # This will not be parsed by PEP 440 and we cannot determine # any semantic meaning from it. This operator is discouraged # but included entirely as an escape hatch. (?<====) # Only match for the identity operator \s* [^\s]* # We just match everything, except for whitespace # since we are only testing for strict identity. ) | (?: # The (non)equality operators allow for wild card and local # versions to be specified so we have to define these two # operators separately to enable that. (?<===|!=) # Only match for equals and not equals \s* v? (?:[0-9]+!)? # epoch [0-9]+(?:\.[0-9]+)* # release (?: # pre release [-_\.]? (a|b|c|rc|alpha|beta|pre|preview) [-_\.]? [0-9]* )? (?: # post release (?:-[0-9]+)|(?:[-_\.]?(post|rev|r)[-_\.]?[0-9]*) )? # You cannot use a wild card and a dev or local version # together so group them with a | and make them optional. (?: (?:[-_\.]?dev[-_\.]?[0-9]*)? # dev release (?:\+[a-z0-9]+(?:[-_\.][a-z0-9]+)*)? # local | \.\* # Wild card syntax of .* )? ) | (?: # The compatible operator requires at least two digits in the # release segment. (?<=~=) # Only match for the compatible operator \s* v? (?:[0-9]+!)? # epoch [0-9]+(?:\.[0-9]+)+ # release (We have a + instead of a *) (?: # pre release [-_\.]? (a|b|c|rc|alpha|beta|pre|preview) [-_\.]? [0-9]* )? (?: # post release (?:-[0-9]+)|(?:[-_\.]?(post|rev|r)[-_\.]?[0-9]*) )? (?:[-_\.]?dev[-_\.]?[0-9]*)? # dev release ) | (?: # All other operators only allow a sub set of what the # (non)equality operators do. Specifically they do not allow # local versions to be specified nor do they allow the prefix # matching wild cards. (?„óz/Specifier._compare_compatible..éÿÿÿÿú.*r]rZ)ÚjoinÚlistÚ itertoolsÚ takewhileÚ_version_splitrB)rrbr2ÚprefixrrrÚ_compare_compatiblevs þÿûÿ ÿzSpecifier._compare_compatiblecCsp| d¡rPt|jƒ}t|dd…ƒ}tt|ƒƒ}|dt|ƒ…}t||ƒ\}}nt|ƒ}|jsht|jƒ}||kS)Nr~éþÿÿÿ)ÚendswithrZpublicrƒr7ÚlenÚ _pad_versionÚlocalrarrrrc‘s    zSpecifier._compare_equalcCs| ||¡ Sr:)rcrarrrrd´szSpecifier._compare_not_equalcCs |t|ƒkSr:©rrarrrre¸sz"Specifier._compare_less_than_equalcCs |t|ƒkSr:r‹rarrrrf¼sz%Specifier._compare_greater_than_equalcCs<t|ƒ}||ksdS|js8|jr8t|jƒt|jƒkr8dSdS©NFT)rrKÚ base_versionrarrrrgÀs zSpecifier._compare_less_thancCs^t|ƒ}||ksdS|js8|jr8t|jƒt|jƒkr8dS|jdk rZt|jƒt|jƒkrZdSdSrŒ)rZis_postreleaser�rŠrarrrrhÙs  zSpecifier._compare_greater_thancCst|ƒ ¡t|ƒ ¡kSr:)r7ÚlowerrarrrÚ_compare_arbitraryøszSpecifier._compare_arbitrarycCsR|jdk r|jS|j\}}|dkrN|dkr@| d¡r@|dd…}t|ƒjrNdSdS)N)rZr]r\rurvrZr~r†TF)r1r0r‡r rK)rr)r*rrrrûs    zSpecifier.prereleasescCs ||_dSr:rFrrrrrsN)r r rrirjrkrlrmr+r@rsr…rcrdrerfrgrhr�rPrr&rrrrrt s<]ø   "      rtz^([0-9]+)((?:a|b|c|rc)[0-9]+)$cCs@g}| d¡D],}t |¡}|r0| | ¡¡q| |¡q|S)Nrw)ÚsplitÚ _prefix_regexr,ÚextendÚgroupsrL)r*Úresultrr3rrrrƒs  rƒc Csægg}}| tt dd„|¡ƒ¡| tt dd„|¡ƒ¡| |t|dƒd…¡| |t|dƒd…¡| ddgtdt|dƒt|dƒƒ¡| ddgtdt|dƒt|dƒƒ¡ttj|Žƒttj|ŽƒfS)NcSs| ¡Sr:©Úisdigitryrrrr{*r|z_pad_version..cSs| ¡Sr:r•ryrrrr{+r|rrÚ0)rLr€r�r‚rˆÚinsertÚmaxÚchain)ÚleftÚrightZ left_splitZ right_splitrrrr‰&s ,,r‰c@sŒeZdZddd„Zdd„Zdd„Zd d „Zd d „Zd d„Zdd„Z dd„Z dd„Z e dd„ƒZ e jdd„ƒZ dd„Zddd„Zd dd„ZdS)!Ú SpecifierSetr(Nc Csndd„| d¡Dƒ}tƒ}|D]:}z| t|ƒ¡Wqtk rV| t|ƒ¡YqXqt|ƒ|_||_dS)NcSsg|]}| ¡r| ¡‘qSr)r/©Ú.0ÚsrrrÚ <sz)SpecifierSet.__init__..ú,) r�ÚsetÚaddrtr rQÚ frozensetÚ_specsr1)rZ specifiersrZparsedÚ specifierrrrr49s zSpecifierSet.__init__cCs*|jdk rd |j¡nd}d t|ƒ|¡S)Nr5r(z)r1r-rr7r8rrrr9Ns ÿýzSpecifierSet.__repr__cCsd tdd„|jDƒƒ¡S)Nr¢css|]}t|ƒVqdSr:)r7ržrrrÚ Xsz'SpecifierSet.__str__..)rÚsortedr¦rrrrrWszSpecifierSet.__str__cCs t|jƒSr:)r;r¦rrrrrZszSpecifierSet.__hash__cCs˜t|tƒrt|ƒ}nt|tƒs"tStƒ}t|j|jBƒ|_|jdkrX|jdk rX|j|_n<|jdk rv|jdkrv|j|_n|j|jkrŒ|j|_ntdƒ‚|S)NzFCannot combine SpecifierSets with True and False prerelease overrides.)r=rr�r>r¥r¦r1Ú ValueError)rrr§rrrÚ__and__]s        ÿzSpecifierSet.__and__cCsFt|tƒrt|ƒ}n&t|tƒr,tt|ƒƒ}nt|tƒs:tS|j|jkSr:©r=rr�r'r7r>r¦rrrrrts    zSpecifierSet.__eq__cCsFt|tƒrt|ƒ}n&t|tƒr,tt|ƒƒ}nt|tƒs:tS|j|jkSr:r¬rrrrr~s    zSpecifierSet.__ne__cCs t|jƒSr:)rˆr¦rrrrÚ__len__ˆszSpecifierSet.__len__cCs t|jƒSr:)Úiterr¦rrrrÚ__iter__‹szSpecifierSet.__iter__cCs.|jdk r|jS|jsdStdd„|jDƒƒS)Ncss|] }|jVqdSr:©rržrrrr¨�sz+SpecifierSet.prereleases..)r1r¦ÚanyrrrrrŽs  zSpecifierSet.prereleasescCs ||_dSr:rFrrrrrŸscCs | |¡Sr:rGrHrrrrI£szSpecifierSet.__contains__csLtˆttfƒstˆƒ‰ˆdkr$|j‰ˆs2ˆjr2dSt‡‡fdd„|jDƒƒS)NFc3s|]}|jˆˆd�VqdS)r°NrGrž©rrrrr¨¾sz(SpecifierSet.contains..)r=r rr rrKÚallr¦rrr²rr ¦s zSpecifierSet.containscCs°|dkr|j}|jr6|jD]}|j|t|ƒd�}q|Sg}g}|D]P}t|ttfƒs^t|ƒ}n|}t|tƒrnqB|jrˆ|sˆ|s’|  |¡qB|  |¡qB|s¨|r¨|dkr¨|S|SdS)Nr°) rr¦r"Úboolr=r rr rKrL)rr!rr2ZfilteredrMrrOrrrr"Às*      zSpecifierSet.filter)r(N)N)N)r r rr4r9rrr«rrr­r¯rPrr&rIr r"rrrrr�8s        r�)Z __future__rrrr#rqr�rjZ_compatrrr*rr r rªr ÚABCMetaÚobjectrr'rQrsrtrkr‘rƒr‰r�rrrrÚs&81