o
    qoi                     @   s   d Z ddlZddl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 Ze
jeje dd
dZdd Zdd Ze
jeje e
jeje e
je	je dedefddZdS )aK  Serialization helper that writes YAML output.

Note: This API is highly experimental, and primarily intended for dumping
objects in a medium-easy-to-read format, using indentation/spaces instead of
`printing.py`'s dot-separated paths. Please use `serialization.py` whenever
you need to serialize Fiddle objects in a robust manner.
    N)Any)config)partial)taggingc                 C   s
   |  |S )N)represent_dictdumperdata r
   _/home/ubuntu/.local/lib/python3.10/site-packages/fiddle/_src/experimental/yaml_serialization.py_defaultdict_representer"   s   
r   
fdl.Configc                 C   sP   t |j}d|v rtdtt|jt|jd|d< | 	d| |S )z(Returns a YAML representation of `data`.__fn_or_cls__z]It is not supported to dump objects of functions/classes that have a __fn_or_cls__ parameter.)modulename!)
dict__arguments__
ValueErrorinspect	getmodule
config_libget_callable__name____qualname__represent_mapping)r   r	   	type_namevaluer
   r
   r   _config_representer+   s   


r   c                 C   s   t | |ddS )Nzfdl.Partial)r   )r   r   r
   r
   r   _partial_representer?   s   r   c                 C   s    |  ddd |jD |jdS )Nz!fdl.TaggedValuec                 S   s   g | ]}|j qS r
   )r   ).0tagr
   r
   r   
<listcomp>G   s    z,_taggedvalue_representer.<locals>.<listcomp>)tagsr   )r   r#   r   r   r
   r
   r   _taggedvalue_representerC   s   r$   r   returnc                 C   s
   t | S )zReturns the YAML serialization of `value`.

  Args:
    value: The value to serialize.

  Raises:
    PyrefError: If an error is encountered while serializing a Python reference.
  )yaml	safe_dump)r   r
   r
   r   	dump_yamlT   s   
	r(   )r   )__doc__collectionsr   typingr   fiddle._srcr   r   r   r   r&   r   
SafeDumperadd_representerdefaultdictr   r   r$   ConfigPartialTaggedValueClsstrr(   r
   r
   r
   r   <module>   s*   

