8f:ldZddlmZddlZddlZddlZddlmZmZm Z m Z m Z ddl m Z ddlmZe eefZe de ZeeegefZd%dZGddeZGddejZGddeZejdZd&dZd'dZd(dZd)d"Z Gd#d$eZ!dS)*z .. testsetup:: from pip._vendor.packaging.specifiers import Specifier, SpecifierSet, InvalidSpecifier from pip._vendor.packaging.version import Version ) annotationsN)CallableIterableIteratorTypeVarUnion)canonicalize_version)VersionUnparsedVersionVar)boundversionUnparsedVersionreturnr cNt|tst|}|SN) isinstancer )rs /builddir/build/BUILD/imunify360-venv-2.3.5/opt/imunify360/venv/lib/python3.11/site-packages/pip/_vendor/packaging/specifiers.py_coerce_versionrs& gw ' '#'"" NceZdZdZdS)InvalidSpecifiera Raised when attempting to create a :class:`Specifier` with a specifier string that is invalid. >>> Specifier("lolwat") Traceback (most recent call last): ... packaging.specifiers.InvalidSpecifier: Invalid specifier: 'lolwat' N)__name__ __module__ __qualname____doc__rrrr srrceZdZejddZejddZejdd Zeejdd Z e j ddZ ejdddZ ej dddZ dS) BaseSpecifierrstrcdS)z Returns the str representation of this Specifier-like object. This should be representative of the Specifier itself. Nrselfs r__str__zBaseSpecifier.__str__-rintcdS)zF Returns a hash value for this Specifier-like object. Nrr"s r__hash__zBaseSpecifier.__hash__4r%rotherobjectboolcdS)z Returns a boolean representing whether or not the two Specifier-like objects are equal. :param other: The other object to check against. Nrr#r)s r__eq__zBaseSpecifier.__eq__:r%r bool | NonecdS)zWhether or not pre-releases as a whole are allowed. This can be set to either ``True`` or ``False`` to explicitly enable or disable prereleases or it can be set to ``None`` (the default) to use default semantics. Nrr"s r prereleaseszBaseSpecifier.prereleasesCr%rvalueNonecdS)zQSetter for :attr:`prereleases`. :param value: The value to set. Nrr#r2s rr1zBaseSpecifier.prereleasesLr%rNitemr1cdS)zR Determines if the given item is contained within this specifier. Nr)r#r6r1s rcontainszBaseSpecifier.containsSr%riterableIterable[UnparsedVersionVar]Iterator[UnparsedVersionVar]cdS)z Takes an iterable of items and filters them so that only items which are contained within this specifier are allowed in it. Nr)r#r9r1s rfilterzBaseSpecifier.filterYr%rrr rr&r)r*rr+rr/r2r+rr3r)r6r r1r/rr+r9r:r1r/rr;) rrrabcabstractmethodr$r(r.propertyr1setterr8r=rrrrr,s%                 X            QU       rr) metaclassc eZdZdZdZdZejdezezdzejej zZ dddd d d d d dZ d>d?dZ e d@dZejdAdZe dBdZe dBdZdBdZdBdZe dCd!ZdDd#ZdEd&ZdFd)ZdGd,ZdGd-ZdGd.ZdGd/ZdGd0ZdHd2ZdHd3ZdGd4ZdId7Z dJdKd9Z! dJdLd=Z"dS)M Specifiera?This class abstracts handling of version specifiers. .. tip:: It is generally not required to instantiate this manually. You should instead prefer to work with :class:`SpecifierSet` instead, which can parse comma-separated version specifiers (which is what package metadata contains). z8 (?P(~=|==|!=|<=|>=|<|>|===)) a (?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;)]* # The arbitrary version can be just about anything, # we match everything except for whitespace, a # semi-colon for marker support, and a closing paren # since versions can be enclosed in them. ) | (?: # 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 # You cannot use a wild card and a pre-release, post-release, a dev or # local version together so group them with a | and make them optional. (?: \.\* # Wild card syntax of .* | (?: # pre release [-_\.]? (alpha|beta|preview|pre|a|b|c|rc) [-_\.]? [0-9]* )? (?: # post release (?:-[0-9]+)|(?:[-_\.]?(post|rev|r)[-_\.]?[0-9]*) )? (?:[-_\.]?dev[-_\.]?[0-9]*)? # dev release (?:\+[a-z0-9]+(?:[-_\.][a-z0-9]+)*)? # local )? ) | (?: # 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 [-_\.]? (alpha|beta|preview|pre|a|b|c|rc) [-_\.]? [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. (?=<>===Nspecr r1r/rr3c|j|}|std|d|d|df|_||_dS)aInitialize a Specifier instance. :param spec: The string representation of a specifier which will be parsed and normalized before use. :param prereleases: This tells the specifier if it should accept prerelease versions if applicable or not. The default of ``None`` will autodetect it from the given specifiers. :raises InvalidSpecifier: If the given specifier is invalid (i.e. bad syntax). zInvalid specifier: ''operatorrN)_regexsearchrgroupstrip_spec _prereleases)r#r[r1matchs r__init__zSpecifier.__init__s ""4(( C"#A$#A#A#ABB B KK # # ) ) + + KK " " ( ( * *'  (rr+c|j|jS|j\}}|dvr;|dkr|dr |dd}t|jrdSdS)N)rTrVrUrSrYrT.*TF)rdrcendswithr is_prerelease)r#r^rs rr1zSpecifier.prereleasess|   ($ $ !J' 6 6 64G$4$4T$:$:!#2#,w- turr2c||_dSrrdr5s rr1zSpecifier.prereleases!rc|jdS)z`The operator of this specifier. >>> Specifier("==1.2.3").operator '==' rrcr"s rr^zSpecifier.operatorz!}rc|jdS)zaThe version of this specifier. >>> Specifier("==1.2.3").version '1.2.3' r rpr"s rrzSpecifier.versionrqrcl|j d|jnd}d|jjdt ||dS)aTA representation of the Specifier that shows all internal state. >>> Specifier('>=1.0.0') =1.0.0')> >>> Specifier('>=1.0.0', prereleases=False) =1.0.0', prereleases=False)> >>> Specifier('>=1.0.0', prereleases=True) =1.0.0', prereleases=True)> N, prereleases=rZrW()>)rdr1 __class__rr r#pres r__repr__zSpecifier.__repr__&sT , 2T- 1 1 1 B4>*AASYYA#AAAArc dj|jS)zA string representation of the Specifier that can be round-tripped. >>> str(Specifier('>=1.0.0')) '>=1.0.0' >>> str(Specifier('>=1.0.0', prereleases=False)) '>=1.0.0' z{}{})formatrcr"s rr$zSpecifier.__str__8sv}dj))rtuple[str, str]cvt|jd|jddk}|jd|fS)Nr rrSstrip_trailing_zero)r rc)r#canonical_versions r_canonical_speczSpecifier._canonical_specBsB0 JqM!%A$!6   z!}///rr&c*t|jSr)hashrr"s rr(zSpecifier.__hash__JsD()))rr)r*ct|tr; |t|}n3#t$r tcYSwxYwt||jstS|j|jkS)a>Whether or not the two Specifier-like objects are equal. :param other: The other object to check against. The value of :attr:`prereleases` is ignored. >>> Specifier("==1.2.3") == Specifier("== 1.2.3.0") True >>> (Specifier("==1.2.3", prereleases=False) == ... Specifier("==1.2.3", prereleases=True)) True >>> Specifier("==1.2.3") == "==1.2.3" True >>> Specifier("==1.2.3") == Specifier("==1.2.4") False >>> Specifier("==1.2.3") == Specifier("~=1.2.3") False )rr rwrNotImplementedrr-s rr.zSpecifier.__eq__Ms& eS ! ! " &s5zz22# & & &%%%% &E4>22 "! !#u'<<>> "1.2.3" in Specifier(">=1.2.3") True >>> Version("1.2.3") in Specifier(">=1.2.3") True >>> "1.0.0" in Specifier(">=1.2.3") False >>> "1.3.0a1" in Specifier(">=1.2.3") False >>> "1.3.0a1" in Specifier(">=1.2.3", prereleases=True) True r8r#r6s r __contains__zSpecifier.__contains__&}}T"""rrc||j}t|}|jr|sdS||j}|||jS)alReturn whether or not the item is contained in this specifier. :param item: The item to check for, which can be a version string or a :class:`Version` instance. :param prereleases: Whether or not to match prereleases with this Specifier. If set to ``None`` (the default), it uses :attr:`prereleases` to determine whether or not prereleases are allowed. >>> Specifier(">=1.2.3").contains("1.2.3") True >>> Specifier(">=1.2.3").contains(Version("1.2.3")) True >>> Specifier(">=1.2.3").contains("1.0.0") False >>> Specifier(">=1.2.3").contains("1.3.0a1") False >>> Specifier(">=1.2.3", prereleases=True).contains("1.3.0a1") True >>> Specifier(">=1.2.3").contains("1.3.0a1", prereleases=True) True NF)r1rrkrr^r)r#r6r1normalized_itemrs rr8zSpecifier.contains sg4  *K*$//  (  5/3.@.@.O.O  $,???rr9r:r;c#Kd}g}d||ndi}|D]K}t|}|j|fi|r,|jr|s|js||Ed}|VL|s |r |D] }|VdSdSdS)aOFilter items in the given iterable, that match the specifier. :param iterable: An iterable that can contain version strings and :class:`Version` instances. The items in the iterable will be filtered according to the specifier. :param prereleases: Whether or not to allow prereleases in the returned iterator. If set to ``None`` (the default), it will be intelligently decide whether to allow prereleases or not (based on the :attr:`prereleases` attribute, and whether the only versions matching are prereleases). This method is smarter than just ``filter(Specifier().contains, [...])`` because it implements the rule from :pep:`440` that a prerelease item SHOULD be accepted if no other versions match the given specifier. >>> list(Specifier(">=1.2.3").filter(["1.2", "1.3", "1.5a1"])) ['1.3'] >>> list(Specifier(">=1.2.3").filter(["1.2", "1.2.3", "1.3", Version("1.4")])) ['1.2.3', '1.3', ] >>> list(Specifier(">=1.2.3").filter(["1.2", "1.5a1"])) ['1.5a1'] >>> list(Specifier(">=1.2.3").filter(["1.3", "1.5a1"], prereleases=True)) ['1.3', '1.5a1'] >>> list(Specifier(">=1.2.3", prereleases=True).filter(["1.3", "1.5a1"])) ['1.3', '1.5a1'] Fr1NT)rr8rkr1append)r#r9r1yieldedfound_prereleaseskwrparsed_versions rr=zSpecifier.filter5s<K,C[[ N  " "G,W55Nt}^22r22 ""/""#'#3"&,,W5555#G!MMM  , ,         rrZN)r[r r1r/rr3)rr+rBr>)rr}r?r@)rr rr)rr r[r rr+)rr rr rr+)r6rrr+r)r6rr1r/rr+rC)#rrrr_operator_regex_str_version_regex_strrecompileVERBOSE IGNORECASEr_rrfrFr1rGr^rrzr$rr(r.rrrrrrrrrrr8r=rrrrJrJcs \ |RZ%%(::WD R]"F "    J(((((4X.""""XXBBBB$****000X0****====:!!!!     (&/&/&/&/P::::<<<< <<<< 0<====####**@*@*@*@*@ZRV;;;;;;;rrJz^([0-9]+)((?:a|b|c|rc)[0-9]+)$r list[str]cLg}|d\}}}||pd|dD][}t|}|r(||F||\|S)aSplit version into components. The split components are intended for version comparison. The logic does not attempt to retain the original version string, so joining the components back with :func:`_version_join` may not produce the original version string. !0.) rpartitionrsplit _prefix_regexr`extendgroups)rresultepochrrestr6res rrrvsF'',,NE1d MM%,3 3  $$T**  MM%,,.. ) ) ) ) MM$     Mr componentsc>|^}}|dd|S)zJoin split version components into a version string. This function assumes the input came from :func:`_version_split`, where the first component must be the epoch (either empty or numeric), and all other components numeric. rr)join)rrrs rrrs+LED & &chhtnn & &&rsegmentr+c<tfddD S)Nc3BK|]}|VdSr) startswith).0rrs r z!_is_not_suffix..sB'-6""r)devabrcpost)any)rs`rrrs@1P rleftrighttuple[list[str], list[str]]c gg}}|ttjd||ttjd|||t |dd||t |dd|ddgt dt |dt |dz z|ddgt dt |dt |dz zttj|ttj|fS)Nc*|Srisdigitxs rz_pad_version..src*|Srrrs rrz_pad_version..s!))++rrr r) rrrrrinsertmaxchain from_iterable)rr left_split right_splits rrrs " Jd9./D/DdKKLLMMMtI/0E0EuMMNNOOOd3z!}--//0111uSQ00223444a#QKN(;(;c*Q->P>P(P!Q!QQRRRq3%#aZ]););c+a.>Q>Q)Q"R"RRSSS Y_ * *: 6 677 Y_ * *; 7 788 rceZdZdZd$d%d Zed&d Zejd'dZd(dZd(dZ d)dZ d*dZ d+dZ d)dZ d,dZd-dZ d.d/dZ d0d1d#ZdS)2 SpecifierSetzThis class abstracts handling of a set of version specifiers. It can be passed a single specifier (``>=3.0``), a comma-separated list of specifiers (``>=3.0,!=3.1``), or no specifier at all. rZN specifiersr r1r/rr3cd|dD}ttt||_||_dS)aNInitialize a SpecifierSet instance. :param specifiers: The string representation of a specifier or a comma-separated list of specifiers which will be parsed and normalized before use. :param prereleases: This tells the SpecifierSet if it should accept prerelease versions if applicable or not. The default of ``None`` will autodetect it from the given specifiers. :raises InvalidSpecifier: If the given ``specifiers`` are not parseable than this exception will be raised. c^g|]*}||+Sr)rbrss r z)SpecifierSet.__init__..s-RRR! RAGGIIRRRr,N)r frozensetmaprJ_specsrd)r#rr1split_specifierss rrfzSpecifierSet.__init__sS$SRz/?/?/D/DRRR I/? @ @AA (rcl|j|jS|jsdStd|jDS)Nc3$K|] }|jV dSrr1rs rrz+SpecifierSet.prereleases..s$66Q1=666666r)rdr rr"s rr1zSpecifierSet.prereleasessH   ($ $ { 466$+666666rr2r+c||_dSrrmr5s rr1zSpecifierSet.prereleasesrnrcR|j d|jnd}dt||dS)aA representation of the specifier set that shows all internal state. Note that the ordering of the individual specifiers within the set may not match the input string. >>> SpecifierSet('>=1.0.0,!=2.0.0') =1.0.0')> >>> SpecifierSet('>=1.0.0,!=2.0.0', prereleases=False) =1.0.0', prereleases=False)> >>> SpecifierSet('>=1.0.0,!=2.0.0', prereleases=True) =1.0.0', prereleases=True)> NrtrZz>> str(SpecifierSet(">=1.0.0,!=1.0.1")) '!=1.0.1,>=1.0.0' >>> str(SpecifierSet(">=1.0.0,!=1.0.1", prereleases=False)) '!=1.0.1,>=1.0.0' rc34K|]}t|VdSr)r rs rrz'SpecifierSet.__str__.. s(;;!s1vv;;;;;;r)rsortedr r"s rr$zSpecifierSet.__str__s/xx;;t{;;;;;<<>> SpecifierSet(">=1.0.0,!=1.0.1") & '<=2.0.0,!=2.0.1' =1.0.0')> >>> SpecifierSet(">=1.0.0,!=1.0.1") & SpecifierSet('<=2.0.0,!=2.0.1') =1.0.0')> NzFCannot combine SpecifierSets with True and False prerelease overrides.)rr rrrr rd ValueError)r#r) specifiers r__and__zSpecifierSet.__and__s eS ! ! " ''EEE<00 "! ! NN $T[5<%?@@    $);)G%*%7I " "   *u/A/I%)%6I " "  %"4 4 4%)%6I " "  rr*ct|ttfrtt|}nt|tstS|j|jkS)aWhether or not the two SpecifierSet-like objects are equal. :param other: The other object to check against. The value of :attr:`prereleases` is ignored. >>> SpecifierSet(">=1.0.0,!=1.0.1") == SpecifierSet(">=1.0.0,!=1.0.1") True >>> (SpecifierSet(">=1.0.0,!=1.0.1", prereleases=False) == ... SpecifierSet(">=1.0.0,!=1.0.1", prereleases=True)) True >>> SpecifierSet(">=1.0.0,!=1.0.1") == ">=1.0.0,!=1.0.1" True >>> SpecifierSet(">=1.0.0,!=1.0.1") == SpecifierSet(">=1.0.0") False >>> SpecifierSet(">=1.0.0,!=1.0.1") == SpecifierSet(">=1.0.0,!=1.0.2") False )rr rJrrr r-s rr.zSpecifierSet.__eq__.sW& ec9- . . " U,,EEE<00 "! !{el**rc*t|jS)z7Returns the number of specifiers in this specifier set.)rr r"s r__len__zSpecifierSet.__len__Hs4;rIterator[Specifier]c*t|jS)z Returns an iterator over all the underlying :class:`Specifier` instances in this specifier set. >>> sorted(SpecifierSet(">=1.0.0,!=1.0.1"), key=str) [, =1.0.0')>] )iterr r"s r__iter__zSpecifierSet.__iter__LsDK   rr6rc,||S)arReturn whether or not the item is contained in this specifier. :param item: The item to check for. This is used for the ``in`` operator and behaves the same as :meth:`contains` with no ``prereleases`` argument passed. >>> "1.2.3" in SpecifierSet(">=1.0.0,!=1.0.1") True >>> Version("1.2.3") in SpecifierSet(">=1.0.0,!=1.0.1") True >>> "1.0.1" in SpecifierSet(">=1.0.0,!=1.0.1") False >>> "1.3.0a1" in SpecifierSet(">=1.0.0,!=1.0.1") False >>> "1.3.0a1" in SpecifierSet(">=1.0.0,!=1.0.1", prereleases=True) True rrs rrzSpecifierSet.__contains__Vrr installedcttst|js jrdS|rjrtjt fd|jDS)aReturn whether or not the item is contained in this SpecifierSet. :param item: The item to check for, which can be a version string or a :class:`Version` instance. :param prereleases: Whether or not to match prereleases with this SpecifierSet. If set to ``None`` (the default), it uses :attr:`prereleases` to determine whether or not prereleases are allowed. >>> SpecifierSet(">=1.0.0,!=1.0.1").contains("1.2.3") True >>> SpecifierSet(">=1.0.0,!=1.0.1").contains(Version("1.2.3")) True >>> SpecifierSet(">=1.0.0,!=1.0.1").contains("1.0.1") False >>> SpecifierSet(">=1.0.0,!=1.0.1").contains("1.3.0a1") False >>> SpecifierSet(">=1.0.0,!=1.0.1", prereleases=True).contains("1.3.0a1") True >>> SpecifierSet(">=1.0.0,!=1.0.1").contains("1.3.0a1", prereleases=True) True NFc3FK|]}|VdS)rNr)rrr6r1s rrz(SpecifierSet.contains..s3RR1::d :<<RRRRRRr)rr r1rkrallr )r#r6r1r"s `` rr8zSpecifierSet.containsks<$(( !4==D  *K t1 5  .+ .4,--D RRRRRdkRRRRRRrr9r:r;c||j}|jr=|jD]&}||t|}'t |Sg}g}|D]G}t |}|jr|s|s||2||H|s|r|t |St |S)a.Filter items in the given iterable, that match the specifiers in this set. :param iterable: An iterable that can contain version strings and :class:`Version` instances. The items in the iterable will be filtered according to the specifier. :param prereleases: Whether or not to allow prereleases in the returned iterator. If set to ``None`` (the default), it will be intelligently decide whether to allow prereleases or not (based on the :attr:`prereleases` attribute, and whether the only versions matching are prereleases). This method is smarter than just ``filter(SpecifierSet(...).contains, [...])`` because it implements the rule from :pep:`440` that a prerelease item SHOULD be accepted if no other versions match the given specifier. >>> list(SpecifierSet(">=1.2.3").filter(["1.2", "1.3", "1.5a1"])) ['1.3'] >>> list(SpecifierSet(">=1.2.3").filter(["1.2", "1.3", Version("1.4")])) ['1.3', ] >>> list(SpecifierSet(">=1.2.3").filter(["1.2", "1.5a1"])) [] >>> list(SpecifierSet(">=1.2.3").filter(["1.3", "1.5a1"], prereleases=True)) ['1.3', '1.5a1'] >>> list(SpecifierSet(">=1.2.3", prereleases=True).filter(["1.3", "1.5a1"])) ['1.3', '1.5a1'] An "empty" SpecifierSet will filter items based on the presence of prerelease versions in the set. >>> list(SpecifierSet("").filter(["1.3", "1.5a1"])) ['1.3'] >>> list(SpecifierSet("").filter(["1.5a1"])) ['1.5a1'] >>> list(SpecifierSet("", prereleases=True).filter(["1.3", "1.5a1"])) ['1.3', '1.5a1'] >>> list(SpecifierSet("").filter(["1.3", "1.5a1"], prereleases=True)) ['1.3', '1.5a1'] Nr)r1r r=r+rrrkr)r#r9r1r[filteredrr6rs rr=zSpecifierSet.filtersX  *K ; "  P P;;xT+=N=N;OO>> ! 24H:<  * *!0!6!6"/* *#7)00666OOD)))) / 1 /k6I-...>> !rr)rr r1r/rr3rArBr>r?)r)rrrr@)rr)r6rrr+)NN)r6rr1r/r"r/rr+rrC)rrrrrfrFr1rGrzr$r(rr.rr rr8r=rrrrrsj (((((6777X7 """"5555* = = = =!!!!@++++4    !!!!####0$(!% 7S7S7S7S7StRVM"M"M"M"M"M"M"rr)rrrr )rr rr)rrrr )rr rr+)rrrrrr)"r __future__rrDrrtypingrrrrrutilsr rr r rr r+rrrrABCMetarrJrrrrrrrrrrr,s #"""""  ??????????????'''''' %W1IIIWcND01     z   4 4 4 4 4 ck4 4 4 4 nMMMMM MMM` <== ,'''' *"""""="""""r