
    i?                         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Zdde
d	ede	fd
ZdededdfdZdded	ede	fdZy)    N   )msgpack)msgpack_encodersmsgpack_decoders)
force_pathFilePathJSONInputBinJSONOutputBindatareturnc                 0    t        j                  | 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   s    c/var/www/vps2.regionflexible.com/Desarrollo/venv/lib/python3.12/site-packages/srsly/_msgpack_api.pymsgpack_dumpsr      s     ==D11    use_listc                     t        j                          t        j                  | d|      }t        j                          |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   msgs      r   msgpack_loadsr      s-     JJL
--%(
;CIIKJr   pathc                     t        | d      }|j                  d      5 }t        j                  ||d       ddd       y# 1 sw Y   yxY w)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fs       r   write_msgpackr&       sC     46I		 1T1401 1 1s   AA
c                     t        |       }|j                  d      5 }t        j                          t	        j
                  |d|      }t        j                          |cddd       S # 1 sw Y   yxY w)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   s        r   read_msgpackr*   +   sX     4 I		 


ll1%(;
		  s   AA))A2)T)r    r   r   r   utilr   r   r	   r
   bytesr   boolr   r&   r*    r   r   <module>r0      su    	  7 C C2 2 2   1 1 1 1x 4 = r   