a )gY @sddlmZmZmZeZddlZddlmZddl m Z ddl m Z ddl mZddlmZddlmZdd lmZd Zd d Zdd dZdddZdS))absolute_importdivisionprint_functionN) YAMLError)AnsibleParserError)YAML_SYNTAX_ERROR) to_native) AnsibleLoader)AnsibleBaseYAMLObject)AnsibleJSONDecoder) from_yamlcCshd}t|dr0t}||jjd|jjdf|_ttt|dd}dt||f}t ||||ddS)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_markZproblemzcWe were unable to read either as JSON nor YAML, these are the errors we got from each: JSON: %s %s)obj show_contentorig_exc) hasattrr r linecolumnZ ansible_posrrgetattrr)json_excyaml_exc file_namerZerr_objZn_yaml_syntax_errorZ n_err_msgr>/usr/lib/python3.9/site-packages/ansible/parsing/utils/yaml.py _handle_errors   rcCst|||}zL|Wz |WSty4YS0Sz |Wq|tyVYq|0n"z |WntyxYn00dS)zD Implements yaml.safe_load(), except using our custom loader class. N)r Zget_single_dataZdisposeAttributeError)streamr vault_secretsloaderrrr _safe_load.s        r!TFc Csd}zt|tj|td}Wn~ty}zf|rDtt||dzt|||d}Wn2ty}zt ||||WYd}~n d}~00WYd}~n d}~00|S)zl Creates a python datastructure from the given data, which can be either a JSON or YAML string. N)cls)r)rr) r Z set_secretsjsonloads Exceptionrrr!rr)datarrrZ json_onlyZnew_datarrrrrr ;s :r )NN)r"TNF)Z __future__rrrtypeZ __metaclass__r$ZyamlrZansible.errorsrZansible.errors.yaml_stringsrZansible.module_utils._textrZansible.parsing.yaml.loaderr Zansible.parsing.yaml.objectsr Zansible.parsing.ajsonr __all__rr!r rrrrs