o
    "“iy	  ã                   @   sð   d Z ddlmZm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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fdd„Z eeƒde	de	defdd„ƒZ!dS )z#Preconfigured converters for ujson.é    )Ú	b85decodeÚ	b85encode)ÚSet)ÚdateÚdatetime)ÚAnyÚAnyStrÚTypeVarÚUnion)ÚdumpsÚloadsé   )ÚBaseConverterÚ	Converter)Úidentity)Úis_literal_containing_enums)Úconfigure_union_passthroughé   )Úis_primitive_enumÚ'literals_with_enums_unstructure_factoryÚwrap)ÚUjsonConverterÚ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!   úT/var/www/html/premium_crap/venv/lib/python3.10/site-packages/cattrs/preconf/ujson.pyr      s   zUjsonConverter.dumpsÚdataÚclc                 K   s   |   t|fi |¤Ž|¡S ©N)Ú	structurer   )r    r#   r$   r   r!   r!   r"   r      s   zUjsonConverter.loadsr%   )
Ú__name__Ú
__module__Ú__qualname__r   Ústrr   r   Útyper   r   r!   r!   r!   r"   r      s    "r   Ú	converterc                 C   s”   |   tdd„ ¡ |  tdd„ ¡ |   tdd„ ¡ |  tdd„ ¡ |   tdd„ ¡ |  tdd„ ¡ |  tt¡ |  t	t
¡ ttttttdf | ƒ dS )	af  
    Configure the converter for use with the ujson library.

    * bytes are serialized as base64 strings
    * datetimes are serialized as ISO 8601
    * 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   | r	t | ƒ d¡S d d¡S )Nó    Úutf8)r   Údecode©Úvr!   r!   r"   Ú<lambda>*   s    z%configure_converter.<locals>.<lambda>c                 S   s   t | ƒS r%   )r   ©r1   Ú_r!   r!   r"   r2   ,   ó    c                 S   ó   |   ¡ S r%   ©Ú	isoformatr0   r!   r!   r"   r2   .   r5   c                 S   ó
   t  | ¡S r%   )r   Úfromisoformatr3   r!   r!   r"   r2   /   ó   
 c                 S   r6   r%   r7   r0   r!   r!   r"   r2   0   r5   c                 S   r9   r%   )r   r:   r3   r!   r!   r"   r2   1   r;   N)Úregister_unstructure_hookÚbytesÚregister_structure_hookr   r   Úregister_unstructure_hook_funcr   r   Ú!register_unstructure_hook_factoryr   r   r   r
   r*   ÚboolÚintÚfloat)r,   r!   r!   r"   r      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   )rD   r   Úresr!   r!   r"   r   9   s   ÿ
þr   N)"Ú__doc__Úbase64r   r   Úcollections.abcr   r   r   Útypingr   r   r	   r
   Úujsonr   r   Ú
convertersr   r   Úfnsr   Úliteralsr   Ú
strategiesr   Ú r   r   r   Ú__all__r   r   r   r   r!   r!   r!   r"   Ú<module>   s"    