o
                         @   s  d dl mZmZmZ d dlT d dlT d dlmZmZm	Z	m
Z
mZmZ d dlmZmZ d dlmZmZmZmZmZ d dlmZmZmZmZmZ d dlmZ d dlmZ d d	lm Z  d d
l!Z!d d
l"Z"d d
l#Z#erod d
l$Z$d d
l%Z%nd d
l&Z$	 g dZ.G dd de/Z0e
rdd Z1G dd de2Z3G dd de3Z4e45e6d
e4j7 e45e8e4j9 e
re45e:e4j; ne45e<e4j= e45e>e4j? e45e@e4jA e
re45eBe4jC e45eDe4jE e45eFe4jG e45eHe4jG e45eIe4jJ e45eKe4jL e45ee4jM e"jNdkr
d d
lOZOe45eOjPe4jM e45e!jQe4jR e45e!j!e4jS e45d
e4jT G dd de4ZUe
rAeU5e8eUj9 eU5e:eUj; eU5eBeUjC eU5eVeUjW eU5eHeUjX eU5e6eUjY e
raeU5e#jZeUjY eU5e#j[eUjY eU5e#j\eUjY eU5e#j]eUj^ e
reU_e#j`eUja eU_e2eUjb eU_e6eUjY d dlcmdZdmeZemfZfmgZgmhZhmiZimjZjmkZkmlZl G dd de4Zmem5e6d
emj7 em5eemjn em5eemjo em5eemjp em5eemjq em5eemjr em5eemjs em5eemjt em5eemju em5eemjv em5eemjw em5eemjx em5eemjy em5efemjG em5edemjJ em5eeemjM e"jNdkr4d d
lOZOem5eOjPemjM em5eiemjL em5elemjz em5e emjS d
S )    )print_functionabsolute_importdivision)*)	text_typebinary_type
to_unicodePY2PY3ordereddict)nprintnprintf)LiteralScalarStringFoldedScalarStringSingleQuotedScalarStringDoubleQuotedScalarStringPlainScalarString)	ScalarInt	BinaryIntOctalIntHexInt
HexCapsInt)ScalarFloat)ScalarBoolean)	TimeStampNF)DictListAnyUnionTextOptional)BaseRepresenterSafeRepresenterRepresenterRepresenterErrorRoundTripRepresenterc                   @   s   e Zd ZdS )r$   N)__name__
__module____qualname__ r)   r)   @/tmp/google-cloud-sdk/lib/third_party/ruamel/yaml/representer.pyr$   )   s    r$   c                 C   s$   | g}| j D ]	}|t| q|S N)	__bases__extendget_classobj_bases)clsbasesbaser)   r)   r*   r.   /   s   
r.   c                   @   s   e Zd Zi Zi ZdddZedd Zdd Zdd	 Z	d
d Z
edd Zedd ZdddZdddZdddZdddZdd ZdS )r!   Nc                 C   s@   || _ | j d ur| | j _|| _|| _i | _g | _d | _d| _d S )NT)dumper_representerdefault_styledefault_flow_stylerepresented_objectsobject_keeper	alias_key sort_base_mapping_type_on_outputselfr4   r5   r2   r)   r)   r*   __init__<   s   

zBaseRepresenter.__init__c                 C   s8   zt | jdr| jjW S | jjW S  ty   |  Y S w )Ntyp)hasattrr2   
serializer_serializerAttributeError)r;   r)   r)   r*   r?   H   s   

zBaseRepresenter.serializerc                 C   s,   |  |}| j| i | _g | _d | _d S r+   )represent_datar?   	serializer6   r7   r8   )r;   datanoder)   r)   r*   	representR   s
   

zBaseRepresenter.representc                 C   s  |  |r	d | _nt|| _| jd ur'| j| jv r!| j| j }|S | j| t|j}tr=t	|t
jr=t|jt| }|d | jv rP| j|d  | |}|S |D ]}|| jv rd| j| | |} |S qRd | jv rt| jd  | |}|S d | jv r| jd  | |}|S td t|}|S )Nr   )ignore_aliasesr8   idr6   r7   appendtype__mro__r	   
isinstancetypesInstanceTyper.   	__class__listyaml_representersyaml_multi_representers
ScalarNoder   )r;   rD   rE   
data_types	data_typer)   r)   r*   rB   Z   s:   







zBaseRepresenter.represent_datac                 C   s
   |  |S )a  
        David Fraser: Extract a method to represent keys in mappings, so that
        a subclass can choose not to quote them (for example)
        used in represent_mapping
        https://bitbucket.org/davidfraser/pyyaml/commits/d81df6eb95f20cac4a79eed95ae553b5c6f77b8c
        )rB   r;   rD   r)   r)   r*   represent_key   s   
zBaseRepresenter.represent_keyc                 C   $   d| j vr| j | _|| j|< d S )NrQ   )__dict__rQ   copyr/   rU   representerr)   r)   r*   add_representer      
zBaseRepresenter.add_representerc                 C   rX   )NrR   )rY   rR   rZ   r[   r)   r)   r*   add_multi_representer   r^   z%BaseRepresenter.add_multi_representerc                 C   sh   |d u r| j }d }|r|d dv rt|dd }|rd |gg}t|||||d}| jd ur2|| j| j< |S )Nr   z|>comment)styler`   anchor)r4   getattrrS   r8   r6   )r;   tagvaluera   rb   r`   rE   r)   r)   r*   represent_scalar   s   

z BaseRepresenter.represent_scalarc           	      C   s   g }t |||d}| jd ur|| j| j< d}|D ]}| |}t|tr'|jr)d}|| q|d u rA| jd ur>| j|_	|S ||_	|S )N
flow_styleTF)
SequenceNoder8   r6   rB   rL   rS   ra   rI   r5   rh   )	r;   rd   sequencerh   re   rE   
best_styleitem	node_itemr)   r)   r*   represent_sequence   s    


z"BaseRepresenter.represent_sequencec           
      C   s~   g }t |||d}| jd ur|| j| j< d}|D ]}|| }| ||i}	||	 q|d u r=| jd ur:| j|_|S ||_|S )Nrg   T)ri   r8   r6   rB   rI   r5   rh   )
r;   rd   omaprh   re   rE   rk   item_keyitem_valrm   r)   r)   r*   represent_omap   s   

zBaseRepresenter.represent_omapc                 C   s   g }t |||d}| jd ur|| j| j< d}t|dr4t| }| jr4zt|}W n	 ty3   Y nw |D ])\}}| 	|}	| 
|}
t|	trL|	jrNd}t|
trV|
jrXd}||	|
f q6|d u rr| jd uro| j|_|S ||_|S )Nrg   TitemsF)MappingNoder8   r6   r>   rP   rs   r9   sorted	TypeErrorrW   rB   rL   rS   ra   rI   r5   rh   )r;   rd   mappingrh   re   rE   rk   rp   
item_valuenode_key
node_valuer)   r)   r*   represent_mapping   s6   




z!BaseRepresenter.represent_mappingc                 C   s   dS NFr)   rV   r)   r)   r*   rG      s   zBaseRepresenter.ignore_aliasesNNN)NNr+   )r&   r'   r(   rQ   rR   r<   propertyr?   rF   rB   rW   classmethodr]   r_   rf   rn   rr   r{   rG   r)   r)   r)   r*   r!   7   s$    

	&






r!   c                   @   s   e Zd Zdd Zdd Zerdd Zdd Znd	d Zd
d Zd&ddZ	dd Z
er.dd ZdZeeeee krHee9 Zeeeee ks: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"   c                 C   s:   |d u st |tr|dkrdS t |tttttfrdS dS )Nr)   TF)rL   tupler   r   boolintfloatrV   r)   r)   r*   rG      s
   zSafeRepresenter.ignore_aliasesc                 C   s   |  ddS )Ntag:yaml.org,2002:nullnullrf   rV   r)   r)   r*   represent_none      zSafeRepresenter.represent_nonec                 C      |  d|S Ntag:yaml.org,2002:strr   rV   r)   r)   r*   represent_str  r   zSafeRepresenter.represent_strc                 C   s<   t tdrt|d}nt|d}| jd|ddS )Nencodebytesasciitag:yaml.org,2002:binary|ra   )r>   base64r   decodeencodestringrf   rV   r)   r)   r*   represent_binary  s   
z SafeRepresenter.represent_binaryc                 C   sv   d }d }z	t |d}d}W n% ty2   z	t |d}d}W n ty/   |d}d}d}Y nw Y nw | j|||dS )Nr   r   utf-8r   r   r   r   unicodeUnicodeDecodeErrorencoderf   r;   rD   rd   ra   r)   r)   r*   r     "   


c                 C   r   r   r   rV   r)   r)   r*   represent_unicode!  r   z!SafeRepresenter.represent_unicodeNc                 C   sF   z
| j jt| }W n ty   |rd}nd}Y nw | jd||dS )Ntruefalseztag:yaml.org,2002:boolrb   )r2   boolean_representationr   rA   rf   )r;   rD   rb   re   r)   r)   r*   represent_bool%  s   zSafeRepresenter.represent_boolc                 C      |  dt|S Ntag:yaml.org,2002:intrf   r   rV   r)   r)   r*   represent_int0     zSafeRepresenter.represent_intc                 C   r   r   r   rV   r)   r)   r*   represent_long6  r   zSafeRepresenter.represent_longgu <7~c                 C   s   ||ks|dkr|dkrd}n1|| j krd}n)|| j  kr d}n tt| }t| jdd dkr@d|vr@d	|v r@|d	d
d}| d|S )N              ?.nan.inf-.infuse_version)   r   .ez.0er   tag:yaml.org,2002:float)	inf_valuer   reprlowerrc   r?   replacerf   r;   rD   re   r)   r)   r*   represent_float>  s   
zSafeRepresenter.represent_floatc                 C   r   )Ntag:yaml.org,2002:seqrn   rV   r)   r)   r*   represent_listT  s   	zSafeRepresenter.represent_listc                 C   r   )Ntag:yaml.org,2002:mapr{   rV   r)   r)   r*   represent_dicte  r   zSafeRepresenter.represent_dictc                 C   r   )Nztag:yaml.org,2002:omap)rr   rV   r)   r)   r*   represent_ordereddicti  r   z%SafeRepresenter.represent_ordereddictc                 C   s"   i }|D ]}d ||< q|  d|S )Ntag:yaml.org,2002:setr   )r;   rD   re   keyr)   r)   r*   represent_setm  s   
zSafeRepresenter.represent_setc                 C   s   t | }| d|S )Ntag:yaml.org,2002:timestampr   	isoformatrf   r   r)   r)   r*   represent_datet  s   zSafeRepresenter.represent_datec                 C   s   t |d}| d|S )N r   r   r   r)   r)   r*   represent_datetimey  s   z"SafeRepresenter.represent_datetimec                 C   s.   t |dr
| }n|j }| j|||dS )N__getstate__rg   )r>   r   rY   rZ   r{   )r;   rd   rD   r/   rh   stater)   r)   r*   represent_yaml_object~  s   


z%SafeRepresenter.represent_yaml_objectc                 C   s   t d|f )Nzcannot represent an object: %s)r$   rV   r)   r)   r*   represent_undefined  s   z#SafeRepresenter.represent_undefinedr+   )r&   r'   r(   rG   r   r
   r   r   r   r   r   r	   r   r   r   r   r   r   r   r   r   r   r   r   r)   r)   r)   r*   r"      s2    



r"   )      c                   @   s\   e Zd Zerdd Zdd Zdd Zdd Zd	d
 Zdd Z	dd Z
er(dd Zdd ZdS )r#   c                 C   sv   d }d }z	t |d}d}W n% ty2   z	t |d}d}W n ty/   |d}d}d}Y nw Y nw | j|||dS )	Nr   r   r   ztag:yaml.org,2002:python/strr   r   r   r   r   r   r)   r)   r*   r     r   zRepresenter.represent_strc                 C   s:   d }z	| d d}W n ty   d}Y nw | ||S )Nr   z tag:yaml.org,2002:python/unicoder   )r   UnicodeEncodeErrorrf   r;   rD   rd   r)   r)   r*   r     s   
zRepresenter.represent_unicodec                 C   s$   d}t ||ur
d}| |t|S )Nr   ztag:yaml.org,2002:python/long)r   rf   r   r   r)   r)   r*   r     s   zRepresenter.represent_longc                 C   sd   |j dkrd|j }n!|jdkrd|j  }n|j dkr$d|j|j f }nd|j|j f }| d|S )Nr   z%rz%rjr   z%r+%rjz%r%rjz tag:yaml.org,2002:python/complex)imagrealrf   rV   r)   r)   r*   represent_complex  s   


zRepresenter.represent_complexc                 C   r   )Nztag:yaml.org,2002:python/tupler   rV   r)   r)   r*   represent_tuple  r   zRepresenter.represent_tuplec                 C   sH   z
d|j |jf }W n ty   d|j |jf }Y nw | d| dS )N%s.%sztag:yaml.org,2002:python/name: )r'   r(   rA   r&   rf   )r;   rD   namer)   r)   r*   represent_name  s   zRepresenter.represent_namec                 C   s   |  d|j dS )Nz tag:yaml.org,2002:python/module:r   )rf   r&   rV   r)   r)   r*   represent_module  s   zRepresenter.represent_modulec                 C   s   |j }d|j|jf }d }d }t|drt| }t|dr$| }n|j}|d u r8t|t	r8| 
d| |S t|t	rG|sG| d| |S i }t|rQ||d< ||d< | 
d| |S )Nr   __getinitargs__r    tag:yaml.org,2002:python/object:$tag:yaml.org,2002:python/object/new:argsr   )rO   r'   r&   r>   rP   r   r   rY   rL   dictr{   rn   r   )r;   rD   r/   
class_namer   r   re   r)   r)   r*   represent_instance  s0   


zRepresenter.represent_instancec                 C   s  t |}|tjv rtj| |}nt|dr|d}nt|dr&| }ntd|f t|d gd  d d }|\}}}}}t|}|d u rKi }|d urSt|}|d ur[t|}|j	dkro|d }|dd  }d	}	d
}
nd}	d}
z
d|j
|jf }W n ty   d|j
|j	f }Y nw |s|s|st|tr|
r| d| |S |s|st|tr|s| |	| |S i }|r||d< |st|ts||d< |r||d< |r||d< | |	| |S )N__reduce_ex__r   
__reduce__zcannot represent object: %r   
__newobj__r   r   r   Tz&tag:yaml.org,2002:python/object/apply:Fr   r   r   r   	listitems	dictitems)rJ   copyregdispatch_tabler>   r   r   r$   rP   r   r&   r'   r(   rA   rL   r{   rn   )r;   rD   r/   reducefunctionr   r   r   r   rd   newobjfunction_namere   r)   r)   r*   represent_object&  sZ   




zRepresenter.represent_objectN)r&   r'   r(   r	   r   r   r   r   r   r   r   r   r   r)   r)   r)   r*   r#     s    
	-r#   )	CommentedMapCommentedOrderedMapCommentedSeqCommentedKeySeqCommentedKeyMapCommentedSetcomment_attribmerge_attribTaggedScalarc                   @   s   e Zd Zd6ddZdd Zdd Zdd	 ZeZd
d Zdd Z	dd Z
dd Zd7ddZdd Zdd Zdd Zdd Zdd Zdd Zd7d d!Zd"d# Zd$d% Zd7d&d'Zd7d(d)Zd*d+ Zd,d- Zd.d/ Zd0d1 Zd2d3 Zd4d5 ZdS )8r%   Nc                 C   s,   t |ds|d u rd}tj| |||d d S )Nr=   F)r4   r5   r2   )r>   r"   r<   r:   r)   r)   r*   r<     s   
zRoundTripRepresenter.__init__c                 C   s@   z|j d ur|j jd urW dS W n	 ty   Y nw t| |S r|   )rb   re   rA   r"   rG   rV   r)   r)   r*   rG     s   z#RoundTripRepresenter.ignore_aliasesc                 C   s.   t | jdkr| jjs| ddS | ddS )Nr   r   r   r   )lenr6   r?   use_explicit_startrf   rV   r)   r)   r*   r     s   z#RoundTripRepresenter.represent_nonec                 C   B   d }d}|j dd}trt|tst|d}d}| j||||dS )Nr   Tanyr   r   ra   rb   yaml_anchorr	   rL   r   rf   r;   rD   rd   ra   rb   r)   r)   r*   represent_literal_scalarstring     
z3RoundTripRepresenter.represent_literal_scalarstringc                 C   s   d }d}|j dd}tt|dg D ]0}|| dkrB|dkrB||d   sB|t|k rB||d   sB|d | d ||d   }qtrOt|tsOt|d	}d
}| j||||dS )N>Tr   fold_posr   r   r   r   r   r   )	r   reversedrc   isspacer   r	   rL   r   rf   )r;   rD   rd   ra   rb   r  r)   r)   r*   represent_folded_scalarstring  s   
z2RoundTripRepresenter.represent_folded_scalarstringc                 C   r   )N'Tr   r   r   r   r   r   r)   r)   r*   $represent_single_quoted_scalarstring  r  z9RoundTripRepresenter.represent_single_quoted_scalarstringc                 C   r   )N"Tr   r   r   r   r   r   r)   r)   r*   $represent_double_quoted_scalarstring  r  z9RoundTripRepresenter.represent_double_quoted_scalarstringc                 C   r   )Nr   Tr   r   r   r   r   r   r)   r)   r*   represent_plain_scalarstring  r  z1RoundTripRepresenter.represent_plain_scalarstringc                 C   s   |d u r| j d|| |dS |d r7t|}t||d  }|dkr2||d ||d 8 }|dks"d|}|d r?d| }|d rG|d7 }| j d|| |dS )Nr   r   r   _r   r   r   )rf   rP   r   insertjoin)r;   prefixs
underscorerb   slposr)   r)   r*   insert_underscore  s   
z&RoundTripRepresenter.insert_underscorec                 C   D   |j d urd||j }nt|d}|jdd}| jd||j|dS )Nz{:0{}d}dTr   r   r   _widthformatr   r  _underscorer;   rD   r  rb   r)   r)   r*   represent_scalar_int  s
   

z)RoundTripRepresenter.represent_scalar_intc                 C   r  )Nz{:0{}b}bTr   0br   r  r  r)   r)   r*   represent_binary_int  
   

z)RoundTripRepresenter.represent_binary_intc                 C   r  )Nz{:0{}o}oTr   0or   r  r  r)   r)   r*   represent_octal_int  r"  z(RoundTripRepresenter.represent_octal_intc                 C   r  )Nz{:0{}x}xTr   0xr   r  r  r)   r)   r*   represent_hex_int  r"  z&RoundTripRepresenter.represent_hex_intc                 C   r  )Nz{:0{}X}XTr   r'  r   r  r  r)   r)   r*   represent_hex_caps_int%  r"  z+RoundTripRepresenter.represent_hex_caps_intc                 C   s  d}|j dd}||ks|dkr|dkrd}n|| jkrd}n|| j kr'd}|r1| jd	||d
S |jdu rU|jdkrU|j|jd krUd|jrK|jndtt	|}n|jdu r|j}|jrc|jnd}d|t||jt
| |j| d }|dks|dkr|dkr|dd}t
||jk r|d7 }t
||jk snAd||j|j|jrdnd d\}}|jdkr|jn|jd }|dk r|d7 }|d| }t	|}	|d\}
}t
|
t
| |j|jdkrdnd k r|d7 }t
|
t
| |j|jdkrdnd k s|jr|dkrd|
 }
|jrdnd}|jdk rq|dkr/|	t
|8 }	nd}t
|
t
| |jr>dnd |jk ra|d7 }|	d8 }	t
|
t
| |jrZdnd |jk sE|
| |j d|	||j }no|jdkr|	t
|8 }	|
| d |j d|	||j }nQ|jdkrd|jd  |
 | }d}
|d|j  }|	|j7 }	t
|
|jk r|
|d 7 }
|dd }|	d8 }	t
|
|jk s|
d | |j d|	||j }|du rtt| }| jd	||d
S )z this is way more complicated NTr   r   r   r   r   r   r   r   r   r   z{}{:d}.r   z{}{:0{}.{}f}z0.r   0z	{:{}.{}e}r   +z	{:{}0{}d})r   r   rf   _exp_precr  r  _m_signabsr   r   r   split_e_sign_e_width_m_lead0r   r   r   )r;   rD   re   rb   precmsmeswr   m1m2esgnr)   r)   r*   represent_scalar_float/  s   
$$
 **
((  
 
z+RoundTripRepresenter.represent_scalar_floatc                 C   s  g }z|j |}W n ty   |}Y nw z| }W n ty'   d }Y nw t||||d}| jd ur;|| j| j< d}zTt|t}|j	|_	|j	r[|j	d r[|j	d D ]}	|	
  qT|j}
|
 D ]}|ru|d ru|d D ]}	|	
  qnqb|j}
|j	|_	z	|j	|j W n	 ty   Y nw W n ty   i }
Y nw t|D ]!\}}| |}| ||
| t|tr|jrd}|| q|d u rt|dkr| jd ur| j|_|S ||_|S )Nrh   rb   Tr   Fr   )farh   rA   r   ri   r8   r6   rc   r   r`   resetrs   valuesrI   end	enumeraterB   merge_commentsgetrL   rS   ra   r   r5   )r;   rd   rj   rh   re   rb   rE   rk   r`   ctitem_commentsvidxrl   rm   r)   r)   r*   rn   ~  sd   




z'RoundTripRepresenter.represent_sequencec                 C   s   |d u rt |dsJ |S t|dd d ur=t|D ]#\}}|t|jkr%q|j| }|d ur<|d u s8||ks8J |||< q||_|S )Nr`   )r>   rc   rC  r   r`   )r;   rE   commentsrI  valncr)   r)   r*   rD    s   
z#RoundTripRepresenter.merge_commentsc                 C   sL   t |trd | _| jd|ddS t |tr d | _| jd|ddS t| |S )Nr   Trg   r   )rL   r   r8   rn   r   r{   r"   rW   rV   r)   r)   r*   rW     s   

z"RoundTripRepresenter.represent_keyc                 C   s  g }z|j |}W n ty   |}Y nw z| }W n ty'   d }Y nw t||||d}| jd ur;|| j| j< d}zMt|t}|j	|_	|j	r[|j	d r[|j	d D ]}	|	
  qT|j}
|
 D ]}|ru|d ru|d D ]}	|	
  qnqbz	|j	|j W n	 ty   Y nw W n ty   i }
Y nw dd t|tg D }zt|tdggd d }W n ty   d}Y nw d}t|r| }n| }|D ]i\}}|d7 }| |}| |}|
|}|rt|dd d u sJ |d d |_	t|dd }|d ur|d |d< |d	 |d< n|dd  |_	t|tr |jr"d
}t|tr,|jr.d
}|||f q|d u rS|dksEt|rP| jd urP| j|_n||_t|rzt|dkrg| |d }n| |}d|_||tdd|f |S )Nr>  Tr   c                 S   s   g | ]}|d  qS )r   r)   ).0r7  r)   r)   r*   
<listcomp>  s    z:RoundTripRepresenter.represent_mapping.<locals>.<listcomp>r   r`   r      Fztag:yaml.org,2002:mergez<<)r?  rh   rA   r   rt   r8   r6   rc   r   r`   r@  rs   rA  rI   rB  r   
IndexErrorr   non_merged_itemsrW   rB   rE  rL   rS   ra   r5   r   r  )r;   rd   rw   rh   re   rb   rE   rk   r`   rF  rG  rH  
merge_list	merge_pos
item_countrs   rp   rx   ry   rz   item_commentnvcargr)   r)   r*   r{     s   









 


z&RoundTripRepresenter.represent_mappingc                 C   s,  g }z|j |}W n ty   |}Y nw z| }W n ty'   d }Y nw t||||d}| jd ur;|| j| j< d}zMt|t}|j	|_	|j	r[|j	d r[|j	d D ]}	|	
  qT|j}
|
 D ]}|ru|d ru|d D ]}	|	
  qnqbz	|j	|j W n	 ty   Y nw W n ty   i }
Y nw |D ]g}|| }| ||i}|
|}|r|d rd |d g|_	t|jd d dd d u sJ |d d g|jd d _	t|jd d dd }|d ur|d |d< |d |d< n|dd  |jd d _	|| q|d u r| jd ur| j|_|S ||_|S )Nr>  Tr   r   r`   r   rO  )r?  rh   rA   r   ri   r8   r6   rc   r   r`   r@  rs   rA  rI   rB  rB   rE  re   r5   )r;   rd   ro   rh   re   rb   rE   rk   r`   rF  rG  rH  rp   rq   rm   rU  rV  r)   r)   r*   rr     sr   





z#RoundTripRepresenter.represent_omapc                 C   s  d}d}g }|j |}z| }W n ty   d }Y nw t||||d}| jd ur1|| j| j< d}zMt|t}|j	|_	|j	rQ|j	d rQ|j	d D ]}	|	
  qJ|j}
|
 D ]}|rk|d rk|d D ]}	|	
  qdqXz	|j	|j W n	 ty~   Y nw W n ty   i }
Y nw |jD ]E}| |}| d }|
|}|rt|dd d u sJ |d d |_	d |_|_t|tr|jrd}t|tr|jrd}|||f q|}|S )	NFr   r>  Tr   r`   r   ?)r?  rh   r   rA   rt   r8   r6   rc   r   r`   r@  rs   rA  rI   rB  odictrW   rB   rE  ra   rL   rS   )r;   settingrh   rd   re   rb   rE   rk   r`   rF  rG  rH  rp   ry   rz   rU  r)   r)   r*   r   U  sb   







z"RoundTripRepresenter.represent_setc                 C   sZ   z|j j}W n ty   d}Y nw |r%|dr"d|dd  }n|}nd}| ||S )z!write out tag if saved on loadingN!!tag:yaml.org,2002:r   r   )rd   re   rA   
startswithr{   r;   rD   trd   r)   r)   r*   r     s   
z#RoundTripRepresenter.represent_dictc                 C   sZ   z|j j}W n ty   d }Y nw |r%|dr"d|dd   }n|}nd}| ||S )Nr[  r\  r   r   )rd   re   rA   r]  rn   r^  r)   r)   r*   r     s   
z#RoundTripRepresenter.represent_listc                 C   sf   |j d rdnd}|j }|d r||d 7 }||}n||}|d r+||d 7 }| dt|S )Nr_  Tr   deltatzr   )_yamlr   rf   r   )r;   rD   interrc  re   r)   r)   r*   r     s   
z'RoundTripRepresenter.represent_datetimec                 C   s^   z|j j}W n ty   d }Y nw z| }W n ty#   d }Y nw | j||j|j|dS )Nr   )rd   re   rA   r   rf   ra   )r;   rD   rd   rb   r)   r)   r*   represent_tagged_scalar  s   z,RoundTripRepresenter.represent_tagged_scalarc                 C   s4   z|  }W n ty   d }Y nw tj| ||dS )Nr   )r   rA   r"   r   )r;   rD   rb   r)   r)   r*   represent_scalar_bool  s   z*RoundTripRepresenter.represent_scalar_boolr}   r+   )r&   r'   r(   r<   rG   r   r   represent_preserved_scalarstringr  r
  r  r  r  r  r!  r%  r(  r*  r=  rn   rD  rW   r{   rr   r   r   r   r   re  rf  r)   r)   r)   r*   r%     s8    
	




	




O3


N<1r%   ){
__future__r   r   r   ruamel.yaml.errorruamel.yaml.nodesruamel.yaml.compatr   r   r   r	   r
   r   r   r   ruamel.yaml.scalarstringr   r   r   r   r   ruamel.yaml.scalarintr   r   r   r   r   ruamel.yaml.scalarfloatr   ruamel.yaml.scalarboolr   ruamel.yaml.timestampr   datetimesysrM   r   r   copy_regtypingr   r   r   r   r   r    __all__	YAMLErrorr$   r.   objectr!   r"   r]   rJ   r   strr   r   r   bytesr   r   r   r   r   longr   r   r   rP   r   r   r   r   setr   r   version_infocollectionsOrderedDictdater   r   r   r#   complexr   r   r   	ClassTypeFunctionTypeBuiltinFunctionType
ModuleTyper   r_   rN   r   r   ruamel.yaml.commentsr   r   r   r   r   r   r   r   r   r%   r  r  r
  r  r  r  r!  r%  r(  r*  r=  rf  re  r)   r)   r)   r*   <module>   s    
 :  5,    8