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/modules/__pycache__/aliases.cpython-310.pyc
o

�N�g.�@s�dZddlZddlZddlZddlZddlZddlZddlZddl	Zddl
mZdddddd�Ze�
d�Zdd	�Zd
d�Zdd
�Zdd�Zdd�Zdd�Zdd�Zdd�ZdS)z,
Manage the information in the aliases file
�N)�SaltInvocationError�txtZyaml)�rm_alias�
has_target�
get_target�
set_target�list_aliasesz"([^:#]*)\s*:?\s*([^#]*?)(\s+#.*|$)cCstj�tdd��S)z9
    Return the path to the appropriate aliases file
    z
config.optionzaliases.file)�os�path�realpath�__salt__�r
r
�H/opt/saltstack/salt/lib/python3.10/site-packages/salt/modules/aliases.py�__get_aliases_filenamesrcCs�t�}g}tj�|�s
|Stjj�|d��.}|D]"}tjj�	|�}t
�|�}|r0|�|�
��q|�dd|��f�qWd�|S1sFwY|S)z�
    Parse the aliases file, and return a list of line components:

    [
      (alias1, target1, comment1),
      (alias2, target2, comment2),
    ]
    �rN)rr	r
�isfile�salt�utils�filesZfopenZstringutilsZ
to_unicode�
__ALIAS_RE�match�append�groups�strip)�afn�retZifile�linerr
r
r�__parse_aliases"s 	
�
��rc
CsLt�}tj�|�}tj|dd��r}t�dd�sGtj�|�r8t�	|�}t�
|jt	�|j
��t�|j|j|j�nt�
|jd�t�|jdd�|D]1\}}}t|t�rXd�|�}|s\d}|rk|rk|�d|�|�d	�}n|�d	�}|�t�}|�|�qIWd
�n1s�wYtjj�|j|�tjj�d�}	|	d
ur�td|	�d
S)zm
    Write a new copy of the aliases file.  Lines is a list of lines
    as returned by __parse_aliases.
    F)�dir�deletezintegration.testi�r�, �z: �
N�
newaliaseszcmd.runT)rr	r
�dirname�tempfileZNamedTemporaryFileZ__opts__�getr�stat�chmod�name�S_IMODE�st_mode�chown�st_uid�st_gid�
isinstance�list�join�encodeZ__salt_system_encoding__�writerrZ
atomicfileZ
atomic_rename�whichr)
�linesrZadir�outZafn_st�
line_alias�line_target�line_commentZ
write_liner#r
r
r�__write_aliases_file:s6




��r:cCsdd�t�D�}|S)z�
    Return the aliases found in the aliases file in this format::

        {'alias': 'target'}

    CLI Example:

    .. code-block:: bash

        salt '*' aliases.list_aliases
    cSsi|]
\}}}|r||�qSr
r
)�.0�alias�target�_r
r
r�
<dictcomp>osz list_aliases.<locals>.<dictcomp>)r)rr
r
rrcsrcCst�}||vr||SdS)z�
    Return the target associated with an alias

    CLI Example:

    .. code-block:: bash

        salt '*' aliases.get_target alias
    r!)r)r<�aliasesr
r
rrss
rcCsB|dkrtd��t�}||vrdSt|t�rd�|�}|||kS)z�
    Return true if the alias/target is set

    CLI Example:

    .. code-block:: bash

        salt '*' aliases.has_target alias target
    r!�!target can not be an empty stringFr )rrr/r0r1)r<r=r@r
r
rr�s


rcCs�|dkrtd��|dkrtd��t|�|krdSt�}g}d}|D]\}}}||kr7|s6|�|||f�d}q!|�|||f�q!|sJ|�||df�t|�dS)a
    Set the entry in the aliases file for the given alias, this will overwrite
    any previous entry for the given alias or create a new one if it does not
    exist.

    CLI Example:

    .. code-block:: bash

        salt '*' aliases.set_target alias target
    r!z alias can not be an empty stringrATF)rrrrr:)r<r=r5r6Zovrr7r8r9r
r
rr�s(
�rcCsJt|�sdSt�}g}|D]\}}}||kr|�|||f�q
t|�dS)z�
    Remove an entry from the aliases file

    CLI Example:

    .. code-block:: bash

        salt '*' aliases.rm_alias alias
    T)rrrr:)r<r5r6r7r8r9r
r
rr�s
�r)�__doc__r	�rer'r%Zsalt.utils.atomicfilerZsalt.utils.filesZsalt.utils.pathZsalt.utils.stringutilsZsalt.exceptionsrZ
__outputter__�compilerrrr:rrrrrr
r
r
r�<module>s2�
)'