File manager - Edit - /opt/saltstack/salt/lib/python3.10/site-packages/salt/renderers/__pycache__/yaml.cpython-310.pyc
Back
o ;j9 � @ s� d Z ddlZddlZddlmZ ddlmZ ddlmZ ddl m Z ddlZddl m mZ ddlm mZ ddlmZ e�e�Zdd iZd d� Zddd�ZdS )zZ YAML Renderer for Salt For YAML usage information see :ref:`Understanding YAML <yaml>`. � N)�OrderedDict)�ConstructorError)�ParserError)�ScannerError)�SaltRenderErrorz0found character '\t' that cannot start any tokenzIllegal tab characterc C s dd� }|S )z- Return the ordered dict yaml loader c W s$ t �d�rt}nt}|j| dti�S )N�use_yamlloader_oldZ dictclass)�__opts__�get�yamlloader_old�yamlloader_newZSaltYamlSafeLoaderr )�args� yamlloader� r �G/opt/saltstack/salt/lib/python3.10/site-packages/salt/renderers/yaml.py�yaml_loader s z$get_yaml_loader.<locals>.yaml_loaderr )�argliner r r r �get_yaml_loader s r �base� c s0 t �d�r t�d� t}nt}t| t�s| �� } t j dd��p}z|j| t|�d�}W n3 t yL } zt�|j|j�} |jjd } t| | |jj��d}~w ttfy] } zt|��d}~ww t|�dkrw|D ]}t�d |jtjj�|�|� qf|s{i }� fd d�� � |� |W d � S 1 s�w Y dS )z� Accepts YAML as a string or as a file object and runs it through the YAML parser. :rtype: A Python data structure r z]Using the old YAML Loader for rendering, consider disabling this and using the tojson filter.T)�record)�Loader� Nr z%s found in %s saltenv=%sc s^ t | t�r| �� D ]\}}t |t�rtd��� |� q dS t | t�r+| D ]}� |� q$dS dS )a PyYAML will for some reason allow improper YAML to be formed into an unhashable dict (that is, one with a dict as a key). This function will recursively go through and check the keys to make sure they're not dicts. z)Invalid YAML, possible double curly-braceN)� isinstance�dict�itemsr �list)�data�key�value�item��_validate_datar r r! P s � � �zrender.<locals>._validate_data)r r �log�warningr r r �str�read�warnings�catch_warnings�loadr r � _ERROR_MAPZproblemZproblem_mark�liner �bufferr r �len�message�salt�utils�url�create)Z yaml_dataZsaltenvZslsr �kwsr Z warn_listr �excZerr_typeZline_numr r r r �render* sD � ����$�r4 )r r r )�__doc__�loggingr&