관리-도구
편집 파일: native_helpers.cpython-39.opt-1.pyc
a �)g � @ s� d dl mZmZmZ eZd dlZd dlmZm Z d dl mZ d dlm Z d dlmZ d dlmZ d dlmZ d d dd�ZG dd � d ej�Zdd� Zdd� Zdd� ZdS )� )�absolute_import�division�print_functionN)�islice�chain)� GeneratorType��to_text)�string_types)�AnsibleVaultEncryptedUnicode)�NativeJinjaTextTF)�trueZfalseZnullc @ s e Zd Zdd� ZdS )�Json2Pythonc C s |j tvr|S tjt|j d�S )N)�value)�id� _JSON_MAP�astZConstant)�selfZnode� r �C/usr/lib/python3.9/site-packages/ansible/template/native_helpers.py� visit_Name s zJson2Python.visit_NameN)�__name__� __module__�__qualname__r r r r r r s r c C s� t t| d��}|sdS t|�dkrB|d }t|t�r8|S t|�}n(t| t�rVt|| �} d�dd� | D ��}|� d�s||dv r�z&t �t �t � �t j|d d ����}W n tttfy� Y n0 |S )an Return a string of concatenated compiled nodes. Throw an undefined error if any of the nodes is undefined. If the result of concat appears to be a dictionary, list or bool, try and convert it to such using literal_eval, the same mechanism as used in jinja2_native. Used in Templar.template() when jinja2_native=False and convert_data=True. � � � r c S s g | ]}t |��qS r r ��.0�vr r r � <listcomp>: � z'ansible_eval_concat.<locals>.<listcomp>)�{�[)�True�False�eval��mode)�listr �len� isinstancer r r r �join� startswithr �literal_evalZfix_missing_locationsr Zvisit�parse� ValueError�SyntaxError�MemoryError)�nodes�head�outr r r �ansible_eval_concat! s. ���r6 c C s d� dd� | D ��S )a Return a string of concatenated compiled nodes. Throw an undefined error if any of the nodes is undefined. Other than that it is equivalent to Jinja2's default concat function. Used in Templar.template() when jinja2_native=False and convert_data=False. r c S s g | ]}t |��qS r r r r r r r S r! z"ansible_concat.<locals>.<listcomp>)r, )r3 r r r �ansible_concatL s r7 c C s� t t| d��}|sdS t|�dkrX|d }t|t�r:|jS t|t�rH|S t|t�s�|S n(t| t�rlt || �} d� dd� | D ��}zt�tj |dd ��}W n tttfy� | Y S 0 t|t�r�|d }|� |� |� �S |S ) a� Return a native Python type from the list of compiled nodes. If the result is a single node, its value is returned. Otherwise, the nodes are concatenated as strings. If the result can be parsed with :func:`ast.literal_eval`, the parsed value is returned. Otherwise, the string is returned. https://github.com/pallets/jinja/blob/master/src/jinja2/nativetypes.py r Nr r r c S s g | ]}t |��qS r r r r r r r { r! z)ansible_native_concat.<locals>.<listcomp>r&