File: //opt/saltstack/salt/lib/python3.10/site-packages/salt/modules/__pycache__/incron.cpython-310.pyc
o
�N�g| � @ s� d Z ddlZddlZddlZddlZddlZddlZe�e �Z
dZdZg d�Z
dd� Zdd � Zd
d� Zdd
� Zdd� Zdd� Zdd� Zdd� Zdd� Zdd� Zdd� Zejj�ed�Zdd� Zdd � Zejj�ed!�ZdS )"z
Work with incron
� Nz## Line managed by Salt, do not editz/etc/incron.d/)Z IN_ACCESSZ IN_ATTRIBZIN_CLOSE_WRITEZIN_CLOSE_NOWRITEZ IN_CREATEZ IN_DELETEZIN_DELETE_SELFZ IN_MODIFYZIN_MOVE_SELFZ
IN_MOVED_FROMZIN_MOVED_TOZIN_OPENZ
IN_ALL_EVENTSZIN_MOVEZIN_CLOSEZIN_DONT_FOLLOWZ
IN_ONESHOTZ
IN_ONLYDIRZ
IN_NO_LOOPc C s0 | |kr|dkr| dkrdS dS |d urdS dS )N�random�*TF� )�old�newr r �G/opt/saltstack/salt/lib/python3.10/site-packages/salt/modules/incron.py�
_needs_change) s �r c C sT g }| d D ]
}|� |� d�� q| d D ]}|� d�|d |d |d �� q|S )z[
Takes a tab list structure and renders it to a list for applying it to
a file
�pre�
�cronsz {} {} {}
�path�mask�cmd)�append�format)�lst�retr �cronr r r �_render_tab4 s ��r c C s
d| � �S )zL
Returns a format string, to be used to build an incrontab command.
z
incrontab r )r r r r �_get_incron_cmdstrG s
r c C s t d t|�| dd�dkS )z�
Writes the contents of a file to a user's incrontab
CLI Example:
.. code-block:: bash
salt '*' incron.write_incron_file root /tmp/new_incron
zcmd.retcodeF��runas�python_shellr ��__salt__r ��userr r r r �write_incron_fileN s
���r c C s t d t|�| dd�S )z�
Writes the contents of a file to a user's incrontab and return error message on error
CLI Example:
.. code-block:: bash
salt '*' incron.write_incron_file_verbose root /tmp/new_incron
�cmd.run_allFr r r r r r �write_incron_file_verbose` s
�r c C s� | dkri }t tdd�|��|d<