U cfR? @sdZddlmZddlZddlZddlmZmZmZm Z m Z m Z ddl m Z mZmZmZddd d gZe e eefd fZe eee eeffZe ee e e eefe ee eefffd ffZe ee ed feeeefZeeegefZGd d d eZdd dddZGdd d eZGdddZdZeZ Gdd d eZ!ddddddZ"e#dZ$ddddd Z%d!d"ddddd#d$d%d&Z&dS)'zN .. testsetup:: from pip._vendor.packaging.version import parse, Version ) annotationsN)AnyCallable NamedTuple SupportsIntTupleUnion)Infinity InfinityTypeNegativeInfinityNegativeInfinityTypeVERSION_PATTERNparseVersionInvalidVersion.c@s>eZdZUded<ded<ded<ded<ded<d ed <d S) _Versionintepochtuple[int, ...]releasetuple[str, int] | NonedevprepostLocalType | NonelocalN)__name__ __module__ __qualname____annotations__r!r!K/opt/hc_python/lib/python3.8/site-packages/pip/_vendor/packaging/version.pyr&s rstrversionreturncCst|S)zParse the given version string. >>> parse('1.0.dev1') :param version: The version string to parse. :raises InvalidVersion: When the version string is not a valid version. )r)r%r!r!r"r/s c@seZdZdZdS)rzRaised when a version string is not a valid version. >>> Version("invalid") Traceback (most recent call last): ... packaging.version.InvalidVersion: Invalid version: 'invalid' N)rrr__doc__r!r!r!r"r;sc@seZdZUded<ddddZdddd d Zdddd d Zd ddddZdddddZdddddZ d ddddZ dS) _BaseVersionztuple[Any, ...]_keyrr&cCs t|jSN)hashr)selfr!r!r"__hash__Hsz_BaseVersion.__hash__bool)otherr&cCst|tstS|j|jkSr+ isinstancer(NotImplementedr)r.r1r!r!r"__lt__Ns z_BaseVersion.__lt__cCst|tstS|j|jkSr+r2r5r!r!r"__le__Ts z_BaseVersion.__le__objectcCst|tstS|j|jkSr+r2r5r!r!r"__eq__Zs z_BaseVersion.__eq__cCst|tstS|j|jkSr+r2r5r!r!r"__ge__`s z_BaseVersion.__ge__cCst|tstS|j|jkSr+r2r5r!r!r"__gt__fs z_BaseVersion.__gt__cCst|tstS|j|jkSr+r2r5r!r!r"__ne__ls z_BaseVersion.__ne__N) rrrr r/r6r7r9r:r;r<r!r!r!r"r(Es r(a v? (?: (?:(?P[0-9]+)!)? # epoch (?P[0-9]+(?:\.[0-9]+)*) # release segment (?P
                                          # pre-release
            [-_\.]?
            (?Palpha|a|beta|b|preview|pre|c|rc)
            [-_\.]?
            (?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^eZdZUdZededejejBZ	de
d<dddd	d
Zdddd
ZddddZ
eddddZeddddZeddddZeddddZeddddZedddd Zeddd!d"Zeddd#d$Zed%dd&d'Zed%dd(d)Zed%dd*d+Zeddd,d-Zeddd.d/Zeddd0d1Zd2S)3raThis class abstracts handling of a project's versions.

    A :class:`Version` instance is comparison aware and can be compared and
    sorted using the standard Python interfaces.

    >>> v1 = Version("1.0a5")
    >>> v2 = Version("1.0")
    >>> v1
    
    >>> v2
    
    >>> v1 < v2
    True
    >>> v1 == v2
    False
    >>> v1 > v2
    False
    >>> v1 >= v2
    False
    >>> v1 <= v2
    True
    z^\s*z\s*$CmpKeyr)r#Noner$c
Cs|j|}|s td|dt|dr:t|dndtdd|ddDt|d	|d
t|d|dp|d
t|d|dt	|dd|_
t|j
j|j
j
|j
j|j
j|j
j|j
j|_dS)aCInitialize a Version object.

        :param version:
            The string representation of a version which will be parsed and normalized
            before use.
        :raises InvalidVersion:
            If the ``version`` does not conform to PEP 440 in any way then this
            exception will be raised.
        zInvalid version: ''rrcss|]}t|VqdSr+)r.0ir!r!r"	sz#Version.__init__..r.pre_lpre_npost_lpost_n1post_n2dev_ldev_nr)rrrrrrN)_regexsearchrrgrouprtuplesplit_parse_letter_version_parse_local_version_version_cmpkeyrrrrrrr))r.r%matchr!r!r"__init__s,zVersion.__init__r*cCsd|dS)zA representation of the Version that shows all internal state.

        >>> Version('1.0.0')
        
        z
r!r-r!r!r"__repr__szVersion.__repr__cCsg}|jdkr ||jd|ddd|jD|jdk	rb|ddd|jD|jdk	r~|d	|j|jdk	r|d
|j|jdk	r|d|jd|S)zA string representation of the version that can be rounded-tripped.

        >>> str(Version("1.0a5"))
        '1.0a5'
        r!rDcss|]}t|VqdSr+r#rAxr!r!r"rCsz"Version.__str__..Ncss|]}t|VqdSr+rYrZr!r!r"rCsz.postz.dev+)rappendjoinrrrrrr.partsr!r!r"__str__s




zVersion.__str__rcCs|jjS)zThe epoch of the version.

        >>> Version("2.0.0").epoch
        0
        >>> Version("1!2.0.0").epoch
        1
        )rSrr-r!r!r"rs	z
Version.epochrcCs|jjS)adThe components of the "release" segment of the version.

        >>> Version("1.2.3").release
        (1, 2, 3)
        >>> Version("2.0.0").release
        (2, 0, 0)
        >>> Version("1!2.0.0.post0").release
        (2, 0, 0)

        Includes trailing zeroes but not the epoch or any pre-release / development /
        post-release suffixes.
        )rSrr-r!r!r"rszVersion.releasercCs|jjS)aThe pre-release segment of the version.

        >>> print(Version("1.2.3").pre)
        None
        >>> Version("1.2.3a1").pre
        ('a', 1)
        >>> Version("1.2.3b1").pre
        ('b', 1)
        >>> Version("1.2.3rc1").pre
        ('rc', 1)
        )rSrr-r!r!r"r&s
zVersion.prez
int | NonecCs|jjr|jjdSdS)zThe post-release number of the version.

        >>> print(Version("1.2.3").post)
        None
        >>> Version("1.2.3.post1").post
        1
        r	N)rSrr-r!r!r"r5s	zVersion.postcCs|jjr|jjdSdS)zThe development number of the version.

        >>> print(Version("1.2.3").dev)
        None
        >>> Version("1.2.3.dev1").dev
        1
        r	N)rSrr-r!r!r"r@s	zVersion.dev
str | NonecCs(|jjr ddd|jjDSdSdS)zThe local version segment of the version.

        >>> print(Version("1.2.3").local)
        None
        >>> Version("1.2.3+abc").local
        'abc'
        rDcss|]}t|VqdSr+rYrZr!r!r"rCUsz Version.local..N)rSrr_r-r!r!r"rKs	z
Version.localcCst|dddS)zThe public portion of the version.

        >>> Version("1.2.3").public
        '1.2.3'
        >>> Version("1.2.3+abc").public
        '1.2.3'
        >>> Version("1.2.3+abc.dev1").public
        '1.2.3'
        r]r	r)r#rPr-r!r!r"publicYszVersion.publiccCsFg}|jdkr ||jd|ddd|jDd|S)a]The "base version" of the version.

        >>> Version("1.2.3").base_version
        '1.2.3'
        >>> Version("1.2.3+abc").base_version
        '1.2.3'
        >>> Version("1!1.2.3+abc.dev1").base_version
        '1!1.2.3'

        The "base version" is the public version of the project without any pre or post
        release markers.
        rrXrDcss|]}t|VqdSr+rYrZr!r!r"rC{sz'Version.base_version..r\)rr^r_rr`r!r!r"base_versionfs

zVersion.base_versionr0cCs|jdk	p|jdk	S)aTWhether this version is a pre-release.

        >>> Version("1.2.3").is_prerelease
        False
        >>> Version("1.2.3a1").is_prerelease
        True
        >>> Version("1.2.3b1").is_prerelease
        True
        >>> Version("1.2.3rc1").is_prerelease
        True
        >>> Version("1.2.3dev1").is_prerelease
        True
        N)rrr-r!r!r"
is_prereleaseszVersion.is_prereleasecCs
|jdk	S)zWhether this version is a post-release.

        >>> Version("1.2.3").is_postrelease
        False
        >>> Version("1.2.3.post1").is_postrelease
        True
        N)rr-r!r!r"is_postreleases	zVersion.is_postreleasecCs
|jdk	S)zWhether this version is a development release.

        >>> Version("1.2.3").is_devrelease
        False
        >>> Version("1.2.3.dev1").is_devrelease
        True
        N)rr-r!r!r"
is_devreleases	zVersion.is_devreleasecCst|jdkr|jdSdS)zqThe first item of :attr:`release` or ``0`` if unavailable.

        >>> Version("1.2.3").major
        1
        r	rlenrr-r!r!r"majorsz
Version.majorcCst|jdkr|jdSdS)zThe second item of :attr:`release` or ``0`` if unavailable.

        >>> Version("1.2.3").minor
        2
        >>> Version("1").minor
        0
        r	rrir-r!r!r"minors	z
Version.minorcCst|jdkr|jdSdS)zThe third item of :attr:`release` or ``0`` if unavailable.

        >>> Version("1.2.3").micro
        3
        >>> Version("1").micro
        0
        rlrrir-r!r!r"micros	z
Version.microN)rrrr'recompilerVERBOSE
IGNORECASErLr rVrWrbpropertyrrrrrrrdrerfrgrhrkrmror!r!r!r"rsD
&!






rcz str | bytes | SupportsInt | Noner)letternumberr&cCsv|rZ|dkrd}|}|dkr&d}n(|dkr4d}n|dkrBd}n|dkrNd	}|t|fS|sr|rrd	}|t|fSdS)
Nralphaabetab)crpreviewrc)revrr)lowerr)rurvr!r!r"rQs"rQz[\._-]r)rr&cCs$|dk	r tddt|DSdS)zR
    Takes a string like abc.1.twelve and turns it into ("abc", 1, "twelve").
    Ncss&|]}|s|nt|VqdSr+)isdigitrr)rApartr!r!r"rCsz'_parse_local_version..)rO_local_version_separatorsrP)rr!r!r"rRs
rRrrr=)rrrrrrr&cCsttttddt|}|dkr>|dkr>|dk	r>t}n|dkrLt}n|}|dkr^t}n|}|dkrpt}	n|}	|dkrt}
ntdd|D}
|||||	|
fS)NcSs|dkS)Nrr!)r[r!r!r"z_cmpkey..css(|] }t|tr|dfnt|fVqdS)r\N)r3rrr@r!r!r"rC/sz_cmpkey..)rOreversedlist	itertools	dropwhilerr
)rrrrrr_release_pre_post_dev_localr!r!r"rTs(
	rT)'r'
__future__rrrptypingrrrrrr_structuresr
rrr
__all__rr#	LocalTypeZCmpPrePostDevTypeZCmpLocalTyper=r0VersionComparisonMethodrr
ValueErrorrr(Z_VERSION_PATTERNrrrQrqrrRrTr!r!r!r"sH *
	
0
'#