o
    P+ iY                     @  s  d dl mZ d dlT d dlT 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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$m%Z% d dl&Z&d dl'Z'd dl(Z(d dl)Z)d dl*Z*	 g dZ2G dd de3Z4G dd dZ5G dd de5Z6e67e8de6j9 e67e:e6j; e67e<e6j= e67e>e6j? e67e@e6jA e67eBe6jC e67eDe6jE e67eFe6jE e67eGe6jH e67eIe6jJ e67ee6jK e67e&jLe6jK e67e'jMe6jN e67e'j'e6jO e67de6jP G dd de6ZQeQ7eReQjS eQ7eFeQjT eQ7e8eQjU eQ7e(jVeQjU eQ7e(jWeQjU eQ7e(jXeQjY eQZe[eQj\ eQZe8eQjU G dd de6Z]e]7e8de]j9 e]7e	e]j^ e]7e
e]j_ e]7ee]j` e]7ee]ja e]7ee]jb e]7ee]jc e]7ee]jd e]7ee]je e]7ee]jf e]7ee]jg e]7ee]jh e]7e!e]ji e]7ee]jE e]7ee]jH e]7ee]jK e]7e&jLe]jK e]7ee]jJ e]7ee]jj e]7e#e]jO dS )    )annotations)*)ordereddict)nprintnprintf)LiteralScalarStringFoldedScalarStringSingleQuotedScalarStringDoubleQuotedScalarStringPlainScalarString)	CommentedMapCommentedOrderedMapCommentedSeqCommentedKeySeqCommentedKeyMapCommentedSetcomment_attribmerge_attribTaggedScalar)	ScalarInt	BinaryIntOctalIntHexInt
HexCapsInt)ScalarFloat)ScalarBoolean)	TimeStamp)AnchorNF)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,   c/home/app/PaddleOCR-VL-test/.venv_paddleocr/lib/python3.10/site-packages/ruamel/yaml/representer.pyr'   0   s    r'   c                   @  s   e Zd ZU i Zded< i Zded< 			d3d4ddZed5ddZd6ddZ	d7ddZ
d7ddZed8ddZed8ddZ	d9d:d"d#Z	d;d<d'd(Zd;d=d*d+Zd;d>d.d/Zd?d1d2ZdS )@r$   zDict[Any, Any]yaml_representersyaml_multi_representersNselfr    default_styledefault_flow_styledumperreturnNonec                 C  s@   || _ | j d ur| | j _|| _|| _i | _g | _d | _d| _d S )NT)r3   Z_representerr1   r2   represented_objectsobject_keeper	alias_key sort_base_mapping_type_on_outputr0   r1   r2   r3   r,   r,   r-   __init__9   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   
serializerZ_serializerAttributeError)r0   r,   r,   r-   r>   I   s   

zBaseRepresenter.serializerdatac                 C  s,   |  |}| j| i | _g | _d | _d S N)represent_datar>   	serializer6   r7   r8   )r0   r@   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}|d | jv r?| j|d  | |}|S |D ]}|| j	v rS| j	| | |} |S qAd | j	v rc| j	d  | |}|S d | jv rr| jd  | |}|S t
d t|}|S )Nr   )ignore_aliasesr8   idr6   r7   appendtype__mro__r.   r/   
ScalarNodestr)r0   r@   rD   
data_types	data_typer,   r,   r-   rB   Y   s4   







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   r0   r@   r,   r,   r-   represent_keyz   s   
zBaseRepresenter.represent_keyrN   representerc                 C  $   d| j vr| j | _|| j|< d S )Nr.   )__dict__r.   copyclsrN   rQ   r,   r,   r-   add_representer      
zBaseRepresenter.add_representerc                 C  rR   )Nr/   )rS   r/   rT   rU   r,   r,   r-   add_multi_representer   rX   z%BaseRepresenter.add_multi_representertagvaluestyleanchorrK   c                 C  s|   |d u r| j }d }|r|d dv rt|dd }|rd |gg}t|tr(t|d}t|||||d}| jd ur<|| j| j< |S )Nr   z|>commentsuffix)r\   r^   r]   )r1   getattr
isinstancerL   TagrK   r8   r6   )r0   rZ   r[   r\   r]   r^   rD   r,   r,   r-   represent_scalar   s   



z BaseRepresenter.represent_scalarsequence
flow_styleSequenceNodec           	      C  s   g }t |trt|d}t|||d}| jd ur|| j| j< d}|D ]}| |}t |tr1|jr3d}|	| q"|d u rK| j
d urH| j
|_|S ||_|S )Nr_   rf   TF)rb   rL   rc   rg   r8   r6   rB   rK   r\   rH   r2   rf   )	r0   rZ   re   rf   r[   rD   
best_styleitem	node_itemr,   r,   r-   represent_sequence   s$   




z"BaseRepresenter.represent_sequenceomapc           
      C  s   g }t |trt|d}t|||d}| jd ur|| j| j< d}|D ]}|| }| ||i}	||	 q"|d u rG| jd urD| j|_	|S ||_	|S )Nr_   rh   T)
rb   rL   rc   rg   r8   r6   rB   rH   r2   rf   )
r0   rZ   rm   rf   r[   rD   ri   item_keyitem_valrk   r,   r,   r-   represent_omap   s"   



zBaseRepresenter.represent_omapmappingMappingNodec                 C  s   g }t |trt|d}t|||d}| jd ur|| j| j< d}t|dr>t| }| j	r>zt
|}W n	 ty=   Y nw |D ])\}}| |}	| |}
t |	trV|	jrXd}t |
tr`|
jrbd}||	|
f q@|d u r|| jd ury| j|_|S ||_|S )Nr_   rh   TitemsF)rb   rL   rc   rr   r8   r6   r=   listrs   r9   sorted	TypeErrorrP   rB   rK   r\   rH   r2   rf   )r0   rZ   rq   rf   r[   rD   ri   rn   
item_valuenode_key
node_valuer,   r,   r-   represent_mapping   s:   






z!BaseRepresenter.represent_mappingboolc                 C  s   dS NFr,   rO   r,   r,   r-   rF      s   zBaseRepresenter.ignore_aliasesNNN)
r0   r    r1   r    r2   r    r3   r    r4   r5   )r4   r    r@   r    r4   r5   r@   r    r4   r    )rN   r    rQ   r    r4   r5   )NN)
rZ   r    r[   r    r\   r    r]   r    r4   rK   rA   rZ   r    re   r    rf   r    r4   rg   rZ   r    rm   r    rf   r    r4   rg   rZ   r    rq   r    rf   r    r4   rr   r@   r    r4   r{   )r)   r*   r+   r.   __annotations__r/   r;   propertyr>   rE   rB   rP   classmethodrW   rY   rd   rl   rp   rz   rF   r,   r,   r,   r-   r$   4   s.   
 


!	r$   c                   @  s   e Zd Zd.ddZd/dd	Zd0d
dZd/ddZd1d2ddZd/ddZdZ	e
e	e
e	e	 kr=e	e	9 Z	e
e	e
e	e	 ks/d/ddZd3ddZd4ddZd3ddZd4d d!Zd/d"d#Zd/d$d%Z	d1d5d)d*Zd6d,d-ZdS )7r%   r@   r    r4   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)rb   tuplebytesrL   r{   intfloatrO   r,   r,   r-   rF      s
   zSafeRepresenter.ignore_aliasesrK   c                 C  s   |  ddS )Ntag:yaml.org,2002:nullnullrd   rO   r,   r,   r-   represent_none      zSafeRepresenter.represent_nonec                 C     |  d|S )Ntag:yaml.org,2002:strr   rO   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asciiztag:yaml.org,2002:binary|)r\   )r=   base64r   decodeencodestringrd   rO   r,   r,   r-   represent_binary   s   
z SafeRepresenter.represent_binaryNr]   Optional[Any]c                 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r]   )r3   Zboolean_representationr{   r?   rd   )r0   r@   r]   r[   r,   r,   r-   represent_bool  s   zSafeRepresenter.represent_boolc                 C  s   |  dt|S )Ntag:yaml.org,2002:int)rd   rL   rO   r,   r,   r-   represent_int  s   zSafeRepresenter.represent_intgu <7~c                 C  s   ||ks|dkr|dkrd}n/|| j krd}n'|| j  kr d}n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_valuereprlowerra   r>   replacerd   r0   r@   r[   r,   r,   r-   represent_float  s   
zSafeRepresenter.represent_floatrg   c                 C  r   )Ntag:yaml.org,2002:seqrl   rO   r,   r,   r-   represent_list-  s   zSafeRepresenter.represent_listrr   c                 C  r   )Ntag:yaml.org,2002:maprz   rO   r,   r,   r-   represent_dict=  r   zSafeRepresenter.represent_dictc                 C  r   )Nztag:yaml.org,2002:omap)rp   rO   r,   r,   r-   represent_ordereddict@  r   z%SafeRepresenter.represent_ordereddictc                 C  s"   i }|D ]}d ||< q|  d|S )Ntag:yaml.org,2002:setr   )r0   r@   r[   keyr,   r,   r-   represent_setC  s   
zSafeRepresenter.represent_setc                 C  s   |  }| d|S )Ntag:yaml.org,2002:timestamp	isoformatrd   r   r,   r,   r-   represent_dateI  s   zSafeRepresenter.represent_datec                 C  s   | d}| d|S )N r   r   r   r,   r,   r-   represent_datetimeM  s   
z"SafeRepresenter.represent_datetimerZ   rV   rf   c                 C  s.   t |dr
| }n|j }| j|||dS N__getstate__rh   )r=   r   rS   rT   rz   )r0   rZ   r@   rV   rf   stater,   r,   r-   represent_yaml_objectQ  s   


z%SafeRepresenter.represent_yaml_objectr5   c                 C  s   t d|)Nzcannot represent an object: )r'   rO   r,   r,   r-   represent_undefinedZ  s   z#SafeRepresenter.represent_undefinedr   r@   r    r4   rK   r   rA   )r@   r    r]   r   r4   rK   r@   r    r4   rg   r@   r    r4   rr   )
rZ   r    r@   r    rV   r    rf   r    r4   rr   r~   )r)   r*   r+   rF   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r,   r,   r,   r-   r%      s*    













	r%   c                   @  s>   e Zd ZdddZdddZdd
dZdddZdddZdS )r&   r@   r    r4   c                 C  sl   |j dkrt|j}n%|jdkr|j d}n|j dkr'|jd|j d}n	|j|j d}| d|S )Nr   jr   +z tag:yaml.org,2002:python/complex)imagr   realrd   rO   r,   r,   r-   represent_complex  s   


zRepresenter.represent_complexrg   c                 C  r   )Nztag:yaml.org,2002:python/tupler   rO   r,   r,   r-   represent_tuple  r   zRepresenter.represent_tuplerK   c                 C  sL   z|j d|j}W n ty   |j d|j}Y nw | d| dS )Nr   ztag:yaml.org,2002:python/name: )r*   r+   r?   r)   rd   )r0   r@   namer,   r,   r-   represent_name  s   zRepresenter.represent_namec                 C  s   |  d|j dS )Nz tag:yaml.org,2002:python/module:r   )rd   r)   rO   r,   r,   r-   represent_module  s   zRepresenter.represent_module Union[SequenceNode, MappingNode]c                 C  s  t |}|tjv rtj| |}nt|dr|d}nt|dr&| }ntd|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|j
d|j}W n ty   |j
d|j	}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__   
__reduce__zcannot represent object:    
__newobj__r   r   z$tag:yaml.org,2002:python/object/new:Tz&tag:yaml.org,2002:python/object/apply:Fr   z tag:yaml.org,2002:python/object:argsr   	listitems	dictitems)rI   copyregdispatch_tabler=   r   r   r'   rt   dictr)   r*   r+   r?   rb   rz   rl   )r0   r@   rV   reducefunctionr   r   r   r   rZ   ZnewobjZfunction_namer[   r,   r,   r-   represent_object  sZ   




zRepresenter.represent_objectNr   r   r   )r@   r    r4   r   )r)   r*   r+   r   r   r   r   r   r,   r,   r,   r-   r&     s    



r&   c                   @  s2  e Zd Z	dQdRdd	ZdSddZdTddZdTddZeZdTddZdTddZ	dTddZ
dTddZ	dUdVdd ZdTd!d"ZdTd#d$ZdTd%d&ZdTd'd(ZdTd)d*ZdTd+d,Z	dUdWd1d2ZdXd5d6ZdYd7d8ZdUdZd;d<ZdUd[d>d?Zd\dAdBZd]dCdDZd^dEdFZdTdGdHZdTdIdJZdTdKdLZ	dUd_dOdPZdS )`r(   Nr1   r    r2   r3   r4   r5   c                 C  s,   t |ds|d u rd}tj| |||d d S )Nr<   F)r1   r2   r3   )r=   r%   r;   r:   r,   r,   r-   r;     s   
zRoundTripRepresenter.__init__r@   r{   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|   )r]   r[   r?   r%   rF   rO   r,   r,   r-   rF     s   z#RoundTripRepresenter.ignore_aliasesrK   c                 C  s.   t | jdkr| jjs| ddS | ddS )Nr   r   r   r   )lenr6   r>   Zuse_explicit_startrd   rO   r,   r,   r-   r     s   z#RoundTripRepresenter.represent_nonec                 C  *   d }d}|j dd}d}| j||||dS )Nr   Tanyr   r\   r]   yaml_anchorrd   r0   r@   rZ   r\   r]   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d	}| j||||d
S )N>Tr   fold_posr   r   r   r   r   )r   reversedra   isspacer   rd   )r0   r@   rZ   r\   r]   r   r,   r,   r-   represent_folded_scalarstring  s   z2RoundTripRepresenter.represent_folded_scalarstringc                 C  r   )N'Tr   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-   $represent_double_quoted_scalarstring(  r   z9RoundTripRepresenter.represent_double_quoted_scalarstringc                 C  r   )Nr   Tr   r   r   r   r   r,   r,   r-   represent_plain_scalarstring/  r   z1RoundTripRepresenter.represent_plain_scalarstringprefixs
underscorer]   c                 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   )rd   rt   r   insertjoin)r0   r   r   r   r]   slposr,   r,   r-   insert_underscore6  s   
z&RoundTripRepresenter.insert_underscorec                 C  H   |j d ur|d|j  d}nt|d}|jdd}| jd||j|dS )N0dTr   r   r   _widthformatr   r   _underscorer0   r@   r   r]   r,   r,   r-   represent_scalar_intH  s
   

z)RoundTripRepresenter.represent_scalar_intc                 C  r  )Nr  bTr   0br   r  r  r,   r,   r-   represent_binary_intP  
   

z)RoundTripRepresenter.represent_binary_intc                 C  sb   |j d ur|d|j  d}nt|d}|jdd}d}t| jdd dkr'd}| j|||j|dS )	Nr  oTr   Z0or   r   r   )r  r  r   ra   r>   r   r  )r0   r@   r   r]   r   r,   r,   r-   represent_octal_intY  s   

z(RoundTripRepresenter.represent_octal_intc                 C  r  )Nr  xTr   0xr   r  r  r,   r,   r-   represent_hex_inte  r  z&RoundTripRepresenter.represent_hex_intc                 C  r  )Nr  XTr   r  r   r  r  r,   r,   r-   represent_hex_caps_intn  r  z+RoundTripRepresenter.represent_hex_caps_intc                 C  sD  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 rW|jdkrW|j|jd krW|jrI|jnd tt|dd}n|jdu r|j}|jre|jnd}|dk r| tt|d|jt	|  d}n,| t|d|jt	|  d|j| d  d}|dks|dkr|dkr|
dd}t	||jk r|d7 }t	||jk snO||j d|j|jrdnd  dd\}}|jdkr|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 }t	|
t	| |j|jdkr)dnd k s|jr;|dkr;d|
 }
|jrAdnd}|jdk r|dkrU|	t	|8 }	nd}t	|
t	| |jrddnd |jk r|d7 }|	d8 }	t	|
t	| |jrdnd |jk sk|
| |j |	| d|j d }nu|jdkr|	t	|8 }	|
| d |j |	| d|j d }nT|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 }|du rt| }| jd	||d
S )z this is way more complicated NTr   r   r   r   r   r   r   r   r   r   r   r  r   r  fz0.r   r   )r   r   rd   _expZ_precr  Z_m_signabsr   r   r   splitZ_e_signZ_e_widthZ_m_lead0r   r   )r0   r@   r[   r]   precmsmeswr   m1m2Zesgnr,   r,   r-   represent_scalar_floatw  s   
$(
*4*,,
((&*
(
z+RoundTripRepresenter.represent_scalar_floatrZ   re   rf   rg   c                 C  s  g }z|j |}W n ty   |}Y nw z| }W n ty'   d }Y nw t|tr2t|d}t||||d}| jd urE|| j	| j< d}zbt
|t}|j|_|jre|jd re|jd D ]}	|	  q^|j}
|
 D ]}|r|d r|d D ]}	|	  qxql|j}
|jd u r|j|_n|jd d  |_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 )Nr_   rf   r]   Tr   Fr   )farf   r?   r   rb   rL   rc   rg   r8   r6   ra   r   r^   resetrs   valuesrH   end	enumeraterB   merge_commentsgetrK   r\   r   r2   )r0   rZ   re   rf   r[   r]   rD   ri   r^   ctitem_commentsvidxrj   rk   r,   r,   r-   rl     sl   








z'RoundTripRepresenter.represent_sequencerD   commentsc                 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=   ra   r&  r   r^   )r0   rD   r-  r,  val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   Trh   r   )rb   r   r8   rl   r   rz   r%   rP   rO   r,   r,   r-   rP   	  s   

z"RoundTripRepresenter.represent_keyrq   rr   c              	   C  s  g }z|j |}W n ty   |}Y nw z| }W n ty'   d }Y nw t|tr2t|d}t||||d}| jd urE|| j	| j< d}zbt
|t}|jd u rW|j|_n|jd d  |_|jrs|jd rs|jd D ]}	|	  ql|j}
| jjd u r|
 D ]}|r|d r|d D ]}	|	  qqz	|j|j W n
 ty   Y nw 	 W n ty   i }
Y nw t
|tg }z|j}W n ttfy   d}Y nw d}t|dkr| }n| }|D ]_\}}|d7 }| |}| |}|
|}|r!|d d |_t
|dd }|d ur|d |d< |d |d< n|dd  |_t|tr+|jr-d	}t|tr7|jr9d	}|||f q|d u r`|dksRt|dkr]| jd ur]| j|_n||_t|dkr|jd u ru| |d }n| |j}| |ttd
dd|f |S )Nr_   r!  Tr   r   r   r^      Fztag:yaml.org,2002:mergez<<)!r"  rf   r?   r   rb   rL   rc   rr   r8   r6   ra   r   r^   r#  rs   r3   Zcomment_handlingr$  rH   r%  r   	merge_pos
IndexErrorr   Znon_merged_itemsrP   rB   r(  rK   r\   r2   re   r   )r0   rZ   rq   rf   r[   r]   rD   ri   r^   r)  r*  r+  Zmerge_valuer1  
item_countrs   rn   rw   rx   ry   item_commentnvcargr,   r,   r-   rz     s   














$
z&RoundTripRepresenter.represent_mappingrm   c                 C  s`  g }z|j |}W n ty   |}Y nw z| }W n ty'   d }Y nw t|tr2t|d}t||||d}| jd urE|| j	| j< d}z[t
|t}|jd u rW|j|_n|jd d  |_|jrs|jd rs|jd D ]}	|	  ql|j}
|
 D ]}|r|d r|d D ]}	|	  qqzz	|j|j W n	 ty   Y nw W n ty   i }
Y nw |D ]i}|| }| ||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_   r!  Tr   r   r^   r   r0  )r"  rf   r?   r   rb   rL   rc   rg   r8   r6   ra   r   r^   r#  rs   r$  rH   r%  rB   r(  r[   r2   )r0   rZ   rm   rf   r[   r]   rD   ri   r^   r)  r*  r+  rn   ro   rk   r4  r5  r,   r,   r-   rp   t  sz   










z#RoundTripRepresenter.represent_omapsettingc                 C  s  d}t dd}g }|j|}z| }W n ty    d }Y nw t||||d}| jd ur4|| j| j< d}z[t|t	}|j
d u rF|j
|_
n|j
d d  |_
|j
rb|j
d rb|j
d D ]}	|	  q[|j}
|
 D ]}|r||d r||d D ]}	|	  quqiz	|j
|j W n	 ty   Y nw W n ty   i }
Y nw |jD ]I}| |}| d }|
|}|rt|dd d u sJ |d d |_
d	|_|rd
nd	|_t|tr|jrd}t|tr|jrd}|||f q|}|S )NFr   r_   r!  Tr   r^   r   ?-)rc   r"  rf   r   r?   rr   r8   r6   ra   r   r^   r#  rs   r$  rH   r%  ZodictrP   rB   r(  r\   rb   rK   )r0   r7  rf   rZ   r[   r]   rD   ri   r^   r)  r*  r+  rn   rx   ry   r4  r,   r,   r-   r     sh   










z"RoundTripRepresenter.represent_setc                 C  sv   z|j }W n ty   tdd}Y n"w |j jr0|j dr,td|j jdd  d}n	|j }ntdd}| ||S )z!write out tag if saved on loadingr   r_   !!tag:yaml.org,2002:r   N)rZ   r?   rc   trval
startswithrz   r0   r@   r   rZ   r,   r,   r-   r     s   

z#RoundTripRepresenter.represent_dictc                 C  sv   z|j }W n ty   tdd}Y n"w |j jr0|j dr,td|j jdd   d}n	|j }ntdd}| ||S )Nr   r_   r:  r;  r   )rZ   r?   rc   r<  r=  rl   r>  r,   r,   r-   r     s   

z#RoundTripRepresenter.represent_listc                 C  sh   |j d rdnd}|j }	 || }	 |jr.t|jr.|d dv r.|d d t|j }| d	|S )
NtTr   Fdeltatziz+-r   )_yamlr   striptzinforL   rd   )r0   r@   interrC  r[   r,   r,   r-   r   	  s   z'RoundTripRepresenter.represent_datetimec                 C  s   z|j jdkr|j j d|j j }n|j }W n ty"   d }Y nw z| }W n ty4   d }Y nw | j||j|j|dS )Nr:  r   r   )rZ   handler`   r?   r   rd   r[   r\   )r0   r@   rZ   r]   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   r?   r%   r   )r0   r@   r]   r,   r,   r-   represent_scalar_bool&  s   z*RoundTripRepresenter.represent_scalar_boolrV   r   c                 C  sN   t |dr
| }n|j }|tjd }| j|||d}|d ur%||_|S r   )	r=   r   rS   rT   popr   attribrz   r]   )r0   rZ   r@   rV   rf   r   r]   resr,   r,   r-   r   -  s   


z*RoundTripRepresenter.represent_yaml_objectr}   )r1   r    r2   r    r3   r    r4   r5   r   r   rA   )
r   r    r   r    r   r    r]   r    r4   rK   r   )rD   r    r-  r    r4   r    r   r   r   )r7  r    r4   rr   r   r   )
rZ   r    r@   r    rV   r    rf   r   r4   rr   )r)   r*   r+   r;   rF   r   r   Z represent_preserved_scalarstringr   r   r   r   r   r	  r  r  r  r  r   rl   r'  rP   rz   rp   r   r   r   r   rH  rI  r   r,   r,   r,   r-   r(     sB    









	

	
	J
:
	b
A
5



r(   )k
__future__r   Zruamel.yaml.errorZruamel.yaml.nodesZruamel.yaml.compatr   r   r   Zruamel.yaml.scalarstringr   r   r	   r
   r   Zruamel.yaml.commentsr   r   r   r   r   r   r   r   r   Zruamel.yaml.scalarintr   r   r   r   r   Zruamel.yaml.scalarfloatr   Zruamel.yaml.scalarboolr   Zruamel.yaml.timestampr   Zruamel.yaml.anchorr   collectionsdatetimetypesr   r   typingr   r   r    r!   r"   r#   __all__Z	YAMLErrorr'   r$   r%   rW   rI   r   rL   r   r   r   r{   r   r   r   r   r   rt   r   r   r   r   setr   r   OrderedDictdater   r   r   r&   complexr   r   r   FunctionTypeBuiltinFunctionType
ModuleTyper   rY   objectr   r(   r   r   r   r   r   r	  r  r  r  r  r   rI  rH  r,   r,   r,   r-   <module>   s   , ;p\    S