�
܍~c\ � �P � d dl mZ d dlmZ d dlmZmZmZmZ d dl Z e j
Z
edd� � Z G d� de j � � Z
G d � d
e j � � Ze
� de
j � � G d� d
e j j � � Zdeeeeef f fd�Zd� Zdd�ZdS )� )�
namedtuple)�chain)�Any�Dict�List�TupleN�SchemaPathMarks)�path�
start_mark�end_markc � � � e Zd Z� fd�Z� xZS )�_CustomSafeLoaderc �F �� t � � � |� � S �N)�super�construct_scalar)�self�node� __class__s ��4/usr/lib/python3/dist-packages/cloudinit/safeyaml.py�construct_python_unicodez*_CustomSafeLoader.construct_python_unicode s �� ��w�w�'�'��-�-�-� )�__name__�
__module__�__qualname__r �
__classcell__�r s @r r r s8 �� � � � � �.� .� .� .� .� .� .� .� .r r c �H � � e Zd ZdZ� fd�Zd� Z� fd�Zd� fd� Z� fd�Z� xZ S ) �_CustomSafeLoaderWithMarksa� A loader which provides line and column start and end marks for YAML.
If the YAML loaded represents a dictionary, get_single_data will inject
a top-level "schemamarks" key in that dictionary which can be used at
call-sites to process YAML paths schemamark metadata when annotating
YAML files for errors.
The schemamarks key is dictionary where each key is a dot-delimited path
into the YAML object. Each dot represents an element that is nested under
a parent and list items are represented with the format
`<parent>.<list-index>`.
The values in schemamarks will be the line number in the original content
where YAML element begins to aid in annotation when encountering schema
errors.
The example YAML shows expected schemamarks for both dicts and lists:
one: val1
two:
subtwo: val2
three: [val3, val4]
schemamarks == {
"one": 1, "two": 2, "two.subtwo": 3, "three": 4, "three.0": 4,
"three.1": 4
}
c �X �� t � � � |� � i | _ d S r )r �__init__�schemamarks_by_line)r �streamr s �r r! z#_CustomSafeLoaderWithMarks.__init__: s) �� �
������ � � �EG�� � � r c �� � |j j | j v r&| j |j j d d � d�S t | j � � � d�� � D ]�\ }}|d d d� D ]x}|j j |j j k r\|j j |j j k rB|j j |j j k r(|j j |j j k r|j � d�c c S �y��dS )Nr �.T)�reverse���� )r �liner" |