o
    "“iG
  ã                   @   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
 ddlmZmZmZ ddl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 the stdlib json.é    )Ú	b85decodeÚ	b85encode)ÚSet)ÚdateÚdatetime)ÚdumpsÚloads)ÚAnyÚTypeVarÚUnioné   )ÚCounter)ÚBaseConverterÚ	Converter)Úidentity)Úis_literal_containing_enums)Úconfigure_union_passthroughé   )Úis_primitive_enumÚ'literals_with_enums_unstructure_factoryÚwrap)ÚJsonConverterÚconfigure_converterÚmake_converterÚTc                	   @   sN   e Zd Zddedededefdd„Zdeeef 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!   úS/var/www/html/premium_crap/venv/lib/python3.10/site-packages/cattrs/preconf/json.pyr      s   zJsonConverter.dumpsÚdataÚclc                 K   s   |   t|fi |¤Ž|¡S ©N)Ú	structurer   )r    r#   r$   r   r!   r!   r"   r      s   zJsonConverter.loadsr%   )Ú__name__Ú
__module__Ú__qualname__r	   Ústrr   r   ÚbytesÚtyper   r   r!   r!   r!   r"   r      s    *r   Ú	converterr   Nc                 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 )	aò  
    Configure the converter for use with the stdlib json module.

    * bytes are serialized as base85 strings
    * datetimes are serialized as ISO 8601
    * counters are serialized as dicts
    * sets are serialized as lists
    * string and int enums are passed through when unstructuring
    * union passthrough is configured for unions of strings, bools, ints,
      floats and None

    .. 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   ©r2   Ú_r!   r!   r"   r3   /   ó    c                 S   ó   |   ¡ S r%   ©Ú	isoformatr1   r!   r!   r"   r3   0   r6   c                 S   ó
   t  | ¡S r%   )r   Úfromisoformatr4   r!   r!   r"   r3   1   ó   
 c                 S   r7   r%   r8   r1   r!   r!   r"   r3   2   r6   c                 S   r:   r%   )r   r;   r4   r!   r!   r"   r3   3   r<   N)Úregister_unstructure_hookr+   Úregister_structure_hookr   r   Ú!register_unstructure_hook_factoryr   r   Úregister_unstructure_hook_funcr   r   r   r   r*   ÚboolÚintÚfloat)r-   r!   r!   r"   r      s   ÿÿr   Úargsr   c                  O   s6   t ttti| di ¡¥|d< t| i |¤Ž}t|ƒ |S )NÚunstruct_collection_overrides)r   Úlistr   ÚdictÚgetr   r   )rD   r   Úresr!   r!   r"   r   ;   s   þ
ýr   )#Ú__doc__Úbase64r   r   Úcollections.abcr   r   r   Újsonr   r   Útypingr	   r
   r   Ú_compatr   Ú
convertersr   r   Úfnsr   Úliteralsr   Ú
strategiesr   Ú r   r   r   Ú__all__r   r   r   r   r!   r!   r!   r"   Ú<module>   s$    