%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /snap/core24/current/lib/python3/dist-packages/cloudinit/__pycache__/
Upload File :
Create Path :
Current File : //snap/core24/current/lib/python3/dist-packages/cloudinit/__pycache__/templater.cpython-312.pyc

�

�qgj:���ddlZddlZddlZddlZddlmZmZddlmZddl	m
Z
ddl	mZddl	m
Z
ddlmZej e�ZdZGd	�d
e�ZGd�de�Ze
j,d
�d��Zd�Zd�Zdd�Zd�Zdd�Zy)�N)�DebugUndefined�TemplateSyntaxError)�SandboxedEnvironment)�performance)�
type_utils)�util)�
write_filezCI_MISSING_JINJA_VAR/c
�X��eZdZdeddf�fd�Zd�Ze	ddedededefd	��Zd
Z	�xZ
S)�JinjaSyntaxParsingException�error�returnNc���t�|�|jxsd|j|j|j
�|j|_y)Nzunknown syntax error)�super�__init__�message�lineno�name�filename�source)�selfr�	__class__s  ��5/usr/lib/python3/dist-packages/cloudinit/templater.pyrz$JinjaSyntaxParsingException.__init__!sA���	����M�M�3�3��L�L��J�J��N�N�		
��l�l���c��|j|j|j|jj	�|jdz
j���S)�;Avoid jinja2.TemplateSyntaxError multi-line __str__ format.���syntax_error�line_number�line_content)�format_error_messagerrr�
splitlines�strip�rs r�__str__z#JinjaSyntaxParsingException.__str__-sN���(�(����������/�/�1�$�+�+��/�B�H�H�J�)�
�	
rrrr c�X�|rd|��nd}tjj|||��S)rz: �r)r�message_template�formatrs   rr!z0JinjaSyntaxParsingException.format_error_message5s<��/;��L�>�*���*�;�;�B�B�%�#�%�C�
�	
rzfUnable to parse Jinja template due to syntax error: {syntax_error} on line {line_number}{line_content})r')�__name__�
__module__�__qualname__rrr%�staticmethod�strr!r(�
__classcell__)rs@rrr sf���
#�"�
#�
�
#�
���
��
��
��
�

�	
��
�	=�rrc��eZdZdZd�Zd�Zy)�UndefinedJinjaVariablez>Class used to represent any undefined jinja template variable.c�*�t�|j��S�N)�MISSING_JINJA_PREFIX�_undefined_namer$s rr%zUndefinedJinjaVariable.__str__Ns��-�t�/C�/C�D�Drc��t|�jtd�}tdj	|j
|����)Nr'zhUndefined jinja variable: "{this}-{other}". Jinja tried subtraction. Perhaps you meant "{this}_{other}"?)�this�other)r.�replacer4�	TypeErrorr)r5)rr8s  r�__sub__zUndefinedJinjaVariable.__sub__QsI���E�
�"�"�#7��<���
@�@F���)�)��AG�A�
�	
rN)r*r+r,�__doc__r%r;�rrr1r1Ks��H�E�
rr1zRendering basic templatec�<���fd�}tjd||�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
�0��|jd�}|�|jd�}|�td��tj|j	d��}�}t|�dkDr\|j
�}t|t�s(td|�dtj|��d|�d���||}t|�dkDr�\|j
�}t|t�s'td	|�d
|�dtj|�����t||�S)N�rz,Match encountered but no valid group present�.z&Can not traverse into non-dictionary 'z
' of type z while looking for subkey '�'zCan not extract key 'z' from non-dictionary ')
�group�RuntimeError�collections�deque�split�len�popleft�
isinstance�dictr:�tu�obj_namer.)�matchr�path�selected_params�key�paramss     �r�replacerzbasic_render.<locals>.replacerds�����{�{�1�~���<��;�;�q�>�D��<��M�N�N�� � ����C��1�� ���$�i�!�m��,�,�.�C��o�t�4��'����O�(D�c�K���.�c�2�O��$�i�!�m��l�l�n���/�4�0�������_�)E�G��
��?�3�'�(�(rz)\$\{([A-Za-z0-9_.]+)\}|\$([A-Za-z0-9_.]+))�re�sub)�contentrRrSs ` r�basic_renderrW[s"���)�6�6�6�4�h���rc�h�d�}|jd�dk7r|jdd�\}}n|}d}tjd|tj�}|s	dt
|fS|j
d�j�j�}|dvrtd	|z��|d
k(rd
||fSdt
|fS)Nc�v�|jd�rdnd}	tjd�5ttddg��}|j|�jd	i|��|zcddd�S#1swYyxYw#t$r'}|xjdz
c_t|��|�d}~wt$r}||�d}~wwxYw)
N�
r'zRendering jinja2 templateTz
jinja2.ext.do)�	undefined�trim_blocks�
extensionsr@)rr=)�endswithr�Timedrr1�from_string�renderrrr�	Exception)rVrR�add�	jinja_env�template_syntax_error�
unknown_errors      r�jinja_renderz%detect_template.<locals>.jinja_render�s����&�&�t�,�d�"��	3��"�"�#>�?�
M�0�4� $� /�0��	�
=�y�,�,�W�5�<�<�F�v�F��L�

M�
M�
M��#�	)�!�(�(�A�-�(�-�+��(�
)���	3��]�2��	3�s@�A9�7A-�#	A9�-A6�2A9�6A9�9	B8�"B$�$B8�0B3�3B8rZ���r@r'z##\s*template:(.*)�basic)�jinjariz.Unknown template rendering type '%s' requestedrj)
�findrGrTrN�IrWrC�lowerr#�
ValueError)�textrg�ident�rest�
type_match�
template_types      r�detect_templatert�s���3�&�y�y���"���j�j��q�)���t��������/�����=�J����t�,�,�"�(�(��+�1�1�3�9�9�;�
�� 2�2��@�� ��
��g�
%��\�4�0�0���t�,�,rc��|si}ttj|��\}}}tj	d||�|||�S)Nz+Rendering content of '%s' using renderer %s)rtr�load_text_file�LOG�debug)�fnrRrs�rendererrVs     r�render_from_filer{�sD�����'6�t�7J�7J�2�7N�'O�$�M�8�W��I�I�;�R��O��G�V�$�$rc�L�t||�}tj|||��y)N)�mode)r{rr	)ry�outfnrRr}�contentss     r�render_to_filer��s����F�+�H��O�O�E�8�$�/rc�:�|si}t|�\}}}|||�S)z
Render string)rt)rVrR�_template_typerzs    r�
render_stringr��s(�����(7��(@�%�N�H�g��G�V�$�$rc�*�tj|�}||d�}t||�j�dz}|r'tj|d��}|std|z��|dk(r tjj|�yt||d��y)	N)�variant�prefixrZT)�defaultz.Cannot render template file %s - invalid yaml.�-�w)�omode)
rrvr��rstrip�	load_yamlrD�sys�stdout�writer	)r��template�output�is_yamlr�r�
tpl_params�outs        r�render_templater��s����"�"�8�,�H�$��7�J��h�
�3�;�;�=��D�H���n�n�X�t�4����@�8�K��
���}��
�
����"��6�8�3�/r)i�r3)rE�loggingrTr��jinja2rr�jinja2.sandboxr�	cloudinitrrrLr�cloudinit.atomic_helperr	�	getLoggerr*rwr4rr1�timedrWrtr{r�r�r�r=rr�<module>r�s�����	�
�6�/�!�&��.��g����!��.��&�"5�&�V

�^�

� ����-�.�%�/�%�P&-�R%�0�
%�
0r

Zerion Mini Shell 1.0