o
    @˜=`Á&  ã                   @   sÊ   d Z ddlmZmZ ddlZddlZejdk rdZndZzeZ	W n e
y-   dd„ Z	Y nw d	d
„ ZeG dd„ deƒƒZeƒ ZG dd„ deƒZeG dd„ deƒƒZdd„ Zdd„ ZddlmZ g d¢ZdS )z0
Versions for Python packages.

See L{Version}.
é    )ÚdivisionÚabsolute_importN)é   r   FTc                 C   s   | |k rdS | |krdS dS )z™
        Compare two objects.

        Returns a negative number if C{a < b}, zero if they are equal, and a
        positive number if C{a > b}.
        éÿÿÿÿr   é   © )ÚaÚbr   r   ú6/usr/lib/python3/dist-packages/incremental/__init__.pyÚ_cmp   s
   r   c                 C   s`   t s| S dd„ }dd„ }dd„ }dd„ }d	d
„ }dd„ }|| _|| _|| _|| _|| _|| _| S )zü
    Class decorator that ensures support for the special C{__cmp__} method.

    On Python 2 this does nothing.

    On Python 3, C{__eq__}, C{__lt__}, etc. methods are added to the class,
    relying on C{__cmp__} to implement their comparisons.
    c                 S   s   |   |¡}|tu r|S |dkS ©Nr   ©Ú__cmp__ÚNotImplemented©ÚselfÚotherÚcr   r   r
   Ú__eq__8   ó   
z_comparable.<locals>.__eq__c                 S   s   |   |¡}|tu r|S |dkS r   r   r   r   r   r
   Ú__ne__>   r   z_comparable.<locals>.__ne__c                 S   s   |   |¡}|tu r|S |dk S r   r   r   r   r   r
   Ú__lt__D   r   z_comparable.<locals>.__lt__c                 S   s   |   |¡}|tu r|S |dkS r   r   r   r   r   r
   Ú__le__J   r   z_comparable.<locals>.__le__c                 S   s   |   |¡}|tu r|S |dkS r   r   r   r   r   r
   Ú__gt__P   r   z_comparable.<locals>.__gt__c                 S   s   |   |¡}|tu r|S |dkS r   r   r   r   r   r
   Ú__ge__V   r   z_comparable.<locals>.__ge__)Ú_PY3r   r   r   r   r   r   )Úklassr   r   r   r   r   r   r   r   r
   Ú_comparable+   s   
r   c                   @   s   e Zd ZdZdd„ ZdS )Ú_infz:
    An object that is bigger than all other objects.
    c                 C   s   |t u rdS dS )z‘
        @param other: Another object.
        @type other: any

        @return: 0 if other is inf, 1 otherwise.
        @rtype: C{int}
        r   r   )r   )r   r   r   r   r
   r   p   s   z_inf.__cmp__N)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r   r   r   r
   r   j   s    r   c                   @   s   e Zd ZdZdS )ÚIncomparableVersionsz-
    Two versions could not be compared.
    N)r   r    r!   r"   r   r   r   r
   r#   €   s    r#   c                   @   sZ   e Zd ZdZ				ddd„Zedd„ ƒZdd„ ZeZeZ	eZ
d	d
„ Zdd„ Zdd„ ZdS )ÚVersionzÑ
    An encapsulation of a version for a project, with support for outputting
    PEP-440 compatible version strings.

    This class supports the standard major.minor.micro[rcN] scheme of
    versioning.
    Nc	           	      C   s~   |r|rt dƒ‚|r|s|}tjdtdd� |dkr(|s$|s$|s$|s$|r(t dƒ‚|| _|| _|| _|| _|| _|| _	|| _
dS )aÒ  
        @param package: Name of the package that this is a version of.
        @type package: C{str}
        @param major: The major version number.
        @type major: C{int} or C{str} (for the "NEXT" symbol)
        @param minor: The minor version number.
        @type minor: C{int}
        @param micro: The micro version number.
        @type micro: C{int}
        @param release_candidate: The release candidate number.
        @type release_candidate: C{int}
        @param prerelease: The prerelease number. (Deprecated)
        @type prerelease: C{int}
        @param post: The postrelease number.
        @type post: C{int}
        @param dev: The development release number.
        @type dev: C{int}
        z Please only return one of these.zvPassing prerelease to incremental.Version was deprecated in Incremental 16.9.0. Please pass release_candidate instead.é   ©Ú
stacklevelÚNEXTz;When using NEXT, all other values except Package must be 0.N)Ú
ValueErrorÚwarningsÚwarnÚDeprecationWarningÚpackageÚmajorÚminorÚmicroÚrelease_candidateÚpostÚdev)	r   r-   r.   r/   r0   r1   Ú
prereleaser2   r3   r   r   r
   Ú__init__�   s*   ù
ÿ
zVersion.__init__c                 C   s   t jdtdd�f | jS )NzuAccessing incremental.Version.prerelease was deprecated in Incremental 16.9.0. Use Version.release_candidate instead.r%   r&   )r*   r+   r,   r1   ©r   r   r   r
   r4   É   s   ù	zVersion.prereleasec                 C   s~   | j dkr| j S | jdu rd}nd| jf }| jdu rd}nd| jf }| jdu r,d}nd| jf }d| j | j| j|||f S )zÆ
        Return a PEP440-compatible "public" representation of this L{Version}.

        Examples:

          - 14.4.0
          - 1.2.3rc1
          - 14.2.1rc1dev9
          - 16.04.0dev0
        r(   NÚ z.rc%sz.post%sz.dev%sz%r.%d.%d%s%s%s)r.   r1   r2   r3   r/   r0   )r   Úrcr2   r3   r   r   r
   ÚpublicÖ   s   



zVersion.publicc              	   C   sx   | j d u rd}nd| j f }| jd u rd}nd| jf }| jd u r$d}nd| jf }d| jj| j| j| j| j|||f S )Nr7   z, release_candidate=%rz	, post=%rz, dev=%rz%s(%r, %r, %d, %d%s%s%s))	r1   r2   r3   Ú	__class__r   r-   r.   r/   r0   )r   r1   r2   r3   r   r   r
   Ú__repr__ù   s&   


øzVersion.__repr__c                 C   s   d| j |  ¡ f S )Nz[%s, version %s]©r-   Úshortr6   r   r   r
   Ú__str__  s   zVersion.__str__c                 C   s  t || jƒstS | j ¡ |j ¡ krtd| j|jf ƒ‚| jdkr$t}n| j}| jdu r/t}n| j}| j	du r:d}n| j	}| j
du rEt}n| j
}|jdkrPt}n|j}|jdu r[t}n|j}|j	du rfd}n|j	}|j
du rqt}	n|j
}	t|| j| j|||f||j|j|||	fƒ}
|
S )aw  
        Compare two versions, considering major versions, minor versions, micro
        versions, then release candidates, then postreleases, then dev
        releases. Package names are case insensitive.

        A version with a release candidate is always less than a version
        without a release candidate. If both versions have release candidates,
        they will be included in the comparison.

        Likewise, a version with a dev release is always less than a version
        without a dev release. If both versions have dev releases, they will
        be included in the comparison.

        @param other: Another version.
        @type other: L{Version}

        @return: NotImplemented when the other object is not a Version, or one
            of -1, 0, or 1.

        @raise IncomparableVersions: when the package names of the versions
            differ.
        z%r != %rr(   Nr   )Ú
isinstancer:   r   r-   Úlowerr#   r.   r   r1   r2   r3   r   r/   r0   )r   r   r.   r1   r2   r3   Ú
othermajorÚotherrcÚ	otherpostÚotherdevÚxr   r   r
   r     sB   







þzVersion.__cmp__)NNNN)r   r    r!   r"   r5   Úpropertyr4   r9   Úbaser=   Úlocalr;   r>   r   r   r   r   r
   r$   †   s     
÷9
r$   c                 C   s   d| j |  ¡ f }|S )z®
    Get a friendly string for the given version object.

    @param version: A L{Version} object.
    @return: A string containing the package and short version number.
    z%s %sr<   )ÚversionÚresultr   r   r
   ÚgetVersionStringc  s   rK   c              	   C   sœ   |sdS ddl m} | | ¡}| ¡  | ¡ D ]2}|d dkrIi }t|d ƒ�}t| ¡ |ƒ W d  ƒ n1 s9w   Y  |d  ¡ | j_	 dS qt
dƒ‚)	zF
    Get the version from the package listed in the Distribution.
    Nr   )Úbuild_pyr   Ú_versionr%   Ú__version__zNo _version.py found.)Údistutils.commandrL   Úfinalize_optionsÚfind_all_modulesÚopenÚexecÚreadr9   ÚmetadatarI   Ú	Exception)ÚdistÚkeywordÚvaluerL   Ú
sp_commandÚitemÚversion_fileÚfr   r   r
   Ú_get_versionn  s   
ÿù	r^   r   )rN   )rN   r$   rK   )r"   Ú
__future__r   r   Úsysr*   Úversion_infor   Úcmpr   Ú	NameErrorr   Úobjectr   Ú	TypeErrorr#   r$   rK   r^   rM   rN   Ú__all__r   r   r   r
   Ú<module>   s0   
þ? ]