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/wheel/__pycache__/file_roots.cpython-310.pyc
o

�N�g4�@sPdZddlZddlZddlZddd�Zddd�Zdd	�Zdd
d�Zddd
�Z	dS)zB
Read in files from the file_root and save files to the file root
�N�basec	Cs�g}|tdvr
|Std|D]H}tj�||�}tjjj||dd�s$qtj�|�rXtjj	�
|d��}tjj	�|�rB|�|di�n|�|di�Wd�n1sSwYq|S)zP
    Return a dict of the files located with the given path and environment
    �
file_rootsT�Zsubdir�rb�txt�binN)
�__opts__�os�path�join�salt�utils�verify�
clean_path�isfile�files�fopenZis_text�append)r
�saltenv�ret�root�full�fp_�r�I/opt/saltstack/salt/lib/python3.10/site-packages/salt/wheel/file_roots.py�finds ���rc
Cs�i}|tdvr
|Std|D]\}i||<tjj�|�D]N\}}}||}||krY|}g}tj�||�sPtj�|�}	|	rC|�d|	�tj�	|�}tj�||�r5|D]}
||
}qR|D]}i||<q[|D]}d||<qdqq|S)z>
    Return all of the file paths found in an environment
    rr�f)
rrr
r
Zos_walkr	�samefile�basename�insert�dirname)
rrZf_rootr�dirsr�subZsrootZaboverZarootZdir_�fn_rrr�list_env!s2�


��r$cCs0i}tdD]}g||<||�t|��q|S)zE
    Return all of the files names in all available environments
    r)rrr$)rrrrr�
list_roots?s
r%c	Cs�g}t||�}|D]8}tt|����}||}|dkrAtjj�|d��}|�|tjj	�
|���i�Wd�n1s<wYq	|S)zP
    Read the contents of a text file, if the file is binary then ignore it
    rrN)r�next�iter�keysrr
rrr�stringutilsZ
to_unicode�read)r
rrrr#rZformrrrrr*Js
��r*cCs�|tdvrd|�d�Sttd|�|krd�||�Stj�|�r(d�||�Std||}tj�||�}tjj	j
||dd�sFd|��Stj�|�}tj�|�sWt�
|�tjj�|d	��}|�tjj�|��Wd
�n1stwYd|��S)z�
    Write the named file, by default the first file found is written, but the
    index of the file can be specified to write to a lower priority file root
    rzNamed environment z is not presentz3Specified index {} in environment {} is not presentz;The path passed in {} is not relative to the environment {}TrzInvalid path: zw+NzWrote data to file )r�len�formatr	r
�isabsrrr
rrr �isdir�makedirsrr�writer)Zto_str)�datar
r�indexr�destZdest_dirrrrrr0Zs*��

�
r0)r)rr)
�__doc__r	Zsalt.utils.filesrZsalt.utils.pathrr$r%r*r0rrrr�<module>s