3 7]$-@sddlmZmZmZddlZddlZddlZddlmZddddd gZ ej d d d d dddgZ ddZ Gddde ZGdddeZGdddeZejdejZddddddZddZddZdZGd ddeZd!d"Zejd#Zd$d%Zd&d'ZdS)()absolute_importdivisionprint_functionN)InfinityparseVersion LegacyVersionInvalidVersionVERSION_PATTERN_Versionepochreleasedevprepostlocalc Cs&yt|Stk r t|SXdS)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 )versionr/usr/lib/python3.6/version.pyrsc@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|jS)N)hash_key)selfrrr__hash__,sz_BaseVersion.__hash__cCs|j|ddS)NcSs||kS)Nr)sorrr0sz%_BaseVersion.__lt__..)_compare)rotherrrr__lt__/sz_BaseVersion.__lt__cCs|j|ddS)NcSs||kS)Nr)rr rrrr!3sz%_BaseVersion.__le__..)r")rr#rrr__le__2sz_BaseVersion.__le__cCs|j|ddS)NcSs||kS)Nr)rr rrrr!6sz%_BaseVersion.__eq__..)r")rr#rrr__eq__5sz_BaseVersion.__eq__cCs|j|ddS)NcSs||kS)Nr)rr rrrr!9sz%_BaseVersion.__ge__..)r")rr#rrr__ge__8sz_BaseVersion.__ge__cCs|j|ddS)NcSs||kS)Nr)rr rrrr!<sz%_BaseVersion.__gt__..)r")rr#rrr__gt__;sz_BaseVersion.__gt__cCs|j|ddS)NcSs||kS)Nr)rr rrrr!?sz%_BaseVersion.__ne__..)r")rr#rrr__ne__>sz_BaseVersion.__ne__cCst|tstS||j|jS)N) isinstancerNotImplementedr)rr#methodrrrr"As z_BaseVersion._compareN) rrrrr$r%r&r'r(r)r"rrrrr*src@s`eZdZddZddZddZeddZed d Zed d Z ed dZ eddZ dS)r cCst||_t|j|_dS)N)str_version_legacy_cmpkeyr)rrrrr__init__Js zLegacyVersion.__init__cCs|jS)N)r.)rrrr__str__NszLegacyVersion.__str__cCsdjtt|S)Nz)formatreprr-)rrrr__repr__QszLegacyVersion.__repr__cCs|jS)N)r.)rrrrpublicTszLegacyVersion.publiccCs|jS)N)r.)rrrr base_versionXszLegacyVersion.base_versioncCsdS)Nr)rrrrr\szLegacyVersion.localcCsdS)NFr)rrrr is_prerelease`szLegacyVersion.is_prereleasecCsdS)NFr)rrrris_postreleasedszLegacyVersion.is_postreleaseN) rrrr0r1r4propertyr5r6rr7r8rrrrr Hs    z(\d+ | [a-z]+ | \.| -)czfinal-@)rpreview-rcrccsbxVtj|D]H}tj||}| s |dkr,q |dddkrJ|jdVq d|Vq WdVdS)N.r 0123456789*z*final)_legacy_version_component_resplit_legacy_version_replacement_mapgetzfill)rpartrrr_parse_version_partsrs rIcCsd}g}xlt|jD]\}|jdrh|dkrJx|rH|ddkrH|jq.Wx|rf|ddkrf|jqLW|j|qWt|}||fS) NrrBz*finalz*final-Z00000000rJrJ)rIlower startswithpopappendtuple)rr partsrHrrrr/s   r/a 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@s|eZdZejdedejejBZddZ	ddZ
ddZed	d
Z
eddZed
dZeddZeddZdS)rz^\s*z\s*$c	Cs|jj|}|stdj|t|jdr8t|jdndtdd|jdjdDt	|jd|jd	t	|jd
|jdp|jdt	|jd
|jdt
|jdd|_t|jj
|jj|jj|jj|jj|jj|_dS)NzInvalid version: '{0}'r
rcss|]}t|VqdS)N)int).0irrr	sz#Version.__init__..rr?Zpre_lZpre_nZpost_lZpost_n1Zpost_n2Zdev_lZdev_nr)r
rrrrr)_regexsearchr
r2rgrouprQrOrD_parse_letter_version_parse_local_versionr._cmpkeyr
rrrrrr)rrmatchrrrr0s.

zVersion.__init__cCsdjtt|S)Nz)r2r3r-)rrrrr4szVersion.__repr__cCsg}|jjdkr$|jdj|jj|jdjdd|jjD|jjdk	rl|jdjdd|jjD|jjdk	r|jdj|jjd	|jjdk	r|jd
j|jjd	|jj	dk	r|jdjdjdd|jj	Ddj|S)
Nrz{0}!r?css|]}t|VqdS)N)r-)rRxrrrrTsz"Version.__str__..css|]}t|VqdS)N)r-)rRr\rrrrTsz.post{0}rz.dev{0}z+{0}css|]}t|VqdS)N)r-)rRr\rrrrTs)
r.r
rNr2joinrrrrr)rrPrrrr1s zVersion.__str__cCst|jdddS)N+rr)r-rD)rrrrr5
szVersion.publiccCsLg}|jjdkr$|jdj|jj|jdjdd|jjDdj|S)Nrz{0}!r?css|]}t|VqdS)N)r-)rRr\rrrrTsz'Version.base_version..r])r.r
rNr2r^r)rrPrrrr6s
zVersion.base_versioncCs$t|}d|kr |jdddSdS)Nr_r)r-rD)rZversion_stringrrrrsz
Version.localcCst|jjp|jjS)N)boolr.rr)rrrrr7!szVersion.is_prereleasecCst|jjS)N)r`r.r)rrrrr8%szVersion.is_postreleaseN)rrrrecompilerVERBOSE
IGNORECASErUr0r4r1r9r5r6rr7r8rrrrrs
#
cCsx|rZ|dkrd}|j}|dkr&d}n(|dkr4d}n|d
krBd	}n|dkrNd}|t|fS|rt|rtd}|t|fSdS)NrZalphaaZbetabr:rr<r>revrr)r:rr<)rgrh)rKrQ)ZletterZnumberrrrrX*s 
rXz[\._-]cCs$|dk	r tddtj|DSdS)zR
    Takes a string like abc.1.twelve and turns it into ("abc", 1, "twelve").
    Ncss&|]}|js|jnt|VqdS)N)isdigitrKrQ)rRrHrrrrTRsz'_parse_local_version..)rO_local_version_seperatorsrD)rrrrrYLsrYcCsttttjddt|}|dkr@|dkr@|dk	r@t}n|dkrLt}|dkrZt}|dkrft}|dkrvt}ntdd|D}||||||fS)NcSs|dkS)Nrr)r\rrrr!`sz_cmpkey..css*|]"}t|tr|dfnt|fVqdS)r]N)r*rQr)rRrSrrrrTsz_cmpkey..)rOreversedlist	itertools	dropwhiler)r
rrrrrrrrrZWs&		
rZ)Z
__future__rrrcollectionsrmraZ_structuresr__all__
namedtuplerr
ValueErrorr
objectrr	rbrcrCrErIr/rrrXrjrYrZrrrrs.!
9k