HEX
Server: Apache
System: Linux server2.voipitup.com.au 4.18.0-553.109.1.lve.el8.x86_64 #1 SMP Thu Mar 5 20:23:46 UTC 2026 x86_64
User: posscale (1027)
PHP: 8.2.30
Disabled: exec,passthru,shell_exec,system
Upload Files
File: //opt/saltstack/salt/lib/python3.10/site-packages/salt/utils/__pycache__/versions.cpython-310.pyc
o

�N�g�G�@s�dZddlZddlZddlZddlZddlZddlZddlZddlZddl	Z
ddlZe�
e�ZGdd�de
jj�ZGdd�de�ZGdd�dej�Zdd	d
�Zedddfdd
�Zedddfdd�Zedddfdd�Zddd�Zddd�Z	ddd�ZdS)z�
    salt.utils.versions
    ~~~~~~~~~~~~~~~~~~~

    Version parsing based on `packaging.version` and `looseversion.LooseVersion`
    which works under python 3 because on python 3 you can no longer compare
    strings against integers.
�NcsXeZdZ�fdd�Z�fdd�Z�fdd�Z�fdd�Z�fd	d
�Z�fdd�Z�Z	S)
�Versionc�t|t�r	t|�}t��|�S�N)�
isinstance�strr�super�__lt__��self�other��	__class__��G/opt/saltstack/salt/lib/python3.10/site-packages/salt/utils/versions.pyr�
zVersion.__lt__crr)rrrr�__le__r	rrrr rzVersion.__le__crr)rrrr�__eq__r	rrrr%rzVersion.__eq__crr)rrrr�__ge__r	rrrr*rzVersion.__ge__crr)rrrr�__gt__r	rrrr/rzVersion.__gt__crr)rrrr�__ne__r	rrrr4rzVersion.__ne__)
�__name__�
__module__�__qualname__rrrrrr�
__classcell__rrrrrsrcseZdZ�fdd�Z�ZS)�
StrictVersionc	s4tddt�dt�dt�d��t�j|i|��dS)Ni��'z�.StrictVersion' is no longer a subclass of 'distutils.versions.StrictVersion'. It's usage has been deprecated and should no longer be used. Please switch to 'z?.Version' which is a subclass of 'packaging.version.Version'. 'z-.StrictVersion' will be removed in {version}.)�
warn_untilrr�__init__)r
�args�kwargsrrrr;s���	zStrictVersion.__init__)rrrrrrrrrr:srcs(eZdZ�fdd�Z�fdd�Z�ZS)�LooseVersioncs"t��|�dd�|jD�|_dS)NcSs(g|]}t|t�rt|��d�n|�qS)�)r�intr�zfill)�.0Zvprrr�
<listcomp>Ls�z&LooseVersion.parse.<locals>.<listcomp>)r�parse�version�_str_version)r
Zvstringrrrr&Is�zLooseVersion.parsecs�t|t�r	t|�}d}|j|jD]}t|t�sd}nq|dur't��|�S|j|jkr/dS|j|jkr7dS|j|jkr?dSdS)NFTr����)rrr r'r"r�_cmpr()r
rZstring_in_version�partrrrr+Ps"

��zLooseVersion._cmp)rrrr&r+rrrrrr Hsr cCs|�d|�d|j�d|�d�S)zg
    Replacement for warnings.formatwarning that disables the echoing of
    the 'line' parameter.
    �:z: �
)r)�message�category�filename�lineno�linerrr�_format_warninggsr4Fc	Cspt|tjj�rtjj|j�}nIt|t�rtj�|�}n=t|t�r'tjj|�}n1t|t�rM|�	�tjjj
vrEtd�dd�tjj
��D����tjj�|�}nt|tjj�sXtd��|dur^d}|durftjj}tjj|�}||kr�t�t�|d��}dj|j|j|j|jd	�}tj�d
d�dkr�t|��tj�d
|�d
��tj��|dur�tj|j|jd�||d�dSdS)aV
    Helper function to raise a warning, by default, a ``DeprecationWarning``,
    until the provided ``version``, after which, a ``RuntimeError`` will
    be raised to remind the developers to remove the warning because the
    target version has been reached.

    :param version: The version info or name after which the warning becomes a ``RuntimeError``.
                    For example ``(2019, 2)``, ``3000``, ``Hydrogen`` or an instance of
                    :class:`salt.version.SaltStackVersion` or :class:`salt.version.SaltVersion`.
    :param message: The warning message to be displayed.
    :param category: The warning class to be thrown, by default
                     ``DeprecationWarning``
    :param stacklevel: There should be no need to set the value of
                       ``stacklevel``. Salt should be able to do the right thing.
    :param _version_info_: In order to reuse this function for other SaltStack
                           projects, they need to be able to provide the
                           version info to compare to.
    :param _dont_call_warnings: This parameter is used just to get the
                                functionality until the actual error is to be
                                issued. When we're only after the salt version
                                checks to raise a ``RuntimeError``.
    zhIncorrect spelling for the release name in the warn_utils call. Expecting one of these release names: {}cSsg|]}|j�qSr)�name)r$Zvsrrrr%�szwarn_until.<locals>.<listcomp>z�The 'version' argument should be passed as a tuple, integer, string or an instance of 'salt.version.SaltVersion' or 'salt.version.SaltStackVersion'.N�r*z�The warning triggered on filename '{filename}', line number {lineno}, is supposed to be shown until version {until_version} is released. Current version is now {salt_version}. Please remove the warning.)r1r2Z
until_versionZsalt_version�!RAISE_DEPRECATIONS_RUNTIME_ERRORS�0�1r.F)r'��
stacklevel) r�saltr'ZSaltVersion�SaltStackVersion�infor"�tupler�lowerZLNAMES�RuntimeError�formatZSaltVersionsInfoZversions�	from_name�__version_info__�inspect�getframeinfo�sys�	_getframer1r2Zformatted_version�os�environ�get�stderr�write�flush�warnings�warn)	r'r/r0r;�_version_info_�_dont_call_warnings�	_version_�caller�deprecated_messagerrrrosZ


�����

��rc
Cs*d}t|ttjtjf�std�|���t|t�rtj�||�}t|tj�r)|��}|dur/d}|p7tj����}||kr|t�	t
�|d��}dj|j|��|��d�|j
|j|��|��d�f}	tj�d	d
�dkrmt|	��t
j�d|	�d��t
j��|d
ur�tj|j|��|��d�||d�dSdS)a�
    Helper function to raise a warning, by default, a ``DeprecationWarning``,
    until the provided ``date``, after which, a ``RuntimeError`` will
    be raised to remind the developers to remove the warning because the
    target date has been reached.

    :param date: A ``datetime.date`` or ``datetime.datetime`` instance.
    :param message: The warning message to be displayed.
    :param category: The warning class to be thrown, by default
                     ``DeprecationWarning``
    :param stacklevel: There should be no need to set the value of
                       ``stacklevel``. Salt should be able to do the right thing.
    :param _dont_call_warnings: This parameter is used just to get the
                                functionality until the actual error is to be
                                issued. When we're only after the date
                                checks to raise a ``RuntimeError``.
    z%Y%m%dz�The 'date' argument should be passed as a 'datetime.date()' or 'datetime.datetime()' objects or as string parserable by 'datetime.datetime.strptime()' with the following format '{}'.Nr6r*z�{message} This warning(now exception) triggered on filename '{filename}', line number {lineno}, is supposed to be shown until {date}. Today is {today}. Please remove the warning.)�date�today)r/r1r2rVrWr7r8r9r.Fr:)rr�datetimerVrArB�strptime�utcnowrErFrGrH�	isoformatr1r2rIrJrKrLrMrNrOrP)
rVr/r0r;Z
_current_daterRZ
_strptime_fmtrWrTrUrrr�warn_until_date�sJ��
��

��r\cCs�t|tttjjf�std��t|t�rtjj|�}nt|t�r&tjj�|�}|dur,d}|dur4tjj}tjj|�}|sB|j	|j	kr^d�
dd�|D��}t|d�|j
|�|||j	|d�dSdS)	a�
    Helper function to raise a warning (by default, a ``DeprecationWarning``)
    when unhandled keyword arguments are passed to function, until the
    provided ``version_info``, after which, a ``RuntimeError`` will be raised
    to remind the developers to remove the ``**kwargs`` because the target
    version has been reached.
    This function is used to help deprecate unused legacy ``**kwargs`` that
    were added to function parameters lists to preserve backwards compatibility
    when removing a parameter. See
    :ref:`the deprecation development docs <deprecations>`
    for the modern strategy for deprecating a function parameter.

    :param kwargs: The caller's ``**kwargs`` argument value (a ``dict``).
    :param version: The version info or name after which the warning becomes a
                    ``RuntimeError``. For example ``(0, 17)`` or ``Hydrogen``
                    or an instance of :class:`salt.version.SaltStackVersion`.
    :param category: The warning class to be thrown, by default
                     ``DeprecationWarning``
    :param stacklevel: There should be no need to set the value of
                       ``stacklevel``. Salt should be able to do the right thing.
    :param _version_info_: In order to reuse this function for other SaltStack
                           projects, they need to be able to provide the
                           version info to compare to.
    :param _dont_call_warnings: This parameter is used just to get the
                                functionality until the actual error is to be
                                issued. When we're only after the salt version
                                checks to raise a ``RuntimeError``.
    zmThe 'version' argument should be passed as a tuple, string or an instance of 'salt.version.SaltStackVersion'.N�z, css�|]	}d|�d�VqdS)rNr)r$�keyrrr�	<genexpr>Ns�z$kwargs_warn_until.<locals>.<genexpr>zPThe following parameter(s) have been deprecated and will be removed in '{}': {}.)r/r0r;rQrR)rr?rr<r'r=rArCrDr>�joinrrB�string)rr'r0r;rQrRrSZ	arg_namesrrr�kwargs_warn_untils2$�



��rbc
s��fdd�}||�}||�}z$t|�t|�krWdSt|�t|�kr%WdSt|�t|�kr0WdSWdStyJ}zt�|�WYd}~dSd}~ww)aB
    Compares two version strings using `LooseVersion`. This
    is a fallback for providers which don't have a version comparison utility
    built into them.  Return -1 if version1 < version2, 0 if version1 ==
    version2, and 1 if version1 > version2. Return None if there was a problem
    making the comparison.
    cs �rt|��dd�dSt|�S)Nr-r*r))r�split)�x��ignore_epochrr�	normalizees zversion_cmp.<locals>.normalizer)rr*N)r �	Exception�log�	exception)Zpkg1Zpkg2rfrg�excrrer�version_cmp\s"	����rl��==cCs�dddddd�}|dvr||vrt�d|�d	S|d
urt}||||d�}|d
ur+d	St|tj�s8t�d�d	S|d
krB||dvS|dkrId}n|dkrOd}|||vS)z�
    Compares two version numbers. Accepts a custom function to perform the
    cmp-style version comparison, otherwise uses version_cmp().
    )r))r)r)r)rr*)r*)�<z<=rnz>=�>)�!=z,Invalid operator '%s' for version comparisonFNrez?The version comparison function did not return an integer/long.rqrnr)r*)ri�errorrlr�numbersZIntegral)Zver1ZoperZver2Zcmp_funcrfZcmp_mapZ
cmp_resultrrr�comparexs&
rtTc
Cs�|dur0zddl}d}Wntyd}Ynw|durd}|r(t|j|�dkr0dd|�d�fS|durzzddl}ddl}d}	WntyKd}	Ynw|durRd	}|durXd
}|	rbt|j|�dkrjdd|�d�fSt|j|�dkrzdd|�d
�fSdS)a�
    Checks for the version of various required boto libs in one central location. Most
    boto states and modules rely on a single version of the boto, boto3, or botocore libs.
    However, some require newer versions of any of these dependencies. This function allows
    the module to pass in a version to override the default minimum required version.

    This function is useful in centralizing checks for ``__virtual__()`` functions in the
    various, and many, boto modules and states.

    boto_ver
        The minimum required version of the boto library. Defaults to ``2.0.0``.

    boto3_ver
        The minimum required version of the boto3 library. Defaults to ``1.2.6``.

    botocore_ver
        The minimum required version of the botocore library. Defaults to ``1.3.23``.

    check_boto
        Boolean defining whether or not to check for boto deps. This defaults to ``True`` as
        most boto modules/states rely on boto, but some do not.

    check_boto3
        Boolean defining whether or not to check for boto3 (and therefore botocore) deps.
        This defaults to ``True`` as most boto modules/states rely on boto3/botocore, but
        some do not.
    TrNFz2.0.0r)zA minimum version of boto z
 is required.z1.2.6z1.3.23zA minimum version of boto3 zA minimum version of botocore z is required)�boto�ImportErrorrl�__version__�boto3�botocore)
Zboto_verZ	boto3_verZbotocore_verZ
check_botoZcheck_boto3ruZhas_botorxryZ	has_boto3rrr�check_boto_reqs�s@��
�
�rzr)F)rmrnrmNF)NNNTT)�__doc__rXrE�loggingrsrIrGrOZlooseversionZpackaging.versionZ	packagingZsalt.versionr<�	getLoggerrrir'rrr r4�DeprecationWarningrr\rbrlrtrzrrrr�<module>sF	
 

�]
�O
�
G
#�