o
    s                     @   sv  d dl mZ 	 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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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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ZG d/d0 d0eZ G d1d2 d2eZ!d3S )4    )unicode_literalsF)TextAnyDictOptionalList   )
StreamMarkTc                   @   sV   e Zd ZdZdd Zdd Zdd Zdd	 Zd
d Ze	dd Z
dddZdd ZdS )Token)
start_markend_mark_commentc                 C   s   || _ || _d S N)r   r   )selfr   r    r   ;/tmp/google-cloud-sdk/lib/third_party/ruamel/yaml/tokens.py__init__   s   
zToken.__init__c                    s   dd  j D }|  d fdd|D }tr+z|dt jj 7 }W n   Y z|dt j 7 }W n   Y d j	j
|S )Nc                 S   s   g | ]	}| d s|qS )_mark)endswith.0keyr   r   r   
<listcomp>   s    z"Token.__repr__.<locals>.<listcomp>z, c                    s   g | ]}d |t  |f qS )z%s=%rgetattrr   r   r   r   r      s    , line: z, comment: z{}({}))	__slots__sortjoin	SHOWLINESstrr   liner   format	__class____name__)r   
attributes	argumentsr   r   r   __repr__   s   zToken.__repr__c                 C   s"   t | ds
d d g| _|| jd< d S )Nr   r   hasattrr   )r   commentr   r   r   add_post_comment'   s   

zToken.add_post_commentc                 C   s4   t | ds
d d g| _| jd d u sJ || jd< d S )Nr   r   r)   )r   commentsr   r   r   add_pre_comments-   s   

zToken.add_pre_commentsc                 C      t | dd S Nr   r   r   r   r   r   get_comment4   s   zToken.get_commentc                 C   r/   r0   r   r   r   r   r   r+   8   s   zToken.commentFc                 C   s   | j }|du r	dS t|ttfrdS t| d |j }|s0|r+|d |d dd|d g}||_| S |d r8|d s@|d rH|d rHtd||f |d rR|d |d< |d r\|d |d< | S )zmove a comment from this token to target (normally next token)
        used to combine e.g. comments before a BlockEntryToken to the
        ScalarToken that follows it
        empty is a special for empty values -> comment after key
        Nr   r   r   zoverlap in comment %r %r)r+   
isinstanceStreamEndTokenDocumentStartTokendelattrr   NotImplementedError)r   targetemptyctcr   r   r   move_comment=   s&   
 zToken.move_commentc                 C   sD   | j }|du s|d du rdS |d dg}|d du r t| d |S )z split the post part of a comment, and return it
        as comment to be added. Delete second part if [None, None]
         abc:  # this goes to sequence
           # this goes to first element
           - first element
        Nr   r   r   )r+   r5   )r   r+   ret_valr   r   r   split_comment[   s   
zToken.split_commentN)F)r%   
__module____qualname__r   r   r(   r,   r.   r1   propertyr+   r;   r=   r   r   r   r   r
      s    

r
   c                   @      e Zd ZdZdZdd ZdS )DirectiveToken)namevaluez<directive>c                 C   s   t | || || _|| _d S r   )r
   r   rC   rD   )r   rC   rD   r   r   r   r   r   r   t   s   
zDirectiveToken.__init__Nr%   r>   r?   r   idr   r   r   r   r   rB   p       rB   c                   @      e Zd ZdZdZdS )r4   r   z<document start>Nr%   r>   r?   r   rF   r   r   r   r   r4   {       r4   c                   @   rH   )DocumentEndTokenr   z<document end>NrI   r   r   r   r   rK      rJ   rK   c                   @      e Zd ZdZdZdddZdS )StreamStartToken)encodingz<stream start>Nc                 C   s   t | || || _d S r   )r
   r   rN   )r   r   r   rN   r   r   r   r         
zStreamStartToken.__init__)NNNrE   r   r   r   r   rM          rM   c                   @   rH   )r3   r   z<stream end>NrI   r   r   r   r   r3      rJ   r3   c                   @   rH   )BlockSequenceStartTokenr   z<block sequence start>NrI   r   r   r   r   rQ      rJ   rQ   c                   @   rH   )BlockMappingStartTokenr   z<block mapping start>NrI   r   r   r   r   rR      rJ   rR   c                   @   rH   )BlockEndTokenr   z<block end>NrI   r   r   r   r   rS      rJ   rS   c                   @   rH   )FlowSequenceStartTokenr   [NrI   r   r   r   r   rT      rJ   rT   c                   @   rH   )FlowMappingStartTokenr   {NrI   r   r   r   r   rV      rJ   rV   c                   @   rH   )FlowSequenceEndTokenr   ]NrI   r   r   r   r   rX      rJ   rX   c                   @   rH   )FlowMappingEndTokenr   }NrI   r   r   r   r   rZ      rJ   rZ   c                   @   rH   )KeyTokenr   ?NrI   r   r   r   r   r\      rJ   r\   c                   @   rH   )
ValueTokenr   :NrI   r   r   r   r   r^      rJ   r^   c                   @   rH   )BlockEntryTokenr   -NrI   r   r   r   r   r`      rJ   r`   c                   @   rH   )FlowEntryTokenr   ,NrI   r   r   r   r   rb      rJ   rb   c                   @   rA   )
AliasTokenrD   z<alias>c                 C      t | || || _d S r   r
   r   rD   r   rD   r   r   r   r   r   r      rO   zAliasToken.__init__NrE   r   r   r   r   rd      rG   rd   c                   @   rA   )AnchorTokenre   z<anchor>c                 C   rf   r   rg   rh   r   r   r   r      rO   zAnchorToken.__init__NrE   r   r   r   r   ri      rG   ri   c                   @   rA   )TagTokenre   z<tag>c                 C   rf   r   rg   rh   r   r   r   r      rO   zTagToken.__init__NrE   r   r   r   r   rj      rG   rj   c                   @   rL   )ScalarToken)rD   plainstylez<scalar>Nc                 C   s$   t | || || _|| _|| _d S r   )r
   r   rD   rl   rm   )r   rD   rl   r   r   rm   r   r   r   r      s   
zScalarToken.__init__r   rE   r   r   r   r   rk      rP   rk   c                   @   s,   e Zd ZdZdZdd Zdd Zdd Zd	S )
CommentToken)rD   pre_donez	<comment>c                 C   rf   r   rg   rh   r   r   r   r      rO   zCommentToken.__init__c                 C   s   t | drt| d d S d S )Nro   )r*   r5   r   r   r   r   reset  s   
zCommentToken.resetc                 C   s<   d | j}trz|dt| jj 7 }W n   Y d |S )Nz{!r}r   zCommentToken({}))r#   rD   r    r!   r   r"   )r   vr   r   r   r(     s   
zCommentToken.__repr__N)r%   r>   r?   r   rF   r   rp   r(   r   r   r   r   rn      s    rn   N)"
__future__r   typingr   r   r   r   r   errorr	   r    objectr
   rB   r4   rK   rM   r3   rQ   rR   rS   rT   rV   rX   rZ   r\   r^   r`   rb   rd   ri   rj   rk   rn   r   r   r   r   <module>   s2   c
	


