U .e. @sddlmZmZmZddlZddlZddlZddlmZddddd gZ e d d d d dddgZ ddZ Gddde ZGdddeZGdddeZedejZddddddZddZddZdZGd ddeZd!d"Zed#Zd$d%Zd&d'ZdS)()absolute_importdivisionprint_functionN)InfinityparseVersion LegacyVersionInvalidVersionVERSION_PATTERN_VersionepochreleasedevprepostlocalcCs,z t|WStk r&t|YSXdS)z Parse the given version string and return either a :class:`Version` object or a :class:`LegacyVersion` object depending on if the given version is a valid PEP 440 version or a legacy version. N)rr r )versionrA/usr/lib/python3.8/site-packages/pip/_vendor/packaging/version.pyrs c@seZdZdZdS)r zF An invalid version was found, users should refer to PEP 440. N)__name__ __module__ __qualname____doc__rrrrr !sc@sLeZdZddZddZddZddZd d Zd d Zd dZ ddZ dS) _BaseVersioncCs t|jSN)hash_keyselfrrr__hash__(sz_BaseVersion.__hash__cCs||ddS)NcSs||kSrrsorrr,z%_BaseVersion.__lt__.._comparerotherrrr__lt__+sz_BaseVersion.__lt__cCs||ddS)NcSs||kSrrr!rrrr$/r%z%_BaseVersion.__le__..r&r(rrr__le__.sz_BaseVersion.__le__cCs||ddS)NcSs||kSrrr!rrrr$2r%z%_BaseVersion.__eq__..r&r(rrr__eq__1sz_BaseVersion.__eq__cCs||ddS)NcSs||kSrrr!rrrr$5r%z%_BaseVersion.__ge__..r&r(rrr__ge__4sz_BaseVersion.__ge__cCs||ddS)NcSs||kSrrr!rrrr$8r%z%_BaseVersion.__gt__..r&r(rrr__gt__7sz_BaseVersion.__gt__cCs||ddS)NcSs||kSrrr!rrrr$;r%z%_BaseVersion.__ne__..r&r(rrr__ne__:sz_BaseVersion.__ne__cCst|tstS||j|jSr) isinstancerNotImplementedr)rr)methodrrrr'=s z_BaseVersion._compareN) rrrr r*r+r,r-r.r/r'rrrrr'src@seZdZddZddZddZeddZed d Zed d Z ed dZ eddZ eddZ eddZ eddZeddZeddZeddZdS)r cCst||_t|j|_dSr)str_version_legacy_cmpkeyr)rrrrr__init__Es zLegacyVersion.__init__cCs|jSrr4rrrr__str__IszLegacyVersion.__str__cCsdtt|S)Nzformatreprr3rrrr__repr__LszLegacyVersion.__repr__cCs|jSrr7rrrrpublicOszLegacyVersion.publiccCs|jSrr7rrrr base_versionSszLegacyVersion.base_versioncCsdS)Nrrrrrr WszLegacyVersion.epochcCsdSrrrrrrr[szLegacyVersion.releasecCsdSrrrrrrr_szLegacyVersion.precCsdSrrrrrrrcszLegacyVersion.postcCsdSrrrrrrrgszLegacyVersion.devcCsdSrrrrrrrkszLegacyVersion.localcCsdSNFrrrrr is_prereleaseoszLegacyVersion.is_prereleasecCsdSr@rrrrris_postreleasesszLegacyVersion.is_postreleasecCsdSr@rrrrr is_devreleasewszLegacyVersion.is_devreleaseN)rrrr6r8r<propertyr=r>r rrrrrrArBrCrrrrr Ds2          z(\d+ | [a-z]+ | \.| -)czfinal-@)rpreview-rcrccs\t|D]F}t||}|r |dkr(q |dddkrF|dVq d|Vq dVdS)N.r 0123456789**final)_legacy_version_component_resplit_legacy_version_replacement_mapgetzfill)r"partrrr_parse_version_partss   rUcCszd}g}t|D]T}|dr^|dkrD|rD|ddkrD|q*|r^|ddkr^|qD||qt|}||fS)Nr?rMrNz*final-Z00000000)rUlower startswithpopappendtuple)rr partsrTrrrr5s    r5a v? (?: (?:(?P[0-9]+)!)? # epoch (?P[0-9]+(?:\.[0-9]+)*) # release segment (?P
                                          # pre-release
            [-_\.]?
            (?P(a|b|c|rc|alpha|beta|pre|preview))
            [-_\.]?
            (?P[0-9]+)?
        )?
        (?P                                         # post release
            (?:-(?P[0-9]+))
            |
            (?:
                [-_\.]?
                (?Ppost|rev|r)
                [-_\.]?
                (?P[0-9]+)?
            )
        )?
        (?P                                          # dev release
            [-_\.]?
            (?Pdev)
            [-_\.]?
            (?P[0-9]+)?
        )?
    )
    (?:\+(?P[a-z0-9]+(?:[-_\.][a-z0-9]+)*))?       # local version
c@seZdZededejejBZddZ	ddZ
ddZed	d
Z
eddZed
dZeddZeddZeddZeddZeddZeddZeddZeddZdS) rz^\s*z\s*$c
Cs|j|}|std|t|dr8t|dndtdd|ddDt	|d|d	t	|d
|dp|dt	|d
|dt
|dd|_t|jj
|jj|jj|jj|jj|jj|_dS)NzInvalid version: '{0}'r
rcss|]}t|VqdSr)int.0irrr	sz#Version.__init__..rrJZpre_lZpre_nZpost_lZpost_n1Zpost_n2Zdev_lZdev_nrr
rrrrr)_regexsearchr
r:rgroupr\rZrP_parse_letter_version_parse_local_versionr4_cmpkeyr
rrrrrr)rrmatchrrrr6s,zVersion.__init__cCsdtt|S)Nzr9rrrrr<szVersion.__repr__cCsg}|jdkr |d|j|ddd|jD|jdk	rb|ddd|jD|jdk	r~|d|j|jdk	r|d	|j|jdk	r|d
|jd|S)Nr{0}!rJcss|]}t|VqdSrr3r^xrrrr`sz"Version.__str__..css|]}t|VqdSrrjrkrrrr`sz.post{0}z.dev{0}z+{0})	r
rYr:joinrrrrrrr[rrrr8s




zVersion.__str__cCs|jjSr)r4r
rrrrr
sz
Version.epochcCs|jjSr)r4rrrrrrszVersion.releasecCs|jjSr)r4rrrrrrszVersion.precCs|jjr|jjdSdSNr)r4rrrrrr szVersion.postcCs|jjr|jjdSdSrp)r4rrrrrr$szVersion.devcCs(|jjr ddd|jjDSdSdS)NrJcss|]}t|VqdSrrjrkrrrr`+sz Version.local..)r4rrnrrrrr(sz
Version.localcCst|dddS)N+rr)r3rPrrrrr=/szVersion.publiccCsFg}|jdkr |d|j|ddd|jDd|S)NrrirJcss|]}t|VqdSrrjrkrrrr`<sz'Version.base_version..rm)r
rYr:rnrrorrrr>3s

zVersion.base_versioncCs|jdk	p|jdk	Sr)rrrrrrrA@szVersion.is_prereleasecCs
|jdk	Sr)rrrrrrBDszVersion.is_postreleasecCs
|jdk	Sr)rrrrrrCHszVersion.is_devreleaseN)rrrrecompilerVERBOSE
IGNORECASErbr6r<r8rDr
rrrrrr=r>rArBrCrrrrrs4









cCsv|rZ|dkrd}|}|dkr&d}n(|dkr4d}n|dkrBd}n|dkrNd	}|t|fS|sr|rrd	}|t|fSdS)
NrZalphaaZbetab)rErrGrI)Zrevrr)rVr\)ZletterZnumberrrrreMs rez[\._-]cCs$|dk	r tddt|DSdS)zR
    Takes a string like abc.1.twelve and turns it into ("abc", 1, "twelve").
    Ncss&|]}|s|nt|VqdSr)isdigitrVr\)r^rTrrrr`tsz'_parse_local_version..)rZ_local_version_separatorsrP)rrrrrfosrfcCsttttddt|}|dkr@|dkr@|dk	r@t}n|dkrLt}|dkrZt}|dkrft}|dkrvt}ntdd|D}||||||fS)NcSs|dkS)Nrr)rlrrrr$r%z_cmpkey..css*|]"}t|tr|dfnt|fVqdS)rmN)r0r\rr]rrrr`sz_cmpkey..)rZreversedlist	itertools	dropwhilerrarrrrgzs	rg)Z
__future__rrrcollectionsr}rrZ_structuresr__all__
namedtuplerr
ValueErrorr
objectrr	rsrtrOrQrUr5rrrerzrfrgrrrrs88	 x