%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /lib/python3/dist-packages/cloudinit/__pycache__/
Upload File :
Create Path :
Current File : //lib/python3/dist-packages/cloudinit/__pycache__/safeyaml.cpython-312.pyc

�

�f#)���ddlmZddlmZddlmZmZmZmZddl	Z	e	jZ
Gd�d�ZGd�de	j�Z
d	�Zd
eefd�Zded
eedeefd�ZGd�de	j�Ze
j%de
j&�Gd�de	j(j*�Zdeeeeefffd�Zd�Zdd�Zy)�)�defaultdict)�chain)�Any�Dict�List�TupleNc�T�eZdZdedej
dej
fd�Zd�Zd�Zy)�SchemaPathMarks�path�
start_mark�end_markc�.�||_||_||_y�N)rrr
)�selfrrr
s    �4/usr/lib/python3/dist-packages/cloudinit/safeyaml.py�__init__zSchemaPathMarks.__init__s����	�$��� ��
�c�&�|jj|jjks-|jj|jjkDry|jj|jjk(r.|jj|jjkry|jj|jjk(r.|jj|jjkDryy)z;Return whether other start/end marks are within self marks.FT)r�liner
�column�r�others  r�__contains__zSchemaPathMarks.__contains__s���
���!�!�D�O�O�$8�$8�8��~�~�"�"�T�]�]�%7�%7�7�����!�!�T�_�_�%9�%9�9�� � �'�'�$�/�/�*@�*@�@���N�N���4�=�=�#5�#5�5����%�%��
�
�(<�(<�<��rc�v�|jj|jjk(xr�|jj|jjk(xr\|jj|jjk(xr-|jj|jjk(Sr)rrrr
rs  r�__eq__zSchemaPathMarks.__eq__+s����O�O� � �E�$4�$4�$9�$9�9�
>����&�&�%�*:�*:�*A�*A�A�
>��
�
�"�"�e�n�n�&9�&9�9�
>��
�
�$�$����(=�(=�=�		
rN)	�__name__�
__module__�__qualname__�str�yaml�Markrrr�rrr
r
s.��!�S�!�d�i�i�!�4�9�9�!�
�&
rr
c���eZdZ�fd�Z�xZS)�_CustomSafeLoaderc�"��t�|�|�Sr)�super�construct_scalar)r�node�	__class__s  �r�construct_python_unicodez*_CustomSafeLoader.construct_python_unicode5s����w�'��-�-r)rrrr*�
__classcell__�r)s@rr$r$4s
���.�.rr$c�:�|ddd�D]}||vs�||k(r�|cSy)N���r")�
child_mark�marks�marks   r�_find_closest_parentr29s2���d��d�������j�D�&8��K��r�
line_marksc�D�|D]�}t||�}|s�|jjdd�\}}|j|jk(s&|jj|j�r�p|jj	||jd�|_��y)zP
    Update any SchemaPathMarks.path for items not under the proper parent.
    �.�N)r2r�rsplit�
startswith�replace)r3r1�parent�path_prefix�	_path_idxs     r�_reparent_schema_mark_childrenr=@s����K��%�d�J�7���%)�Y�Y�%5�%5�c�1�%=�"�K���y�y�F�K�K�'�t�y�y�/C�/C����0�!�I�I�-�-�k�6�;�;��J��	�Kr�new_markr0�returnc���g}d}|D]@}||vr|j|��||vrd}|j|�|j|��B|r
t|�|S|j|�|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>r0�	new_marks�reparent_pathsr1s     r�_add_mark_and_reparent_marksrDOs���"�I��N�����x�����T�"���9�$�!�N����X�&��������&�y�1���	����"��rc�H��eZdZdZ�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�L��t�|�|�tt�|_yr)r&rr�list�schemamarks_by_line)r�streamr)s  �rrz#_CustomSafeLoaderWithMarks.__init__�s"���
���� �
���	
� rc���|jj|jvrp|j|jjd}|j|jjddD]}||vs�||vs�
|}�||vr|jdzSt	|jj�d��D])\}}|ddd�D]}||vs�|j�d�ccS�+y)Nrr6r5T)�reverser.�)rrrIr�sorted�items)rr(�most_specific_mark�	path_mark�	_line_num�schema_marksr1s       r�_get_nested_path_prefixz2_CustomSafeLoaderWithMarks._get_nested_path_prefix�s���?�?���4�#;�#;�;�!%�!9�!9����$�$�"��"��"�5�5�d�o�o�6J�6J�K����
3�	��9�$��6H�)H�)2�&�	
3�
�)�)�)�.�.��4�4�'-��$�$�*�*�,�d�(
�	+�#�I�|�%�T�r�T�*�
+���4�<�"�i�i�[��?�*�
+�	+�rc�R��t�|�|�}|j|�}|jD]v\}}|�|j��}|jj
}t
||j|j�}|j|}	t||	�}
|
|j|<�x|Sr)
r&�construct_mappingrT�valuerrr
r
rIrD)rr(�mapping�nested_path_prefix�key_node�
value_node�
node_key_path�line_numr>rSrBr)s           �rrVz,_CustomSafeLoaderWithMarks.construct_mapping�s�����'�+�D�1��!�9�9�$�?��$(�J�J�	;� �H�j�1�2�8�>�>�2B�C�M��*�*�/�/�H�&��x�2�2�J�4G�4G��H� �3�3�H�=�L�4�X�|�L�I�1:�D�$�$�X�.�	;��rc�"��t�
|�|d��}|j|�}t|j�D�]R\}}|j
j}|�|��}t||j
|j�}	||jvr|	g|j|<�c||jjk(r+|j|}
t|	|
�}||j|<��t||jj�D]�}||jvs�|j|}
t|	|
�}||k(rI|
dj|k7r7|jdt||
dj
|
dj��||j|<����U|S)NT)�deeprr.)r&�construct_sequencerT�	enumeraterWrrr
r
rIrD�ranger�insert)rr(r_�sequencerY�index�
sequence_itemr]r\r>rSrB�
inner_liner)s             �rr`z-_CustomSafeLoaderWithMarks.construct_sequence�s�����7�-�d��-�>��!�9�9�$�?��$-�d�j�j�$9�$	M� �E�=�$�/�/�4�4�H�1�2�5�'�:�M�&��}�7�7��9O�9O��H��t�7�7�7�6>�Z��(�(��2��}�5�5�:�:�:�#'�#;�#;�H�#E�L� <� �,�!�I�:C�D�,�,�X�6�&+� �-�"8�"8�"=�"=�'�M�
�&��)A�)A�A�+/�+C�+C�J�+O�L�(D� (�,�)�I�!+�h� 6�$0��O�$8�$8�M�$I� )� 0� 0�$%�$3�(5�(4�Q��(B�(B�(4�R�(8�(A�(A�%&�!"�DM�D�4�4�Z�@�)M�!$	M�J�rc���t�|��}t|t�r]tt	|j
j
��D�cgc]'}|j|jjdzf��)c}�|d<|Scc}w)Nr6�schemamarks)
r&�get_single_data�
isinstance�dictrrI�valuesrrr)r�data�vr)s   �rrjz*_CustomSafeLoaderWithMarks.get_single_data�sy����w�&�(���d�D�!�"&�#�D�$<�$<�$C�$C�$E�F����V�V�Q�\�\�.�.��2�3��#�D������s�,A?)F)
rrr�__doc__rrTrVr`rjr+r,s@rrFrFrs'����:��*�(�T	�	rrFz tag:yaml.org,2002:python/unicodec��eZdZdZd�Zy)�NoAliasSafeDumperz>A class which avoids constructing anchors/aliases on yaml dumpc��y)NTr")rrns  r�ignore_aliasesz NoAliasSafeDumper.ignore_aliases�s��rN)rrrrprtr"rrrrrr�s
��H�rrrc��tj|t��}t|t�si}||fS|jd�}||fS)a�Perform YAML SafeLoad and track start and end marks during parse.

    JSON schema errors come with an encoded object path such as:
        <key1>.<key2>.<list_item_index>

    YAML loader needs to preserve a mapping of schema path to line and column
    marks to annotate original content with JSON schema error marks for the
    command:
        cloud-init devel schema --annotate


    ��Loaderri)r �loadrFrkrl�pop)�blob�resultris   r�load_with_marksr|�sL���Y�Y�t�$>�
?�F��f�d�#����;����j�j��/���;��rc�8�tj|t��S)Nrv)r rxr$)rzs rrxrxs���9�9�T�"3�4�4rc	��tj|dd||d|rt��Stjj��S)z%Return data in nicely formatted yaml.�
�F)�
line_break�indent�explicit_start�explicit_end�default_flow_style�Dumper)r �dumprr�dumper�
SafeDumper)�objr�r��noaliass    r�dumpsr�sF���9�9����%�!� �%,�!���37�+�+�2H�2H��r)TTF)�collectionsr�	itertoolsr�typingrrrrr �	YAMLErrorr
�
SafeLoaderr$r2r=rDrF�add_constructorr*r�r�rrr�intr|rxr�r"rr�<module>r�s���$��)�)���N�N�	�

�
�D.����.�
�K�t�O�/D�K� �� �&*�?�&;� �	�/�� �Fz����z�z�!�!�&��.�.������.�.���U�3��S�#�X��#6�7��*5�r

Zerion Mini Shell 1.0