o
    
i?                     @   s   d dl Z ddlmZ ddlmZmZ ddlmZmZmZm	Z	 dede
fdd	Zdde
dede	fddZdededdfddZddedede	fddZdS )    N   )msgpack)msgpack_encodersmsgpack_decoders)
force_pathFilePathJSONInputBinJSONOutputBindatareturnc                 C   s   t j| ddS )zSerialize an object to a msgpack byte string.

    data: The data to serialize.
    RETURNS (bytes): The serialized bytes.
    Tuse_bin_type)r   dumps)r
    r   F/home/ubuntu/.local/lib/python3.10/site-packages/srsly/_msgpack_api.pymsgpack_dumps   s   r   Tuse_listc                 C   s$   t   tj| d|d}t   |S )zDeserialize msgpack bytes to a Python object.

    data (bytes): The data to deserialize.
    use_list (bool): Don't use tuples instead of lists. Can make
        deserialization slower.
    RETURNS: The deserialized Python object.
    Frawr   )gcdisabler   loadsenable)r
   r   msgr   r   r   msgpack_loads   s   	r   pathc                 C   sL   t | dd}|d}tj||dd W d   dS 1 sw   Y  dS )zCreate a msgpack file and dump contents.

    location (FilePath): The file path.
    data (JSONInputBin): The data to serialize.
    F)require_existswbTr   N)r   openr   dump)r   r
   	file_pathfr   r   r   write_msgpack    s   "r"   c                 C   sZ   t | }|d}t  tj|d|d}t  |W  d   S 1 s&w   Y  dS )zLoad a msgpack file.

    location (FilePath): The file path.
    use_list (bool): Don't use tuples instead of lists. Can make
        deserialization slower.
    RETURNS (JSONOutputBin): The loaded and deserialized content.
    rbFr   N)r   r   r   r   r   loadr   )r   r   r    r!   r   r   r   r   read_msgpack+   s   $r%   )T)r    r   r   r   utilr   r   r   r	   bytesr   boolr   r"   r%   r   r   r   r   <module>   s    	