o
    Îó·i¾=  ã                   @   s|  d Z ddlZddlZddlZddlmZ ddlmZmZm	Z	m
Z
mZmZmZ er.ddlmZ dededefd	d
„ZG dd„ dƒZeƒ ZG dd„ deƒZG dd„ dƒZdedefdd„Zdededefdd„Zdedefdd„Zd3dd„Zddded eddfd!d"„Zd#e	defd$d%„Zed&d'�G d(d)„ d)ƒƒZ d*ede fd+d,„Z!d-e
eef dee
eef  fd.d/„Z"d0d1l#m$Z$ g d2¢Z%dS )4z0
Versions for Python packages.

See L{Version}.
é    N)Ú	dataclass)ÚTYPE_CHECKINGÚAnyÚBinaryIOÚDictÚLiteralÚOptionalÚUnion)ÚDistributionÚaÚbÚreturnc                 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   é   N© )r   r   r   r   úZC:\Users\psant\Downloads\PAF backend\school\venv\Lib\site-packages\incremental/__init__.pyÚ_cmp   s
   r   c                   @   sj   e Zd ZdZdedefdd„Zdedefdd„Zdedefdd	„Z	dedefd
d„Z
dedefdd„ZdS )Ú_Infz:
    An object that is bigger than all other objects.
    Úotherr   c                 C   s   |t u rdS dS )zz
        @param other: Another object.
        @type other: any

        @return: 0 if other is inf, 1 otherwise.
        r   r   N)Ú_inf©Úselfr   r   r   r   Ú__cmp__2   s   z_Inf.__cmp__c                 C   s   |   |¡dk S ©Nr   ©r   r   r   r   r   Ú__lt__=   ó   z_Inf.__lt__c                 C   s   |   |¡dkS r   r   r   r   r   r   Ú__le__@   r   z_Inf.__le__c                 C   s   |   |¡dkS r   r   r   r   r   r   Ú__gt__C   r   z_Inf.__gt__c                 C   s   |   |¡dkS r   r   r   r   r   r   Ú__ge__F   r   z_Inf.__ge__N)Ú__name__Ú
__module__Ú__qualname__Ú__doc__ÚobjectÚintr   Úboolr   r   r   r   r   r   r   r   r   -   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'   M   s    r'   c                   @   s*  e Zd ZdZ				d&dedeed ef dededee d	ee d
ee dee fdd„Z	e
dee fdd„ƒZdefdd„ZeZeZeZdefdd„Zdefdd„Zdedefdd„Zdedefdd„Zdedefdd„Zdedefdd„Zdedefd d!„Zdedefd"d#„Zdedef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.
    NÚpackageÚmajorÚNEXTÚminorÚmicroÚrelease_candidateÚ
prereleaseÚpostÚdevc	           	      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.é   ©Ú
stacklevelr+   z;When using NEXT, all other values except Package must be 0.N)Ú
ValueErrorÚwarningsÚwarnÚDeprecationWarningr)   r*   r,   r-   r.   r0   r1   )	r   r)   r*   r,   r-   r.   r/   r0   r1   r   r   r   Ú__init__\   s*   ûÿ
zVersion.__init__r   c                 C   s   t jdtdd� | jS )NzuAccessing incremental.Version.prerelease was deprecated in Incremental 16.9.0. Use Version.release_candidate instead.r2   r3   )r6   r7   r8   r.   ©r   r   r   r   r/   “   s   ûzVersion.prereleasec                 C   sŽ   | j dkr| j S | jdu rd}nd| j› �}| jdu rd}nd| j› �}| jdu r,d}nd| j› �}| j ›d| jd›d| jd›|› |› |› �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Ú Úrcz.postz.devÚ.Úd)r*   r.   r0   r1   r,   r-   )r   r<   r0   r1   r   r   r   Úpublicž   s   



*zVersion.publicc                 C   s’   | j d u rd}nd| j ›�}| jd u rd}nd| j›�}| jd u r$d}nd| j›�}| jj› d| j›d| j›d| jd›d| jd›|› |› |› d�S )	Nr;   z, release_candidate=z, post=z, dev=ú(z, r>   ú))	r.   r0   r1   Ú	__class__r    r)   r*   r,   r-   )r   r.   r0   r1   r   r   r   Ú__repr__Á   s2   



ÿÿÿÿþþþÿzVersion.__repr__c                 C   s   d| j › d|  ¡ › d�S )Nú[z
, version ú]©r)   Úshortr:   r   r   r   Ú__str__×   s   zVersion.__str__r   c                 C   s  t || jƒstS | j ¡ |j ¡ krt| j›d|j›�ƒ‚| jdkr%t}n| j}| jdu r0t}n| j}| j	du r;d}n| j	}| j
du rFt}n| j
}|jdkrQt}n|j}|jdu r\t}n|j}|j	du rgd}n|j	}|j
du rrt}	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+   Nr   )Ú
isinstancerB   ÚNotImplementedr)   Úlowerr'   r*   r   r.   r0   r1   r   r,   r-   )r   r   r*   r.   r0   r1   Z
othermajorZotherrcZ	otherpostZotherdevÚxr   r   r   r   Ú   sB   







þzVersion.__cmp__c                 C   s   |   |¡}|tu r|S |dkS r   ©r   rJ   ©r   r   Úcr   r   r   Ú__eq__(  ó   
zVersion.__eq__c                 C   s   |   |¡}|tu r|S |dkS r   rM   rN   r   r   r   Ú__ne__.  rQ   zVersion.__ne__c                 C   s   |   |¡}|tu r|S |dk S r   rM   rN   r   r   r   r   4  rQ   zVersion.__lt__c                 C   s   |   |¡}|tu r|S |dkS r   rM   rN   r   r   r   r   :  rQ   zVersion.__le__c                 C   s   |   |¡}|tu r|S |dkS r   rM   rN   r   r   r   r   @  rQ   zVersion.__gt__c                 C   s   |   |¡}|tu r|S |dkS r   rM   rN   r   r   r   r   F  rQ   zVersion.__ge__)NNNN)r    r!   r"   r#   Ústrr	   r   r%   r   r9   Úpropertyr/   r?   ÚbaserG   ÚlocalrC   rH   r$   r   r&   rP   rR   r   r   r   r   r   r   r   r   r(   S   sL    ÷þýüûúùø	
÷7
Nr(   Úversionc                 C   s   | j › d|  ¡ › �}|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.
    ú NrF   )rW   Úresultr   r   r   ÚgetVersionStringM  s   rZ   Úpathr)   c                 C   s`   t j | d| ¡ ¡}t j | | ¡ ¡}t j |¡r|S t j |¡r#|S td|› d|› d|› �ƒ‚)zš
    Determine the package root directory.

    The result is one of:

        - src/{package}
        - {package}

    Where {package} is downcased.
    Úsrcz$Can't find the directory of project z: I looked in z and N)Úosr[   ÚjoinrK   Úisdirr5   )r[   r)   Úsrc_dirZcurrent_dirr   r   r   Ú	_findPathX  s   ÿra   Úversion_pathc                 C   sH   i }t | ƒ�}t| ¡ |ƒ W d  ƒ |d S 1 sw   Y  |d S )z?
    Load the current version from a ``_version.py`` file.
    NÚ__version__)ÚopenÚexecÚread)rb   Úversion_infoÚfr   r   r   Ú_existing_versionp  s   

ÿýri   ÚdistÚ_Distributionc                 C   s`   zt dƒ}W n
 ty   Y dS w |jsdS zt|jƒ}W n
 ty'   Y dS w | ¡ | j_dS )a’  
    Setuptools integration: load the version from the working directory

    This function is registered as a setuptools.finalize_distribution_options
    entry point [1]. Consequently, it is called in all sorts of weird
    contexts. In setuptools, silent failure is the law.

    [1]: https://setuptools.pypa.io/en/latest/userguide/extension.html#customizing-distribution-options

    @param dist:
        A (possibly) empty C{setuptools.Distribution} instance to mutate.
        There may be some metadata here if a `setup.py` called `setup()`,
        but this hook is always called before setuptools loads anything
        from ``pyproject.toml``.
    z./pyproject.tomlN)	Ú_load_pyproject_tomlÚ	ExceptionÚopt_inri   rb   ÚFileNotFoundErrorr?   ÚmetadatarW   )rj   ÚconfigrW   r   r   r   Ú_get_setuptools_version|  s   ÿÿrr   ÚkeywordÚvaluec                 C   sx   |sdS ddl m} | | ¡}| ¡  | ¡ D ] }|d dkr7tj tj |d ¡d¡}t|ƒ 	¡ | j
_ dS qtdƒ‚)	a  
    Distutils integration: get the version from the package listed in the Distribution.

    This function is invoked when a C{setup.py} calls C{setup(use_incremental=True)}.

    @see: https://setuptools.pypa.io/en/latest/userguide/extension.html#adding-arguments
    Nr   )Úbuild_pyr   Ú_versionr2   ú_version.pyzNo _version.py found.)Zsetuptools.commandru   Úfinalize_optionsZfind_all_modulesr]   r[   r^   Údirnameri   r?   rp   rW   rm   )rj   rs   rt   ru   Z
sp_commandÚitemrb   r   r   r   Ú_get_distutils_versionŸ  s   

ýr{   rh   c                 C   s&   t jdkr
ddl}nddl}| | ¡S )z*
    Read the content of a TOML file.
    )é   é   r   N)Úsysrg   ÚtomllibÚtomliÚload)rh   r   r   r   r   Ú
_load_tomlº  s   


r‚   T)Úfrozenc                   @   sB   e Zd ZU dZeed< 	 eed< 	 eed< 	 edefdd„ƒZdS )	Ú_IncrementalConfigz>
    Configuration loaded from a ``pyproject.toml`` file.
    rn   r)   r[   r   c                 C   s   t j | jd¡S )z0Path of the ``_version.py`` file. May not exist.rw   N)r]   r[   r^   r:   r   r   r   rb   Û  s   z_IncrementalConfig.version_pathN)	r    r!   r"   r#   r&   Ú__annotations__rS   rT   rb   r   r   r   r   r„   È  s   
 r„   Ú	toml_pathc                 C   sÎ   t | dƒ�}t|ƒ}W d  ƒ n1 sw   Y  t|ƒ}d}|dur+d|v r+|d }|du rAz|d d }W n	 ty@   Y nw |du rItdƒ‚t|tƒsWtdt|ƒ› �ƒ‚t	|du|t
tj | ¡|ƒd�S )aƒ  
    Load Incremental configuration from a ``pyproject.toml``

    If the [tool.incremental] section is empty we take the project name
    from the [project] section. Otherwise we require only a C{name} key
    specifying the project name. Other keys are forbidden to allow future
    extension and catch typos.

    @param toml_path:
        Path to the ``pyproject.toml`` to load.
    ÚrbNÚnameÚprojectz¤Incremental failed to extract the project name from pyproject.toml. Specify it like:

    [project]
    name = "Foo"

Or:

    [tool.incremental]
    name = "Foo"

z-The project name must be a string, but found )rn   r)   r[   )rd   r‚   Ú_extract_tool_incrementalÚKeyErrorr5   rI   rS   Ú	TypeErrorÚtyper„   ra   r]   r[   ry   )r†   rh   ÚdataÚtool_incrementalr)   r   r   r   rl   á  s,   
ÿÿ
ýrl   rŽ   c                 C   sl   d| vrd S t | d tƒstdƒ‚d| d vrd S | d d }t |tƒs(tdƒ‚dh | ¡ ¡s4tdƒ‚|S )NZtoolz[tool] must be a tableÚincrementalz"[tool.incremental] must be a tablerˆ   z'Unexpected key(s) in [tool.incremental])rI   Údictr5   Ú
issupersetÚkeys)rŽ   r�   r   r   r   rŠ     s   
rŠ   r   )rc   )r(   rc   rZ   )rj   rk   r   N)&r#   r]   r~   r6   Údataclassesr   Útypingr   r   r   r   r   r   r	   Údistutils.distr
   rk   r%   r   r   r   rŒ   r'   r(   rS   rZ   ra   ri   rr   r$   r{   r‚   r„   rl   rŠ   rv   rc   Ú__all__r   r   r   r   Ú<module>   sD   $ {
#ÿÿÿ
þ&3