o ƚRe[ @sZdZddlZddlZddlmZddlmZgdZee Z Gddde Z Gd d d e ZGd d d e Zed ZddZeZGdddeZddZGdddeZeddfeddfeddfeddfeddfeddfed d!fed"d#fed$d%fed&d'ff Zed(dfed)dfed*d!fed d!fed+dffZed,Zd-d.Zd/d0Zed1ejZd2d2d3d2d4ddd5Zd6d7ZGd8d9d9eZ Gd:d;d;eZ!edZ#d?d@Z$GdAdBdBeZ%GdCdDdDeZ&GdEdFdFe Z'e'eeee'ee!dGdHe'e$e&edIZ(e(dJe(dK<dLdMZ)dS)Nz~ Implementation of a flexible versioning scheme providing support for PEP-440, setuptools-compatible and semantic versioning. N) string_typesparse_requirement)NormalizedVersionNormalizedMatcher LegacyVersion LegacyMatcherSemanticVersionSemanticMatcherUnsupportedVersionError get_schemec@seZdZdZdS)r zThis is an unsupported version.N)__name__ __module__ __qualname____doc__rr/builddir/build/BUILDROOT/alt-python310-pip-21.3.1-3.el8.x86_64/opt/alt/python310/lib/python3.10/site-packages/pip/_vendor/distlib/version.pyr sr c@sxeZdZddZddZddZddZd d Zd d Zd dZ ddZ ddZ ddZ ddZ ddZeddZdS)VersioncCs@||_}|||_}t|tsJt|dksJdS)Nr)strip_stringparse_parts isinstancetuplelen)selfspartsrrr__init__szVersion.__init__cCtd)Nzplease implement in a subclassNotImplementedErrorrrrrrr%z Version.parsecCs$t|t|krtd||fdS)Nzcannot compare %r and %r)type TypeErrorrotherrrr_check_compatible(szVersion._check_compatiblecCs|||j|jkSNr)rr'rrr__eq__,  zVersion.__eq__cC || Sr*r,r'rrr__ne__0 zVersion.__ne__cCs|||j|jkSr*r+r'rrr__lt__3r-zVersion.__lt__cCs||p || Sr*r2r,r'rrr__gt__7szVersion.__gt__cC||p ||Sr*r3r'rrr__le__:zVersion.__le__cCr5r*)r4r,r'rrr__ge__=r7zVersion.__ge__cCs t|jSr*)hashrrrrr__hash__A zVersion.__hash__cCd|jj|jfS)Nz%s('%s') __class__rrr:rrr__repr__DzVersion.__repr__cC|jSr*rr:rrr__str__GzVersion.__str__cCr )NzPlease implement in subclasses.r!r:rrr is_prereleaseJszVersion.is_prereleaseN)rrrrrr)r,r0r2r4r6r8r;r@rDpropertyrFrrrrrsrc @seZdZdZddddddddddddd dd dd Zd d ZddZddZeddZ ddZ ddZ ddZ ddZ ddZddZdS) MatcherNcCs||kSr*rvcprrrTzMatcher.cCs||kSr*rrIrrrrMUrNcCs||kp||kSr*rrIrrrrMVcC||kp||kSr*rrIrrrrMWrOcC||kSr*rrIrrrrMXrNcCrQr*rrIrrrrMYrNcCrPr*rrIrrrrM[rOcCs||kSr*rrIrrrrM\rN)<><=>======~=!=cCt|Sr*rr#rrrrar$zMatcher.parse_requirementcCs|jdur td||_}||}|std||j|_|j|_g}|jrb|jD]2\}}| drQ|dvrBtd||ddd}}||n||d}}| |||fq/t ||_ dS) NzPlease specify a version classz Not valid: %rz.*)rVrYz#'.*' not allowed for %r constraintsTF) version_class ValueErrorrrrnamelowerkey constraintsendswithappendrr)rrrZclistopZvnprefixrrrrds*      zMatcher.__init__cCsxt|tr ||}|jD],\}}}|j|}t|tr"t||}|s0d||jjf}t |||||s9dSq dS)z Check if the provided version matches the constraints. :param version: The version to match against this instance. :type version: String or :class:`Version` instance. z%r not implemented for %sFT) rrr\r _operatorsgetgetattrr?rr")rversionoperator constraintrffmsgrrrmatchs       z Matcher.matchcCs6d}t|jdkr|jdddvr|jdd}|S)Nrr)rVrW)rr)rresultrrr exact_versions zMatcher.exact_versioncCs0t|t|ks|j|jkrtd||fdS)Nzcannot compare %s and %s)r%r^r&r'rrrr)szMatcher._check_compatiblecCs"|||j|jko|j|jkSr*)r)r`rr'rrrr,s zMatcher.__eq__cCr.r*r/r'rrrr0r1zMatcher.__ne__cCst|jt|jSr*)r9r`rr:rrrr;r7zMatcher.__hash__cCr=)Nz%s(%r)r>r:rrrr@rAzMatcher.__repr__cCrBr*rCr:rrrrDrEzMatcher.__str__)rrrr\rgrrrorGrqr)r,r0r;r@rDrrrrrHOs,  rHzk^v?(\d+!)?(\d+(\.\d+)*)((a|b|c|rc)(\d+))?(\.(post)(\d+))?(\.(dev)(\d+))?(\+([a-zA-Z\d]+(\.[a-zA-Z\d]+)?))?$c Cs|}t|}|std||}tdd|ddD}t|dkrA|ddkrA|dd}t|dkrA|ddks/|dsHd}n t|ddd}|dd }|d d }|d d }|d}|dkrod}n |dt|df}|dkrd}n |dt|df}|dkrd}n |dt|df}|durd}n"g} |dD]} | rdt| f} nd| f} | | qt| }|s|s|rd}nd}|sd}|sd}||||||fS)NzNot a valid version: %scs|]}t|VqdSr*int.0rJrrr z_pep_440_key..r.r )NNr)arz)z)_)final) rPEP440_VERSION_REror groupsrsplitrrtisdigitrc) rmrnumsepochprepostdevlocalrpartrrr _pep_440_keysV       rc@s0eZdZdZddZegdZeddZdS)raIA rational version. Good: 1.2 # equivalent to "1.2.0" 1.2.0 1.2a1 1.2.3a2 1.2.3b1 1.2.3c1 1.2.3.4 TODO: fill this out Bad: 1 # minimum two numbers 1.2a # release level must have a release serial 1.2.3b cCs<t|}t|}|}tdd|ddD|_|S)Ncsrrr*rsrurrrrwrxz*NormalizedVersion.parse..rry)_normalized_keyrrorrr_release_clause)rrrprrrrrr s  zNormalizedVersion.parse)rbrKrcrcstfddjDS)Nc3s"|] }|r|djvVqdS)rN) PREREL_TAGS)rvtr:rrrws z2NormalizedVersion.is_prerelease..)anyrr:rr:rrFszNormalizedVersion.is_prereleaseN) rrrrrsetrrGrFrrrrrs  rcCs>t|}t|}||krdS||sdSt|}||dkS)NTFry)str startswithr)xynrrr _match_prefixs  rc @sneZdZeZddddddddd Zd d Zd d ZddZddZ ddZ ddZ ddZ ddZ ddZdS)r_match_compatible _match_lt _match_gt _match_le _match_ge _match_eq_match_arbitrary _match_ne)rXrRrSrTrUrVrWrYcCsV|r d|vo |jd}n |jd o|jd}|r'|jddd}||}||fS)N+rzrr)rrrr\)rrjrlrfZ strip_localrrrr _adjust_local6s zNormalizedMatcher._adjust_localcCsD||||\}}||krdS|j}ddd|D}t|| S)NFrycSg|]}t|qSrrrvirrr Iz/NormalizedMatcher._match_lt..rrjoinrrrjrlrfZrelease_clausepfxrrrrD  zNormalizedMatcher._match_ltcCsD||||\}}||krdS|j}ddd|D}t|| S)NFrycSrrrrrrrrQrz/NormalizedMatcher._match_gt..rrrrrrLrzNormalizedMatcher._match_gtcCs||||\}}||kSr*rrrjrlrfrrrrTzNormalizedMatcher._match_lecCs||||\}}||kSr*rrrrrrXrzNormalizedMatcher._match_gecCs0||||\}}|s||k}|St||}|Sr*rrrrjrlrfrprrrr\s  zNormalizedMatcher._match_eqcCst|t|kSr*rrrrrrdsz"NormalizedMatcher._match_arbitrarycCs2||||\}}|s||k}|St|| }|Sr*rrrrrrgs  zNormalizedMatcher._match_necCsf||||\}}||krdS||krdS|j}t|dkr$|dd}ddd|D}t||S)NTFrrzrycSrrrrrrrrzrz7NormalizedMatcher._match_compatible..)rrrrrrrrrros   z#NormalizedMatcher._match_compatibleN)rrrrr\rgrrrrrrrrrrrrrr's(  rz[.+-]$z^[.](\d)z0.\1z^[.-]z ^\((.*)\)$\1z^v(ersion)?\s*(\d+)z\2z^r(ev)?\s*(\d+)z[.]{2,}ryz\b(alfa|apha)\balphaz\b(pre-alpha|prealpha)\bz pre.alphaz \(beta\)$betaz ^[:~._+-]+z [,*")([\]]z[~:+_ -]z\.$z (\d+(\.\d+)*)cCsN|}tD] \}}|||}q|sd}t|}|s#d}|}nZ|dd}dd|D}t|dkrD| dt|dks9t|dkrS|| d}nd dd|ddD|| d}|dd}d d d|D}|}|rt D] \}}|||}q|s|}nd |vrd nd }|||}t |sd}|S) z Try to suggest a semantic form for a version for which _suggest_normalized_version couldn't come up with anything. z0.0.0rrycSrrrsrrrrrrz-_suggest_semantic_version..NcSrrrrrrrrrcSrrrrrrrrrr-r)rr_ _REPLACEMENTSsub_NUMERIC_PREFIXrorrrrcendr_SUFFIX_REPLACEMENTS is_semver)rrppatreplrrfsuffixseprrr_suggest_semantic_versions<      ,   rcCsbzt||WStyYnw|}dD] \}}|||}qtdd|}tdd|}tdd|}tdd |}td d |}|d rP|d d}tdd |}tdd|}tdd|}tdd|}tdd|}tdd|}tdd|}tdd|}tdd|}tdd|}tdd |}zt|W|Styd}Y|Sw)!aSuggest a normalized version close to the given version string. If you have a version string that isn't rational (i.e. NormalizedVersion doesn't like it) then you might be able to get an equivalent (or close) rational version from this function. This does a number of simple normalizations to the given string, based on observation of versions currently in use on PyPI. Given a dump of those version during PyCon 2009, 4287 of them: - 2312 (53.93%) match NormalizedVersion without change with the automatic suggestion - 3474 (81.04%) match when using this suggestion method @param s {str} An irrational version string. @returns A rational version string, or None, if couldn't determine one. ))z-alphar)z-betar)rr)rr)rrK)z-finalr)z-prerK)z-releaser)z.releaser)z-stabler)rry)rry) r)z.finalr)rrzpre$Zpre0zdev$Zdev0z([abc]|rc)[\-\.](\d+)$z\1\2z[\-\.](dev)[\-\.]?r?(\d+)$z.\1\2z[.~]?([abc])\.?rrJrNz\b0+(\d+)(?!\d)z (\d+[abc])$z\g<1>0z\.?(dev-r|dev\.r)\.?(\d+)$z.dev\2z-(a|b|c)(\d+)$z[\.\-](dev|devel)$z.dev0z(?![\.\-])dev$z(final|stable)$rz\.?(r|-|-r)\.?(\d+)$z.post\2z\.?(dev|git|bzr)\.?(\d+)$z\.?(pre|preview|-c)(\d+)$zc\g<2>zp(\d+)$z.post\1)rr r_replacererr)rrsorigrrrr_suggest_normalized_versionsD       rz([a-z]+|\d+|[\.-])rKzfinal-@)rpreviewrrrrrycCsdd}g}||D]8}|dr=|dkr)|r)|ddkr)||r)|ddks|r=|ddkr=||r=|ddks1||q t|S)NcSstg}t|D])}t||}|r2d|ddkr!dkr)nn|d}nd|}||q |d|S)N0r9**final) _VERSION_PARTrr__VERSION_REPLACErhzfillrc)rrprLrrr get_partsCs     z_legacy_key..get_partsrrrzz*final-00000000)rpoprcr)rrrprLrrr _legacy_keyBs   rc@ eZdZddZeddZdS)rcCrZr*)rr#rrrr]r$zLegacyVersion.parsecCs:d}|jD]}t|tr|dr|dkrd}|Sq|S)NFrrT)rrrr)rrprrrrrF`s zLegacyVersion.is_prereleaseNrrrrrGrFrrrrr\rc@s4eZdZeZeejZded<e dZ ddZ dS)r rrXz^(\d+(\.\d+)*)cCs`||krdS|jt|}|std||dS|d}d|vr+|ddd}t||S)NFzACannot compute compatible match for version %s and constraint %sTrryr) numeric_rerorloggerwarningrrsplitr)rrjrlrfrrrrrrss  zLegacyMatcher._match_compatibleN) rrrrr\dictrHrgrcompilerrrrrrr ks    r zN^(\d+)\.(\d+)\.(\d+)(-[a-z0-9]+(\.[a-z0-9-]+)*)?(\+[a-z0-9]+(\.[a-z0-9-]+)*)?$cCs t|Sr*) _SEMVER_REro)rrrrrr<rc Csndd}t|}|st||}dd|ddD\}}}||dd||dd}}|||f||fS) NcSs:|dur |f}|S|ddd}tdd|D}|S)NrrycSs"g|] }|r |dn|qS)r)rr)rvrLrrrrs"z5_semantic_key..make_tuple..)rr)rZabsentrprrrr make_tuples z!_semantic_key..make_tuplecSrrrsrrrrrrz!_semantic_key..r|r)rr r) rrrrmajorminorpatchrbuildrrr _semantic_keys rc@r)r cCrZr*)rr#rrrrr$zSemanticVersion.parsecCs|jdddkS)Nrrr)rr:rrrrFszSemanticVersion.is_prereleaseNrrrrrr rr c@seZdZeZdS)r N)rrrr r\rrrrr sr c@s6eZdZd ddZddZddZdd Zd d ZdS) VersionSchemeNcCs||_||_||_dSr*)r`matcher suggester)rr`rrrrrrs zVersionScheme.__init__cCs0z |j|d}W|Styd}Y|SwNTF)rr\r rrrprrris_valid_versions  zVersionScheme.is_valid_versioncCs.z ||d}W|Styd}Y|Swr)rr rrrris_valid_matchers  zVersionScheme.is_valid_matchercCs$|dr |dd}|d|S)z: Used for processing some metadata fields ,Nrzzdummy_name (%s))rbrr#rrris_valid_constraint_lists  z&VersionScheme.is_valid_constraint_listcCs |jdur d}|S||}|Sr*)rrrrrsuggests  zVersionScheme.suggestr*)rrrrrrrrrrrrrs   rcCs|Sr*rr#rrrrMsrM) normalizedlegacyZsemanticrdefaultcCs|tvr td|t|S)Nzunknown scheme name: %r)_SCHEMESr])r^rrrr s r )*rloggingrcompatrutilr__all__ getLoggerrrr]r objectrrHrrrrrrrrrrrrIrrrrr rrrr r rrr rrrrs   1 d=$ W              .r  '