
    Sfy?                     |   d Z ddlmZmZ ddlZddlZddlZddlmZm	Z	m
Z
mZmZmZmZ ddlmZ erddlZddlmZ ddlmZ d Z G d	 d
e          Z e            Z G d de          Z G d de          Zd Zd Zd Z d Z!d Z"d Z# ed           G d d                      Z$d Z%d Z&ddl'm(Z( d Z)g dZ*dS )z0
Versions for Python packages.

See L{Version}.
    )divisionabsolute_importN)TYPE_CHECKINGAnyTypeVarUnionOptionalDictBinaryIO)	dataclass)Literal)Distributionc                 &    | |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bs     F/var/www/html/env/lib/python3.11/site-packages/incremental/__init__.py_cmpr      s%     	1uur	
aqq    c                   0    e Zd ZdZd Zd Zd Zd Zd ZdS )_Infz:
    An object that is bigger than all other objects.
    c                     |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   )_infselfothers     r   __cmp__z_Inf.__cmp__7   s     D==1qr   c                 4    |                      |          dk     S Nr   r   r   s     r   __lt__z_Inf.__lt__C       ||E""Q&&r   c                 4    |                      |          dk    S r!   r"   r   s     r   __le__z_Inf.__le__F       ||E""a''r   c                 4    |                      |          dk    S r!   r"   r   s     r   __gt__z_Inf.__gt__I   r$   r   c                 4    |                      |          dk    S r!   r"   r   s     r   __ge__z_Inf.__ge__L   r'   r   N)	__name__
__module____qualname____doc__r   r#   r&   r)   r+   r   r   r   r   r   2   si         
 
 
' ' '( ( (' ' '( ( ( ( (r   r   c                       e Zd ZdZdS )IncomparableVersionsz-
    Two versions could not be compared.
    N)r,   r-   r.   r/   r   r   r   r1   r1   S   s           r   r1   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d	 Zd
 Zd Zd Zd Z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	                    |r|rt          d          |r |s|}t          j        dt          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?   r@   rA   
prereleaserB   rC   s	            r   __init__zVersion.__init__b   s    :  
	 
	?@@@ 	 1 	 *M- #    F??  !2 d c  Q   


!2	r   c                 H    t          j        dt          d           | j        S )NzuAccessing incremental.Version.prerelease was deprecated in Incremental 16.9.0. Use Version.release_candidate instead.r5   r6   )r:   r;   r<   rA   r   s    r   rD   zVersion.prerelease   s3    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
        r8   N rcz.postz.devz%r.%d.%d%s%s%s)r>   rA   rB   rC   r?   r@   )r   rJ   rB   rC   s       r   publiczVersion.public   s     ::!)BB *  113B9DD  !%		+D8CC  #hh(C4:tz4:r4QT"UUUr   c           	          | 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 )NrI   z, release_candidate=z, post=z, dev=z%s(%r, %r, %d, %d%s%s%s))	rA   rB   rC   	__class__r,   r=   r>   r?   r@   )r   rA   rB   rC   s       r   __repr__zVersion.__repr__   s    !) " * =A<R<R T9DD  #'))-D8CC  !%*C)N#LJJJ	-
 	
 		
r   c                 B    d| j         d|                                 dS )N[z
, version ]r=   shortrG   s    r   __str__zVersion.__str__   s!     %)\\\4::<<<<@@r   c           	         t          || j                  st          S | j                                        |j                                        k    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 != r8   Nr   )
isinstancerM   NotImplementedr=   lowerr1   r>   r   rA   rB   rC   r   r?   r@   )r   r   r>   rA   rB   rC   
othermajorotherrc	otherpostotherdevxs              r   r   zVersion.__cmp__   sb   . %00 	"!!<5=#6#6#8#888&T\\\5=='QRRR:EEJE!) $ $ 69DD9D8CC(C;&  JJJ"*GG-G:II
I9HHyHDJ
,=tSIek7IxP
 
 r   c                 N    |                      |          }|t          u r|S |dk    S r!   r   rW   r   r   cs      r   __eq__zVersion.__eq__/  ,    LLHAvr   c                 N    |                      |          }|t          u r|S |dk    S r!   r_   r`   s      r   __ne__zVersion.__ne__5  rc   r   c                 N    |                      |          }|t          u r|S |dk     S r!   r_   r`   s      r   r#   zVersion.__lt__;  ,    LLH1ur   c                 N    |                      |          }|t          u r|S |dk    S r!   r_   r`   s      r   r&   zVersion.__le__A  rc   r   c                 N    |                      |          }|t          u r|S |dk    S r!   r_   r`   s      r   r)   zVersion.__gt__G  rg   r   c                 N    |                      |          }|t          u r|S |dk    S r!   r_   r`   s      r   r+   zVersion.__ge__M  rc   r   )NNNN)r,   r-   r.   r/   rE   propertyrD   rK   baserS   localrN   rT   r   rb   re   r#   r&   r)   r+   r   r   r   r3   r3   Y   s         5 5 5 5n & & X&V V V> DEE
 
 
6A A AH H HT              r   r3   c                 B    | 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.
     rR   )versionresults     r   getVersionStringrr   T  s#      9FMr   c                    t           j                            | d|                                          }t           j                            | |                                          }t           j                            |          r|S t           j                            |          r|S t          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 {}: I looked in {} and {})ospathjoinrX   isdirr9   format)rv   r=   src_dircurrent_dirs       r   	_findPathr|   _  s     gll488G',,tW]]__55K	w}}W 	
	{	#	# 
KRR+ 
 
 	
r   c                     i }t          | d          5 }t          |                                |           ddd           n# 1 swxY w Y   |d         S )z?
    Load the current version from a ``_version.py`` file.
    rN__version__)openexecread)version_pathversion_infofs      r   _existing_versionr   y  s     L	lC	 	  %AQVVXX|$$$% % % % % % % % % % % % % % % &&s   #AA	Ac                     	 t          d          }n# t          $ r Y dS w xY w|j        sdS 	 t          |j                  }n# t
          $ r Y dS w xY 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_inr   r   FileNotFoundErrorrK   metadatarp   )distconfigrp   s      r   _get_setuptools_versionr     s      &&899    = #F$788    $NN,,DMs    
  A 
AAc                    |sdS ddl m} |                    |           }|                                 |                                D ]}|d         dk    rqt          j                            t          j                            |d                   d          }t          |          	                                | j
        _         dS 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   _versionr5   _version.pyzNo _version.py found.)setuptools.commandr   finalize_optionsfind_all_modulesru   rv   rw   dirnamer   rK   r   rp   r   )r   keywordvaluer   
sp_commanditemr   s          r   _get_distutils_versionr     s      ++++++""4((J!!!++--  7j  7<<Q(@(@-PPL$5l$C$C$J$J$L$LDM!FF !
 +
,
,,r   c                 ^    t           j        dk    rddl}nddl}|                    |           S )z*
    Read the content of a TOML file.
    )      r   N)sysr   tomllibtomliload)r   r   s     r   
_load_tomlr     s9     '!!<<??r   T)frozenc                   N    e Zd ZU dZeed<   	 eed<   	 eed<   	 ed             ZdS )_IncrementalConfigz>
    Configuration loaded from a ``pyproject.toml`` file.
    r   r=   rv   c                 L    t           j                            | j        d          S )z0Path of the ``_version.py`` file. May not exist.r   )ru   rv   rw   rG   s    r   r   z_IncrementalConfig.version_path  s     w||DI}555r   N)	r,   r-   r.   r/   bool__annotations__strrk   r   r   r   r   r   r     sc           LLL LLLC
III"6 6 X6 6 6r   r   c           	         t          | d          5 }t          |          }ddd           n# 1 swxY w Y   t          |          }d}|d|v r|d         }| 	 |d         d         }n# t          $ r Y nw xY w|t	          d          t          |t                    s/t          d                    t          |                              t          |du|t          t          j                            |           |                    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projectzIncremental 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 {})r   r=   rv   )r   r   _extract_tool_incrementalKeyErrorr9   rV   r   	TypeErrorry   typer   r|   ru   rv   r   )	toml_pathr   datatool_incrementalr=   s        r   r   r     su    
i		 !!}}               166 G#2B(B(B"6*	9of-GG 	 	 	D	    	 gs## 
=DDT']]SS
 
 	
 t+rwy117;;   s   -11A) )
A65A6c                 P   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                    |                                          st          d          |S )Ntoolz[tool] must be a tableincrementalz"[tool.incremental] must be a tabler   z'Unexpected key(s) in [tool.incremental])rV   dictr9   
issupersetkeys)r   r   s     r   r   r     s    Ttd6lD)) 31222DL((tF|M2&-- ?=>>>8/446677 DBCCCr   r   )r   c                  (    t          j                    S )N)r   rK   r   r   r   _setuptools_versionr   1  s    r   )r   r3   rr   )+r/   
__future__r   r   ru   r   r:   typingr   r   r   r   r	   r
   r   dataclassesr   iotyping_extensionsr   distutils.distr   _Distributionr   objectr   r   r   r1   r3   rr   r|   r   r   r   r   r   r   r   r   r   r   __all__r   r   r   <module>r      sV    1 0 0 0 0 0 0 0 				 



  O O O O O O O O O O O O O O O O O O ! ! ! ! ! !  =III))))))<<<<<<  (( ( ( ( (6 ( ( (< tvv    9   x x x x xf x x xv  
 
 
4	' 	' 	' -  -  -F- - -2   $6 6 6 6 6 6 6 602 2 2j  " " ! ! ! ! !      9
8
8r   