U
    [e&                     @   s   d Z ddlmZmZ ddlZddlZejdk r4dZndZzeZ	W n e
k
r\   dd Z	Y nX 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 dddg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 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      N )abr   r   V/var/www/html/services/stratfitenv/lib/python3.8/site-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kr|S |dkS Nr   __cmp__NotImplementedselfothercr   r   r
   __eq__8   s    
z_comparable.<locals>.__eq__c                 S   s   |  |}|tkr|S |dkS r   r   r   r   r   r
   __ne__>   s    
z_comparable.<locals>.__ne__c                 S   s   |  |}|tkr|S |dk S r   r   r   r   r   r
   __lt__D   s    
z_comparable.<locals>.__lt__c                 S   s   |  |}|tkr|S |dkS r   r   r   r   r   r
   __le__J   s    
z_comparable.<locals>.__le__c                 S   s   |  |}|tkr|S |dkS r   r   r   r   r   r
   __gt__P   s    
z_comparable.<locals>.__gt__c                 S   s   |  |}|tkr|S |dkS r   r   r   r   r   r
   __ge__V   s    
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 k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                   @   sR   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n|r.|s.|}tjdtdd |dkrR|sJ|sJ|sJ|sJ|rRt 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.   r/   r0   
prereleaser1   r2   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+   r0   r   r   r   r
   r3      s    	zVersion.prereleasec                 C   s~   | j dkr| j S | jdkr d}nd| jf }| jdkr<d}nd| jf }| jdkrXd}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-   r0   r1   r2   r.   r/   )r   rcr1   r2   r   r   r
   public   s    



zVersion.publicc              	   C   sx   | j d krd}nd| j f }| jd kr,d}nd| jf }| jd krHd}nd| jf }d| jj| j| j| j| j|||f S )Nr6   z, release_candidate=%rz	, post=%rz, dev=%rz%s(%r, %r, %d, %d%s%s%s))	r0   r1   r2   	__class__r   r,   r-   r.   r/   )r   r0   r1   r2   r   r   r
   __repr__   s&    


zVersion.__repr__c                 C   s   d| j |  f S )Nz[%s, version %s]r,   shortr5   r   r   r
   __str__  s    zVersion.__str__c                 C   s  t || jstS | j |j kr8td| j|jf | jdkrHt}n| j}| jdkr^t}n| j}| j	dkrtd}n| j	}| j
dkrt}n| j
}|jdkrt}n|j}|jdkrt}n|j}|j	dkrd}n|j	}|j
dkrt}	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   )
isinstancer9   r   r,   lowerr"   r-   r   r0   r1   r2   r   r.   r/   )r   r   r-   r0   r1   r2   Z
othermajorZotherrcZ	otherpostZotherdevxr   r   r
   r     sB    







zVersion.__cmp__)NNNN)r   r   r    r!   r4   propertyr3   r8   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    rF   c              
   C   s   |sdS ddl m} || }|  | D ]P}|d dkr.i }t|d }t| | W 5 Q R X |d  | j_	 dS q.t
ddS )	zF
    Get the version from the package listed in the Distribution.
    Nr   )build_pyr   _versionr$   __version__zNo _version.py found.)distutils.commandrG   finalize_optionsZfind_all_modulesopenexecreadr8   metadatarD   	Exception)distkeywordvaluerG   Z
sp_commanditemZversion_filefr   r   r
   _get_versionn  s    
rV   r   )rI   rI   )r!   
__future__r   r   sysr)   version_infor   cmpr   	NameErrorr   objectr   	TypeErrorr"   r#   rF   rV   rH   rI   __all__r   r   r   r
   <module>   s,   
? ]