| Server IP : 3.96.16.70 / Your IP : 216.73.216.15 Web Server : Apache System : Linux ip-172-31-26-103.ca-central-1.compute.internal 6.1.163-186.299.amzn2023.x86_64 #1 SMP PREEMPT_DYNAMIC Tue Feb 24 16:35:42 UTC 2026 x86_64 User : ec2-user ( 1000) PHP Version : 8.4.18 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : OFF Directory : /lib/python3.9/site-packages/cloudinit/__pycache__/ |
Upload File : |
a
�½bP � @ s� d dl Z d dlZd dlZz d dlmZ d dlmZ dZW n e e
fyV dZeZY n0 d dlm
Z d dlmZ d dlmZ d d lmZ e�e�Ze�d
ej�Ze�d�ZdZG d
d� de�Zdd� Zdd� Zdd� Zddd�Z ddd�Z!dd� Z"dd� Z#dS ) � N)�DebugUndefined)�TemplateTF)�log)�
type_utils)�util)�
write_filez##\s*template:(.*)z)\$\{([A-Za-z0-9_.]+)\}|\$([A-Za-z0-9_.]+)zCI_MISSING_JINJA_VAR/c @ s e Zd ZdZdd� Zdd� ZdS )�UndefinedJinjaVariablez>Class used to represent any undefined jinja template variable.c C s dt | jf S )Nz%s%s)�MISSING_JINJA_PREFIX�_undefined_name)�self� r �7/usr/lib/python3.9/site-packages/cloudinit/templater.py�__str__( s zUndefinedJinjaVariable.__str__c C s( t |��td�}tdj| j|d���d S )N� zhUndefined jinja variable: "{this}-{other}". Jinja tried subtraction. Perhaps you meant "{this}_{other}"?)�this�other)�str�replacer � TypeError�formatr
)r r r r r
�__sub__+ s ��zUndefinedJinjaVariable.__sub__N)�__name__�
__module__�__qualname__�__doc__r r r r r r
r % s r c s � fdd�}t �|| �S )z�This does simple replacement of bash variable like templates.
It identifies patterns like ${a} or $a and can also identify patterns like
${a.b} or $a.b which will look for a key 'b' in the dictionary rooted
by key 'a'.
c s� | � d�}|d u r| � d�}|d u r,td��t�|�d��}� }t|�dkr�|�� }t|t�svt d|t
�|�|f ��|| }q@|�� }t|t�s�t d||t
�|�f ��t|| �S )N� � z,Match encountered but no valid group present�.zRCan not traverse into non-dictionary '%s' of type %s while looking for subkey '%s'z<Can not extract key '%s' from non-dictionary '%s' of type %s)
�group�RuntimeError�collections�deque�split�len�popleft�
isinstance�dictr �tuZobj_namer )�match�name�pathZselected_params�key��paramsr r
�replacer= s0
��
��zbasic_render.<locals>.replacer)�
BASIC_MATCHER�sub)�contentr- r. r r, r
�basic_render5 s r2 c C s� dd� }| � d�dkr(| �dd�\}}n| }d}t�|�}|sHdt| fS |�d��� �� }|dvrntd | ��|d
kr�t s�t
�d� dt|fS |d
kr�t r�d
||fS dt|fS d S )Nc S s4 | � d�rdnd}t| tddgd�jf i |��| S )N�
r Tz
jinja2.ext.do)Z undefinedZtrim_blocks�
extensions)�endswith� JTemplater Zrender)r1 r- �addr r r
�jinja_render\ s �
���z%detect_template.<locals>.jinja_renderr3 ���r r �basic)�jinjar: z.Unknown template rendering type '%s' requestedr; zcJinja not available as the selected renderer for desired template, reverting to the basic renderer.)�findr"