U
    ={f                  0   @   s2  U d dl Z d dl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mZ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mZmZmZ d d
lmZ d dlmZ ddl m!Z! ddl"m#Z# ddlm$Z$m%Z% ddlm&Z& ese&Z'dZ(ee j)e j*f e+dddZ,eee-e.f dddZ/e0dd e!e+e j)e,e j e,e j*e,e j1dd ee/edd e2e3ee3ee3e	e+e
e+ee+ee+ee+ee+e#e+ee+edd e$e+e%e+e4e3ee+iZ5eee eegef f e6d< edddeed d!d"Z7ed#ddeeeee gef f eed$d%d&Z8ed'dde j1e+d(d)d*Z9dS )+    N)deque)Decimal)Enum)IPv4AddressIPv4InterfaceIPv4NetworkIPv6AddressIPv6InterfaceIPv6Network)Path)Pattern)GeneratorType)TYPE_CHECKINGAnyCallableDictTypeUnion)UUID)
deprecated   )Color)	NameEmail)SecretBytes	SecretStr)PydanticDeprecatedSince20)pydantic_encodercustom_pydantic_encodertimedelta_isoformat)oreturnc                 C   s   |   S N)	isoformatr    r$   W/var/www/html/Darija-Ai-API/env/lib/python3.8/site-packages/pydantic/deprecated/json.pyr"      s    r"   )	dec_valuer    c                 C   s0   |   j}t|tr$|dkr$t| S t| S dS )a  Encodes a Decimal as int of there's no exponent, otherwise float.

    This is useful when we use ConstrainedDecimal to represent Numeric(x,0)
    where a integer (but not int typed) is used. Encoding this as a float
    results in failed round-tripping between encode and parse.
    Our Id type is a prime example of this.

    >>> decimal_encoder(Decimal("1.0"))
    1.0

    >>> decimal_encoder(Decimal("1"))
    1
    r   N)as_tupleexponent
isinstanceintfloat)r&   r(   r$   r$   r%   decimal_encoder    s    
r,   c                 C   s   |   S r!   )decoder#   r$   r$   r%   <lambda>6       r.   c                 C   s   |   S r!   )total_seconds)tdr$   r$   r%   r.   ;   r/   c                 C   s   | j S r!   )valuer#   r$   r$   r%   r.   =   r/   c                 C   s   | j S r!   )patternr#   r$   r$   r%   r.   I   r/   ENCODERS_BY_TYPEQ`pydantic_encoder` is deprecated, use `pydantic_core.to_jsonable_python` instead.)category)objr    c              	   C   s   t jdtdd ddlm}m} ddlm} t| |r>| 	 S || rN|| S | j
jd d D ]4}zt| }W n tk
r   Y q^Y nX ||   S td| j
j d	d S )
Nr5   r   r6   
stacklevelr   )asdictis_dataclass)	BaseModelzObject of type 'z' is not JSON serializable)warningswarnr   dataclassesr:   r;   mainr<   r)   Z
model_dump	__class____mro__r4   KeyError	TypeError__name__)r7   r:   r;   r<   baseencoderr$   r$   r%   r   Q   s$    

r   L`custom_pydantic_encoder` is deprecated, use `BaseModel.model_dump` instead.)type_encodersr7   r    c              	   C   s^   t jdtdd |jjd d D ]4}z| | }W n tk
rH   Y q Y nX ||  S t|S )NrI   r   r8   r=   )r>   r?   r   rB   rC   rD   r   )rJ   r7   rG   rH   r$   r$   r%   r   p   s    
r   $`timedelta_isoformat` is deprecated.)r1   r    c                 C   st   t jdtdd t| jd\}}t|d\}}| jdk r<dnd dt| j d	|d
d|d
d|d
d| jddS )z.ISO 8601 encoding for Python timedelta object.rK   r   r8   <   r   - PZDTdHM.Z06dS)r>   r?   r   divmodsecondsdaysabsmicroseconds)r1   minutesrV   hoursr$   r$   r%   r      s    r   ):datetimer>   collectionsr   decimalr   enumr   	ipaddressr   r   r   r   r	   r
   pathlibr   rer   typesr   typingr   r   r   r   r   r   uuidr   Ztyping_extensionsr   colorr   Znetworksr   r   r   r   DeprecationWarning__all__datetimestrr"   r*   r+   r,   bytes	timedelta	frozensetlistsetr4   __annotations__r   r   r   r$   r$   r$   r%   <module>   s                              "*
