File: //opt/saltstack/salt/lib/python3.10/site-packages/salt/modules/__pycache__/win_path.cpython-310.pyc
o
�N�gv, � @ s� d Z ddlZddlZddlZddlZddlZddlZddlZzdZ W n e
y- dZ Y nw e�e�Z
dZdZdZdZeej�Zd d
� Zdd� Zd
d� Zdd� Zdd� Zdd� Zddd�Zdd� ZdS )z�
Manage the Windows System PATH
Note that not all Windows applications will rehash the PATH environment variable,
Only the ones that listen to the WM_SETTINGCHANGE message
http://support.microsoft.com/kb/104011
� NTF�HKEY_LOCAL_MACHINE�<SYSTEM\CurrentControlSet\Control\Session Manager\Environment�PATHZ
REG_EXPAND_SZc C s t jj�� r
tr
dS dS )z
Load only on Windows
Zwin_path)Fz5Module win_path: module only works on Windows systems)�salt�utils�platformZ
is_windows� HAS_WIN32� r r �I/opt/saltstack/salt/lib/python3.10/site-packages/salt/modules/win_path.py�__virtual__! s r c C s t j�tjj�| ��S )z=
Normalize the directory to make comparison possible
)�os�path�normpathr r �stringutils�
to_unicode)Zstring_r r r
�_normalize_dir* s r c C s t jj�d�S )a�
Send a WM_SETTINGCHANGE Broadcast to Windows to refresh the Environment
variables for new processes.
.. note::
This will only affect new processes that aren't launched by services. To
apply changes to the path to services, the host must be restarted. The
``salt-minion``, if running as a service, will not see changes to the
environment until the system is restarted. See
`MSDN Documentation <https://support.microsoft.com/en-us/help/821761/changes-that-you-make-to-environment-variables-do-not-affect-services>`_
CLI Example:
.. code-block:: bash
salt '*' win_path.rehash
ZEnvironment)r r Z
win_functionsZbroadcast_setting_changer r r r
�rehash1 s r c C sN t jj�td ddd�d ��d�} | d dkr| d d� n| } ttt| ��S )
z�
Returns a list of items in the SYSTEM path
CLI Example:
.. code-block:: bash
salt '*' win_path.get_path
zreg.read_valuer r r Zvdata�;���� N) r r r r � __utils__�split�list�mapr )�retr r r
�get_pathF s
����
r c C s$ t | �} t� }| �� dd� |D �v S )ap
Check if the directory is configured in the SYSTEM path
Case-insensitive and ignores trailing backslash
Returns:
boolean True if path exists, False if not
CLI Example:
.. code-block:: bash
salt '*' win_path.exists 'c:\python27'
salt '*' win_path.exists 'c:\python27\'
salt '*' win_path.exists 'C:\pyThon27'
c s s � | ]}|� � V qd S �N��lower��.0�xr r r
� <genexpr>r s � zexists.<locals>.<genexpr>)r r r )r
ZsysPathr r r
�exists_ s r# c C s t �| �tjd<