U âQabymã@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úN/usr/lib/python3.8/site-packages/pkg_resources/_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Ú prereleases2szBaseSpecifier.prereleasescCsdS)zd Sets whether or not pre-releases as a whole are allowed by this specifier. Nr©rÚvaluerrrr9sNcCsdS)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ÚfilterFszBaseSpecifier.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__Rs   þ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-r0rrrrrlsz_IndividualSpecifier.__str__cCs t|jƒS©N)Úhashr0rrrrrosz_IndividualSpecifier.__hash__cCsPt|tƒr4z| |¡}WqDtk r0tYSXnt||jƒsDtS|j|jkSr:©Ú isinstancerr6r ÚNotImplementedr0rrrrrrs   z_IndividualSpecifier.__eq__cCsPt|tƒr4z| |¡}WqDtk r0tYSXnt||jƒsDtS|j|jkSr:r<rrrrr}s   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'Ns(         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_equalsz+LegacySpecifier._compare_greater_than_equalcCs|| |¡kSr:r`rarrrÚ_compare_less_thansz"LegacySpecifier._compare_less_thancCs|| |¡kSr:r`rarrrÚ_compare_greater_thansz%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Úwrapped s z)_require_version_compare..wrapped)Ú functoolsÚwraps)rorprrnrÚ_require_version_compare srsc @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. (?�s ÿz/Specifier._compare_compatible..éÿÿÿÿú.*r]rZ)ÚjoinÚlistÚ itertoolsÚ takewhileÚ_version_splitrB)rrbr2ÚprefixrrrÚ_compare_compatible‚s ýÿúÿ ÿ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_arbitraryszSpecifier._compare_arbitrarycCsR|jdk r|jS|j\}}|dkrN|dkr@| d¡r@|dd…}t|ƒjrNdSdS)N)rZr]r\rurvrZr}r…TF)r1r0r†r rK)rr)r*rrrrs    zSpecifier.prereleasescCs ||_dSr:rFrrrrrsN)r r rrirjrkrlrmr+r@rsr„rcrdrerfrgrhrŽrPrr&rrrrrtsDÿ_ ÿø   "      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{6óz_pad_version..cSs| ¡Sr:r”ryrrrr{7r–rrÚ0)rLrr€r�r‡ÚinsertÚmaxÚchain)ÚleftÚrightZ left_splitZ right_splitrrrrˆ2s  "þ"þ  þ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Ú Rsz)SpecifierSet.__init__..ú,) r�ÚsetÚaddrtr rQÚ frozensetÚ_specsr1)rZ specifiersrZparsedÚ specifierrrrr4Os zSpecifierSet.__init__cCs*|jdk rd |j¡nd}d t|ƒ|¡S)Nr5r(z)r1r-rr7r8rrrr9ds ÿýzSpecifierSet.__repr__cCsd tdd„|jDƒƒ¡S)Nr¢css|]}t|ƒVqdSr:)r7ržrrrÚ nsz'SpecifierSet.__str__..)r~Úsortedr¦rrrrrmszSpecifierSet.__str__cCs t|jƒSr:)r;r¦rrrrrpszSpecifierSet.__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__ss        ÿzSpecifierSet.__and__cCsFt|tƒrt|ƒ}n&t|tƒr,tt|ƒƒ}nt|tƒs:tS|j|jkSr:©r=rr�r'r7r>r¦rrrrrŠs    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¨Ôsÿz(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�Ms        r�)Z __future__rrrr#rqr€rjZ_compatrrr*rr r rªr ÚABCMetaÚobjectrr'rQrsrtrkr�r‚rˆr�rrrrÚs&9 4