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/states/__pycache__/win_path.cpython-310.pyc
o

�N�g#�@s:dZddlZddlZdd�Zdd�Zdd�Zdd	d
�ZdS)z 
Manage the Windows System PATH
�NcCsdtvrdSdS)z7
    Load this state if the win_path module exists
    �win_path.rehashZwin_path)Fz#win_path module could not be loaded��__salt__�rr�H/opt/saltstack/salt/lib/python3.10/site-packages/salt/states/win_path.py�__virtual__
srcCsd�|�|d<|S)N� �comment)�join)�ret�commentsrrr�_format_commentssr
cCs�|didd�}td|�s|�d�|d<|Stdr'|�d�|d<d	|d
<|Std|�td|�rAd|�d
�|d<d|d
<|Sd|�d
�|d<||dd<|S)z�
    Remove the directory from the SYSTEM path

    Example:

    .. code-block:: yaml

        'C:\sysinternals':
          win_path.absent
    T���name�result�changesr	zwin_path.existsz is not in the PATHr	�testz would be removed from the PATHNrzwin_path.removezFailed to remove z from the PATHFzRemoved rZremoved)r�__opts__)rrrrr�absents �rc
s"z
tj�tjj�����Wn
tyt���Ynw�didd�}�dur5t	�t
�s5d|d<d|d<|Sd	d
��d&���fdd�	}d
d�}��}t|�}�dury�|kre|�dg��
d�|���|�n�|kry|�dg��
d�|���d�||�}g}|durLjdur�|�
��d��t||�S�|kr�|�
��d��d��t||�Stdr�d|d<|�
d��|���||��|d<t||�Sn&tdr�d|d<|�
d���dur�d���nd��||��|d<t||�Sz
td��dd�|d<Wn t�y}	z|�
d|	�d��d|d<WYd}	~	nd}	~	ww|d�r1td�|d<|d�s1|�
d�|�}
|d�rH�du�rB|
dun�|
k|d<�du�re|du�re|�
d �|d�r]d!nd"�|���n|�
d#�|d�rpd$nd%��du�r|d���nd��||
k�r�|||
�|d<t||�S)'a�
    Add the directory to the system PATH at index location

    index
        Position where the directory should be placed in the PATH. This is
        0-indexed, so 0 means to prepend at the very start of the PATH.

        .. note::
            If the index is not specified, and the directory needs to be added
            to the PATH, then the directory will be appended to the PATH, and
            this state will not enforce its location within the PATH.

    Examples:

    .. code-block:: yaml

        'C:\python27':
          win_path.exists

        'C:\sysinternals':
          win_path.exists:
            - index: 0

        'C:\mystuff':
          win_path.exists:
            - index: -1
    TrrNzIndex must be an integerr	FrcSsdd�td�D�S)NcSsg|]}|���qSr)�lower)�.0�xrrr�
<listcomp>csz7exists.<locals>._get_path_lowercase.<locals>.<listcomp>zwin_path.get_pathrrrrr�_get_path_lowercasebsz#exists.<locals>._get_path_lowercasecsX|dur��}z	|�����}Wn
tyYdSw�dur*�dkr*t|�|S|S)Nr)�indexr�
ValueError�len)�path�pos�rrrrr�_indexes�zexists.<locals>._indexcSsd||d�iS)Nr��old�newrr"rrr�_changesuszexists.<locals>._changes�warningszQThere are only {0} directories in the PATH, using an index of {0} instead of {1}.zMThere are only {} directories in the PATH, using an index of 0 instead of {}.rz already exists in the PATH.z% already exists in the PATH at index �.rz&{} would be moved from index {} to {}.rz {} would be added to the PATH{}.z
 at index zwin_path.add)rZrehashzEncountered error: rz5Updated registry with new PATH, but failed to rehash.z{} {} from index {} to {}.ZMovedzFailed to movez{} {} to the PATH{}.ZAddedz
Failed to add�N)�osr�normpath�salt�utilsZstringutilsZ
to_unicode�	TypeError�str�
isinstance�intr�
setdefault�append�formatr
rr�	Exception)rrrr!r%Zpre_pathZnum_dirsZ	old_indexr�excZ	new_indexrr r�exists:s���
�

��
���
��



����

r6r()�__doc__r)Zsalt.utils.stringutilsr+rr
rr6rrrr�<module>s	"