File manager - Edit - /opt/saltstack/salt/lib/python3.10/site-packages/salt/utils/__pycache__/yamlencoding.cpython-310.pyc
Back
o ;j5 � @ sV d Z ddlZddlZddlZddlmZ e� dd� �Ze� dd� �Ze� dd � �ZdS ) z9 Functions for adding yaml encoding to the jinja context � N)�jinja_filterc C �T t �� �}tjj|tjd�}|�t| �� |� � W d � S 1 s#w Y dS )z� Make text into a double-quoted YAML string with correct escaping for special characters. Includes the opening and closing double quote characters. ��widthN) �io�StringIO�yaml�emitter�Emitter�sys�maxsizeZwrite_double_quoted�str�getvalue��textZostreamZyemitter� r �K/opt/saltstack/salt/lib/python3.10/site-packages/salt/utils/yamlencoding.py�yaml_dquote � $�r c C r )z� Make text into a single-quoted YAML string with correct escaping for special characters. Includes the opening and closing single quote characters. r N) r r r r r r r Zwrite_single_quotedr r r r r r �yaml_squote r r c C s` t j�� }|�| �}t|t j�std�t| ����|j � dd�d }|j}|dkr.t|j�}|S )zn A simple YAML encode that can take a single-element datatype and return a string representation. z=yaml_encode() only works with YAML scalar data; failed for {}�:� ���r ) r ZrepresenterZSafeRepresenterZrepresent_data� isinstanceZ ScalarNode� TypeError�format�type�tag�rsplit�valuer )�dataZyreprZynoder �retr r r �yaml_encode'