File: //opt/saltstack/salt/lib/python3.10/site-packages/salt/utils/__pycache__/extend.cpython-310.pyc
o
�N�g5# �
@ s d Z ddlZddlZddlZddlZddlZddlmZ ddlm Z ddl
ZddlZddl
mZ ddlmZ e�e�ZzddlZdZW n eyW Z zdZW Y dZ[ndZ[ww d Zd
d� Zdd
� Zdd� Zdd� Zdd� Zdd� Zdd� Z ddd�Z edkr�e � dS dS )a*
SaltStack Extend
~~~~~~~~~~~~~~~~
A templating tool for extending SaltStack.
Takes a template directory and merges it into a SaltStack source code
directory. This tool uses Jinja2 for templating.
This tool is accessed using `salt-extend`
:codeauthor: Anthony Shaw <anthonyshaw@apache.org>
� N)�date)�Template)�deserialize)�OrderedDictTFztemplate.ymlc C sP t jj�| d��}t|�}||�dd�|f}W d � |S 1 s!w Y |S )a-
Get the contents of a template file and provide it as a module type
:param path: path to the template.yml file
:type path: ``str``
:param option_key: The unique key of this template
:type option_key: ``str``
:returns: Details about the template
:rtype: ``tuple``
�r�description� N)�salt�utils�files�fopenr �get)�pathZ
option_keyZ
template_f�template�info� r �E/opt/saltstack/salt/lib/python3.10/site-packages/salt/utils/extend.py�
_get_template) s
��r c C sx g }t �d| � t�| �D ],}tj�| |�}tj�|�r9tj�|t�}tj�|�r2|� t
||�� q
t �d|t� q
|S )z�
Fetch all of the templates in the src directory
:param src: The source path
:type src: ``str``
:rtype: ``list`` of ``tuple``
:returns: ``list`` of ('key', 'description')
zListing contents of %sz Directory does not contain %s %s)�log�debug�os�listdirr �join�isdir�TEMPLATE_FILE_NAME�isfile�appendr )�src� templates�item�sZ
template_pathr r r �_fetch_templates<