o
    "i	                     @   s   d Z ddlmZ ddlmZmZmZmZ ddlmZm	Z	m
Z
 ddlmZmZ ddlmZmZ ddlmZ dd	lmZ dd
lmZ ddlmZmZmZ g dZe	dZG dd deZdeddfddZeedededefddZdS )z%Preconfigured converters for msgpack.    )Set)datedatetimetimetimezone)AnyTypeVarUnion)dumpsloads   )BaseConverter	Converter)identity)is_literal_containing_enums)configure_union_passthrough   )is_primitive_enum'literals_with_enums_unstructure_factorywrap)MsgpackConverterconfigure_convertermake_converterTc                	   @   sF   e Zd ZddedededefddZded	ee dedefd
dZdS )r   Nobjunstructure_askwargsreturnc                 K   s   t | j||dfi |S )N)r   )r
   unstructure)selfr   r   r    r    V/var/www/html/premium_crap/venv/lib/python3.10/site-packages/cattrs/preconf/msgpack.pyr
      s   zMsgpackConverter.dumpsdataclc                 K   s   |  t|fi ||S N)	structurer   )r   r"   r#   r   r    r    r!   r      s   zMsgpackConverter.loadsr$   )	__name__
__module____qualname__r   bytesr
   typer   r   r    r    r    r!   r      s    "r   	converterr   Nc                 C   sv   |  tdd  | tdd  |  tdd  | tdd  | tt | tt	 t
tttttdtf |  dS )aC  
    Configure the converter for use with the msgpack library.

    * datetimes are serialized as timestamp floats
    * sets are serialized as lists
    * string and int enums are passed through when unstructuring

    .. versionchanged:: 24.2.0
        Enums are left to the library to unstructure, speeding them up.
    c                 S   s   |   S r$   )	timestampvr    r    r!   <lambda>'   s    z%configure_converter.<locals>.<lambda>c                 S   s   t | tjS r$   )r   fromtimestampr   utcr.   _r    r    r!   r/   )   s    c                 S   s   t | ttjd S )N)tzinfo)r   combiner   r   r1   r,   r-   r    r    r!   r/   ,   s    c                 S   s   t | tj S r$   )r   r0   r   r1   r   r2   r    r    r!   r/   /   s    N)register_unstructure_hookr   register_structure_hookr   register_unstructure_hook_funcr   r   !register_unstructure_hook_factoryr   r   r   r	   strboolintfloatr)   )r+   r    r    r!   r      s   r   argsr   c                  O   s2   t ti|di |d< t| i |}t| |S )Nunstruct_collection_overrides)r   listgetr   r   )r>   r   resr    r    r!   r   8   s   
r   ) __doc__collections.abcr   r   r   r   r   typingr   r   r	   msgpackr
   r   
convertersr   r   fnsr   literalsr   
strategiesr    r   r   r   __all__r   r   r   r   r    r    r    r!   <module>   s     