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/utils/__pycache__/mako.cpython-310.pyc
o

�N�g��@spdZzddlmZmZdZWneydZYnwer6ddlZddlZddl	Z
ddlZ
Gdd�de�ZdSdS)z+
Functions for working with Mako templates
�)�TemplateCollection�TemplateLookupTFNc@sDeZdZdZddd�Zdd�Zdd	�Zddd�Zd
d�Zdd�Z	d
S)�SaltMakoTemplateLookupa
        Look up Mako template files using file:// or salt:// URLs with <%include/>
        or <%namespace/>.

        (1) Look up mako template files on local file system via files://... URL.
            Make sure mako template file is present locally on minion beforehand.

          Examples:
            <%include   file="file:///etc/salt/lib/templates/sls-parts.mako"/>
            <%namespace file="file:///etc/salt/lib/templates/utils.mako" import="helper"/>

        (2) Look up mako template files on Salt master via salt://... URL.
            If URL is a relative  path (without an URL scheme) then assume it's relative
            to the directory of the salt file that's doing the lookup. If URL is an absolute
            path then it's treated as if it has been prefixed with salt://.

           Examples::
             <%include   file="templates/sls-parts.mako"/>
             <%include   file="salt://lib/templates/sls-parts.mako"/>
             <%include   file="/lib/templates/sls-parts.mako"/>                 ##-- treated as salt://

             <%namespace file="templates/utils.mako"/>
             <%namespace file="salt://lib/templates/utils.mako" import="helper"/>
             <%namespace file="/lib/templates/utils.mako" import="helper"/>     ##-- treated as salt://

        �baseFcCs.||_||_d|_||_tdd�|_i|_dS)N�/��directories)�opts�saltenv�_file_client�pillar_rendr�lookup�cache)�selfr	r
r�r�C/opt/saltstack/salt/lib/python3.10/site-packages/salt/utils/mako.py�__init__2s
zSaltMakoTemplateLookup.__init__cCs |js
tj�|j|j�|_|jS)z6
            Setup and return file_client
            )r�saltZ
fileclientZget_file_clientr	r)rrrr�file_client:s
�z"SaltMakoTemplateLookup.file_clientcCs@tj�|�j}|dvr
|S|rtd|�d|����|j�||�S)N)r�filezUnsupported URL scheme(z) in )�urllib�parse�urlparse�scheme�
ValueErrorr
�
adjust_uri)r�uri�filenamerrrrrDsz!SaltMakoTemplateLookup.adjust_uriNcCs�|�d�rd}d}|}n2d}|jddkr|jd|j}n
tj�|jdd|j�g}|�|�r2|ntjj�	|�}|�
|�t|d	�|_|j�
|t|�d��S)
Nzfile://rzsalt://r�localZ
file_rootsZcachedir�filesr)�
startswithr	r
�os�path�joinr�utils�url�create�
cache_filerr
�get_template�len)rrZ
relativeto�protoZ
searchpathZsalt_urirrrr(Ls
�
z#SaltMakoTemplateLookup.get_templatecCs.||jvr|���|dd|j�|j|<dSdS)N�T)rrZget_filer
)rZfpathrrrr'_s


��z!SaltMakoTemplateLookup.cache_filecCs:|jr|j}d|_z|��WdStyYdSwdS�N)r�destroy�AttributeError)rrrrrr-es��zSaltMakoTemplateLookup.destroy)rFr,)
�__name__�
__module__�__qualname__�__doc__rrrr(r'r-rrrrrs


r)
r2Zmako.lookuprrZHAS_MAKO�ImportErrorr!�urllib.parserZsalt.fileclientrZsalt.utils.urlrrrrr�<module>s��