o
    
i)                     @   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 ddl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rsd 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
rEeU5e8eUj9 eU5e:eUj; eU5eBeUjC eU5eVeUjW eU5eHeUjX eU5e6eUjY e
reeU5e#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r8d 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*   Q/home/ubuntu/.local/lib/python3.10/site-packages/srsly/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/   0   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selfr5   r6   r3   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)hasattrr3   
serializer_serializerAttributeError)r<   r*   r*   r+   r@   I   s   

zBaseRepresenter.serializerc                 C   s,   |  |}| j| i | _g | _d | _d S r,   )represent_datar@   	serializer7   r8   r9   )r<   datanoder*   r*   r+   	representS   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_aliasesr9   idr7   r8   appendtype__mro__r
   
isinstancetypesInstanceTyper/   	__class__listyaml_representersyaml_multi_representers
ScalarNoder   )r<   rE   rF   
data_types	data_typer*   r*   r+   rC   [   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
        )rC   r<   rE   r*   r*   r+   represent_key   s   
zBaseRepresenter.represent_keyc                 C   $   d| j vr| j | _|| j|< d S )NrR   )__dict__rR   copyr0   rV   representerr*   r*   r+   add_representer      
zBaseRepresenter.add_representerc                 C   rY   )NrS   )rZ   rS   r[   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)stylera   anchor)r5   getattrrT   r9   r7   )r<   tagvaluerb   rc   ra   rF   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)
SequenceNoder9   r7   rC   rM   rT   rb   rJ   r6   ri   )	r<   re   sequenceri   rf   rF   
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 )Nrh   T)rj   r9   r7   rC   rJ   r6   ri   )
r<   re   omapri   rf   rF   rl   item_keyitem_valrn   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 )Nrh   TitemsF)MappingNoder9   r7   r?   rQ   rt   r:   sorted	TypeErrorrX   rC   rM   rT   rb   rJ   r6   ri   )r<   re   mappingri   rf   rF   rl   rq   
item_valuenode_key
node_valuer*   r*   r+   represent_mapping   s6   




z!BaseRepresenter.represent_mappingc                 C   s   dS NFr*   rW   r*   r*   r+   rH      s   zBaseRepresenter.ignore_aliasesNNN)NNr,   )r'   r(   r)   rR   rS   r=   propertyr@   rG   rC   rX   classmethodr^   r`   rg   ro   rs   r|   rH   r*   r*   r*   r+   r"   8   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)rM   tupler   r   boolintfloatrW   r*   r*   r+   rH      s
   zSafeRepresenter.ignore_aliasesc                 C   s   |  ddS )Ntag:yaml.org,2002:nullnullrg   rW   r*   r*   r+   represent_none      zSafeRepresenter.represent_nonec                 C      |  d|S Ntag:yaml.org,2002:strr   rW   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|rb   )r?   base64r   decodeencodestringrg   rW   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encoderg   r<   rE   re   rb   r*   r*   r+   r     "   


c                 C   r   r   r   rW   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rc   )r3   boolean_representationr   rB   rg   )r<   rE   rc   rf   r*   r*   r+   represent_bool&  s   zSafeRepresenter.represent_boolc                 C      |  dt|S Ntag:yaml.org,2002:intrg   r   rW   r*   r*   r+   represent_int1     zSafeRepresenter.represent_intc                 C   r   r   r   rW   r*   r*   r+   represent_long7  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   r   .ez.0er   tag:yaml.org,2002:float)	inf_valuer	   reprlowerrd   r@   replacerg   r<   rE   rf   r*   r*   r+   represent_float?  s   
zSafeRepresenter.represent_floatc                 C   r   )Ntag:yaml.org,2002:seqro   rW   r*   r*   r+   represent_listU  s   	zSafeRepresenter.represent_listc                 C   r   )Ntag:yaml.org,2002:mapr|   rW   r*   r*   r+   represent_dictf  r   zSafeRepresenter.represent_dictc                 C   r   )Nztag:yaml.org,2002:omap)rs   rW   r*   r*   r+   represent_ordereddictj  r   z%SafeRepresenter.represent_ordereddictc                 C   s"   i }|D ]}d ||< q|  d|S )Ntag:yaml.org,2002:setr   )r<   rE   rf   keyr*   r*   r+   represent_setn  s   
zSafeRepresenter.represent_setc                 C   s   t | }| d|S )Ntag:yaml.org,2002:timestampr	   	isoformatrg   r   r*   r*   r+   represent_dateu  s   zSafeRepresenter.represent_datec                 C   s   t |d}| d|S )N r   r   r   r*   r*   r+   represent_datetimez  s   z"SafeRepresenter.represent_datetimec                 C   s.   t |dr
| }n|j }| j|||dS )N__getstate__rh   )r?   r   rZ   r[   r|   )r<   re   rE   r0   ri   stater*   r*   r+   represent_yaml_object  s   


z%SafeRepresenter.represent_yaml_objectc                 C   s   t d|f )Nzcannot represent an object: %s)r%   rW   r*   r*   r+   represent_undefined  s   z#SafeRepresenter.represent_undefinedr,   )r'   r(   r)   rH   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   UnicodeEncodeErrorrg   r<   rE   re   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   rg   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realrg   rW   r*   r*   r+   represent_complex  s   


zRepresenter.represent_complexc                 C   r   )Nztag:yaml.org,2002:python/tupler   rW   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)   rB   r'   rg   )r<   rE   namer*   r*   r+   represent_name  s   zRepresenter.represent_namec                 C   s   |  d|j dS )Nz tag:yaml.org,2002:python/module:r   )rg   r'   rW   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   )rP   r(   r'   r?   rQ   r   r   rZ   rM   dictr|   ro   r   )r<   rE   r0   
class_namer   r   rf   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)rK   copyregdispatch_tabler?   r   r   r%   rQ   r   r'   r(   r)   rB   rM   r|   ro   )r<   rE   r0   reducefunctionr   r   r   r   re   newobjfunction_namerf   r*   r*   r+   represent_object)  sl   




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)r5   r6   r3   )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}   )rc   rf   rB   r#   rH   rW   r*   r*   r+   rH     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   )lenr7   r@   use_explicit_startrg   rW   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   rb   rc   yaml_anchorr
   rM   r   rg   r<   rE   re   rb   rc   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   reversedrd   isspacer   r
   rM   r   rg   )r<   rE   re   rb   rc   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   )rg   rQ   r   insertjoin)r<   prefixs
underscorerc   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<   rE   r  rc   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_int7  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   rg   _exp_precr  r  _m_signabsr   r   r   split_e_sign_e_width_m_lead0r	   r   r   )r<   rE   rf   rc   precmsmeswr   m1m2esgnr*   r*   r+   represent_scalar_floatA  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ri   rc   Tr   Fr   )fari   rB   r   rj   r9   r7   rd   r   ra   resetrt   valuesrJ   end	enumeraterC   merge_commentsgetrM   rT   rb   r   r6   )r<   re   rk   ri   rf   rc   rF   rl   ra   ctitem_commentsvidxrm   rn   r*   r*   r+   ro     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 )Nra   )r?   rd   rC  r   ra   )r<   rF   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   Trh   r   )rM   r   r9   ro   r   r|   r#   rX   rW   r*   r*   r+   rX     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   ra   r      Fztag:yaml.org,2002:mergez<<)r?  ri   rB   r   ru   r9   r7   rd   r   ra   r@  rt   rA  rJ   rB  r   
IndexErrorr   non_merged_itemsrX   rC   rE  rM   rT   rb   r6   r   r  )r<   re   rx   ri   rf   rc   rF   rl   ra   rF  rG  rH  
merge_list	merge_pos
item_countrt   rq   ry   rz   r{   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   ra   r   rO  )r?  ri   rB   r   rj   r9   r7   rd   r   ra   r@  rt   rA  rJ   rB  rC   rE  rf   r6   )r<   re   rp   ri   rf   rc   rF   rl   ra   rF  rG  rH  rq   rr   rn   rU  rV  r*   r*   r+   rs   ?  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   ra   r   ?)r?  ri   r   rB   ru   r9   r7   rd   r   ra   r@  rt   rA  rJ   rB  odictrX   rC   rE  rb   rM   rT   )r<   settingri   re   rf   rc   rF   rl   ra   rF  rG  rH  rq   rz   r{   rU  r*   r*   r+   r   {  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   )re   rf   rB   
startswithr|   r<   rE   tre   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   )re   rf   rB   r]  ro   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   rg   r	   )r<   rE   interrc  rf   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   )re   rf   rB   r   rg   rb   )r<   rE   re   rc   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   rB   r#   r   )r<   rE   rc   r*   r*   r+   represent_scalar_bool  s   z*RoundTripRepresenter.represent_scalar_boolr~   r,   )r'   r(   r)   r=   rH   r   r   represent_preserved_scalarstringr  r
  r  r  r  r  r!  r%  r(  r*  r=  ro   rD  rX   r|   rs   r   r   r   r   re  rf  r*   r*   r*   r+   r&     s8    
	





	




]3

P<1r&   ){
__future__r   r   r   errornodescompatr   r   r	   r
   r   r   r   r   scalarstringr   r   r   r   r   	scalarintr   r   r   r   r   scalarfloatr   
scalarboolr   	timestampr   datetimesysrN   r   r   copy_regtypingr   r   r   r   r    r!   __all__	YAMLErrorr%   r/   objectr"   r#   r^   rK   r   strr   r   r   bytesr   r   r   r   r   longr   r   r   rQ   r   r   r   r   setr   r   version_infocollectionsOrderedDictdater   r   r   r$   complexr   r   r   	ClassTypeFunctionTypeBuiltinFunctionType
ModuleTyper   r`   rO   r   r   rJ  r   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   
 :  =,    S