/usr/lib/python3/dist-packages/cloudinit/__pycache__
Edit: /usr/lib/python3/dist-packages/cloudinit/__pycache__/safeyaml.cpython-310.pyc (7931B)
o
thm( @ s d dl Z d dlmZ d dlmZ d dlmZmZmZm Z d dl
Z
d dlmZ e
eZG dd dZdd Zd
ee fddZd
edee dee fddZG dd de
jZG dd de
jjZedde eeeef f fddZeddddZdS ) N)defaultdict)chain)AnyDictListTuple)performancec @ s6 e Zd ZdedejdejfddZdd Zdd Zd
S )SchemaPathMarkspath
start_markend_markc C s || _ || _|| _d S N)r
r r )selfr
r r r 4/usr/lib/python3/dist-packages/cloudinit/safeyaml.py__init__ s
zSchemaPathMarks.__init__c C sp |j j| j jk s|jj| jjkrdS |j j| j jkr$|j j| j jk r$dS |jj| jjkr6|jj| jjkr6dS dS )z;Return whether other start/end marks are within self marks.FT)r liner columnr otherr r r __contains__ s zSchemaPathMarks.__contains__c C s@ | j j|j jko| j j|j jko| jj|jjko| jj|jjkS r
)r r r r r r r r __eq__/ s zSchemaPathMarks.__eq__N) __name__
__module____qualname__stryamlMarkr r r r r r r r s r c C s0 |d d d D ]}| |v r| |ks| S qd S )Nr )
child_markmarksmarkr r r _find_closest_parent8 s
r"
line_marksc C s\ | D ])}t || }|r+|jdd\}}|j|jks!|j|js+|j||jd|_qdS )zP
Update any SchemaPathMarks.path for items not under the proper parent.
. N)r" r
rsplit
startswithreplace)r# r! parentpath_prefix _path_idxr r r _reparent_schema_mark_children? s
r, new_markr returnc C sd g }d}|D ]}|| vr| | q| |vrd}| | | | q|r+t| |S | | |S )a= Insert new_mark into marks, ordering ancestors first.
Reparent existing SchemaPathMarks.path when new_mark is a parent of
an existing mark item.
Because schema processing is depth first, leaf/child mappings and
sequences may be processed for SchemaPathMarks before their parents.
This leads to SchemaPathMarks.path of 'grandchildren' being incorrectly
parented by the root dictionary instead of an intermediary parents below
root.
Walk through the list of existing marks and reparent marks that are
contained within the new_mark.
FT)appendr, )r- r new_marksreparent_pathsr! r r r _add_mark_and_reparent_marksN s
r2 c sP e Zd ZdZ fddZdd Zd
fdd Zd
fd d
Z fddZ Z 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
`
.`.
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 s t | tt| _d S r
)superr r listschemamarks_by_line)r stream __class__r r r s z#_CustomSafeLoaderWithMarks.__init__c C s |j j| jv r1| j|j j d }| j|j j dd D ]}||v r'||v r'|}q||v r1|jd S t| j ddD ]\}}|d d d D ]}||v rU|j d S qEq:dS )Nr r% r$ T)reverser )r r r6 r
sorteditems)r nodemost_specific_mark path_mark _line_numschema_marksr! r r r _get_nested_path_prefix s.
z2_CustomSafeLoaderWithMarks._get_nested_path_prefixFc sr t j||d}| |}|jD ]&\}}| |j }|jj}t||j|j} | j| }
t | |
}|| j|<