
    i                    N    d Z ddlmZ ddlZddlmZ ddlmZ ddlZdd
Z	ddZ
dS )z.Serialization helpers for JSON and YAML files.    )annotationsN)Path)Anypathr   returndict[str, Any]c                8   | j                                         }|                     d          }|dk    rt          j        |          }n+|dv rt          j        |          }nt          d|           t          |t                    st          d          |S )z.Load structured data from a JSON or YAML file.utf-8encoding.json   .yml.yamlunsupported file format: zexpected top-level mapping)
suffixlower	read_textjsonloadsyaml	safe_load
ValueError
isinstancedict)r   r   textdatas       9/root/projects/multi-agents-meeting/core/serialization.py	load_datar      s     [  F>>7>++Dz$	$	$	$~d##=V==>>>dD!! 75666K    payloadNonec                <   | j                                         }| j                            dd           |dk    rt	          j        |dd          dz   }n.|dv rt          j        |dd	          }nt          d
|           | 	                    |d           dS )z-Write structured data to a JSON or YAML file.T)parentsexist_okr      F)indentensure_ascii
r   )	sort_keysallow_unicoder   r
   r   N)
r   r   parentmkdirr   dumpsr   	safe_dumpr   
write_text)r   r!   r   r   s       r   	dump_datar1      s     [  FKdT222z'!%@@@4G	$	$	$~gdKKK=V==>>>OOD7O+++++r    )r   r   r   r   )r   r   r!   r   r   r"   )__doc__
__future__r   r   pathlibr   typingr   r   r   r1    r    r   <module>r7      s    4 4 " " " " " "                 $, , , , , ,r    