%PDF- %PDF-
Mini Shell

Mini Shell

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

�

�f����UddlZddlZddlZddlZddlmZddlmZddlm	Z
ddlmZddlm
Z
eed<	ddlmZdd	lmZd
ZeZej0e�Zej6dej8�Zej6d
�ZdZGd�de�Z Gd�de�Z!d�Z"d�Z#d�Z$dd�Z%d�Z&dd�Z'y#eef$rdZeZY�{wxYw)�N)�Any)�TemplateSyntaxError)�
type_utils)�util)�
write_file�
JUndefined)�DebugUndefined)�TemplateTFz##\s*template:(.*)z)\$\{([A-Za-z0-9_.]+)\}|\$([A-Za-z0-9_.]+)zCI_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__0sA���	����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�)�
�	
rrr r!c�X�|rd|��nd}tjj|||��S)rz: �r)r�message_template�formatrs   rr"z0JinjaSyntaxParsingException.format_error_messageDs<��/;��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@rrr/sf���
#�"�
#�
�
#�
���
��
��
��
�

�	
��
�	=�rrc��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__]s��-�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/�replacer5�	TypeErrorr*r6)rr9s  r�__sub__zUndefinedJinjaVariable.__sub__`sI���E�
�"�"�#7��<���
@�@F���)�)��AG�A�
�	
rN)r+r,r-�__doc__r&r<�rrr2r2Zs��H�E�
rr2c�:���fd�}tj||�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>.replacerrs�����{�{�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�'�(�(r)�
BASIC_MATCHER�sub)�contentrSrTs ` r�basic_renderrXjs���)�6���X�w�/�/rc��d�}|jd�dk7r|jdd�\}}n|}d}tj|�}|s	dt|fS|jd�j
�j�}|dvrtd|z��|d	k(r$tstjd
�dt|fS|d	k(rtrd	||fSdt|fS)Nc��|jd�rdnd}	t|tddg��jdi|��|zS#t$r'}|xj
dz
c_t
|��|�d}~wt$r}||�d}~wwxYw)	N�
r(Tz
jinja2.ext.do)�	undefined�trim_blocks�
extensionsrA)r
r>)�endswith�	JTemplater2�renderrrr�	Exception)rWrS�add�template_syntax_error�
unknown_errors     r�jinja_renderz%detect_template.<locals>.jinja_render�s����&�&�t�,�d�"��	3��	��4� $� /�0�	�
�&�#�
"�#��
�
��#�	)�!�(�(�A�-�(�-�+��(�
)���	3��]�2��	3�s!�&>�	A=�"A)�)A=�5A8�8A=r[���rAr(�basic)�jinjarhz.Unknown template rendering type '%s' requestedrizcJinja not available as the selected renderer for desired template, reverting to the basic renderer.)�findrH�TYPE_MATCHERrOrXrD�lowerr$�
ValueError�JINJA_AVAILABLE�LOG�warning)�textrf�ident�rest�
type_match�
template_types      r�detect_templaterv�s���3�*�y�y���"���j�j��q�)���t������#�#�E�*�J����t�,�,�"�(�(��+�1�1�3�9�9�;�
�� 2�2��@�� ��
��G�#�O��K�K�F�
��\�4�0�0�
�g�
%�/��\�4�0�0���t�,�,rc��|si}ttj|��\}}}tj	d||�|||�S)Nz+Rendering content of '%s' using renderer %s)rvr�load_text_filero�debug)�fnrSru�rendererrWs     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)rz�outfnrSr~�contentss     r�render_to_filer��s����F�+�H��O�O�E�8�$�/rc�:�|si}t|�\}}}|||�S)z
Render string)rv)rWrS�_template_typer{s    r�
render_stringr��s(�����(7��(@�%�N�H�g��G�V�$�$rc�b�t|d�5}|j�}ddd�||d�}t|�j�dz}|r't	j
|d��}|st
d|z��|dk(r tjj|�yt||d�	�y#1swY��xYw)
N�r)�variant�prefixr[T)�defaultz.Cannot render template file %s - invalid yaml.�-�w)�omode)�open�readr��rstripr�	load_yamlrE�sys�stdout�writer)	r��template�output�is_yamlr��fhr��
tpl_params�outs	         r�render_templater��s���	
�h��	����7�7�9���$��7�J��h�
�3�;�;�=��D�H���n�n�X�t�4����@�8�K��
���}��
�
����"��6�8�3�/���s�B%�%B.)i�r4)(rF�logging�rer��typingr�jinja2r�	cloudinitrrMr�cloudinit.atomic_helperr�__annotations__r	�_DebugUndefinedr
r`rnr�ImportError�AttributeError�object�	getLoggerr+ro�compile�IrkrUr5rr2rXrvr|r�r�r�r>rr�<module>r�s�����	�
��&�&��.�

���8�,��O� �J�
�g����!���r�z�z�/����6����
�
�G�H�
�.��&�"5�&�V

�Z�

� #0�L.-�b%�0�
%�0��c	�^�$���O��J��s�B4�4C�C

Zerion Mini Shell 1.0