관리-도구
편집 파일: yaml.cpython-39.pyc
a �)gY � @ s� d dl mZmZmZ eZd dlZd dlmZ d dl m Z d dlmZ d dl mZ d dlmZ d dlmZ d d lmZ d Zdd� Zdd d�Zddd�ZdS )� )�absolute_import�division�print_functionN)� YAMLError)�AnsibleParserError)�YAML_SYNTAX_ERROR)� to_native)� AnsibleLoader)�AnsibleBaseYAMLObject)�AnsibleJSONDecoder)� from_yamlc C sh d}t |d�r0t� }||jjd |jjd f|_ttt|dd�� }dt| �|f }t ||||d��dS )z� Optionally constructs an object (AnsibleBaseYAMLObject) to encapsulate the file name/position where a YAML exception occurred, and raises an AnsibleParserError to display the syntax exception information. N�problem_mark� Zproblem� zcWe were unable to read either as JSON nor YAML, these are the errors we got from each: JSON: %s %s)�obj�show_content�orig_exc) �hasattrr r �line�columnZansible_posr r �getattrr )�json_exc�yaml_exc� file_namer Zerr_objZn_yaml_syntax_errorZ n_err_msg� r �>/usr/lib/python3.9/site-packages/ansible/parsing/utils/yaml.py� _handle_error s �r c C s� t | ||�}zL|�� W z|�� W S ty4 Y S 0 S z|�� W q| tyV Y q|0 n"z|�� W n tyx Y n0 0 dS )zD Implements yaml.safe_load(), except using our custom loader class. N)r Zget_single_dataZdispose�AttributeError)�streamr � vault_secrets�loaderr r r � _safe_load. s ��r! �<string>TFc C s� d}zt �|� tj| t d�}W n~ ty� } zf|rDtt|�|d��zt| ||d�}W n2 ty� } zt ||||� W Y d}~n d}~0 0 W Y d}~n d}~0 0 |S )zl Creates a python datastructure from the given data, which can be either a JSON or YAML string. N)�cls)r )r r ) r Zset_secrets�json�loads� Exceptionr r r! r r )�datar r r Z json_onlyZnew_datar r r r r r ; s :r )NN)r"