U o aRz@sLddlmZmZmZddlZddlZddlZddlZddlm Z m Z ddl m Z ddl mZmZmZe rddlmZmZmZmZmZmZmZmZmZeeefZeeeefZeeegefZGdd d e Z!Gd d d e ej"e#Z$Gd d d e$Z%Gddde%Z&ddZ'Gddde%Z(e)dZ*ddZ+ddZ,Gddde$Z-dS))absolute_importdivisionprint_functionN) string_typeswith_metaclass)MYPY_CHECK_RUNNING)Version LegacyVersionparse) ListDictUnionIterableIteratorOptionalCallableTuple FrozenSetc@seZdZdZdS)InvalidSpecifierzH An invalid specifier was found, users should refer to PEP 440. N)__name__ __module__ __qualname____doc__rraC:\Users\vtejo\AppData\Local\Temp\pip-unpacked-wheel-6mt8ur68\pip\_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__0szBaseSpecifier.__hash__cCsdS)zq Returns a boolean representing whether or not the two Specifier like objects are equal. Nrrotherrrr__eq__7szBaseSpecifier.__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 prereleasesGszBaseSpecifier.prereleasescCsdS)zd Sets whether or not pre-releases as a whole are allowed by this specifier. Nrrvaluerrrr%OsNcCsdS)zR Determines if the given item is contained within this specifier. Nrritemr%rrrcontainsWszBaseSpecifier.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)rrrabcabstractmethodrr r#r$abstractpropertyr%setterr*r,rrrrr's        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)_regexsearchrformatgroupstrip_spec _prereleases)rspecr%matchrrr__init__ks   z_IndividualSpecifier.__init__cCs0|jdk rd|jnd}d|jjt||S)N, prereleases={0!r}r2z<{0}({1!r}{2})>)r;r7r% __class__rstrrprerrr__repr__ys z_IndividualSpecifier.__repr__cCs dj|jS)Nz{0}{1})r7r:rrrrrsz_IndividualSpecifier.__str__cCs t|jSN)hashr:rrrrr sz_IndividualSpecifier.__hash__cCsTt|tr8z|t|}WqHtk r4tYSXnt||jsHtS|j|jkSrE isinstancerr@rArNotImplementedr:r!rrrr#s   z_IndividualSpecifier.__eq__cCsTt|tr8z|t|}WqHtk r4tYSXnt||jsHtS|j|jkSrErGr!rrrr$s   z_IndividualSpecifier.__ne__cCst|d|j|}|S)Nz _compare_{0})getattrr7 _operators)ropoperator_callablerrr _get_operators z"_IndividualSpecifier._get_operatorcCst|ttfst|}|SrE)rHr r r rr4rrr_coerce_versionsz$_IndividualSpecifier._coerce_versioncCs |jdS)Nrr:rrrrr3sz_IndividualSpecifier.operatorcCs |jdS)NrrQrrrrr4sz_IndividualSpecifier.versioncCs|jSrEr;rrrrr%sz _IndividualSpecifier.prereleasescCs ||_dSrErRr&rrrr%scCs ||SrEr*rr)rrr __contains__sz!_IndividualSpecifier.__contains__cCs>|dkr|j}||}|jr&|s&dS||j}|||jSNF)r%rP is_prereleaserNr3r4)rr)r%normalized_itemrMrrrr*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)rPr*rWr%append)rr+r%yieldedfound_prereleaseskwr4parsed_versionrrrr,s"  z_IndividualSpecifier.filter)r2N)N)N)rrrrKr>rDrr r#r$rNrPpropertyr3r4r%r0rUr*r,rrrrr1gs(         r1c@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|}|SrE)rHr rArOrrrrPs  zLegacySpecifier._coerce_versioncCs|||kSrErPr prospectiver<rrr_compare_equal szLegacySpecifier._compare_equalcCs|||kSrErnrorrr_compare_not_equal$sz"LegacySpecifier._compare_not_equalcCs|||kSrErnrorrr_compare_less_than_equal(sz(LegacySpecifier._compare_less_than_equalcCs|||kSrErnrorrr_compare_greater_than_equal,sz+LegacySpecifier._compare_greater_than_equalcCs|||kSrErnrorrr_compare_less_than0sz"LegacySpecifier._compare_less_thancCs|||kSrErnrorrr_compare_greater_than4sz%LegacySpecifier._compare_greater_thanN)rrr _regex_strrecompileVERBOSE IGNORECASEr5rKrPrqrrrsrtrurvrrrrr_s   r_cstfdd}|S)Ncst|tsdS|||SrV)rHr rofnrrwrapped=s z)_require_version_compare..wrapped) functoolswraps)r}r~rr|r_require_version_compare9src @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_splitrN)rrpr<prefixrrr_compare_compatibles  zSpecifier._compare_compatiblec Csz|drVt|j}t|dd}tt|}|dt|}t||\}}||kSt|}|jsnt|j}||kSdS)Nr)endswithr publicrrAlen _pad_versionlocal) rrpr< split_specsplit_prospectiveshortened_prospective padded_specpadded_prospective spec_versionrrrrqs    zSpecifier._compare_equalcCs||| SrE)rqrorrrrrszSpecifier._compare_not_equalcCs |t|kSrEr rorrrrssz"Specifier._compare_less_than_equalcCs |t|kSrErrorrrrtsz%Specifier._compare_greater_than_equalcCs<t|}||ksdS|js8|jr8t|jt|jkr8dSdSNFT)r rW base_versionrrpspec_strr<rrrrus zSpecifier._compare_less_thancCs^t|}||ksdS|js8|jr8t|jt|jkr8dS|jdk rZt|jt|jkrZdSdSr)r is_postreleaserrrrrrrv#s  zSpecifier._compare_greater_thancCst|t|kSrE)rAlowerrorrr_compare_arbitraryDszSpecifier._compare_arbitrarycCsR|jdk r|jS|j\}}|dkrN|dkr@|dr@|dd}t|jrNdSdS)N)rhrkrjrrrhrrTF)r;r:rr rW)rr3r4rrrr%Hs    zSpecifier.prereleasescCs ||_dSrErRr&rrrr%bsN)rrrrwrxryrzr{r5rKrrrqrrrsrtrurvrr^r%r0rrrrrGs<]   (      rz^([0-9]+)((?:a|b|c|rc)[0-9]+)$cCs@g}|dD],}t|}|r0||q||q|S)Nr)split _prefix_regexr6extendgroupsrY)r4resultr)r=rrrrks  rc Csgg}}|ttdd||ttdd|||t|dd||t|dd|ddgtdt|dt|d|ddgtdt|dt|dttj|ttj|fS)NcSs|SrEisdigitrrrrr|rz_pad_version..cSs|SrErrrrrr}rrr0)rYrrrrinsertmaxchain)leftright left_split right_splitrrrrws ,,rc@seZdZdddZddZddZd d Zd d Zd dZddZ ddZ ddZ e ddZ e jddZ ddZdddZd ddZdS)! SpecifierSetr2Nc Csndd|dD}t}|D]:}z|t|Wqtk rV|t|YqXqt||_||_dS)NcSsg|]}|r|qSr)r9.0srrr sz)SpecifierSet.__init__..,) rsetaddrrr_ frozenset_specsr;)r specifiersr%split_specifiersparsed specifierrrrr>s zSpecifierSet.__init__cCs*|jdk rd|jnd}dt||S)Nr?r2z)r;r7r%rArBrrrrDs zSpecifierSet.__repr__cCsdtdd|jDS)Nrcss|]}t|VqdSrE)rArrrr sz'SpecifierSet.__str__..)rsortedrrrrrrszSpecifierSet.__str__cCs t|jSrE)rFrrrrrr 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.)rHrrrIrrr; ValueError)rr"rrrr__and__s        zSpecifierSet.__and__cCs6t|ttfrtt|}nt|ts*tS|j|jkSrErHrr1rrArIrr!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.|jdk r|jS|jsdStdd|jDS)Ncss|] }|jVqdSrEr%rrrrrsz+SpecifierSet.prereleases..)r;ranyrrrrr%s  zSpecifierSet.prereleasescCs ||_dSrErRr&rrrr%scCs ||SrErSrTrrrrUszSpecifierSet.__contains__csLtttfstdkr$|js2jr2dStfdd|jDS)NFc3s|]}|jdVqdS)rNrSrr)r%rrrsz(SpecifierSet.contains..)rHr r r r%rWallrr(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,boolrHr r r rWrY)rr+r%r<filteredr[r)r]rrrr,s*       zSpecifierSet.filter)r2N)N)N)rrrr>rDrr rr#r$rrr^r%r0rUr*r,rrrrrs"       r). __future__rrrr-rrrx_compatrr_typingrr4r r r typingr r rrrrrrrZ ParsedVersionrAZUnparsedVersionrZCallableOperatorrrABCMetaobjectrr1r_rrryrrrrrrrrs2 , @8#