o
    TiT
                     @   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"   G/home/ubuntu/.local/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dd  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   r3   _r"   r"   r#   r4   /       c                 S      |   S r&   	isoformatr2   r"   r"   r#   r4   0   r7   c                 S   
   t | S r&   )r   fromisoformatr5   r"   r"   r#   r4   1      
 c                 S   r8   r&   r9   r2   r"   r"   r#   r4   2   r7   c                 S   r;   r&   )r   r<   r5   r"   r"   r#   r4   3   r=   c                 S   s   t S r&   r   )r6   r"   r"   r#   r4   7   s    N)register_unstructure_hookr,   register_structure_hookr   r   !register_unstructure_hook_factoryr   r   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$    