U .el@sddlmZmZmZddlZddlZddlZddlZddlm Z m Z ddl m Z m Z mZGdddeZGdd d e ejeZGd d d eZGd d d eZddZGdddeZedZddZddZGdddeZdS))absolute_importdivisionprint_functionN) string_typeswith_metaclass)Version LegacyVersionparsec@seZdZdZdS)InvalidSpecifierzH An invalid specifier was found, users should refer to PEP 440. N)__name__ __module__ __qualname____doc__rrD/usr/lib/python3.8/site-packages/pip/_vendor/packaging/specifiers.pyr sr c@seZdZejddZejddZejddZejddZej d d Z e j d d Z ejdd dZ ejdddZ d S) BaseSpecifiercCsdS)z Returns the str representation of this Specifier like object. This should be representative of the Specifier itself. Nrselfrrr__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. Nrrotherrrr__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. Nrrvaluerrrr8sNcCsdS)zR Determines if the given item is contained within this specifier. Nrritemrrrrcontains?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)riterablerrrrfilterEszBaseSpecifier.filter)N)N)r r rabcabstractmethodrrrrabstractpropertyrsetterr r"rrrrrs        rc@seZdZiZd ddZddZddZd d Zd d Zd dZ ddZ ddZ e ddZ e ddZe ddZejddZddZd!ddZd"ddZdS)#_IndividualSpecifierNcCsF|j|}|std||d|df|_||_dS)NzInvalid specifier: '{0}'operatorversion)_regexsearchr formatgroupstrip_spec _prereleases)rspecrmatchrrr__init__Qs  z_IndividualSpecifier.__init__cCs0|jdk rd|jnd}d|jjt||S)N, prereleases={0!r}r(z<{0}({1!r}{2})>)r1r-r __class__r strrZprerrr__repr__[s z_IndividualSpecifier.__repr__cCs dj|jS)Nz{0}{1})r-r0rrrrrdsz_IndividualSpecifier.__str__cCs t|jSN)hashr0rrrrrgsz_IndividualSpecifier.__hash__cCsPt|tr4z||}WqDtk r0tYSXnt||jsDtS|j|jkSr: isinstancerr6r NotImplementedr0rrrrrjs   z_IndividualSpecifier.__eq__cCsPt|tr4z||}WqDtk r0tYSXnt||jsDtS|j|jkSr:r<rrrrrus   z_IndividualSpecifier.__ne__cCst|d|j|S)Nz _compare_{0})getattrr- _operators)roprrr _get_operatorsz"_IndividualSpecifier._get_operatorcCst|ttfst|}|Sr:)r=r rr rr*rrr_coerce_versionsz$_IndividualSpecifier._coerce_versioncCs |jdS)Nrr0rrrrr)sz_IndividualSpecifier.operatorcCs |jdS)NrrErrrrr*sz_IndividualSpecifier.versioncCs|jSr:r1rrrrrsz _IndividualSpecifier.prereleasescCs ||_dSr:rFrrrrrscCs ||Sr:r rrrrr __contains__sz!_IndividualSpecifier.__contains__cCs:|dkr|j}||}|jr&|s&dS||j||jSNF)rrD is_prereleaserBr)r*rrrrr s   z_IndividualSpecifier.containsccsd}g}d|dk r|ndi}|D]B}||}|j|f|r |jrX|sX|jsX||q d}|Vq |s||r||D] }|VqpdS)NFrT)rDr rKrappend)rr!rZyieldedfound_prereleaseskwr*parsed_versionrrrr"s"  z_IndividualSpecifier.filter)r(N)N)N)r r rr@r4r9rrrrrBrDpropertyr)r*rr&rIr r"rrrrr'Ms(         r'c@sveZdZdZededejejBZdddddd d Z d d Z d dZ ddZ ddZ ddZddZddZdS)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_equalless_than_equalgreater_than_equal less_than greater_than)==!=<=>=<>cCst|tstt|}|Sr:)r=r r7rCrrrrDs  zLegacySpecifier._coerce_versioncCs|||kSr:rDr prospectiver2rrr_compare_equalszLegacySpecifier._compare_equalcCs|||kSr:r`rarrr_compare_not_equalsz"LegacySpecifier._compare_not_equalcCs|||kSr:r`rarrr_compare_less_than_equalsz(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_strrecompileVERBOSE IGNORECASEr+r@rDrcrdrerfrgrhrrrrrQs   rQcstfdd}|S)Ncst|tsdS|||SrJ)r=rrafnrrwrappeds z)_require_version_compare..wrapped) functoolswraps)rorprrnr_require_version_comparesrsc @seZdZdZededejejBZdddddd d d d Z e d dZ e ddZ e ddZ e ddZe ddZe ddZe ddZddZeddZejddZd 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)joinlist itertools takewhile_version_splitrB)rrbr2prefixrrr_compare_compatiblevs  zSpecifier._compare_compatiblecCsp|drPt|j}t|dd}tt|}|dt|}t||\}}nt|}|jsht|j}||kS)Nr~)endswithrZpublicrr7len _pad_versionlocalrarrrrcs    zSpecifier._compare_equalcCs||| Sr:)rcrarrrrdszSpecifier._compare_not_equalcCs |t|kSr:rrarrrresz"Specifier._compare_less_than_equalcCs |t|kSr:rrarrrrfsz%Specifier._compare_greater_than_equalcCs<t|}||ksdS|js8|jr8t|jt|jkr8dSdSNFT)rrK base_versionrarrrrgs zSpecifier._compare_less_thancCs^t|}||ksdS|js8|jr8t|jt|jkr8dS|jdk rZt|jt|jkrZdSdSr)rZis_postreleaserrrarrrrhs  zSpecifier._compare_greater_thancCst|t|kSr:)r7lowerrarrr_compare_arbitraryszSpecifier._compare_arbitrarycCsR|jdk r|jS|j\}}|dkrN|dkr@|dr@|dd}t|jrNdSdS)N)rZr]r\rurvrZr~rTF)r1r0rr rK)rr)r*rrrrs    zSpecifier.prereleasescCs ||_dSr:rFrrrrrsN)r r rrirjrkrlrmr+r@rsrrcrdrerfrgrhrrPrr&rrrrrt s<]   "      rtz^([0-9]+)((?:a|b|c|rc)[0-9]+)$cCs@g}|dD],}t|}|r0||q||q|S)Nrw)split _prefix_regexr,extendgroupsrL)r*resultrr3rrrrs  rc Csgg}}|ttdd||ttdd|||t|dd||t|dd|ddgtdt|dt|d|ddgtdt|dt|dttj|ttj|fS)NcSs|Sr:isdigitryrrrr{*r|z_pad_version..cSs|Sr:rryrrrr{+r|rr0)rLrrrrinsertmaxchain)leftrightZ left_splitZ right_splitrrrr&s ,,rc@seZdZdddZddZddZd d Zd d Zd dZddZ ddZ ddZ e ddZ e jddZ ddZdddZd ddZdS)! SpecifierSetr(Nc Csndd|dD}t}|D]:}z|t|Wqtk rV|t|YqXqt||_||_dS)NcSsg|]}|r|qSr)r/.0srrr <sz)SpecifierSet.__init__..,) rsetaddrtr rQ frozenset_specsr1)rZ specifiersrZparsed specifierrrrr49s zSpecifierSet.__init__cCs*|jdk rd|jnd}dt||S)Nr5r(z)r1r-rr7r8rrrr9Ns zSpecifierSet.__repr__cCsdtdd|jDS)Nrcss|]}t|VqdSr:)r7rrrr Xsz'SpecifierSet.__str__..)rsortedrrrrrrWszSpecifierSet.__str__cCs t|jSr:)r;rrrrrrZszSpecifierSet.__hash__cCst|trt|}nt|ts"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=rrr>rrr1 ValueError)rrrrrr__and__]s        zSpecifierSet.__and__cCsFt|trt|}n&t|tr,tt|}nt|ts:tS|j|jkSr:r=rrr'r7r>rrrrrrts    zSpecifierSet.__eq__cCsFt|trt|}n&t|tr,tt|}nt|ts:tS|j|jkSr:rrrrrr~s    zSpecifierSet.__ne__cCs t|jSr:)rrrrrr__len__szSpecifierSet.__len__cCs t|jSr:)iterrrrrr__iter__szSpecifierSet.__iter__cCs.|jdk r|jS|jsdStdd|jDS)Ncss|] }|jVqdSr:rrrrrrsz+SpecifierSet.prereleases..)r1ranyrrrrrs  zSpecifierSet.prereleasescCs ||_dSr:rFrrrrrscCs ||Sr:rGrHrrrrIszSpecifierSet.__contains__csLtttfstdkr$|js2jr2dStfdd|jDS)NFc3s|]}|jdVqdS)rNrGrrrrrrsz(SpecifierSet.contains..)r=r rr rrKallrrrrrr s zSpecifierSet.containscCs|dkr|j}|jr6|jD]}|j|t|d}q|Sg}g}|D]P}t|ttfs^t|}n|}t|trnqB|jr|s|s| |qB| |qB|s|r|dkr|S|SdS)Nr) rrr"boolr=r rr rKrL)rr!rr2ZfilteredrMrrOrrrr"s*      zSpecifierSet.filter)r(N)N)N)r r rr4r9rrrrrrrrPrr&rIr r"rrrrr8s        r)Z __future__rrrr#rqrrjZ_compatrrr*rr r rr ABCMetaobjectrr'rQrsrtrkrrrrrrrrs&81