Yym@sEddlmZmZmZddlZddlZddlZddlZddlm Z m Z ddl m Z m Z mZGdddeZGdd d e ejeZGd d d eZGd d d eZddZGdddeZejdZddZddZGdddeZdS))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__rr9/tmp/pip-build-3puug3g5/packaging/packaging/specifiers.pyr s r c@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__szBaseSpecifier.__hash__cCsdS)zq Returns a boolean representing whether or not the two Specifier like objects are equal. Nr)rotherrrr__eq__$szBaseSpecifier.__eq__cCsdS)zu Returns a boolean representing whether or not the two Specifier like objects are not equal. Nr)rrrrr__ne__+szBaseSpecifier.__ne__cCsdS)zg Returns whether or not pre-releases as a whole are allowed by this specifier. Nr)rrrr prereleases2szBaseSpecifier.prereleasescCsdS)zd Sets whether or not pre-releases as a whole are allowed by this specifier. Nr)rvaluerrrr9sNcCsdS)zR Determines if the given item is contained within this specifier. Nr)ritemrrrrcontains@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)riterablerrrrfilterFszBaseSpecifier.filter)r r rabcabstractmethodrrrrabstractpropertyrsetterrrrrrrrs rc@seZdZiZddddZddZddZd d Zd d Zd dZ ddZ ddZ e ddZ e ddZe ddZejddZddZdddZdddZdS) _IndividualSpecifierNcCsg|jj|}|s-tdj||jdj|jdjf|_||_dS)NzInvalid specifier: '{0}'operatorversion)_regexsearchr formatgroupstrip_spec _prereleases)rspecrmatchrrr__init__Rs z_IndividualSpecifier.__init__cCsF|jdk r!dj|jnd}dj|jjt||S)Nz, prereleases={0!r}r$z<{0}({1!r}{2})>)r-r)r __class__r str)rprerrr__repr___s !  z_IndividualSpecifier.__repr__cCsdj|jS)Nz{0}{1})r)r,)rrrrrlsz_IndividualSpecifier.__str__cCs t|jS)N)hashr,)rrrrrosz_IndividualSpecifier.__hash__c Csdt|tr>y|j|}WqTtk r:tSYqTXnt||jsTtS|j|jkS)N) isinstancerr1r NotImplementedr,)rrrrrrrs  z_IndividualSpecifier.__eq__c Csdt|tr>y|j|}WqTtk r:tSYqTXnt||jsTtS|j|jkS)N)r6rr1r r7r,)rrrrrr}s  z_IndividualSpecifier.__ne__cCst|dj|j|S)Nz _compare_{0})getattrr) _operators)roprrr _get_operatorsz"_IndividualSpecifier._get_operatorcCs%t|ttfs!t|}|S)N)r6r rr )rr&rrr_coerce_versions z$_IndividualSpecifier._coerce_versioncCs |jdS)Nr)r,)rrrrr%sz_IndividualSpecifier.operatorcCs |jdS)Nr)r,)rrrrr&sz_IndividualSpecifier.versioncCs|jS)N)r-)rrrrrsz _IndividualSpecifier.prereleasescCs ||_dS)N)r-)rrrrrrscCs |j|S)N)r)rrrrr __contains__sz!_IndividualSpecifier.__contains__cCsT|dkr|j}|j|}|jr8| r8dS|j|j||jS)NF)rr< is_prereleaser;r%r&)rrrrrrrs   z_IndividualSpecifier.containsccsd}g}d|dk r!|ndi}xc|D][}|j|}|j||r1|jr|pm|j r|j|q1d}|Vq1W| r|rx|D] }|VqWdS)NFrT)r<rr>rappend)rrryieldedfound_prereleaseskwr&parsed_versionrrrrs     z_IndividualSpecifier.filter)r r rr9r0r4rrrrr;r<propertyr%r&rr"r=rrrrrrr#Ns      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)r6r r2)rr&rrrr<szLegacySpecifier._coerce_versioncCs||j|kS)N)r<)r prospectiver.rrr_compare_equalszLegacySpecifier._compare_equalcCs||j|kS)N)r<)rrNr.rrr_compare_not_equalsz"LegacySpecifier._compare_not_equalcCs||j|kS)N)r<)rrNr.rrr_compare_less_than_equalsz(LegacySpecifier._compare_less_than_equalcCs||j|kS)N)r<)rrNr.rrr_compare_greater_than_equalsz+LegacySpecifier._compare_greater_than_equalcCs||j|kS)N)r<)rrNr.rrr_compare_less_thansz"LegacySpecifier._compare_less_thancCs||j|kS)N)r<)rrNr.rrr_compare_greater_thansz%LegacySpecifier._compare_greater_thanN)r r r _regex_strrecompileVERBOSE IGNORECASEr'r9r<rOrPrQrRrSrTrrrrrEs        rEcs%tjfdd}|S)Ncs#t|tsdS|||S)NF)r6r)rrNr.)fnrrwrapped sz)_require_version_compare..wrapped) functoolswraps)rZr[r)rZr_require_version_compare s!r^c@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. (?=rIrJrKrLrMz=== 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_splitr;)rrNr.prefixrrr_compare_compatibles    zSpecifier._compare_compatiblecCs|jdrtt|j}t|dd}tt|}|dt|}t||\}}n$t|}|jst|j}||kS)Nz.*)endswithrpublicrmr2len _pad_versionlocal)rrNr.rrrrOs  zSpecifier._compare_equalcCs|j|| S)N)rO)rrNr.rrrrPszSpecifier._compare_not_equalcCs|t|kS)N)r)rrNr.rrrrQsz"Specifier._compare_less_than_equalcCs|t|kS)N)r)rrNr.rrrrRsz%Specifier._compare_greater_than_equalcCsUt|}||ksdS|j rQ|jrQt|jt|jkrQdSdS)NFT)rr> base_version)rrNr.rrrrSs  zSpecifier._compare_less_thancCst|}||ksdS|j rQ|jrQt|jt|jkrQdS|jdk rt|jt|jkrdSdS)NFT)ris_postreleaserwrv)rrNr.rrrrTs  zSpecifier._compare_greater_thancCs"t|jt|jkS)N)r2lower)rrNr.rrr_compare_arbitraryszSpecifier._compare_arbitrarycCss|jdk r|jS|j\}}|d kro|dkr\|jdr\|dd }t|jrodSd S) N==>=<=~====z.*rpTF)r{r|r}r~rrq)r-r,rrr r>)rr%r&rrrrs zSpecifier.prereleasescCs ||_dS)N)r-)rrrrrrsN)r r rrUrVrWrXrYr'r9r^rorOrPrQrRrSrTrzrDrr"rrrrr_s* ^ # r_z^([0-9]+)((?:a|b|c|rc)[0-9]+)$cCs\g}xO|jdD]>}tj|}|rG|j|jq|j|qW|S)Nrb)split _prefix_regexr(extendgroupsr?)r&resultrr/rrrrm'srmc Cs1gg}}|jttjdd||jttjdd||j|t|dd|j|t|dd|jddgtdt|dt|d|jddgtdt|dt|dttj|ttj|fS)NcSs |jS)N)isdigit)rfrrrrg6sz_pad_version..cSs |jS)N)r)rfrrrrg7srr0)r?rjrkrlrtinsertmaxchain)leftright left_split right_splitrrrru2s %%!!//ruc@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)r+).0srrr Rs z)SpecifierSet.__init__..,) rsetaddr_r rE frozenset_specsr-)r specifiersrparsed specifierrrrr0Os   zSpecifierSet.__init__cCs=|jdk r!dj|jnd}djt||S)Nz, prereleases={0!r}r$z)r-r)rr2)rr3rrrr4ds!zSpecifierSet.__repr__cCs#djtdd|jDS)Nrcss|]}t|VqdS)N)r2)rrrrr nsz'SpecifierSet.__str__..)risortedr)rrrrrmszSpecifierSet.__str__cCs t|jS)N)r5r)rrrrrpszSpecifierSet.__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.)r6rrr7rrr- ValueError)rrrrrr__and__ss  zSpecifierSet.__and__cCset|trt|}n7t|trBtt|}nt|tsUtS|j|jkS)N)r6rrr#r2r7r)rrrrrrszSpecifierSet.__eq__cCset|trt|}n7t|trBtt|}nt|tsUtS|j|jkS)N)r6rrr#r2r7r)rrrrrrszSpecifierSet.__ne__cCs t|jS)N)rtr)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..)r-rany)rrrrrs  zSpecifierSet.prereleasescCs ||_dS)N)r-)rrrrrrscCs |j|S)N)r)rrrrrr=szSpecifierSet.__contains__csmtttfs!tdkr6|j rJjrJdStfdd|jDS)NFc3s$|]}|jdVqdS)rN)r)rr)rrrrrsz(SpecifierSet.contains..)r6r rr rr>allr)rrrr)rrrrs   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) rrrboolr6r rr r>r?)rrrr.filteredrArrCrrrrs*    zSpecifierSet.filter)r r rr0r4rrrrrrrrDrr"r=rrrrrrrMs       r) __future__rrrrr\rkrV_compatrrr&rr r rr ABCMetaobjectrr#rEr^r_rWrrmrurrrrrs"    "94