U cf\ @sjdZddlZddlZddlmZddlmZdddd d d d d gZee Z Gdd d e Z Gddde ZGddde ZedejZddZeZGdddeZddZGdddeZeddfeddfeddfedd fed!d"fed#d"fed$d%fed&d'fed(d)fed*d+ff Zed,dfed-dfed.d%fed$d%fed/dffZed0Zd1d2Zd3d4Zed5ejZd6d6d7d6d8ddd9Zd:d;ZGdejZ"d?d@Z#dAdBZ$GdCd d eZ%GdDd d eZ&GdEdFdFe Z'e'eeee'ee!dGdHe'e$e&edIZ(e(dJe(dK<dLd Z)dS)Mz~ Implementation of a flexible versioning scheme providing support for PEP-440, setuptools-compatible and semantic versioning. N) string_typesparse_requirementNormalizedVersionNormalizedMatcher LegacyVersion LegacyMatcherSemanticVersionSemanticMatcherUnsupportedVersionError get_schemec@seZdZdZdS)r zThis is an unsupported version.N)__name__ __module__ __qualname____doc__rrI/opt/hc_python/lib/python3.8/site-packages/pip/_vendor/distlib/version.pyr sc@sxeZdZddZddZddZddZd d Zd d Zd dZ ddZ ddZ ddZ ddZ ddZeddZdS)VersioncCs@||_}|||_}t|ts,tt|dksTzMatcher.cCs||kSr)rr>rrrrBUrCcCs||kp||kSr)rr>rrrrBVrCcCs||kp||kSr)rr>rrrrBWrCcCs||kSr)rr>rrrrBXrCcCs||kSr)rr>rrrrBYrCcCs||kp||kSr)rr>rrrrB[rCcCs||kSr)rr>rrrrB\rC)<><=>======~=!=cCst|Sr)rr#rrrraszMatcher.parse_requirementcCs|jdkrtd||_}||}|s:td||j|_|j|_g}|jr|jD]d\}}| dr|dkrtd||ddd}}||n||d}}| |||fq^t ||_ dS) NzPlease specify a version classz Not valid: %rz.*)rHrKz#'.*' not allowed for %r constraintsTF) version_class ValueErrorrrrnamelowerkey constraintsendswithappendrr)rrrZclistopZvnprefixrrrr ds*      zMatcher.__init__cCsxt|tr||}|jD]X\}}}|j|}t|trDt||}|s`d||jjf}t |||||sdSqdS)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) rrrMr _operatorsgetgetattrr7rr")rversionoperator constraintrWfmsgrrrmatchs       z Matcher.matchcCs6d}t|jdkr2|jdddkr2|jdd}|S)Nrr)rHrI)rr)rresultrrr exact_versions zMatcher.exact_versioncCs0t|t|ks|j|jkr,td||fdS)Nzcannot compare %s and %s)r$rOr%r&rrrr(szMatcher._check_compatiblecCs"|||j|jko |j|jkSr))r(rQrr&rrrr+s zMatcher.__eq__cCs || Sr)r,r&rrrr-szMatcher.__ne__cCst|jt|jSr))r3rQrr4rrrr5szMatcher.__hash__cCsd|jj|jfS)Nz%s(%r)r6r4rrrr8szMatcher.__repr__cCs|jSr)r9r4rrrr:szMatcher.__str__)rrrrMrXrr r`r<rbr(r+r-r5r8r:rrrrr=Os* r=z^v?(\d+!)?(\d+(\.\d+)*)((a|alpha|b|beta|c|rc|pre|preview)(\d+)?)?(\.(post|r|rev)(\d+)?)?([._-]?(dev)(\d+)?)?(\+([a-zA-Z\d]+(\.[a-zA-Z\d]+)?))?$c Cs|}t|}|s"td||}tdd|ddD}t|dkrl|ddkrl|dd}qF|dszd}nt|ddd}|dd }|d d }|d d }|d}|dkrd}n.|ddkr|ddf}n|dt|df}|dkrd}n0|ddkr"|ddf}n|dt|df}|dkrFd}n0|ddkrb|ddf}n|dt|df}|dkrd}nHg} |dD]0} | rdt| f} nd| f} | | qt| }|s|s|rd}nd}|sd}|sd}||||||fS)NzNot a valid version: %scss|]}t|VqdSr)int.0r?rrr sz_pep_440_key..r.r )NNr)ari)z)_)final) rPEP440_VERSION_REr`r groupsrsplitrrdisdigitrT) rmrvnumsepochprepostdevlocalrpartrrr _pep_440_keys`           rc@s6eZdZdZddZedddddgZed d Zd S) 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)Ncss|]}t|VqdSr)rcrerrrrgsz*NormalizedVersion.parse..rrh)_normalized_keyrur`rvrrw_release_clause)rrraryrvrrrrs  zNormalizedVersion.parserqbr@rcr~cstfddjDS)Nc3s |]}|r|djkVqdS)rN) PREREL_TAGS)rftr4rrrg!sz2NormalizedVersion.is_prerelease..)anyrr4rr4rr;szNormalizedVersion.is_prereleaseN) rrrrrsetrr<r;rrrrrs  cCs>t|}t|}||krdS||s*dSt|}||dkS)NTFrh)str startswithr)xynrrr _match_prefix$s 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)rJrDrErFrGrHrIrKcCsV|rd|ko|jd}n|jd o,|jd}|rN|jddd}||}||fS)N+rirr)rrrwrM)rr[r]rWZ strip_localrrrr _adjust_local>s zNormalizedMatcher._adjust_localcCsD||||\}}||krdS|j}ddd|D}t|| S)NFrhcSsg|] }t|qSrrrfirrr Qsz/NormalizedMatcher._match_lt..rrjoinrrr[r]rWZrelease_clausepfxrrrrLs zNormalizedMatcher._match_ltcCsD||||\}}||krdS|j}ddd|D}t|| S)NFrhcSsg|] }t|qSrrrrrrrYsz/NormalizedMatcher._match_gt..rrrrrrTs zNormalizedMatcher._match_gtcCs||||\}}||kSr)rrr[r]rWrrrr\szNormalizedMatcher._match_lecCs||||\}}||kSr)rrrrrr`szNormalizedMatcher._match_gecCs.||||\}}|s ||k}n t||}|Sr)rrrr[r]rWrarrrrds   zNormalizedMatcher._match_eqcCst|t|kSr)rrrrrrlsz"NormalizedMatcher._match_arbitrarycCs0||||\}}|s ||k}n t|| }|Sr)rrrrrros   zNormalizedMatcher._match_necCsf||||\}}||krdS||kr*dS|j}t|dkrH|dd}ddd|D}t||S)NTFrrirhcSsg|] }t|qSrrrrrrrsz7NormalizedMatcher._match_compatible..)rrrrrrrrrrws  z#NormalizedMatcher._match_compatibleN)rrrrrMrXrrrrrrrrrrrrrr/s& z[.+-]$z^[.](\d)z0.\1z^[.-]z ^\((.*)\)$\1z^v(ersion)?\s*(\d+)z\2z^r(ev)?\s*(\d+)z[.]{2,}rhz\b(alfa|apha)\balphaz\b(pre-alpha|prealpha)\bz pre.alphaz \(beta\)$betaz ^[:~._+-]+z [,*")([\]]z[~:+_ -]z\.$z (\d+(\.\d+)*)cCsL|}tD]\}}|||}q|s.d}t|}|sFd}|}n|dd}dd|D}t|dkr~| dqft|dkr|| d}n8d dd|ddD|| d}|dd}d d d|D}|}|rt D]\}}|||}q|s|}nd |kr*d nd }|||}t |sHd}|S) z Try to suggest a semantic form for a version for which _suggest_normalized_version couldn't come up with anything. z0.0.0rrhcSsg|] }t|qSrrcrrrrrsz-_suggest_semantic_version..NcSsg|] }t|qSrrrrrrrscSsg|] }t|qSrrrrrrrsr~-r)rrP _REPLACEMENTSsub_NUMERIC_PREFIXr`rvrwrrTendr_SUFFIX_REPLACEMENTS is_semver)rrapatreplryrWsuffixseprrr_suggest_semantic_versions:      ,    rcCshzt||WStk r"YnX|}dD]\}}|||}q0tdd|}tdd|}tdd|}tdd |}td d |}|d r|d d}tdd |}tdd|}tdd|}tdd|}tdd|}tdd|}tdd|}tdd|}tdd|}tdd|}tdd |}z t|Wntk rbd}YnX|S)!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-alpharq)z-betar)rrq)rr)rr@)z-finalr)z-prer@)z-releaser)z.releaser)z-stabler)rrh)rsrh) r)z.finalr)rtrzpre$Zpre0zdev$Zdev0z([abc]|rc)[\-\.](\d+)$z\1\2z[\-\.](dev)[\-\.]?r?(\d+)$z.\1\2z[.~]?([abc])\.?rr?rNz\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 rPreplacererr)rrsorigrrrr_suggest_normalized_versions>      rz([a-z]+|\d+|[\.-])r@zfinal-@)r|previewrrr~rrhcCsrdd}g}||D]T}|dr^|dkrD|rD|ddkrD|q*|r^|ddkr^|qD||qt|S)NcSstg}t|D]R}t||}|rd|ddkrBdkrRnn |d}nd|}||q|d|S)N0r9**final) _VERSION_PARTrwrP_VERSION_REPLACErYzfillrT)rrarArrr get_partsMs     z_legacy_key..get_partsrrriz*final-00000000)rpoprTr)rrrarArrr _legacy_keyLs      rc@s eZdZddZeddZdS)rcCst|Sr))rr#rrrrgszLegacyVersion.parsecCs8d}|jD](}t|tr |dr |dkr d}q4q |S)NFrrT)rrrr)rrarrrrr;js zLegacyVersion.is_prereleaseNrrrrr<r;rrrrrfsc@s4eZdZeZeejZded<e dZ ddZ dS)r rrJz^(\d+(\.\d+)*)cCs`||kr dS|jt|}|s2td||dS|d}d|krV|ddd}t||S)NFzACannot compute compatible match for version %s and constraint %sTrrhr) numeric_rer`rloggerwarningrvrsplitr)rr[r]rWryrrrrr}s zLegacyMatcher._match_compatibleN) rrrrrMdictr=rXrcompilerrrrrrr us   zN^(\d+)\.(\d+)\.(\d+)(-[a-z0-9]+(\.[a-z0-9-]+)*)?(\+[a-z0-9]+(\.[a-z0-9-]+)*)?$cCs t|Sr)) _SEMVER_REr`)rrrrrsrc Csndd}t|}|st||}dd|ddD\}}}||dd||dd}}|||f||fS) NcSs8|dkr|f}n$|ddd}tdd|D}|S)NrrhcSs"g|]}|r|dn|qS)r)rxr)rfrArrrrsz5_semantic_key..make_tuple..)rwr)rZabsentrarrrr make_tuples z!_semantic_key..make_tuplecSsg|] }t|qSrrcrrrrrsz!_semantic_key..r|r)rr rv) rrryrvmajorminorpatchr|buildrrr _semantic_keys rc@s eZdZddZeddZdS)r cCst|Sr))rr#rrrrszSemanticVersion.parsecCs|jdddkS)Nrrr)rr4rrrr;szSemanticVersion.is_prereleaseNrrrrrr sc@seZdZeZdS)r N)rrrr rMrrrrr sc@s6eZdZd ddZddZddZdd Zd d ZdS) VersionSchemeNcCs||_||_||_dSr))rQmatcher suggester)rrQrrrrrr szVersionScheme.__init__cCs2z|j|d}Wntk r,d}YnX|SNTF)rrMr rrrarrris_valid_versions   zVersionScheme.is_valid_versioncCs0z||d}Wntk r*d}YnX|Sr)rr rrrris_valid_matchers   zVersionScheme.is_valid_matchercCs$|dr|dd}|d|S)z: Used for processing some metadata fields ,Nrizdummy_name (%s))rSrr#rrris_valid_constraint_lists  z&VersionScheme.is_valid_constraint_listcCs|jdkrd}n ||}|Sr))rrrrrsuggests  zVersionScheme.suggest)N)rrrr rrrrrrrrrs   rcCs|Sr)rr#rrrrBrCrB) normalizedlegacyZsemanticrdefaultcCs|tkrtd|t|S)Nzunknown scheme name: %r)_SCHEMESrN)rOrrrr s )*rloggingrcompatrutilr__all__ getLoggerrrrNr objectrr=rIrurrrrrrrrrrrrrrr rrrr r rrr rrrrs   1dE$ X               .s  (