HOME


Mini Shell 1.0
Redirecting to https://devs.lapieza.net/iniciar-sesion Redirecting to https://devs.lapieza.net/iniciar-sesion.
DIR: /lib/python3/dist-packages/cloudinit/handlers/__pycache__/
Upload File :
Current File : //lib/python3/dist-packages/cloudinit/handlers/__pycache__/jinja_template.cpython-311.pyc
�

܍~cD���UddlZddlZddlZddlmZddlmZmZddlm	Z	ddlm
Zddlm
Z
ddlmZddlmZmZmZdd	lmZmZmZmZeeed
<	ddlmZddlmZn#e $reZej!d
��ZYnwxYwej"e#��Z$Gd�de��Z%Gd�de��Z&Gd�de	j'��Z(	dd�Z)dd�Z*de+dee+fd�Z,	dd�Z-dS) �N)�EACCES)�Optional�Type)�handlers)�log)�Paths)�
PER_ALWAYS)�MISSING_JINJA_PREFIX�detect_template�
render_string)�b64d�
json_dumps�	load_file�	load_json�JUndefinedError)�UndefinedError)�operator_rez[-.]c��eZdZdS)�JinjaLoadErrorN��__name__�
__module__�__qualname__���C/usr/lib/python3/dist-packages/cloudinit/handlers/jinja_template.pyrr ��������Drrc��eZdZdS)�
NotJinjaErrorNrrrrrr$rrrc�&�eZdZdgZdefd�Zd�ZdS)�JinjaTemplatePartHandlerz## template: jinja�pathsc���tj�|td���||_i|_|�dg��D]#}|���D]}||j|<�
�$dS)N�)�version�sub_handlers)r�Handler�__init__r	r"r&�get�
list_types)�selfr"�_kwargs�handler�ctypes     rr(z!JinjaTemplatePartHandler.__init__,s�����!�!�$�
�A�!�>�>�>���
�����{�{�>�2�6�6�	3�	3�G� �+�+�-�-�
3�
3��+2��!�%�(�(�
3�	3�	3rc��|tjvrdS|j�d��}t	|||��}|sdStj|��}	|j�|	��}
|
st�	d||	��dS|
j
dkr|
�||||||��dS|
j
dkr|
�|||||��dSdS)N�instance_data_sensitivezPIgnoring jinja template for %s. Could not find supported sub-handler for type %sr$�)r�CONTENT_SIGNALSr"�get_runpath�render_jinja_payload_from_file�type_from_starts_withr&r)�LOG�warning�handler_version�handle_part)r+�datar.�filename�payload�	frequency�headers�jinja_json_file�rendered_payload�subtype�sub_handlers           rr9z$JinjaTemplatePartHandler.handle_part4s,���H�,�,�,��F��*�0�0�1J�K�K��9��X��
�
�� �	��F��0�1A�B�B���'�+�+�G�4�4���	��K�K�+���	
�
�
�
�F��&�!�+�+��#�#��e�X�'7��G�
�
�
�
�
��
(�A�
-�
-��#�#��e�X�'7��
�
�
�
�
�.�
-rN)rrr�prefixesrr(r9rrrr!r!(sF������$�%�H�3�e�3�3�3�3�����rr!Fc���t|��ddkrtd���i}d}tj�|��std|z���	t
t|����}nU#t$rH}d}t|ttf��r|jtkrd|z}t|��|�d}~wwxYwt||||��}|sdS|S)aRRender a jinja template payload sourcing variables from jinja_vars_path.

    @param payload: String of jinja template content. Should begin with
        ## template: jinja
.
    @param payload_fn: String representing the filename from which the payload
        was read used in error reporting. Generally in part-handling this is
        'part-##'.
    @param instance_data_file: A path to a json file containing variables that
        will be used as jinja template variables.

    @return: A string of jinja-rendered content with the jinja header removed.
        Returns None on error.
    r�jinjazPayload is not a jinja templateNzFCannot render jinja template vars. Instance data not yet present at %sz"Loading Jinja instance data failedzGCannot render jinja template vars. No read permission on '%s'. Try sudo)rr�os�path�existsrrr�	Exception�
isinstance�IOError�OSError�errnor�render_jinja_payload)r<�
payload_fn�instance_data_file�debug�
instance_datar@�e�msgs        rr4r4Qs%�� �w����"�g�-�-��=�>�>�>��M���
�7�>�>�,�-�-�
��
�1�
2�
�
�	
�
)�!�)�,>�"?�"?�@�@�
�
���)�)�)�2���a�'�7�+�,�,�	��w�&� � �&�(:�;���S�!�!�q�(�����)����,���]�E�������t��s�A<�<
C�AC	�	Cc�
�t||�dg��d���}|r(t�dt	|����	t||��}nH#ttf$r4}t�d|t|����Yd}~dSd}~wwxYwd�tjdtz|��D��}|r/t�d|d	�
|����|S)
Nzbase64-encoded-keysT)�decode_paths�include_key_aliaseszConverted jinja variables
%sz"Ignoring jinja template for %s: %sc�J�g|] }d|�td��z��!S)z'%s'�)�replacer
)�.0�vars  r�
<listcomp>z(render_jinja_payload.<locals>.<listcomp>�s<������	����1�2�6�6�6���rz%s[^\s]+z:Could not render jinja template variables in file '%s': %sz, )�convert_jinja_instance_datar)r6rQrr�	TypeErrorrr7�str�re�findallr
�join)r<rOrRrQ�instance_jinja_varsr@rS�warningss        rrNrN~s9��5��"�&�&�'<�b�A�A� �����

�
��	�	�+�Z�8K�-L�-L�	
�	
�	
��(��2E�F�F������'�������8�*�c�!�f�f�M�M�M��t�t�t�t�t������������:��.�.�0@�
�
����H��
����H���I�I�h���	
�	
�	
�
�s�A#�#B(�4)B#�#B(�	orig_name�returnc�L�tjtd|��}||kr|SdS)a�Return a jinja variable alias, replacing any operators with underscores.

    Provide underscore-delimited key aliases to simplify dot-notation
    attribute references for keys which contain operators "." or "-".
    This provides for simpler short-hand jinja attribute notation
    allowing one to avoid quoting keys which contain operators.
    {{ ds.v1_0.config.user_network_config }} instead of
    {{ ds['v1.0'].config["user.network-config"] }}.

    :param orig_name: String representing a jinja variable name to scrub/alias.

    :return: A string with any jinja operators replaced if needed. Otherwise,
        none if no alias required.
    �_N)ra�subr)rf�
alias_names  r�get_jinja_variable_aliasrl�s-�����S�)�4�4�J��Y������4rrY�/rc�(�i}d�|D��}t|�����D]�\}}|rd�|||��n|}||vrt|��}t	|t
��rdt
|||||���||<tjd|��r7||���D]\}	}
tj
|
��||	<�n|||<|r.t|��}|rtj
||��||<��|S)z�Process instance-data.json dict for use in jinja templates.

    Replace hyphens with underscores for jinja templates and decode any
    base64_encoded_keys.
    c�:�g|]}|�dd����S)�-ri)rZ)r[rGs  rr]z/convert_jinja_instance_data.<locals>.<listcomp>�s&��D�D�D�t�D�L�L��c�*�*�D�D�Drz	{0}{1}{2})�seprVrWzv\d+$)�sorted�items�formatr
rJ�dictr^ra�match�copy�deepcopyrl)r:�prefixrqrVrW�result�key�value�key_path�subkey�subvaluerks            rr^r^�sG���F�D�D�|�D�D�D�L��T�Z�Z�\�\�*�*�@�@�
��U�;A�J�;�%�%�f�c�3�7�7�7�s���|�#�#���K�K�E��e�T�"�"�
	 �5����)�$7����F�3�K��x��#�&�&�
=�(.�s��(9�(9�(;�(;�=�=�$�F�H�%)�]�8�%<�%<�F�6�N�N���F�3�K��	@�1�#�6�6�J��
@�%)�]�6�#�;�%?�%?��z�"���Mr)F)rYrmrF).rwrFrarMr�typingrr�	cloudinitrr�logging�cloudinit.helpersr�cloudinit.settingsr	�cloudinit.templaterr
rr�cloudinit.utilr
rrrrI�__annotations__�jinja2.exceptionsrr�jinja2.lexerr�ImportError�compile�	getLoggerrr6rrr'r!r4rNr`rlr^rrr�<module>r�so�������	�	�	�	�	�	�	�	�������!�!�!�!�!�!�!�!�������$�$�$�$�$�$�#�#�#�#�#�#�)�)�)�)�)�)�����������
B�A�A�A�A�A�A�A�A�A�A�A��i�� � � �&�C�C�C�C�C�C�(�(�(�(�(�(�(���&�&�&��O��"�*�W�%�%�K�K�K�&����
�g���!�!��	�	�	�	�	�Y�	�	�	�	�	�	�	�	�I�	�	�	�&�&�&�&�&�x�/�&�&�&�T49�*�*�*�*�Z����<�����
�����,DI� � � � � � s�A#�#A=�<A=