a ?&Nb}@s\ddlmZmZmZddlZddlZddlZddlZddlZddl m Z m Z ddl m Z ddlmZddlmZmZmZe rddlmZmZmZmZmZmZmZmZeeefZeeeefZeeege fZ!Gd d d e"Z#Gd d d e ej$e%Z&Gd dde&Z'Gddde'Z(ddZ)Gddde'Z*e+dZ,ddZ-ddZ.Gddde&Z/dS))absolute_importdivisionprint_functionN) string_typeswith_metaclass) TYPE_CHECKING)canonicalize_version) LegacyVersionVersionparse)CallableDictIterableIteratorListOptionalTupleUnionc@seZdZdZdS)InvalidSpecifierzH An invalid specifier was found, users should refer to PEP 440. N)__name__ __module__ __qualname____doc__rr8/usr/lib/python3.9/site-packages/packaging/specifiers.pyrsrc@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. Nrr!rrr__ne__7szBaseSpecifier.__ne__cCsdS)zg Returns whether or not pre-releases as a whole are allowed by this specifier. Nrrrrr prereleases?szBaseSpecifier.prereleasescCsdS)zd Sets whether or not pre-releases as a whole are allowed by this specifier. Nrrvaluerrrr%GsNcCsdS)zR Determines if the given item is contained within this specifier. Nrritemr%rrrcontainsOszBaseSpecifier.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%rrrfilterVszBaseSpecifier.filter)N)N)rrrabcabstractmethodrr r#r$abstractpropertyr%setterr*r,rrrrrs        rc@seZdZiZd"ddZddZddZed d Zd d Z d dZ ddZ ddZ ddZ eddZeddZeddZejddZddZd#ddZd$d d!ZdS)%_IndividualSpecifierNcCsF|j|}|std||d|df|_||_dS)NzInvalid specifier: '{0}'operatorversion)_regexsearchrformatgroupstrip_spec _prereleases)rspecr%matchrrr__init__cs   z_IndividualSpecifier.__init__cCs0|jdurd|jnd}d|jjt||S)N, prereleases={0!r}r2z<{0}({1!r}{2})>)r;r7r% __class__rstrrZprerrr__repr__qs z_IndividualSpecifier.__repr__cCs dj|jS)Nz{0}{1})r7r:rrrrr{sz_IndividualSpecifier.__str__cCs|jdt|jdfS)Nrr)r:r rrrr_canonical_specsz$_IndividualSpecifier._canonical_speccCs t|jSN)hashrDrrrrr sz_IndividualSpecifier.__hash__cCsRt|tr6z|t|}WqFty2tYS0nt||jsFtS|j|jkSrE) isinstancerr@rArNotImplementedrDr!rrrr#s    z_IndividualSpecifier.__eq__cCsRt|tr6z|t|}WqFty2tYS0nt||jsFtS|j|jkSrE)rGrr@rArrHr:r!rrrr$s    z_IndividualSpecifier.__ne__cCst|d|j|}|S)Nz _compare_{0})getattrr7 _operators)ropoperator_callablerrr _get_operatorsz"_IndividualSpecifier._get_operatorcCst|ttfst|}|SrE)rGr r r rr4rrr_coerce_versionsz$_IndividualSpecifier._coerce_versioncCs |jdS)Nrr:rrrrr3sz_IndividualSpecifier.operatorcCs |jdS)NrrPrrrrr4sz_IndividualSpecifier.versioncCs|jSrEr;rrrrr%sz _IndividualSpecifier.prereleasescCs ||_dSrErQr&rrrr%scCs ||SrEr*rr)rrr __contains__sz!_IndividualSpecifier.__contains__cCs>|dur|j}||}|jr&|s&dS||j}|||jSNF)r%rO is_prereleaserMr3r4)rr)r%Znormalized_itemrLrrrr*s   z_IndividualSpecifier.containsccsd}g}d|dur|ndi}|D]F}||}|j|fi|r |jr\|s\|js\||q d}|Vq |s|r|D] }|VqtdS)NFr%T)rOr*rVr%append)rr+r%yieldedfound_prereleaseskwr4parsed_versionrrrr,s"  z_IndividualSpecifier.filter)r2N)N)N)rrrrJr>rCrpropertyrDr r#r$rMrOr3r4r%r0rTr*r,rrrrr1_s,          r1cseZdZdZededejejBZdddddd d Z dfd d Z ddZ ddZ ddZ ddZddZddZddZZS)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)==!=<=>=<>r2Ncs"tt|||tdtdS)NzZCreating a LegacyVersion has been deprecated and will be removed in the next major release)superr]r>warningswarnDeprecationWarning)rr<r%r@rrr>s zLegacySpecifier.__init__cCst|tstt|}|SrE)rGr rArNrrrrO!s  zLegacySpecifier._coerce_versioncCs|||kSrErOr prospectiver<rrr_compare_equal'szLegacySpecifier._compare_equalcCs|||kSrErqrrrrr_compare_not_equal+sz"LegacySpecifier._compare_not_equalcCs|||kSrErqrrrrr_compare_less_than_equal/sz(LegacySpecifier._compare_less_than_equalcCs|||kSrErqrrrrr_compare_greater_than_equal3sz+LegacySpecifier._compare_greater_than_equalcCs|||kSrErqrrrrr_compare_less_than7sz"LegacySpecifier._compare_less_thancCs|||kSrErqrrrrr_compare_greater_than;sz%LegacySpecifier._compare_greater_than)r2N)rrr _regex_strrecompileVERBOSE IGNORECASEr5rJr>rOrtrurvrwrxry __classcell__rrrprr]s"   r]cstfdd}|S)Ncst|tsdS|||SrU)rGr rrfnrrwrappedDs z)_require_version_compare..wrapped) functoolswraps)rrrrr_require_version_compare@src @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...*rirf)joinlist itertools takewhile_version_splitrM)rrsr<prefixrrr_compare_compatibles  zSpecifier._compare_compatiblec Csz|drVt|j}t|dd}tt|}|dt|}t||\}}||kSt|}|jsnt|j}||kSdS)Nr)endswithr publicrrAlen _pad_versionlocal) rrsr<Z split_specZsplit_prospectiveZshortened_prospectiveZ padded_specZpadded_prospectiveZ spec_versionrrrrts    zSpecifier._compare_equalcCs||| SrE)rtrrrrrruszSpecifier._compare_not_equalcCst|jt|kSrEr rrrrrrrvsz"Specifier._compare_less_than_equalcCst|jt|kSrErrrrrrrwsz%Specifier._compare_greater_than_equalcCs<t|}||ksdS|js8|jr8t|jt|jkr8dSdSNFT)r rV base_versionrrsZspec_strr<rrrrxs zSpecifier._compare_less_thancCs^t|}||ksdS|js8|jr8t|jt|jkr8dS|jdurZt|jt|jkrZdSdSr)r Zis_postreleaserrrrrrry2s  zSpecifier._compare_greater_thancCst|t|kSrE)rAlowerrrrrr_compare_arbitrarySszSpecifier._compare_arbitrarycCsR|jdur|jS|j\}}|dvrN|dkr@|dr@|dd}t|jrNdSdS)N)rfrirhrrrfrrTF)r;r:rr rV)rr3r4rrrr%Ws    zSpecifier.prereleasescCs ||_dSrErQr&rrrr%qsN)rrrrzr{r|r}r~r5rJrrrtrurvrwrxryrr\r%r0rrrrrNs<]   (      rz^([0-9]+)((?:a|b|c|rc)[0-9]+)$cCs@g}|dD],}t|}|r0||q||q|S)Nr)split _prefix_regexr6extendgroupsrW)r4resultr)r=rrrrzs  rc Csgg}}|ttdd||ttdd|||t|dd||t|dd|ddgtdt|dt|d|ddgtdt|dt|dttj|ttj|fS)NcSs|SrEisdigitrrrrrrz_pad_version..cSs|SrErrrrrrrrr0)rWrrrrinsertmaxchain)leftrightZ left_splitZ right_splitrrrrs ,,rc@seZdZdddZddZddZd d Zd d Zd dZddZ ddZ ddZ e ddZ e jddZ ddZdddZd ddZdS)! SpecifierSetr2Nc Csldd|dD}t}|D]8}z|t|WqtyT|t|Yq0qt||_||_dS)NcSsg|]}|r|qSr)r9.0srrr rz)SpecifierSet.__init__..,) rsetaddrrr] frozenset_specsr;)rZ specifiersr%Zsplit_specifiersparsed specifierrrrr>s  zSpecifierSet.__init__cCs*|jdurd|jnd}dt||S)Nr?r2z)r;r7r%rArBrrrrCs zSpecifierSet.__repr__cCsdtdd|jDS)Nrcss|]}t|VqdSrE)rArrrr rz'SpecifierSet.__str__..)rsortedrrrrrrszSpecifierSet.__str__cCs t|jSrE)rFrrrrrr szSpecifierSet.__hash__cCst|trt|}nt|ts"tSt}t|j|jB|_|jdurX|jdurX|j|_n<|jdurv|jdurv|j|_n|j|jkr|j|_ntd|S)NzFCannot combine SpecifierSets with True and False prerelease overrides.)rGrrrHrrr; ValueError)rr"rrrr__and__s        zSpecifierSet.__and__cCs6t|ttfrtt|}nt|ts*tS|j|jkSrErGrr1rrArHrr!rrrr#s  zSpecifierSet.__eq__cCs6t|ttfrtt|}nt|ts*tS|j|jkSrErr!rrrr$s  zSpecifierSet.__ne__cCs t|jSrE)rrrrrr__len__szSpecifierSet.__len__cCs t|jSrE)iterrrrrr__iter__szSpecifierSet.__iter__cCs.|jdur|jS|jsdStdd|jDS)Ncss|] }|jVqdSrEr%rrrrrrz+SpecifierSet.prereleases..)r;ranyrrrrr%s  zSpecifierSet.prereleasescCs ||_dSrErQr&rrrr%scCs ||SrErRrSrrrrT szSpecifierSet.__contains__csLtttfstdur$|js2jr2dStfdd|jDS)NFc3s|]}|jdVqdS)rNrRrr)r%rrr+rz(SpecifierSet.contains..)rGr r r r%rVallrr(rrrr*s zSpecifierSet.containscCs|dur|j}|jr6|jD]}|j|t|d}q|Sg}g}|D]P}t|ttfs^t|}n|}t|trnqB|jr|s|s| |qB| |qB|s|r|dur|S|SdS)Nr) r%rr,boolrGr r r rVrW)rr+r%r<ZfilteredrYr)r[rrrr,-s*       zSpecifierSet.filter)r2N)N)N)rrrr>rCrr rr#r$rrr\r%r0rTr*r,rrrrrs"       r)0Z __future__rrrr-rrr{rmZ_compatrrZ_typingrZutilsr r4r r r typingr rrrrrrrZ ParsedVersionrAZUnparsedVersionrZCallableOperatorrrABCMetaobjectrr1r]rrr|rrrrrrrrs6  ( @ B+