o
    ˳iȉ                     @   s  d dl mZmZ 	 d dlZd dlZd dlmZ d dlmZmZm	Z	 d dl
mZ d dlmZ er<d dlmZmZmZmZ nd dlmZmZmZmZ 	 g d
ZdZdZdZdZdZ G dd de!Z"dd Z#G dd de!Z$G dd de!Z%G dd de!Z&G dd de!Z'G dd de	e(e'Z)G dd de*e'Z+G d d! d!eZ,G d"d# d#e,eZ-G d$d% d%e,eZ.G d&d' d'e,Z/G d(d) d)ee'Z0e1d*d+ Z2G d,d- d-e'eZ3G d.d/ d/e0Z4G d0d1 d1ee'Z5G d2d3 d3e'Z6d4d5ej7fd6d7Z8dS )8    )absolute_importprint_functionN)ordereddict)PY2string_typesMutableSliceableSequence)ScalarString)Anchor)
MutableSetSizedSetMappingF)AnyDictOptionalListUnionr   Iterator)CommentedSeqCommentedKeySeqCommentedMapCommentedOrderedMapCommentedSetcomment_attribmerge_attrib_yaml_comment_yaml_format_yaml_line_col_yaml_merge	_yaml_tagc                   @   sd   e Zd ZdZeZdd Zdd Zedd Z	edd	 Z
e
jd
d	 Z
edd Zejdd ZdS )Comment)comment_items_end_startc                 C   s   d | _ i | _g | _d S N)r!   r"   r#   self r(   N/home/ubuntu/.local/lib/python3.10/site-packages/strictyaml/ruamel/comments.py__init__/   s   
zComment.__init__c                 C   s0   t | jrdt| j }nd}d| j| j|S )Nz,
  end= z$Comment(comment={0},
  items={1}{2}))boolr#   strformatr!   r"   )r'   endr(   r(   r)   __str__9   s   

zComment.__str__c                 C      | j S r%   r"   r&   r(   r(   r)   itemsC      zComment.itemsc                 C   r1   r%   r#   r&   r(   r(   r)   r/   H   r4   zComment.endc                 C   
   || _ d S r%   r5   r'   valuer(   r(   r)   r/   M      
c                 C   r1   r%   r$   r&   r(   r(   r)   startR   r4   zComment.startc                 C   r6   r%   r:   r7   r(   r(   r)   r;   W   r9   N)__name__
__module____qualname__	__slots__r   attribr*   r0   propertyr3   r/   setterr;   r(   r(   r(   r)   r    )   s    





r    c                   C   s   d S r%   r(   r(   r(   r(   r)   	NoComment^      rC   c                   @   s6   e Zd ZdZeZdd Zdd Zdd Zdd	d
Z	dS )Format_flow_stylec                 C   
   d | _ d S r%   rF   r&   r(   r(   r)   r*   g      
zFormat.__init__c                 C   
   d| _ d S NTrF   r&   r(   r(   r)   set_flow_stylek   rI   zFormat.set_flow_stylec                 C   rJ   NFrF   r&   r(   r(   r)   set_block_styleo   rI   zFormat.set_block_styleNc                 C   s   | j du r|S | j S )a  if default (the flow_style) is None, the flow style tacked on to
        the object explicitly will be taken. If that is None as well the
        default flow style rules the format down the line, or the type
        of the constituent values (simple -> flow, map/list -> block)NrF   )r'   defaultr(   r(   r)   
flow_styles   s   
zFormat.flow_styler%   )
r<   r=   r>   r?   format_attribr@   r*   rL   rN   rP   r(   r(   r(   r)   rE   c   s    rE   c                   @   sH   e Zd ZeZdd Zdd Zdd Zdd Zd	d
 Z	dd Z
dd ZdS )LineColc                 C   s   d | _ d | _d | _d S r%   )linecoldatar&   r(   r(   r)   r*      s   
zLineCol.__init__c                 C      | j d u ri | _ || j |< d S r%   rU   r'   keyrU   r(   r(   r)   add_kv_line_col      
zLineCol.add_kv_line_colc                 C      |  |ddS Nr      _kvr'   kr(   r(   r)   rY         zLineCol.keyc                 C   r\   )N      r_   ra   r(   r(   r)   r8      rc   zLineCol.valuec                 C   s(   | j d u rd S | j | }|| || fS r%   rW   )r'   rb   x0x1rU   r(   r(   r)   r`      s   

zLineCol._kvc                 C   s*   | j d u rd S | j | d | j | d fS r]   rW   r'   idxr(   r(   r)   item   s   
zLineCol.itemc                 C   rV   r%   rW   rX   r(   r(   r)   add_idx_line_col   r[   zLineCol.add_idx_line_colN)r<   r=   r>   line_col_attribr@   r*   rZ   rY   r8   r`   rj   rk   r(   r(   r(   r)   rR   ~   s    rR   c                   @   s(   e Zd ZdZdZeZdd Zdd ZdS )Tagz'store tag information for roundtrippingr8   c                 C   rH   r%   rn   r&   r(   r(   r)   r*      rI   zTag.__init__c                 C   s
   d | S )Nz#{0.__class__.__name__}({0.value!r}))r.   r&   r(   r(   r)   __repr__   rI   zTag.__repr__N)	r<   r=   r>   __doc__r?   
tag_attribr@   r*   ro   r(   r(   r(   r)   rm      s    rm   c                   @   s   e Zd Zedd Zd.ddZd.ddZd.dd	Zd/ddZ	d0ddZ	edd Z
edfddZedd Zdd Zdd Zdd Zedd Zdd Zd.d d!Zed"d# Zd$d% Zd1d&d'Zd(d) Zd*d+ Zd,d- ZdS )2CommentedBasec                 C   (   t | tjst| tjt  t| tjS r%   )hasattrr    r@   setattrgetattrr&   r(   r(   r)   ca      zCommentedBase.caFc                 C   s6   |d u rd S |s| j jd u rg | j _| j j| d S r%   )rw   r/   extend)r'   r!   clearr(   r(   r)   yaml_end_comment_extend   s
   z%CommentedBase.yaml_end_comment_extendc                 C   sr   | j j|g d}|s|d d u r(|d d ur!t|d ts!J |d |d< n	|d |d  |d |d< d S )NNNNNr^   r   rw   r"   
setdefault
isinstancelistry   r'   rY   r!   rz   rr(   r(   r)   yaml_key_comment_extend      z%CommentedBase.yaml_key_comment_extendc                 C   sr   | j j|g d}|s|d d u r(|d d ur!t|d ts!J |d |d< n	|d |d  |d |d< d S )Nr|   re   r^   r   rd   r}   r   r(   r(   r)   yaml_value_comment_extend   r   z'CommentedBase.yaml_value_comment_extendr   c           	      C   s   ddl m} ddlm} |  }|d dkr|dd }||}|dD ]!}| }t|dkr;|d dkr;d	| }|||d |d q%dS )
zoverwrites any preceding comment lines on an object
        expects comment to be without `#` and possible have multiple lines
        r^   CommentMarkCommentToken
Nr   ## )	errorr   tokensr   _yaml_get_pre_commentsplitstriplenappend)	r'   r!   indentr   r   pre_comments
start_markcomcr(   r(   r)   yaml_set_start_comment   s   z$CommentedBase.yaml_set_start_commentNc                    s*  ddl m} ddlm   fdd}|du r|d }|r.t|dkr.|d	 d
kr.|dd	 }|r<|d	 d
kr<|dd	 }||}| jj|dg ddg}	|d
kr[|	d |d| n|ro|	d
D ]}
|	d ||
| qb|r||}|	d du rg |	d< |	d
D ]}
|	d ||
| qdS dS )zc
        expects comment (before/after) to be without `#` and possible have multiple lines
        r   r   r   c                    s    | rdnd|  d |d S )Nr   r+   r   r(   )smarkr   r(   r)   comment_token   s   zFCommentedBase.yaml_set_comment_before_after_key.<locals>.comment_tokenNrd   r^   r   r   r+   re   )
strictyaml.ruamel.errorr   strictyaml.ruamel.tokensr   r   rw   r3   r~   r   r   )r'   rY   beforer   afterafter_indentr   r   r   r   r   r(   r   r)   !yaml_set_comment_before_after_key   s0   z/CommentedBase.yaml_set_comment_before_after_keyc                 C   rs   )z<format attribute

        set_flow_style()/set_block_style())rt   rE   r@   ru   rv   r&   r(   r(   r)   fa  s   zCommentedBase.fac                 C   s   ddl m} ddlm} |du r#z| |}W n ty"   d}Y nw |d dkr-d| }|du r=|d dkr=d| }d}||}|||ddg}| j||d	 dS )
z
        there is a problem as eol comments should start with ' #'
        (but at the beginning of the line the space doesn't have to be before
        the #. The column index is for the # mark
        r^   r   r   Nr   r   r    rY   )r   r   r   r   _yaml_get_columnAttributeError_yaml_add_eol_comment)r'   r!   rY   columnr   r   r   ctr(   r(   r)   yaml_add_eol_comment  s"   z"CommentedBase.yaml_add_eol_commentc                 C   rs   r%   )rt   rR   r@   ru   rv   r&   r(   r(   r)   lc6  rx   zCommentedBase.lcc                 C      || j _|| j _d S r%   )r   rS   rT   )r'   rS   rT   r(   r(   r)   _yaml_set_line_col=     z CommentedBase._yaml_set_line_colc                 C      | j || d S r%   )r   rZ   rX   r(   r(   r)   _yaml_set_kv_line_colB     z#CommentedBase._yaml_set_kv_line_colc                 C   r   r%   )r   rk   rX   r(   r(   r)   _yaml_set_idx_line_colF  r   z$CommentedBase._yaml_set_idx_line_colc                 C   rs   r%   )rt   r	   r@   ru   rv   r&   r(   r(   r)   anchorJ  rx   zCommentedBase.anchorc                 C   s   t | tjsd S | jS r%   )rt   r	   r@   r   r&   r(   r(   r)   yaml_anchorQ  s   zCommentedBase.yaml_anchorc                 C   r   r%   )r   r8   always_dump)r'   r8   r   r(   r(   r)   yaml_set_anchorW  r   zCommentedBase.yaml_set_anchorc                 C   rs   r%   )rt   rm   r@   ru   rv   r&   r(   r(   r)   tag\  rx   zCommentedBase.tagc                 C   s   || j _d S r%   )r   r8   r7   r(   r(   r)   yaml_set_tagc     zCommentedBase.yaml_set_tagc              
   C   sd   t jtjtjtjtjtfD ]"}t| |r/|d ur&t||t	
t| || qt||t| | qd S r%   )r    r@   rE   rR   r	   rm   r   rt   ru   copydeepcopyrv   )r'   tmemoar(   r(   r)   copy_attributesg  s   
zCommentedBase.copy_attributesc                 C      t r%   NotImplementedErrorr'   r!   rY   r(   r(   r)   r   s  rD   z#CommentedBase._yaml_add_eol_commentc                 C   r   r%   r   r&   r(   r(   r)   r   w  rD   z#CommentedBase._yaml_get_pre_commentc                 C   r   r%   r   r'   rY   r(   r(   r)   r   {  rD   zCommentedBase._yaml_get_column)Fr   )Nr   NNr%   )r<   r=   r>   rA   rw   r{   r   r   r   r   r   rC   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r(   r(   r(   r)   rr      s8    





#
	




rr   c                   @   s   e Zd ZejdfZdd Zdd Zdd Zd&d	d
Z	dd Z
dd Zdd Zdd ZefddZdd Zdd Zdd Zdd Zdd Zdd  Zd'd"d#Zd$d% ZdS )(r   _lstc                 O   s   t j| g|R i | d S r%   )r   r*   r'   argskwr(   r(   r)   r*     s   zCommentedSeq.__init__c                 C      t | |S r%   r   __getitem__rh   r(   r(   r)   __getsingleitem__  r   zCommentedSeq.__getsingleitem__c                 C   sP   |t | k rt|trt|tst| | trt| | |}t| || d S r%   )r   r   r   r   typer   __setitem__)r'   ri   r8   r(   r(   r)   __setsingleitem__  s   zCommentedSeq.__setsingleitem__Nc                 C   sV   t | | | jj|d  t| jjD ]}||k rq| jj|| jj|d < qd S Nr^   )r   __delitem__rw   r3   popsorted)r'   ri   
list_indexr(   r(   r)   __delsingleitem__  s   zCommentedSeq.__delsingleitem__c                 C   
   t | S r%   )r   __len__r&   r(   r(   r)   r     rI   zCommentedSeq.__len__c                 C   sP   t | || t| jjddD ]}||k r dS | jj|| jj|d < qdS )z5the comments after the insertion have to move forwardTreverser^   N)r   insertr   rw   r3   r   )r'   ri   valr   r(   r(   r)   r     s   zCommentedSeq.insertc                 C   s   t | | d S r%   )r   ry   )r'   r   r(   r(   r)   ry        zCommentedSeq.extendc                 C   r   r%   )r   __eq__r'   otherr(   r(   r)   r     r   zCommentedSeq.__eq__c                 C   $   |t ur| || d S || j_d S r%   rC   r   rw   r!   r   r(   r(   r)   _yaml_add_comment     zCommentedSeq._yaml_add_commentc                 C      | j ||d d S Nr   r   r   r(   r(   r)   r     r   z"CommentedSeq._yaml_add_eol_commentc                 C      | j j| d jjS Nr   rw   r3   r   r   r   r(   r(   r)   _yaml_get_columnX     zCommentedSeq._yaml_get_columnXc                 C      d }d }|d |d }}|| j jv r|}n!|| j jv r|}nt| D ]\}}||kr- n
|| j jvr4q#|}q#|d ur@| |}|S r   rw   r3   	enumerater   r'   rY   r   sel_idxprepostrow_idx_k1r(   r(   r)   r         
zCommentedSeq._yaml_get_columnc                 C   0   g }| j jd u rd |g| j _|S || j jd< |S r   rw   r!   r'   r   r(   r(   r)   r        z"CommentedSeq._yaml_get_pre_commentc                 C   sB   |   }||t| < | D ]}|t|| | j||d q|S N)r   )	__class__idr   r   r   r   r'   r   resrb   r(   r(   r)   __deepcopy__  s   zCommentedSeq.__deepcopy__c                 C   r   r%   )r   __add__r   r(   r(   r)   r    r   zCommentedSeq.__add__Fc                    s   |d u rt t tt |d}t dd |D  n t tt|t tt |d}t  fdd|D   jj	}i  j_
t|D ]\}}|d }||v r]||  jj	|< qId S )Nr   c                 S   s   g | ]}|d  qS r   r(   .0xr(   r(   r)   
<listcomp>  s    z%CommentedSeq.sort.<locals>.<listcomp>c                    s   g | ]
}t  |d  qS )r^   r   r  r&   r(   r)   r    s    r^   )r   zipranger   r   r*   map__iter__rw   r3   r"   r   )r'   rY   r   tmp_lstitmri   r  	old_indexr(   r&   r)   sort  s   zCommentedSeq.sortc                 C   r   r%   )r   ro   r&   r(   r(   r)   ro      rI   zCommentedSeq.__repr__r%   rM   )r<   r=   r>   r    r@   r?   r*   r   r   r   r   r   ry   r   rC   r   r   r   r   r   r  r  r  ro   r(   r(   r(   r)   r     s&    

				
r   c                   @   s<   e Zd ZdZefddZdd Zdd Zdd	 Zd
d Z	dS )r   zEThis primarily exists to be able to roundtrip keys that are sequencesc                 C   r   r%   r   r   r(   r(   r)   r     r   z!CommentedKeySeq._yaml_add_commentc                 C   r   r   r   r   r(   r(   r)   r     r   z%CommentedKeySeq._yaml_add_eol_commentc                 C   r   r   r   r   r(   r(   r)   r     r   z!CommentedKeySeq._yaml_get_columnXc                 C   r   r   r   r   r(   r(   r)   r     r   z CommentedKeySeq._yaml_get_columnc                 C   r   r   r   r   r(   r(   r)   r   ,  r   z%CommentedKeySeq._yaml_get_pre_commentN)
r<   r=   r>   rp   rC   r   r   r   r   r   r(   r(   r(   r)   r     s    r   c                   @       e Zd ZdZdd Zdd ZdS )CommentedMapView_mappingc                 C   r6   r%   r  )r'   mappingr(   r(   r)   r*   9  rI   zCommentedMapView.__init__c                 C   s   t | j}|S r%   )r   r  )r'   countr(   r(   r)   r   =  s   
zCommentedMapView.__len__N)r<   r=   r>   r?   r*   r   r(   r(   r(   r)   r  6  s    r  c                   @   ,   e Zd ZdZedd Zdd Zdd ZdS )	CommentedMapKeysViewr(   c                 C      t |S r%   setr'   itr(   r(   r)   _from_iterableF     z#CommentedMapKeysView._from_iterablec                 C   
   || j v S r%   r  r   r(   r(   r)   __contains__K  rI   z!CommentedMapKeysView.__contains__c                 c       | j D ]}|V  qd S r%   r  r'   r  r(   r(   r)   r  O  s   
zCommentedMapKeysView.__iter__Nr<   r=   r>   r?   classmethodr  r   r  r(   r(   r(   r)   r  C  s    
r  c                   @   r  )	CommentedMapItemsViewr(   c                 C   r  r%   r  r  r(   r(   r)   r  Y  r  z$CommentedMapItemsView._from_iterablec                 C   s2   |\}}z
| j | }W ||kS  ty   Y dS w rM   )r  KeyError)r'   rj   rY   r8   vr(   r(   r)   r   ^  s   z"CommentedMapItemsView.__contains__c                 c   s&    | j  D ]
}|| j | fV  qd S r%   r  _keysr   r(   r(   r)   r  h  s   zCommentedMapItemsView.__iter__Nr#  r(   r(   r(   r)   r%  V  s    

r%  c                   @   r  )CommentedMapValuesViewr(   c                 C   s$   | j D ]}|| j | kr dS qdS )NTFr  )r'   r8   rY   r(   r(   r)   r   q  s
   
z#CommentedMapValuesView.__contains__c                 c   s"    | j  D ]}| j | V  qd S r%   r(  r   r(   r(   r)   r  x  s   zCommentedMapValuesView.__iter__N)r<   r=   r>   r?   r   r  r(   r(   r(   r)   r*  n  s    r*  c                   @   s  e Zd ZejddfZdd ZeefddZdd Z	d	d
 Z
dd Zdd Zdd ZdTddZdUddZdd Zdd Zdd Zdd ZdTdd Zd!d" Zd#d$ Zd%d& Zd'd( Zd)d* Zd+d, Zd-d. Zersd/d0 Zd1d2 Zd3d4 Znd5d0 Zerd6d7 Z d8d9 Z!d:d; Z"d<d= Z#nd>d9 Z!d?d@ Z$erdAdB Z%dCdD Z&dEdF Z'ndGdB Z%e(dHdI Z)dJdK Z*dLdM Z+dNdO Z,dPdQ Z-dRdS Z.dS )Vr   _ok_refc                 O   s*   t  | _g | _tj| g|R i | d S r%   )r  r+  r,  r   r*   r   r(   r(   r)   r*     s   zCommentedMap.__init__c                 C   <   |t ur| || dS |t ur| || dS || j_dS z>values is set to key to indicate a value attachment of commentNrC   r   r   rw   r!   r'   r!   rY   r8   r(   r(   r)   r        zCommentedMap._yaml_add_commentc                 C      | j ||d dS z6add on the value line, with value specified by the keyrn   Nr   r   r(   r(   r)   r        z"CommentedMap._yaml_add_eol_commentc                 C   r   )Nrd   r   r   r(   r(   r)   r     r   zCommentedMap._yaml_get_columnXc           	      C   s   d }d }d\}}}| D ]}|d ur||kr|} n	||kr|}|}q|| j jv r+|}n|| j jv r4|}n| D ]}||kr> n
|| j jvrEq6|}q6|d urQ| |}|S )NNNN)rw   r3   r   )	r'   rY   r   r   r   r   lastr  k1r(   r(   r)   r     s.   

zCommentedMap._yaml_get_columnc                 C   r   r   r   r   r(   r(   r)   r     r   z"CommentedMap._yaml_get_pre_commentc                 O   s   zt j| g|R i | W n ty&   |d D ]
}|d | | |< qY nw z
| j|  W n tyI   |d D ]
}| j|d  q<Y nw |rV| jj|   d S d S r   )r   update	TypeErrorr+  keysr   add)r'   valsr   r  r(   r(   r)   r8    s"   zCommentedMap.updateNc                 C   s:   t | ||| | j| |dur| j||d dS dS )zPinsert key value into given position
        attach comment if provided
        Nr   )r   r   r+  r;  r   )r'   posrY   r8   r!   r(   r(   r)   r     s
   zCommentedMap.insertFc              	      sh   t |ts| ||S  fdd z |d| W S  ty$   | Y S  ttfy3   s/ | Y S w )z/multi-level get that expects dicts within dictsc                    sZ   s	t |ts	J |t| kr|t| krt|| |d   S  | |d || |d   S r   )r   dictr   
IndexError)key_listleveldget_one_levellist_okr(   r)   rD    s   z)CommentedMap.mlget.<locals>.get_one_levelr^   )r   r   getr&  r9  r?  )r'   rY   rO   rE  r(   rC  r)   mlget  s   

zCommentedMap.mlgetc                 C   sR   zt | |W S  ty(   t| tg D ]}||d v r&|d |    Y S q w r   )r   r   r&  rv   r   )r'   rY   mergedr(   r(   r)   r     s   zCommentedMap.__getitem__c                 C   sX   || v rt |trt |tst | | trt| | |}t| || | j| d S r%   )r   r   r   r   r   r   r+  r;  )r'   rY   r8   r(   r(   r)   r     s   zCommentedMap.__setitem__c                 C   s   || j v rdS d S rK   )r+  r   r(   r(   r)   _unmerged_contains  s   
zCommentedMap._unmerged_containsc                 C      t t| |S r%   )r,   r   r   r   r(   r(   r)   r     r   zCommentedMap.__contains__c                 C   s   z|  |W S    | Y S r%   )r   )r'   rY   rO   r(   r(   r)   rF    s   zCommentedMap.getc                 C   s   t | ddS )Nr   r   )r   ro   replacer&   r(   r(   r)   ro     r   zCommentedMap.__repr__c                 c   s2    t | D ]}|| jv r|t | |fV  qd S r%   )r   r  r+  r   r"  r(   r(   r)   non_merged_items!  s   
zCommentedMap.non_merged_itemsc                 C   s2   | j | t| | | jD ]}|| qd S r%   )r+  discardr   r   r,  update_key_value)r'   rY   refererr(   r(   r)   r   '  s
   
zCommentedMap.__delitem__c                 c       t | D ]}|V  qd S r%   r   r  r"  r(   r(   r)   r  ;     zCommentedMap.__iter__c                 c   rP  r%   rQ  r"  r(   r(   r)   r)  @  rR  zCommentedMap._keysc                 C   s   t t| S r%   )intr   r   r&   r(   r(   r)   r   E  rc   zCommentedMap.__len__c                 C   s   t t| |kS r%   )r,   r>  r   r(   r(   r)   r   I  r   zCommentedMap.__eq__c                 C      t |  S r%   )r   r)  r&   r(   r(   r)   r:  O  r   zCommentedMap.keysc                 C      |   S r%   )r)  r&   r(   r(   r)   iterkeysS     zCommentedMap.iterkeysc                 C      t | S r%   r  r&   r(   r(   r)   viewkeysW  rW  zCommentedMap.viewkeysc                 C   rX  r%   rY  r&   r(   r(   r)   r:  ]  rW  c                 c   s$    t | D ]	}t | |V  qd S r%   r   r  r   r"  r(   r(   r)   _valuesc  s   zCommentedMap._valuesc                 C   rT  r%   )r   r\  r&   r(   r(   r)   valuesh  r   zCommentedMap.valuesc                 C   rU  r%   )r\  r&   r(   r(   r)   
itervaluesl  rW  zCommentedMap.itervaluesc                 C   rX  r%   r*  r&   r(   r(   r)   
viewvaluesp  rW  zCommentedMap.viewvaluesc                 C   rX  r%   r_  r&   r(   r(   r)   r]  v  rW  c                 c   s(    t | D ]}|t | |fV  qd S r%   r[  r"  r(   r(   r)   r"   z  s   zCommentedMap._itemsc                 C   rT  r%   )r   r"   r&   r(   r(   r)   r3     r   zCommentedMap.itemsc                 C   rU  r%   r2   r&   r(   r(   r)   	iteritems  rW  zCommentedMap.iteritemsc                 C   rX  r%   r%  r&   r(   r(   r)   	viewitems  rW  zCommentedMap.viewitemsc                 C   rX  r%   rb  r&   r(   r(   r)   r3     rW  c                 C   s    t | tst| tg  t| tS r%   )rt   r   ru   rv   r&   r(   r(   r)   merge  s   

zCommentedMap.mergec                 C   s2   t |  }|  D ]\}}|||< q	| | |S r%   )r   r"   r   )r'   r  rb   r'  r(   r(   r)   r     s
   


zCommentedMap.copyc                 C   s   || j vr| j | d S d S r%   )r,  r   )r'   cmr(   r(   r)   add_referent  s   
zCommentedMap.add_referentc                 C   sZ   |D ]"}|d  |  |d  D ]\}}t| |rqt| || qq| j| d S r   )rf  r3   r   r   r   rd  ry   )r'   r8   r'  rb   r(   r(   r)   add_yaml_merge  s   zCommentedMap.add_yaml_mergec                 C   sR   || j v rd S | jD ]}||d v r t| ||d |   d S q
t| | d S r   )r+  rd  r   r   r   )r'   rY   r'  r(   r(   r)   rN    s   

zCommentedMap.update_key_valuec                 C   sD   |   }||t| < | D ]}t| | |||< q| j||d |S r   )r   r   r   r   r   r   r(   r(   r)   r    s   zCommentedMap.__deepcopy__r%   rM   )/r<   r=   r>   r    r@   r?   r*   rC   r   r   r   r   r   r8  r   rG  r   r   rI  r   rF  ro   rL  r   r  r)  r   r   r   r:  rV  rZ  r\  r]  r^  r`  r"   r3   ra  rc  rA   rd  r   rf  rg  rN  r  r(   r(   r(   r)   r   ~  s^    	










r   c                 O   s   t d| j)Nz{} objects are immutable)r9  r.   r<   )clsr   kwargsr(   r(   r)   raise_immutable     rj  c                   @   s   e Zd ZejdfZ	 dd Ze Z Z	 Z
 Z Z ZZdd Zdd Zdd	 Zd
d Zdd ZedddZefddZdd Zdd Zdd Zdd ZdS )CommentedKeyMap_odc                 O   sV   t | dr	t|  zt|i || _W d S  ty*   tr)t|d  | _Y d S  w )Nrm  r   )rt   rj  r   rm  r9  r   r3   r   r(   r(   r)   r*     s   
zCommentedKeyMap.__init__c                 C   s
   | j | S r%   )rm  )r'   indexr(   r(   r)   r     rI   zCommentedKeyMap.__getitem__c                 c   s    | j  D ]}|V  qd S r%   )rm  r  r"  r(   r(   r)   r    rR  zCommentedKeyMap.__iter__c                 C   
   t | jS r%   )r   rm  r&   r(   r(   r)   r     rI   zCommentedKeyMap.__len__c                 C   s   t t|  S r%   )hashtupler3   r&   r(   r(   r)   __hash__  r   zCommentedKeyMap.__hash__c                 C   s.   t | ts
| j S dtt| j  d S )Nzordereddict())rt   r   rm  ro   reprr   r3   r&   r(   r(   r)   ro     s   

zCommentedKeyMap.__repr__Nc                 C   rJ  r%   )rl  r>  fromkeys)r:  r'  r(   r(   r)   ru    rk  zCommentedKeyMap.fromkeysc                 C   r   r%   r   r   r(   r(   r)   r     r   z!CommentedKeyMap._yaml_add_commentc                 C   r   r   r   r   r(   r(   r)   r     r   z%CommentedKeyMap._yaml_add_eol_commentc                 C   r   r   r   r   r(   r(   r)   r     r   z!CommentedKeyMap._yaml_get_columnXc                 C   r   r   r   r   r(   r(   r)   r     r   z CommentedKeyMap._yaml_get_columnc                 C   r   r   r   r   r(   r(   r)   r   !  r   z%CommentedKeyMap._yaml_get_pre_commentr%   )r<   r=   r>   r    r@   r?   r*   rj  r   r   rz   r   popitemr~   r8  r   r  r   rr  ro   r$  ru  rC   r   r   r   r   r   r(   r(   r(   r)   rl    s6    
rl  c                   @   s   e Zd ZejfZdS )r   N)r<   r=   r>   r    r@   r?   r(   r(   r(   r)   r   +  s    r   c                   @   sf   e Zd ZejdfZdddZeefddZdd Z	d	d
 Z
dd Zdd Zdd Zdd Zdd ZdS )r   odictNc                 C   s*   t  | _t|  |d ur| |O } d S d S r%   )r   rw  r
   r*   )r'   r]  r(   r(   r)   r*   2  s
   
zCommentedSet.__init__c                 C   r-  r.  r/  r0  r(   r(   r)   r   9  r1  zCommentedSet._yaml_add_commentc                 C   r2  r3  r   r   r(   r(   r)   r   D  r4  z"CommentedSet._yaml_add_eol_commentc                 C   s   d| j |< dS )zAdd an element.Nrw  r7   r(   r(   r)   r;  I  s   zCommentedSet.addc                 C   s   | j |= dS )z8Remove an element.  Do not raise an exception if absent.Nrx  r7   r(   r(   r)   rM  N  s   zCommentedSet.discardc                 C   r  r%   rx  r"  r(   r(   r)   r   S  rI   zCommentedSet.__contains__c                 c   r!  r%   rx  r"  r(   r(   r)   r  W  s   
zCommentedSet.__iter__c                 C   ro  r%   )r   rw  r&   r(   r(   r)   r   \  rI   zCommentedSet.__len__c                 C   s   d | j S )Nz
set({0!r}))r.   rw  r:  r&   r(   r(   r)   ro   `  r   zCommentedSet.__repr__r%   )r<   r=   r>   r    r@   r?   r*   rC   r   r   r;  rM  r   r  r   ro   r(   r(   r(   r)   r   /  s    

r   c                   @   s   e Zd ZdddZdd ZdS )TaggedScalarNc                 C   s&   || _ || _|d ur| | d S d S r%   )r8   styler   )r'   r8   rz  r   r(   r(   r)   r*   g  s
   zTaggedScalar.__init__c                 C   r1   r%   rn   r&   r(   r(   r)   r0   n  s   zTaggedScalar.__str__r5  )r<   r=   r>   r*   r0   r(   r(   r(   r)   ry  e  s    
ry  r+   .c                 C   s   t | tr7t| dr7|rtjd| |d| j | D ]}t| | |r.|| | n|||d q dS t | t	rrt| drt|rLtjd| |d| j t
| D ]\}}t||ri|| t| nt|||d qYdS dS dS )zg
    recursively dump comments, all but the toplevel preceded by the path
    in dotted form x.0.a
    rw   z{}
)namesepoutN)r   r>  rt   sysstdoutwriter.   rw   dump_commentsr   r   r-   )rB  r|  r}  r~  rb   ri   r(   r(   r)   r  s  s"   & r  )9
__future__r   r   r  r   strictyaml.ruamel.compatr   r   r   r   strictyaml.ruamel.scalarstringr   strictyaml.ruamel.anchorr	   collectionsr
   r   r   r   collections.abctypingr   r   r   r   r   r   __all__r   rQ   rl   r   rq   objectr    rC   rE   rR   rm   rr   r   r   rq  r   r  r  r%  r*  r   r$  rj  rl  r   r   ry  r  r  r(   r(   r(   r)   <module>   sT   5+ I 1  J
_6