U
    ïûeÉ´  ã                   @   sf  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 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Zd d	lZd d	l Z erÎd d	l!Z!d d	l"Z"nd d	l#Z!d
ddddgZ*G dd„ de+ƒZ,e
rdd„ Z-G dd
„ d
e.ƒZ/G dd„ de/ƒZ0e0 1e2d	ƒe0j3¡ e0 1e4e0j5¡ e
rXe0 1e6e0j7¡ ne0 1e8e0j9¡ e0 1e:e0j;¡ e0 1e<e0j=¡ e
r–e0 1e>e0j?¡ e0 1e@e0jA¡ e0 1eBe0jC¡ e0 1eDe0jC¡ e0 1eEe0jF¡ e0 1eGe0jH¡ e0 1ee0jI¡ ejJdkrd d	lKZKe0 1eKjLe0jI¡ e0 1ejMe0jN¡ e0 1eje0jO¡ e0 1d	e0jP¡ G dd„ de0ƒZQe
r|eQ 1e4eQj5¡ eQ 1e6eQj7¡ eQ 1e>eQj?¡ eQ 1eReQjS¡ eQ 1eDeQjT¡ eQ 1e2eQjU¡ e
r¼eQ 1e jVeQjU¡ eQ 1e jWeQjU¡ eQ 1e jXeQjU¡ eQ 1e jYeQjZ¡ e
reQ [e j\eQj]¡ eQ [e.eQj^¡ d dl_m`Z`maZambZbmcZcmdZdmeZemfZfmgZgmhZh G dd„ de0ƒZiei 1e2d	ƒeij3¡ ei 1eeijj¡ ei 1eeijk¡ ei 1eeijl¡ ei 1eeijm¡ ei 1eeijn¡ ei 1eeijo¡ ei 1eeijp¡ ei 1eeijq¡ ei 1eeijr¡ ei 1eeijs¡ ei 1ebeijC¡ ei 1e`eijF¡ ei 1eaeijI¡ ejJdkr8d d	lKZKei 1eKjLeijI¡ ei 1eeeijH¡ ei 1eheijt¡ ei 1eeijO¡ d	S )é    )Úprint_functionÚabsolute_importÚdivision)Ú*)Ú	text_typeÚbinary_typeÚ
to_unicodeÚPY2ÚPY3Úordereddict)ÚnprintÚnprintf)ÚLiteralScalarStringÚFoldedScalarStringÚSingleQuotedScalarStringÚDoubleQuotedScalarString)Ú	ScalarIntÚ	BinaryIntÚOctalIntÚHexIntÚ
HexCapsInt)ÚScalarFloat)Ú	TimeStampNÚBaseRepresenterÚSafeRepresenterÚRepresenterÚRepresenterErrorÚRoundTripRepresenterc                   @   s   e Zd ZdS )r   N)Ú__name__Ú
__module__Ú__qualname__© r!   r!   ú6lib/python3.8/site-packages/ruamel_yaml/representer.pyr   '   s   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 k	r| | j _|| _|| _i | _g | _d | _d| _d S )NT)ÚdumperZ_representerÚdefault_styleÚdefault_flow_styleÚrepresented_objectsÚobject_keeperÚ	alias_keyÚ sort_base_mapping_type_on_output©Úselfr+   r,   r*   r!   r!   r"   Ú__init__:   s    
zBaseRepresenter.__init__c                 C   s>   z t | jdƒr| jjW S | jjW S  tk
r8   |  Y S X d S )NÚtyp)Úhasattrr*   Ú
serializerZ_serializerÚAttributeError)r2   r!   r!   r"   r6   F   s    

zBaseRepresenter.serializerc                 C   s,   |   |¡}| j |¡ i | _g | _d | _d S r#   )Úrepresent_datar6   Z	serializer-   r.   r/   )r2   ÚdataÚnoder!   r!   r"   Ú	representP   s
    
zBaseRepresenter.representc                 C   s  |   |¡rd | _n
t|ƒ| _| jd k	rN| j| jkrB| j| j }|S | j |¡ t|ƒj}trzt	|t
jƒrzt|jƒt|ƒ }|d | jkrž| j|d  | |ƒ}nr|D ]$}|| jkr¢| j| | |ƒ} qq¢d | jkrä| jd  | |ƒ}n,d | jkr| jd  | |ƒ}ntd t|ƒƒ}|S )Nr   )Úignore_aliasesr/   Úidr-   r.   ÚappendÚtypeÚ__mro__r	   Ú
isinstanceÚtypesÚInstanceTyper&   Ú	__class__ÚlistÚyaml_representersÚyaml_multi_representersÚ
ScalarNoder   )r2   r9   r:   Ú
data_typesÚ	data_typer!   r!   r"   r8   X   s0    





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
        )r8   ©r2   r9   r!   r!   r"   Úrepresent_key~   s    zBaseRepresenter.represent_keyc                 C   s$   d| j kr| j ¡ | _|| j|< d S )NrF   )Ú__dict__rF   Úcopy©r'   rJ   Zrepresenterr!   r!   r"   Úadd_representerˆ   s    
zBaseRepresenter.add_representerc                 C   s$   d| j kr| j ¡ | _|| j|< d S )NrG   )rM   rG   rN   rO   r!   r!   r"   Úadd_multi_representer   s    
z%BaseRepresenter.add_multi_representerc                 C   sf   |d kr| j }d }|r<|d dkr<t|dd ƒ}|r<d |gg}t||||d}| jd k	rb|| j| j< |S )Nr   z|>Úcomment)ÚstylerR   )r+   ÚgetattrrH   r/   r-   )r2   ÚtagÚvaluerS   rR   r:   r!   r!   r"   Úrepresent_scalar–   s    

z BaseRepresenter.represent_scalarc           	      C   s„   g }t |||d}| jd k	r(|| j| j< d}|D ],}|  |¡}t|tƒrN|jrRd}| |¡ q0|d kr€| jd k	rz| j|_	n||_	|S )N©Ú
flow_styleTF)
ÚSequenceNoder/   r-   r8   rA   rH   rS   r>   r,   rY   )	r2   rU   ÚsequencerY   rV   r:   Ú
best_styleÚitemÚ	node_itemr!   r!   r"   Úrepresent_sequence¤   s    



z"BaseRepresenter.represent_sequencec           
      C   s|   g }t |||d}| jd k	r(|| j| j< d}|D ]$}|| }|  ||i¡}	| |	¡ q0|d krx| jd k	rr| j|_n||_|S )NrX   T)rZ   r/   r-   r8   r>   r,   rY   )
r2   rU   ÚomaprY   rV   r:   r\   Úitem_keyÚitem_valr^   r!   r!   r"   Úrepresent_omap·   s    


zBaseRepresenter.represent_omapc                 C   sè   g }t |||d}| jd k	r(|| j| j< d}t|dƒrjt| ¡ ƒ}| jrjzt|ƒ}W n tk
rh   Y nX |D ]R\}}|  	|¡}	|  
|¡}
t|	tƒrš|	jržd}t|
tƒr®|
jr²d}| |	|
f¡ qn|d krä| jd k	rÞ| j|_n||_|S )NrX   TÚitemsF)ÚMappingNoder/   r-   r5   rE   rd   r0   ÚsortedÚ	TypeErrorrL   r8   rA   rH   rS   r>   r,   rY   )r2   rU   ÚmappingrY   rV   r:   r\   ra   Ú
item_valueÚnode_keyÚ
node_valuer!   r!   r"   Úrepresent_mappingÌ   s2    





z!BaseRepresenter.represent_mappingc                 C   s   dS )NFr!   rK   r!   r!   r"   r<   é   s    zBaseRepresenter.ignore_aliases)NNN)N)N)N)N)r   r   r    rF   rG   r3   Úpropertyr6   r;   r8   rL   ÚclassmethodrP   rQ   rW   r_   rc   rl   r<   r!   r!   r!   r"   r   5   s"   

	&






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„ Z	dd„ Z
erZdd„ ZdZeeƒeee ƒkr|ee9 Zq^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 kst |tƒr|dkrdS t |tttttfƒr6dS dS )Nr!   TF)rA   Útupler   r   ÚboolÚintÚfloatrK   r!   r!   r"   r<   ï   s
    zSafeRepresenter.ignore_aliasesc                 C   s   |   dd¡S )Nútag:yaml.org,2002:nullÚnull©rW   rK   r!   r!   r"   Úrepresent_noneú   s    zSafeRepresenter.represent_nonec                 C   s   |   d|¡S ©Nútag:yaml.org,2002:strru   rK   r!   r!   r"   Úrepresent_str   s    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ú|©rS   )r5   Úbase64rz   ÚdecodeZencodestringrW   rK   r!   r!   r"   Úrepresent_binary  s    
z SafeRepresenter.represent_binaryc                 C   sz   d }d }zt |dƒ}d}W nN tk
rh   zt |dƒ}d}W n& tk
rb   | d¡}d}d}Y nX Y nX | j|||dS )Nr{   rx   úutf-8r   r|   r}   r~   ©ÚunicodeÚUnicodeDecodeErrorÚencoderW   ©r2   r9   rU   rS   r!   r!   r"   ry     s    


c                 C   s   |   d|¡S rw   ru   rK   r!   r!   r"   Úrepresent_unicode  s    z!SafeRepresenter.represent_unicodec                 C   sD   z| j jt|ƒ }W n" tk
r6   |r.d}nd}Y nX |  d|¡S )NÚtrueZfalseztag:yaml.org,2002:bool)r*   Zboolean_representationrp   r7   rW   ©r2   r9   rV   r!   r!   r"   Úrepresent_bool#  s    
zSafeRepresenter.represent_boolc                 C   s   |   dt|ƒ¡S ©Nútag:yaml.org,2002:int©rW   r   rK   r!   r!   r"   Úrepresent_int.  s    zSafeRepresenter.represent_intc                 C   s   |   dt|ƒ¡S rŒ   rŽ   rK   r!   r!   r"   Úrepresent_long4  s    zSafeRepresenter.represent_longgœu ˆ<ä7~c                 C   sŒ   ||ks|dkr|dkrd}nb|| j kr.d}nR|| j  kr@d}n@tt|ƒƒ ¡ }t| jdd ƒdkr€d|kr€d	|kr€| d	d
d¡}|  d|¡S )Nç        ç      ð?ú.nanú.infú-.infZuse_version)é   r–   Ú.Úez.0er–   útag:yaml.org,2002:float)Ú	inf_valuer   ÚreprÚlowerrT   r6   ÚreplacerW   rŠ   r!   r!   r"   Úrepresent_float<  s    
zSafeRepresenter.represent_floatc                 C   s   |   d|¡S )Nútag:yaml.org,2002:seq©r_   rK   r!   r!   r"   Úrepresent_listR  s    	zSafeRepresenter.represent_listc                 C   s   |   d|¡S )Nútag:yaml.org,2002:map©rl   rK   r!   r!   r"   Úrepresent_dictc  s    zSafeRepresenter.represent_dictc                 C   s   |   d|¡S )Nztag:yaml.org,2002:omap)rc   rK   r!   r!   r"   Úrepresent_ordereddictg  s    z%SafeRepresenter.represent_ordereddictc                 C   s"   i }|D ]}d ||< q|   d|¡S )Nútag:yaml.org,2002:setr£   )r2   r9   rV   Úkeyr!   r!   r"   Úrepresent_setk  s    
zSafeRepresenter.represent_setc                 C   s   t | ¡ ƒ}|  d|¡S )Nútag:yaml.org,2002:timestamp©r   Ú	isoformatrW   rŠ   r!   r!   r"   Úrepresent_dater  s    zSafeRepresenter.represent_datec                 C   s   t | d¡ƒ}|  d|¡S )Nú r©   rª   rŠ   r!   r!   r"   Úrepresent_datetimew  s    z"SafeRepresenter.represent_datetimeNc                 C   s.   t |dƒr| ¡ }n
|j ¡ }| j|||dS )NÚ__getstate__rX   )r5   r¯   rM   rN   rl   )r2   rU   r9   r'   rY   Ústater!   r!   r"   Úrepresent_yaml_object|  s    


z%SafeRepresenter.represent_yaml_objectc                 C   s   t d| ƒ‚d S )Nzcannot represent an object: %s)r   rK   r!   r!   r"   Úrepresent_undefined„  s    z#SafeRepresenter.represent_undefined)N)r   r   r    r<   rv   r
   ry   r   rˆ   r‹   r   r	   r   rš   r›   rž   r¡   r¤   r¥   r¨   r¬   r®   r±   r²   r!   r!   r!   r"   r   î   s.   



)é   é   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rPdd„ Zdd„ ZdS )r   c                 C   sz   d }d }zt |dƒ}d}W nN tk
rh   zt |dƒ}d}W n& tk
rb   | d¡}d}d}Y nX Y nX | j|||dS )	Nr{   rx   r‚   ztag:yaml.org,2002:python/strr   r|   r}   r~   rƒ   r‡   r!   r!   r"   ry   ¶  s    


zRepresenter.represent_strc                 C   s<   d }z|  d¡ d}W n tk
r.   d}Y nX |  ||¡S )Nr{   z tag:yaml.org,2002:python/unicoderx   )r†   ÚUnicodeEncodeErrorrW   ©r2   r9   rU   r!   r!   r"   rˆ   Ç  s    

zRepresenter.represent_unicodec                 C   s$   d}t |ƒ|k	rd}|  |t|ƒ¡S )Nr   ztag:yaml.org,2002:python/long)rq   rW   r   r¶   r!   r!   r"   r   Ñ  s    zRepresenter.represent_longc                 C   sd   |j dkrd|j }nB|jdkr,d|j  }n,|j dkrHd|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ÚrealrW   rK   r!   r!   r"   Úrepresent_complexØ  s    


zRepresenter.represent_complexc                 C   s   |   d|¡S )Nztag:yaml.org,2002:python/tupler    rK   r!   r!   r"   Úrepresent_tupleä  s    zRepresenter.represent_tuplec                 C   sJ   zd|j |jf }W n$ tk
r8   d|j |jf }Y nX |  d| d¡S )Nú%s.%sztag:yaml.org,2002:python/name:Ú )r   r    r7   r   rW   )r2   r9   Únamer!   r!   r"   Úrepresent_nameè  s
    zRepresenter.represent_namec                 C   s   |   d|j d¡S )Nz tag:yaml.org,2002:python/module:r¼   )rW   r   rK   r!   r!   r"   Úrepresent_moduleñ  s    zRepresenter.represent_modulec                 C   sº   |j }d|j|jf }d }d }t|dƒr4t| ¡ ƒ}t|dƒrH| ¡ }n|j}|d krpt|t	ƒrp|  
d| |¡S t|t	ƒrŽ|sŽ|  d| |¡S i }t|ƒr¢||d< ||d< |  
d| |¡S )Nr»   Ú__getinitargs__r¯   ú tag:yaml.org,2002:python/object:ú$tag:yaml.org,2002:python/object/new:Úargsr°   )rD   r   r   r5   rE   rÀ   r¯   rM   rA   Údictrl   r_   rp   )r2   r9   r'   Ú
class_namerÃ   r°   rV   r!   r!   r"   Úrepresent_instance÷  s6    


 ÿ ÿ ÿzRepresenter.represent_instancec                 C   sÚ  t |ƒ}|tjkr"tj| |ƒ}n6t|dƒr8| d¡}n t|dƒrL| ¡ }ntd| ƒ‚t|ƒd gd  d d… }|\}}}}}t|ƒ}|d kr”i }|d k	r¤t|ƒ}|d k	r´t|ƒ}|j	dkrÜ|d }|dd … }d	}	d
}
nd}	d}
zd|j
|jf }W n& tk
r   d|j
|j	f }Y nX |sT|sT|sTt|tƒrT|
rT|  d| |¡S |s‚|s‚t|tƒr‚|s‚|  |	| |¡S i }|r”||d< |s¦t|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)r?   ÚcopyregÚdispatch_tabler5   rÇ   rÈ   r   rE   rÄ   r   r   r    r7   rA   rl   r_   )r2   r9   r'   ÚreduceZfunctionrÃ   r°   rË   rÌ   rU   ZnewobjZfunction_namerV   r!   r!   r"   Úrepresent_object$  sZ    




$ ÿzRepresenter.represent_objectN)r   r   r    r	   ry   rˆ   r   r¹   rº   r¾   r¿   rÆ   rÐ   r!   r!   r!   r"   r   ³  s   
	-)	ÚCommentedMapÚCommentedOrderedMapÚCommentedSeqÚCommentedKeySeqÚCommentedKeyMapÚCommentedSetÚcomment_attribÚmerge_attribÚTaggedScalarc                   @   sÐ   e Zd Zd0dd„Zdd„ Zd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d„ Zdd„ Zdd„ Zd1dd„Zdd„ Zd d!„ Zd2d"d#„Zd3d$d%„Zd&d'„ Zd(d)„ Zd*d+„ Zd,d-„ Zd.d/„ ZdS )4r   Nc                 C   s,   t |dƒs|d krd}tj| |||d d S )Nr4   F)r+   r,   r*   )r5   r   r3   r1   r!   r!   r"   r3   ”  s    üzRoundTripRepresenter.__init__c                 C   s.   t | jƒdkr"| jjs"|  dd¡S |  dd¡S )Nr   rs   rt   r¼   )Úlenr-   r6   Zuse_explicit_startrW   rK   r!   r!   r"   rv   Ÿ  s    z#RoundTripRepresenter.represent_nonec                 C   s4   d }d}t r t|tƒs t|dƒ}d}| j|||dS )Nr}   r{   rx   r~   ©r	   rA   r„   rW   r‡   r!   r!   r"   Úrepresent_literal_scalarstring¦  s    
z3RoundTripRepresenter.represent_literal_scalarstringc                 C   s¦   d }d}t t|dg ƒƒD ]`}|| dkr|dkr||d   ¡ s|t|ƒk r||d   ¡ s|d |… d ||d …  }qtr’t|tƒs’t|dƒ}d}| j|||d	S )
Nú>Úfold_posr­   r   r–   úr{   rx   r~   )ÚreversedrT   ÚisspacerÚ   r	   rA   r„   rW   )r2   r9   rU   rS   rÞ   r!   r!   r"   Úrepresent_folded_scalarstring±  s$    
ÿþþ
ýý
z2RoundTripRepresenter.represent_folded_scalarstringc                 C   s4   d }d}t r t|tƒs t|dƒ}d}| j|||dS )Nú'r{   rx   r~   rÛ   r‡   r!   r!   r"   Ú$represent_single_quoted_scalarstringÁ  s    
z9RoundTripRepresenter.represent_single_quoted_scalarstringc                 C   s4   d }d}t r t|tƒs t|dƒ}d}| j|||dS )Nú"r{   rx   r~   rÛ   r‡   r!   r!   r"   Ú$represent_double_quoted_scalarstringÊ  s    
z9RoundTripRepresenter.represent_double_quoted_scalarstringc                 C   s”   |d kr|   d|| ¡S |d rdt|ƒ}t|ƒ|d  }|dkrZ| |d¡ ||d 8 }q8d |¡}|d rtd| }|d r„|d7 }|   d|| ¡S )Nr   r   Ú_r¼   r–   r³   )rW   rE   rÚ   ÚinsertÚjoin)r2   ÚprefixÚsZ
underscoreZslÚposr!   r!   r"   Úinsert_underscoreÓ  s    
z&RoundTripRepresenter.insert_underscorec                 C   s4   |j d k	rd ||j ¡}n
t|dƒ}|  d||j¡S )Nz{:0{}d}Údr¼   ©Ú_widthÚformatrí   Z_underscore©r2   r9   rë   r!   r!   r"   Úrepresent_scalar_intä  s    

z)RoundTripRepresenter.represent_scalar_intc                 C   s4   |j d k	rd ||j ¡}n
t|dƒ}|  d||j¡S )Nz{:0{}b}ÚbZ0brï   rò   r!   r!   r"   Úrepresent_binary_intì  s    

z)RoundTripRepresenter.represent_binary_intc                 C   s4   |j d k	rd ||j ¡}n
t|dƒ}|  d||j¡S )Nz{:0{}o}ÚoZ0orï   rò   r!   r!   r"   Úrepresent_octal_intõ  s    

z(RoundTripRepresenter.represent_octal_intc                 C   s4   |j d k	rd ||j ¡}n
t|dƒ}|  d||j¡S )Nz{:0{}x}ÚxÚ0xrï   rò   r!   r!   r"   Úrepresent_hex_intþ  s    

z&RoundTripRepresenter.represent_hex_intc                 C   s4   |j d k	rd ||j ¡}n
t|dƒ}|  d||j¡S )Nz{:0{}X}ÚXrù   rï   rò   r!   r!   r"   Úrepresent_hex_caps_int  s    

z+RoundTripRepresenter.represent_hex_caps_intc                 C   sŽ  d}||ks|dkr"|dkr"d}n || j kr2d}n|| j  krBd}|rR|  d|¡S |jdkrš|jdkrš|j|jd	 kršd
 |jr†|jndtt|ƒƒ¡}nÎ|jdkr.|j}|jr¸|jnd}d |t|ƒ|jt	|ƒ |j| d	 ¡}|dks|d	kr|dkr| 
dd¡}t	|ƒ|jk rh|d7 }qn:d ||j|j|j |jrNd	nd ¡ d¡\}}|jdkrr|jn|jd	 }|dk rŽ|d	7 }|d|… }t|ƒ}| d¡\}	}
t	|	ƒt	|
ƒ |j|jdkrÒd	nd k rè|
d7 }
q°|jr|dkrd|	 }	|jrdnd}|jdk r–|
dkr6|t	|
ƒ8 }nd}
t	|	ƒt	|
ƒ |jrTd	nd |jk rv|
d7 }
|d	8 }q:|	|
 |j d |||j¡ }nÒ|jdkrÒ|t	|
ƒ8 }|	|
 d |j d |||j¡ }n–|jdkrd|jd	  |	 |
 }
d}	|
d|j … }
||j7 }t	|	ƒ|jk rF|	|
d 7 }	|
d	d… }
|d	8 }q|	d |
 |j d |||j¡ }|dkr‚tt|ƒƒ ¡ }|  d|¡S )z this is way more complicated Nr‘   r’   r“   r”   r•   r™   r   r–   z{}{:d}.r¼   z{}{:0{}.{}f}z0.r—   Ú0z	{:{}.{}e}r˜   ú+z	{:{}0{}d})rš   rW   Z_expZ_precrð   rñ   Z_m_signÚabsrq   rÚ   r   ÚsplitZ_e_signZ_e_widthZ_m_lead0r   r›   rœ   )r2   r9   rV   ZprecZmsÚmZesÚwr˜   Zm1Zm2Zesgnr!   r!   r"   Úrepresent_scalar_float  sˆ    
$$   ÿ  ÿþ
,
(  ÿ
 ÿ
z+RoundTripRepresenter.represent_scalar_floatc                 C   sÐ  g }z|j  |¡}W n tk
r,   |}Y nX z| ¡ }W n tk
rR   d }Y nX t||||d}| jd k	rz|| j| j< d}z¬t|tƒ}|j	|_	|j	rº|j	d rº|j	d D ]}	|	 
¡  q¬|j}
|
 ¡ D ]&}|rÈ|d rÈ|d D ]}	|	 
¡  qàqÈ|j}
|j	|_	z|j	 |j¡ W n tk
r&   Y nX W n tk
rD   i }
Y nX t|ƒD ]H\}}|  |¡}|  ||
 |¡¡ t|tƒr†|jrŠd}| |¡ qN|d krÌt|ƒdkrÆ| jd k	rÆ| j|_n||_|S )N©rY   ÚanchorTr–   Fr   )ÚfarY   r7   Úyaml_anchorrZ   r/   r-   rT   r×   rR   Úresetrd   Úvaluesr>   ÚendÚ	enumerater8   Úmerge_commentsÚgetrA   rH   rS   rÚ   r,   )r2   rU   r[   rY   rV   r  r:   r\   rR   ÚctÚitem_commentsÚvÚidxr]   r^   r!   r!   r"   r_   [  sV    









z'RoundTripRepresenter.represent_sequencec                 C   s„   |d krt |dƒst‚|S t|dd ƒd k	rzt|ƒD ]F\}}|t|jƒkrJq2|j| }|d k	r2|d ksp||kspt‚|||< q2||_|S )NrR   )r5   ÚAssertionErrorrT   r  rÚ   rR   )r2   r:   Zcommentsr  ÚvalZncr!   r!   r"   r  Ž  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Ÿ   TrX   r¢   )rA   rÔ   r/   r_   rÕ   rl   r   rL   rK   r!   r!   r"   rL   ž  s    

z"RoundTripRepresenter.represent_keyc                 C   sÖ  g }z|j  |¡}W n tk
r,   |}Y nX z| ¡ }W n tk
rR   d }Y nX t||||d}| jd k	rz|| j| j< d}zžt|tƒ}|j	|_	|j	rº|j	d rº|j	d D ]}	|	 
¡  q¬|j}
|
 ¡ D ]&}|rÈ|d rÈ|d D ]}	|	 
¡  qàqÈz|j	 |j¡ W n tk
r   Y nX W n tk
r6   i }
Y nX dd„ t|tg ƒD ƒ}d}t|ƒrf| ¡ }n| ¡ }|D ]Ö\}}|d7 }|  |¡}|  |¡}|
 |¡}|rt|dd ƒd ks¼t‚|d d… |_	t|dd ƒ}|d k	rú|d |d< |d	 |d< n|dd … |_	t|tƒr|jr d
}t|tƒr4|jr8d
}| ||f¡ qr|d kr„|dksht|ƒr~| jd k	r~| j|_n||_t|ƒrÒt|ƒdkr¬|  |d ¡}n|  |¡}d|_| dtddƒ|f¡ |S )Nr  Tr–   c                 S   s   g | ]}|d  ‘qS )r–   r!   )Ú.0r  r!   r!   r"   Ú
<listcomp>É  s     z:RoundTripRepresenter.represent_mapping.<locals>.<listcomp>r   rR   r³   é   Fztag:yaml.org,2002:mergez<<)r  rY   r7   r  re   r/   r-   rT   r×   rR   r  rd   r	  r>   r
  rØ   rp   Znon_merged_itemsrL   r8   r  r  rA   rH   rS   r,   rÚ   rè   )r2   rU   rh   rY   rV   r  r:   r\   rR   r  r  r  Z
merge_listZ
item_countrd   ra   ri   rj   rk   Úitem_commentÚnvcÚargr!   r!   r"   rl   ¨  s€    













 


z&RoundTripRepresenter.represent_mappingc                 C   s@  g }z|j  |¡}W n tk
r,   |}Y nX z| ¡ }W n tk
rR   d }Y nX t||||d}| jd k	rz|| j| j< d}zžt|tƒ}|j	|_	|j	rº|j	d rº|j	d D ]}	|	 
¡  q¬|j}
|
 ¡ D ]&}|rÈ|d rÈ|d D ]}	|	 
¡  qàqÈz|j	 |j¡ W n tk
r   Y nX W n tk
r6   i }
Y nX |D ]Ø}|| }|  ||i¡}|
 |¡}|r|d r~d |d g|_	t|jd d dd ƒd ksžt‚|d d g|jd d _	t|jd d dd ƒ}|d k	rð|d |d< |d |d< n|dd … |jd d _	| |¡ q<|d kr<| jd k	r6| j|_n||_|S )Nr  Tr–   r   rR   r³   r  )r  rY   r7   r  rZ   r/   r-   rT   r×   rR   r  rd   r	  r>   r
  r8   r  rV   r  r,   )r2   rU   r`   rY   rV   r  r:   r\   rR   r  r  r  ra   rb   r^   r  r  r!   r!   r"   rc   ò  sd    








 


z#RoundTripRepresenter.represent_omapc                 C   sÊ  d}d}g }|j  |¡}z| ¡ }W n tk
r<   d }Y nX t||||d}| jd k	rd|| j| j< d}zžt|tƒ}|j	|_	|j	r¤|j	d r¤|j	d D ]}	|	 
¡  q–|j}
|
 ¡ D ]&}|r²|d r²|d D ]}	|	 
¡  qÊq²z|j	 |j¡ W n tk
r   Y nX W n tk
r    i }
Y nX |jD ]˜}|  |¡}|  d ¡}|
 |¡}|rtt|dd ƒd ksft‚|d d… |_	d |_|_t|tƒr”|jr˜d}t|tƒr¬|jr°d}| ||f¡ q(|}|S )	NFr¦   r  Tr–   rR   r³   ú?)r  rY   r  r7   re   r/   r-   rT   r×   rR   r  rd   r	  r>   r
  ZodictrL   r8   r  r  rS   rA   rH   )r2   ZsettingrY   rU   rV   r  r:   r\   rR   r  r  r  ra   rj   rk   r  r!   r!   r"   r¨   .  sX    









z"RoundTripRepresenter.represent_setc                 C   s\   z|j j}W n tk
r$   d}Y nX |rL| d¡rFd|dd…  }qP|}nd}|  ||¡S )z!write out tag if saved on loadingNú!!útag:yaml.org,2002:r³   r¢   )rU   rV   r7   Ú
startswithrl   ©r2   r9   ÚtrU   r!   r!   r"   r¤   _  s    

z#RoundTripRepresenter.represent_dictc                 C   s\   z|j j}W n tk
r$   d }Y nX |rL| d¡rFd|dd …  }qP|}nd}|  ||¡S )Nr  r  r³   rŸ   )rU   rV   r7   r  r_   r  r!   r!   r"   r¡   o  s    

z#RoundTripRepresenter.represent_listc                 C   sf   |j d rdnd}|j }|d r8||d 7 }| |¡}n
| |¡}|d rV||d 7 }|  dt|ƒ¡S )Nr  ÚTr­   ZdeltaZtzr©   )Ú_yamlr«   rW   r   )r2   r9   Zinterr!  rV   r!   r!   r"   r®   ~  s    
z'RoundTripRepresenter.represent_datetimec                 C   s:   z|j j}W n tk
r$   d }Y nX | j||j|jdS )Nr~   )rU   rV   r7   rW   rS   r¶   r!   r!   r"   Úrepresent_tagged_scalar‹  s
    
z,RoundTripRepresenter.represent_tagged_scalar)NNN)N)N)N)r   r   r    r3   rv   rÜ   Z represent_preserved_scalarstringrâ   rä   ræ   rí   ró   rõ   r÷   rú   rü   r  r_   r  rL   rl   rc   r¨   r¤   r¡   r®   r"  r!   r!   r!   r"   r     s0   
							K
3

J
<1)uZ
__future__r   r   r   Zruamel_yaml.errorZruamel_yaml.nodesZruamel_yaml.compatr   r   r   r	   r
   r   r   r   Zruamel_yaml.scalarstringr   r   r   r   Zruamel_yaml.scalarintr   r   r   r   r   Zruamel_yaml.scalarfloatr   Zruamel_yaml.timestampr   ZdatetimeÚsysrB   rÍ   r   Zcopy_regZDictZListZAnyZUnionZTextZOptionalÚ__all__Z	YAMLErrorr   r&   Úobjectr   r   rP   r?   rv   Ústrry   r„   rˆ   Úbytesr   rp   r‹   rq   r   Zlongr   rr   rž   rE   r¡   ro   rÄ   r¤   Úsetr¨   r¥   Úversion_infoÚcollectionsÚOrderedDictÚdater¬   r®   r²   r   Úcomplexr¹   rº   r¾   Z	ClassTypeÚFunctionTypeÚBuiltinFunctionTypeÚ
ModuleTyper¿   rQ   rC   rÆ   rÐ   Zruamel_yaml.commentsrÑ   rÒ   rÓ   rÔ   rÕ   rÖ   r×   rØ   rÙ   r   rÜ   râ   rä   ræ   ró   rõ   r÷   rú   rü   r  r"  r!   r!   r!   r"   Ú<module>   sä    
 ÿ :  ÿ 5,     ÿ ÿ ÿ ÿ ÿ ÿ ÿ