o
    "“iæ  ã                   @   sØ   d Z ddlmZ ddl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 edƒZG dd„ deƒZdefdd„Zeeƒdededefdd„ƒZdS )z#Preconfigured converters for cbor2.é    )ÚSet)ÚdateÚdatetimeÚ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Ú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 )ÚCbor2ConverterNÚobjÚunstructure_asÚkwargsÚreturnc                 K   s   t | j||d�fi |¤ŽS )N)r   )r	   Úunstructure)Úselfr   r   r   © r   úT/var/www/html/premium_crap/venv/lib/python3.10/site-packages/cattrs/preconf/cbor2.pyr	      s   zCbor2Converter.dumpsÚdataÚclc                 K   s   |   t|fi |¤Ž|¡S ©N)Ú	structurer
   )r   r   r    r   r   r   r   r
      s   zCbor2Converter.loadsr!   )	Ú__name__Ú
__module__Ú__qualname__r   Úbytesr	   Útyper   r
   r   r   r   r   r      s    "r   Ú	converterc                 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 )zÙ
    Configure the converter for use with the cbor2 library.

    * datetimes are serialized as timestamp floats
    * sets are serialized as lists
    * string and int enums are passed through when unstructuring
    c                 S   ó   |   ¡ S r!   )Ú	timestamp©Úvr   r   r   Ú<lambda>"   ó    z%configure_converter.<locals>.<lambda>c                 S   s   t  | tj¡S r!   )r   Úfromtimestampr   Úutc©r,   Ú_r   r   r   r-   $   s    c                 S   r)   r!   )Ú	isoformatr+   r   r   r   r-   &   r.   c                 S   s
   t  | ¡S r!   )r   Úfromisoformatr1   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   Úconfigure_converter   s   ÿÿr=   Úargsr   r   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   Úmake_converter/   s   ÿ
þrC   N)Ú__doc__Úcollections.abcr   r   r   r   Útypingr   r   r   Úcbor2r	   r
   Ú
convertersr   r   Úfnsr   Úliteralsr   Ú
strategiesr   Ú r   r   r   r   r   r=   rC   r   r   r   r   Ú<module>   s    