Re|@sddlmZmZmZddlZddlZddlZddlZddlm Z m Z ddl m Z ddl mZddlmZmZmZe rddlmZmZmZmZmZmZmZmZmZeeefZeeeefZeeege fZ!Gd d d e"Z#Gd d d e ej$e%Z&Gd dde&Z'Gddde'Z(ddZ)Gddde'Z*ej+dZ,ddZ-ddZ.Gddde&Z/dS))absolute_importdivisionprint_functionN) string_typeswith_metaclass) TYPE_CHECKING)canonicalize_version)Version LegacyVersionparse) ListDictUnionIterableIteratorOptionalCallableTuple FrozenSetc@seZdZdZdS)InvalidSpecifierzH An invalid specifier was found, users should refer to PEP 440. N)__name__ __module__ __qualname____doc__rr/builddir/build/BUILDROOT/alt-python35-pip-20.2.4-5.el8.x86_64/opt/alt/python35/lib/python3.5/site-packages/pip/_vendor/packaging/specifiers.pyr"s rc@seZdZejddZejddZejddZejddZej d d Z e j d d Z ejd d dZ ejd ddZ 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. Nr)rrrr__hash__1szBaseSpecifier.__hash__cCsdS)zq Returns a boolean representing whether or not the two Specifier like objects are equal. Nr)rotherrrr__eq__8szBaseSpecifier.__eq__cCsdS)zu Returns a boolean representing whether or not the two Specifier like objects are not equal. Nr)rr!rrr__ne__@szBaseSpecifier.__ne__cCsdS)zg Returns whether or not pre-releases as a whole are allowed by this specifier. Nr)rrrr prereleasesHszBaseSpecifier.prereleasescCsdS)zd Sets whether or not pre-releases as a whole are allowed by this specifier. Nr)rvaluerrrr$PsNcCsdS)zR Determines if the given item is contained within this specifier. Nr)ritemr$rrrcontainsXszBaseSpecifier.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)riterabler$rrrfilter_szBaseSpecifier.filter)rrrabcabstractmethodrr r"r#abstractpropertyr$setterr'r)rrrrr(s rc@seZdZiZddddZddZddZed d Zd d Z d dZ ddZ ddZ ddZ eddZeddZeddZejddZddZdddZdd d!ZdS)"_IndividualSpecifierNcCsg|jj|}|s-tdj||jdj|jdjf|_||_dS)NzInvalid specifier: '{0}'operatorversion)_regexsearchrformatgroupstrip_spec _prereleases)rspecr$matchrrr__init__ls z_IndividualSpecifier.__init__cCsF|jdk r!dj|jnd}dj|jjt||S)Nz, prereleases={0!r}r/z<{0}({1!r}{2})>)r8r4r$ __class__rstr)rprerrr__repr__zs!z_IndividualSpecifier.__repr__cCsdj|jS)Nz{0}{1})r4r7)rrrrrsz_IndividualSpecifier.__str__cCs|jdt|jdfS)Nrr)r7r )rrrr_canonical_specsz$_IndividualSpecifier._canonical_speccCs t|jS)N)hashr@)rrrrr sz_IndividualSpecifier.__hash__c Csjt|trDy|jt|}WqZtk r@tSYqZXnt||jsZtS|j|jkS)N) isinstancerr<r=rNotImplementedr@)rr!rrrr"s  z_IndividualSpecifier.__eq__c Csjt|trDy|jt|}WqZtk r@tSYqZXnt||jsZtS|j|jkS)N)rBrr<r=rrCr7)rr!rrrr#s  z_IndividualSpecifier.__ne__cCs#t|dj|j|}|S)Nz _compare_{0})getattrr4 _operators)ropoperator_callablerrr _get_operatorsz"_IndividualSpecifier._get_operatorcCs%t|ttfs!t|}|S)N)rBr r r )rr1rrr_coerce_versions z$_IndividualSpecifier._coerce_versioncCs |jdS)Nr)r7)rrrrr0sz_IndividualSpecifier.operatorcCs |jdS)Nr)r7)rrrrr1sz_IndividualSpecifier.versioncCs|jS)N)r8)rrrrr$sz _IndividualSpecifier.prereleasescCs ||_dS)N)r8)rr%rrrr$scCs |j|S)N)r')rr&rrr __contains__sz!_IndividualSpecifier.__contains__cCsZ|dkr|j}|j|}|jr8| r8dS|j|j}|||jS)NF)r$rI is_prereleaserHr0r1)rr&r$normalized_itemrGrrrr's  z_IndividualSpecifier.containsccsd}g}d|dk r!|ndi}xc|D][}|j|}|j||r1|jr|pm|j r|j|q1d}|Vq1W| r|rx|D] }|VqWdS)NFr$T)rIr'rKr$append)rr(r$yieldedfound_prereleaseskwr1parsed_versionrrrr)s     z_IndividualSpecifier.filter)rrrrEr;r?rpropertyr@r r"r#rHrIr0r1r$r-rJr'r)rrrrr.hs"      r.c @seZdZdZejdedejejBZdddddd d d d d ddiZ ddZ ddZ 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. ) z^\s*z\s*$z==equalz!= not_equalz<=less_than_equalz>=greater_than_equal< less_than> greater_thancCs%t|ts!tt|}|S)N)rBr r=)rr1rrrrI szLegacySpecifier._coerce_versioncCs||j|kS)N)rI)r prospectiver9rrr_compare_equal&szLegacySpecifier._compare_equalcCs||j|kS)N)rI)rr\r9rrr_compare_not_equal*sz"LegacySpecifier._compare_not_equalcCs||j|kS)N)rI)rr\r9rrr_compare_less_than_equal.sz(LegacySpecifier._compare_less_than_equalcCs||j|kS)N)rI)rr\r9rrr_compare_greater_than_equal2sz+LegacySpecifier._compare_greater_than_equalcCs||j|kS)N)rI)rr\r9rrr_compare_less_than6sz"LegacySpecifier._compare_less_thancCs||j|kS)N)rI)rr\r9rrr_compare_greater_than:sz%LegacySpecifier._compare_greater_thanN)rrr _regex_strrecompileVERBOSE IGNORECASEr2rErIr]r^r_r`rarbrrrrrSs $       rScs%tjfdd}|S)Ncs#t|tsdS|||S)NF)rBr )rr\r9)fnrrwrappedCsz)_require_version_compare..wrapped) functoolswraps)rhrir)rhr_require_version_compare?s!rlc@s!eZdZdZejdedejejBZdddddd d d d d ddddddiZ e ddZ e ddZ e ddZ e ddZe ddZe ddZe d d!Zd"d#Zed$d%Zejd&d%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. (?=rWrXrYrZr[z=== arbitrarycCsodjttjddt|dd}|d7}|jd||on|jd||S) N.cSs|jd o|jd S)Npostdev) startswith)xrrrsz/Specifier._compare_compatible..rz.*z>=z==)joinlist itertools takewhile_version_splitrH)rr\r9prefixrrr_compare_compatibles    $zSpecifier._compare_compatiblec Cs|jdr{t|j}t|dd}tt|}|dt|}t||\}}||kSt|}|jst|j}||kSdS)Nz.*)endswithr publicr{r=len _pad_versionlocal) rr\r9 split_specsplit_prospectiveshortened_prospective padded_specpadded_prospective spec_versionrrrr]s   zSpecifier._compare_equalcCs|j|| S)N)r])rr\r9rrrr^szSpecifier._compare_not_equalcCst|jt|kS)N)r r)rr\r9rrrr_sz"Specifier._compare_less_than_equalcCst|jt|kS)N)r r)rr\r9rrrr` sz%Specifier._compare_greater_than_equalcCsUt|}||ksdS|j rQ|jrQt|jt|jkrQdSdS)NFT)r rK base_version)rr\spec_strr9rrrras  zSpecifier._compare_less_thancCst|}||ksdS|j rQ|jrQt|jt|jkrQdS|jdk rt|jt|jkrdSdS)NFT)r is_postreleaserr)rr\rr9rrrrb1s  zSpecifier._compare_greater_thancCs"t|jt|jkS)N)r=lower)rr\r9rrr_compare_arbitraryRszSpecifier._compare_arbitrarycCss|jdk r|jS|j\}}|d kro|dkr\|jdr\|dd }t|jrodSd S) N==>=<=~====z.*r~TF)rrrrrr)r8r7rr rK)rr0r1rrrr$Vs zSpecifier.prereleasescCs ||_dS)N)r8)rr%rrrr$psN)rrrrcrdrerfrgr2rErlr}r]r^r_r`rarbrrRr$r-rrrrrmMs( ]$ )  ! rmz^([0-9]+)((?:a|b|c|rc)[0-9]+)$cCs\g}xO|jdD]>}tj|}|rG|j|jq|j|qW|S)Nrp)split _prefix_regexr3extendgroupsrM)r1resultr&r:rrrr{ysr{c Cs1gg}}|jttjdd||jttjdd||j|t|dd|j|t|dd|jddgtdt|dt|d|jddgtdt|dt|dttj|ttj|fS)NcSs |jS)N)isdigit)rtrrrrusz_pad_version..cSs |jS)N)r)rtrrrrusrr0)rMrxryrzrinsertmaxchain)leftright left_split right_splitrrrrs %%!!88rc@seZdZddddZddZddZd d Zd d Zd dZddZ ddZ ddZ e ddZ e jddZ ddZdddZdddZdS) SpecifierSetr/Nc Csdd|jdD}t}xM|D]E}y|jt|Wq,tk rp|jt|Yq,Xq,Wt||_||_dS)NcSs(g|]}|jr|jqSr)r6).0srrr s z)SpecifierSet.__init__..,) rsetaddrmrrS frozenset_specsr8)r specifiersr$split_specifiersparsed specifierrrrr;s   zSpecifierSet.__init__cCs=|jdk r!dj|jnd}djt||S)Nz, prereleases={0!r}r/z)r8r4r$r=)rr>rrrr?s!zSpecifierSet.__repr__cCs#djtdd|jDS)Nrcss|]}t|VqdS)N)r=)rrrrr sz'SpecifierSet.__str__..)rwsortedr)rrrrrszSpecifierSet.__str__cCs t|jS)N)rAr)rrrrr szSpecifierSet.__hash__cCst|trt|}nt|ts1tSt}t|j|jB|_|jdkr|jdk r|j|_nZ|jdk r|jdkr|j|_n-|j|jkr|j|_n td|S)NzFCannot combine SpecifierSets with True and False prerelease overrides.)rBrrrCrrr8 ValueError)rr!rrrr__and__s  zSpecifierSet.__and__cCsMt|ttfr*tt|}nt|ts=tS|j|jkS)N)rBrr.rr=rCr)rr!rrrr"s zSpecifierSet.__eq__cCsMt|ttfr*tt|}nt|ts=tS|j|jkS)N)rBrr.rr=rCr)rr!rrrr#s zSpecifierSet.__ne__cCs t|jS)N)rr)rrrr__len__szSpecifierSet.__len__cCs t|jS)N)iterr)rrrr__iter__szSpecifierSet.__iter__cCs=|jdk r|jS|js#dStdd|jDS)Ncss|]}|jVqdS)N)r$)rrrrrrsz+SpecifierSet.prereleases..)r8rany)rrrrr$s  zSpecifierSet.prereleasescCs ||_dS)N)r8)rr%rrrr$scCs |j|S)N)r')rr&rrrrJ szSpecifierSet.__contains__csmtttfs!tdkr6|j rJjrJdStfdd|jDS)NFc3s$|]}|jdVqdS)r$N)r')rr)r&r$rrr*sz(SpecifierSet.contains..)rBr r r r$rKallr)rr&r$r)r&r$rr's   zSpecifierSet.containscCs|dkr|j}|jrQx,|jD]!}|j|dt|}q(W|Sg}g}x}|D]u}t|ttfst|}n|}t|trqd|jr| r|s|j |qd|j |qdW| r|r|dkr|S|SdS)Nr$) r$rr)boolrBr r r rKrM)rr(r$r9filteredrOr&rQrrrr),s*    zSpecifierSet.filter)rrrr;r?rr rr"r#rrrRr$r-rJr'r)rrrrrs       r)0 __future__rrrr*rjryrd_compatrr_typingrutilsr r1r r r typingr rrrrrrrrZ ParsedVersionr=ZUnparsedVersionrZCallableOperatorrrABCMetaobjectrr.rSrlrmrerr{rrrrrrs0    @ "@8 *