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     