U +a|@sXddlmZmZmZddlZddlZddlZddlZddlm 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*e+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__rrR/tmp/pip-install-1bd_1mtk/setuptools/pkg_resources/_vendor/packaging/specifiers.pyr"src@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__1szBaseSpecifier.__hash__cCsdS)zq Returns a boolean representing whether or not the two Specifier like objects are equal. Nrrotherrrr__eq__8szBaseSpecifier.__eq__cCsdS)zu Returns a boolean representing whether or not the two Specifier like objects are not equal. Nrr"rrr__ne__@szBaseSpecifier.__ne__cCsdS)zg Returns whether or not pre-releases as a whole are allowed by this specifier. Nrrrrr prereleasesHszBaseSpecifier.prereleasescCsdS)zd Sets whether or not pre-releases as a whole are allowed by this specifier. Nrrvaluerrrr&PsNcCsdS)zR Determines if the given item is contained within this specifier. Nrritemr&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)N)N)rrrabcabstractmethodr r!r$r%abstractpropertyr&setterr+r-rrrrr(s        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__ls   z_IndividualSpecifier.__init__cCs0|jdk rd|jnd}d|jjt||S)N, prereleases={0!r}r3z<{0}({1!r}{2})>)r<r8r& __class__rstrrprerrr__repr__zs z_IndividualSpecifier.__repr__cCs dj|jS)Nz{0}{1})r8r;rrrrr sz_IndividualSpecifier.__str__cCs|jdt|jdfS)Nrr)r;r rrrr_canonical_specsz$_IndividualSpecifier._canonical_speccCs t|jSN)hashrFrrrrr!sz_IndividualSpecifier.__hash__cCsTt|tr8z|t|}WqHtk r4tYSXnt||jsHtS|j|jkSrG) isinstancerrArBrNotImplementedrFr"rrrr$s   z_IndividualSpecifier.__eq__cCsTt|tr8z|t|}WqHtk r4tYSXnt||jsHtS|j|jkSrG)rIrrArBrrJr;r"rrrr%s   z_IndividualSpecifier.__ne__cCst|d|j|}|S)Nz _compare_{0})getattrr8 _operators)ropoperator_callablerrr _get_operators z"_IndividualSpecifier._get_operatorcCst|ttfst|}|SrG)rIr r r rr5rrr_coerce_versionsz$_IndividualSpecifier._coerce_versioncCs |jdS)Nrr;rrrrr4sz_IndividualSpecifier.operatorcCs |jdS)NrrRrrrrr5sz_IndividualSpecifier.versioncCs|jSrGr<rrrrr&sz _IndividualSpecifier.prereleasescCs ||_dSrGrSr'rrrr&scCs ||SrGr+rr*rrr __contains__sz!_IndividualSpecifier.__contains__cCs>|dkr|j}||}|jr&|s&dS||j}|||jSNF)r&rQ is_prereleaserOr4r5)rr*r&Znormalized_itemrNrrrr+s   z_IndividualSpecifier.containsccsd}g}d|dk r|ndi}|D]B}||}|j|f|r |jrX|sX|jsX||q d}|Vq |s||r||D] }|VqpdS)NFr&T)rQr+rXr&append)rr,r&yieldedfound_prereleaseskwr5parsed_versionrrrr-s"  z_IndividualSpecifier.filter)r3N)N)N)rrrrLr?rEr propertyrFr!r$r%rOrQr4r5r&r1rVr+r-rrrrr2hs,          r2c@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|}|SrG)rIr rBrPrrrrQ s  zLegacySpecifier._coerce_versioncCs|||kSrGrQr prospectiver=rrr_compare_equal&szLegacySpecifier._compare_equalcCs|||kSrGrnrorrr_compare_not_equal*sz"LegacySpecifier._compare_not_equalcCs|||kSrGrnrorrr_compare_less_than_equal.sz(LegacySpecifier._compare_less_than_equalcCs|||kSrGrnrorrr_compare_greater_than_equal2sz+LegacySpecifier._compare_greater_than_equalcCs|||kSrGrnrorrr_compare_less_than6sz"LegacySpecifier._compare_less_thancCs|||kSrGrnrorrr_compare_greater_than:sz%LegacySpecifier._compare_greater_thanN)rrr _regex_strrecompileVERBOSE IGNORECASEr6rLrQrqrrrsrtrurvrrrrr_s   r_cstfdd}|S)Ncst|tsdS|||SrW)rIr rofnrrwrappedCs z)_require_version_compare..wrapped) functoolswraps)r}r~rr|r_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...*rkrh)joinlist itertools takewhile_version_splitrO)rrpr=prefixrrr_compare_compatibles  zSpecifier._compare_compatiblec Csz|drVt|j}t|dd}tt|}|dt|}t||\}}||kSt|}|jsnt|j}||kSdS)Nr)endswithr publicrrBlen _pad_versionlocal) rrpr=Z split_specZsplit_prospectiveZshortened_prospectiveZ padded_specZpadded_prospectiveZ spec_versionrrrrqs    zSpecifier._compare_equalcCs||| SrG)rqrorrrrrszSpecifier._compare_not_equalcCst|jt|kSrGr rrorrrrssz"Specifier._compare_less_than_equalcCst|jt|kSrGrrorrrrt sz%Specifier._compare_greater_than_equalcCs<t|}||ksdS|js8|jr8t|jt|jkr8dSdSNFT)r rX base_versionrrpZspec_strr=rrrrus zSpecifier._compare_less_thancCs^t|}||ksdS|js8|jr8t|jt|jkr8dS|jdk rZt|jt|jkrZdSdSr)r is_postreleaserrrrrrrv1s  zSpecifier._compare_greater_thancCst|t|kSrG)rBlowerrorrr_compare_arbitraryRszSpecifier._compare_arbitrarycCsR|jdk r|jS|j\}}|dkrN|dkr@|dr@|dd}t|jrNdSdS)N)rhrkrjrrrhrrTF)r<r;rr rX)rr4r5rrrr&Vs    zSpecifier.prereleasescCs ||_dSrGrSr'rrrr&psN)rrrrwrxryrzr{r6rLrrrqrrrsrtrurvrr^r&r1rrrrrMs<]   (      rz^([0-9]+)((?:a|b|c|rc)[0-9]+)$cCs@g}|dD],}t|}|r0||q||q|S)Nr)split _prefix_regexr7extendgroupsrY)r5resultr*r>rrrrys  rc Csgg}}|ttdd||ttdd|||t|dd||t|dd|ddgtdt|dt|d|ddgtdt|dt|dttj|ttj|fS)NcSs|SrGisdigitrrrrrrz_pad_version..cSs|SrGrrrrrrrrr0)rYrrrrinsertmaxchain)leftright left_split right_splitrrrrs ,,rc@seZdZdddZddZddZd d Zd d Zd dZddZ ddZ ddZ e ddZ e jddZ ddZdddZd ddZdS)! SpecifierSetr3Nc Csndd|dD}t}|D]:}z|t|Wqtk rV|t|YqXqt||_||_dS)NcSsg|]}|r|qSr)r:.0srrr sz)SpecifierSet.__init__..,) rsetaddrrr_ frozenset_specsr<)r specifiersr&Zsplit_specifiersparsed specifierrrrr?s zSpecifierSet.__init__cCs*|jdk rd|jnd}dt||S)Nr@r3z)r<r8r&rBrCrrrrEs zSpecifierSet.__repr__cCsdtdd|jDS)Nrcss|]}t|VqdSrG)rBrrrr sz'SpecifierSet.__str__..)rsortedrrrrrr szSpecifierSet.__str__cCs t|jSrG)rHrrrrrr!szSpecifierSet.__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.)rIrrrJrrr< ValueError)rr#rrrr__and__s        zSpecifierSet.__and__cCs6t|ttfrtt|}nt|ts*tS|j|jkSrGrIrr2rrBrJrr"rrrr$s  zSpecifierSet.__eq__cCs6t|ttfrtt|}nt|ts*tS|j|jkSrGrr"rrrr%s  zSpecifierSet.__ne__cCs t|jSrG)rrrrrr__len__szSpecifierSet.__len__cCs t|jSrG)iterrrrrr__iter__szSpecifierSet.__iter__cCs.|jdk r|jS|jsdStdd|jDS)Ncss|] }|jVqdSrGr&rrrrrsz+SpecifierSet.prereleases..)r<ranyrrrrr&s  zSpecifierSet.prereleasescCs ||_dSrGrSr'rrrr&scCs ||SrGrTrUrrrrV szSpecifierSet.__contains__csLtttfstdkr$|js2jr2dStfdd|jDS)NFc3s|]}|jdVqdS)rNrTrr*r&rrr*sz(SpecifierSet.contains..)rIr r r r&rXallrr)rrrr+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) r&rr-boolrIr r r rXrY)rr,r&r=filteredr[r*r]rrrr-,s*       zSpecifierSet.filter)r3N)N)N)rrrr?rEr r!rr$r%rrr^r&r1rVr+r-rrrrrs"       r)0 __future__rrrr.rrrx_compatrrZ_typingrutilsr r5r r r typingr rrrrrrrrZ ParsedVersionrBZUnparsedVersionrZCallableOperatorrrABCMetaobjectrr2r_rrryrrrrrrrrs4  , @ 8+