
    ؒeU+                        d Z ddlmZmZ ddlZddlZddlmZmZm	Z	m
Z
mZmZ  e	dd      ZerddlmZ dd	lmZ neZej(                  d
kD  rd ZneZ G d de      Z e       Z G d de      Z G d de      Zd Zd ZddlmZ d Z g dZ!y)z0
Versions for Python packages.

See L{Version}.
    )divisionabsolute_importN)TYPE_CHECKINGAnyTypeVarUnionOptionalDict_TT)contravariant)Literal)Distribution   c                     | |k  ry| |k(  ryy)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bs     6/usr/lib/python3/dist-packages/incremental/__init__.py_cmpr   !   s     q5!V    c                   N    e Zd ZdZd Zej                  dk\  rd Zd Zd Z	d Z
yy)	_Infz:
    An object that is bigger than all other objects.
    c                     |t         u ryy)z
        @param other: Another object.
        @type other: any

        @return: 0 if other is inf, 1 otherwise.
        @rtype: C{int}
        r   r   )_infselfothers     r   __cmp__z_Inf.__cmp__>   s     D=r   r   c                 *    | j                  |      dk  S Nr   r!   r   s     r   __lt__z_Inf.__lt__L       <<&**r   c                 *    | j                  |      dk  S r#   r$   r   s     r   __le__z_Inf.__le__O       <<&!++r   c                 *    | j                  |      dkD  S r#   r$   r   s     r   __gt__z_Inf.__gt__R   r&   r   c                 *    | j                  |      dk\  S r#   r$   r   s     r   __ge__z_Inf.__ge__U   r)   r   N)__name__
__module____qualname____doc__r!   sysversion_infor%   r(   r+   r-   r   r   r   r   r   9   s5    
 4	+	,	+	,  r   r   c                       e Zd ZdZy)IncomparableVersionsz-
    Two versions could not be compared.
    N)r.   r/   r0   r1   r   r   r   r5   r5   \   s    r   r5   c                       e Zd ZdZ	 	 	 	 ddZed        Zd ZeZeZ	eZ
d Zd Zd Zej                  d	k\  rd
 Zd Zd Zd Zd Zd Zyy)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	                     |r|rt        d      |r |s|}t        j                  dt        d       |dk(  r|s|s|s|s|rt        d      || _        || _        || _        || _        || _        || _	        || _
        y)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   rA   rB   rC   rD   rE   
prereleaserF   rG   s	            r   __init__zVersion.__init__k   s    : ?@@ 1 *MM- # F?!2dc Q  


!2	r   c                 T    t        j                  dt        d      f | j                  S )NzuAccessing incremental.Version.prerelease was deprecated in Incremental 16.9.0. Use Version.release_candidate instead.r9   r:   )r>   r?   r@   rE   r   s    r   rH   zVersion.prerelease   s.    1 	
 	 %%%r   c                 >   | j                   dk(  r| j                   S | j                  d}nd| j                  }| j                  d}nd| j                  }| j                  d}nd| j                  }d| j                   | j                  | j
                  |||fz  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<    z.rcz.postz.devz%r.%d.%d%s%s%s)rB   rE   rF   rG   rC   rD   )r   rcrF   rG   s       r   publiczVersion.public   s     ::::!!)B * !224B99D  !%		+D88C  #hh(C4::tzz4::r4QT"UUUr   c           	      H   | j                   d}nd| j                   }| j                  d}nd| j                  }| j                  d}nd| j                  }d| j                  j                  | j
                  | j                  | j                  | j                  |||fz  S )NrM   z, release_candidate=z, post=z, dev=z%s(%r, %r, %d, %d%s%s%s))	rE   rF   rG   	__class__r.   rA   rB   rC   rD   )r   rE   rF   rG   s       r   __repr__zVersion.__repr__   s    !!) " * =A<R<R T99D  #'))-D88C  !%*C)NN##LLJJJJJJ	-
 	
 		
r   c                 D    d| j                   d| j                         dS )N[z
, version ]rA   shortrK   s    r   __str__zVersion.__str__   s    %)\\4::<@@r   c           	      \   t        || j                        st        S | j                  j	                         |j                  j	                         k7  r$t        | j                  d|j                        | j                  dk(  rt        }n| j                  }| j                  t        }n| j                  }| j                  d}n| j                  }| j                  t        }n| j                  }|j                  dk(  rt        }n|j                  }|j                  t        }n|j                  }|j                  d}n|j                  }|j                  t        }	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<   r   )
isinstancerQ   NotImplementedrA   lowerr5   rB   r   rE   rF   rG   r   rC   rD   )r   r    rB   rE   rF   rG   
othermajorotherrc	otherpostotherdevxs              r   r!   zVersion.__cmp__   sb   . %0!!<<5==#6#6#88&T\\5=='QRR::EJJE!!) $ $ 6 699D99D88C((C;;& JJ""*G--G::I

I99HyyHDJJ

,=tSIekk7IxP
 r   r   c                 B    | j                  |      }|t        u r|S |dk(  S r#   r!   r[   r   r    cs      r   __eq__zVersion.__eq__;  &    U#AN"6Mr   c                 B    | j                  |      }|t        u r|S |dk7  S r#   rc   rd   s      r   __ne__zVersion.__ne__A  rg   r   c                 B    | j                  |      }|t        u r|S |dk  S r#   rc   rd   s      r   r%   zVersion.__lt__G  &    U#AN"q5Lr   c                 B    | j                  |      }|t        u r|S |dk  S r#   rc   rd   s      r   r(   zVersion.__le__M  rg   r   c                 B    | j                  |      }|t        u r|S |dkD  S r#   rc   rd   s      r   r+   zVersion.__gt__S  rk   r   c                 B    | j                  |      }|t        u r|S |dk\  S r#   rc   rd   s      r   r-   zVersion.__ge__Y  rg   r   )NNNN)r.   r/   r0   r1   rI   propertyrH   rO   baserW   localrR   rX   r!   r2   r3   rf   ri   r%   r(   r+   r-   r   r   r   r7   r7   b   s     5n & &V> DEE
8AHT 4						A  r   r7   c                 D    | j                   d| j                         }|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.
     rV   )versionresults     r   getVersionStringrv   `  s      9FMr   c                 l   |syddl m} |j                  |       }|j                          |j                         D ]a  }|d   dk(  si }t	        |d         5 }t        |j                         |       ddd       |d   j                         | j                  _	         y t        d      # 1 sw Y   9xY w)	zF
    Get the version from the package listed in the Distribution.
    Nr   )build_pyr   _versionr9   __version__zNo _version.py found.)distutils.commandrx   finalize_optionsfind_all_modulesopenexecreadrO   metadatart   	Exception)distkeywordvaluerx   
sp_commanditemversion_filefs           r   _get_versionr   k  s     *""4(J!++- 7j Ld1g -!QVVX|,- %1$?$F$F$HDMM! +
,,- -s   B**B3	r   )rz   c                  *    t        j                         S )N)rz   rO   r   r   r   _setuptools_versionr     s    r   )rz   r7   rv   )"r1   
__future__r   r   r2   r>   typingr   r   r   r   r	   r
   r   typing_extensionsr   distutils.distr   _Distributionobjectr3   r   cmpr   r   	TypeErrorr5   r7   rv   r   ry   rz   r   __all__r   r   r   <module>r      s    1 
  E E T& )< Md  D,6 ,@ v9 {f {|-2 "  9r   