o
    h?P                     @  s  U d Z ddlmZ ddlZddlZddlmZm	Z	m
Z
mZmZ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mZ dd
lmZ ddlm Z  ddl!m"Z" erfddl#a#dZ$de%d< nda#g dZ&ej'G dd dej(Z)eZ*	 eee)ddgdf Z+	 eee)dddgdf Z,	 eee)dgdf Z-	 eee)dg ddf Z.	 eee)dg ddf Z/	 eee)ddgdf Z0	 eee)dd gd!d"d#d$f Z1	 eee)d%d&gd'd(f Z2	 eee)d)gd!d*d+f Z3	 eee)g d,d-d(f Z4	 eee)g d.d-d(f Z5	 dGd1d2Z6eree7d3f Z8nG d4d5 d5Z8G d6d7 d7ej9Z:G d8d9 d9Z;G d:d; d;Z<G d<d= d=Z=dHd?d@Z>e> Z?dAZ@	 dIdEdFZAeeBZCdS )JzEThe networks module contains types for common network-related fields.    )annotationsN)IPv4AddressIPv4InterfaceIPv4NetworkIPv6AddressIPv6InterfaceIPv6Network)TYPE_CHECKINGAny)MultiHostUrlPydanticCustomErrorUrlcore_schema)	Annotated	TypeAlias   )_fields_repr_schema_generation_shared)getattr_migration)GetCoreSchemaHandler)JsonSchemaValuez7str | bytes | int | tuple[str | bytes | int, str | int]r   NetworkType)AnyUrl
AnyHttpUrlFileUrlHttpUrlUrlConstraintsEmailStr	NameEmailIPvAnyAddressIPvAnyInterfaceIPvAnyNetworkPostgresDsnCockroachDsnAmqpDsnRedisDsnMongoDsnKafkaDsnvalidate_emailMySQLDsn
MariaDBDsnc                   @  sd   e Zd ZU dZdZded< dZded< dZded< dZd	ed
< dZ	ded< dZ
d	ed< dddZdS )r   a  Url constraints.

    Attributes:
        max_length: The maximum length of the url. Defaults to `None`.
        allowed_schemes: The allowed schemes. Defaults to `None`.
        host_required: Whether the host is required. Defaults to `None`.
        default_host: The default host. Defaults to `None`.
        default_port: The default port. Defaults to `None`.
        default_path: The default path. Defaults to `None`.
    Nz
int | None
max_lengthzlist[str] | Noneallowed_schemeszbool | Nonehost_requiredz
str | Nonedefault_hostdefault_portdefault_pathreturnintc                 C  s2   t | j| jd urt| jnd | j| j| j| jfS N)hashr,   r-   tupler.   r/   r0   r1   self r9   G/var/www/html/ai/venv/lib/python3.10/site-packages/pydantic/networks.py__hash__E   s   zUrlConstraints.__hash__)r2   r3   )__name__
__module____qualname____doc__r,   __annotations__r-   r.   r/   r0   r1   r;   r9   r9   r9   r:   r   1   s   
 r   httphttps)r-   i#  )r,   r-   fileT)	postgres
postgresqlzpostgresql+asyncpgzpostgresql+pg8000zpostgresql+psycopgzpostgresql+psycopg2zpostgresql+psycopg2cffizpostgresql+py-postgresqlzpostgresql+pygresql)r.   r-   )cockroachdbzcockroachdb+psycopg2zcockroachdb+asyncpgamqpamqpsredisrediss	localhosti  z/0)r-   r/   r0   r1   mongodbzmongodb+srvii  )r-   r0   kafkai#  )r-   r/   r0   )mysqlzmysql+mysqlconnectorzmysql+aiomysqlzmysql+asyncmyzmysql+mysqldbzmysql+pymysqlzmysql+cymysqlzmysql+pyodbci  )mariadbzmariadb+mariadbconnectorzmariadb+pymysqlr2   Nonec               
   C  s2   zdd l a W d S  ty }  ztd| d } ~ ww )Nr   zCemail-validator is not installed, run `pip install pydantic[email]`)email_validatorImportError)er9   r9   r:   import_email_validator]  s   
rT   .c                   @  s:   e Zd ZdZeddd	ZedddZedddZdS )r   a   
        Info:
            To use this type, you need to install the optional
            [`email-validator`](https://github.com/JoshData/python-email-validator) package:

            ```bash
            pip install email-validator
            ```

        Validate email addresses.

        ```py
        from pydantic import BaseModel, EmailStr

        class Model(BaseModel):
            email: EmailStr

        print(Model(email='contact@mail.com'))
        #> email='contact@mail.com'
        ```
        _source	type[Any]_handlerr   r2   core_schema.CoreSchemac                 C  s   t   t| jt S r4   )rT   r    no_info_after_validator_function	_validate
str_schemaclsrU   rW   r9   r9   r:   __get_pydantic_core_schema__  s   z%EmailStr.__get_pydantic_core_schema__r   handler._schema_generation_shared.GetJsonSchemaHandlerr   c                 C     ||}|j ddd |S )Nstringemailtypeformatupdater]   r   r_   field_schemar9   r9   r:   __get_pydantic_json_schema__     z%EmailStr.__get_pydantic_json_schema___EmailStr__input_valuestrc                 C  s   t |d S )Nr   )r)   )r]   rm   r9   r9   r:   rZ     s   zEmailStr._validateNrU   rV   rW   r   r2   rX   r   rX   r_   r`   r2   r   )rm   rn   r2   rn   )r<   r=   r>   r?   classmethodr^   rk   rZ   r9   r9   r9   r:   r   i  s    r   c                   @  s\   e Zd ZdZdZd"ddZd#ddZed$ddZed%ddZ	ed&ddZ
d'dd Zd!S )(r   a  
    Info:
        To use this type, you need to install the optional
        [`email-validator`](https://github.com/JoshData/python-email-validator) package:

        ```bash
        pip install email-validator
        ```

    Validate a name and email address combination, as specified by
    [RFC 5322](https://datatracker.ietf.org/doc/html/rfc5322#section-3.4).

    The `NameEmail` has two properties: `name` and `email`.
    In case the `name` is not provided, it's inferred from the email address.

    ```py
    from pydantic import BaseModel, NameEmail

    class User(BaseModel):
        email: NameEmail

    user = User(email='Fred Bloggs <fred.bloggs@example.com>')
    print(user.email)
    #> Fred Bloggs <fred.bloggs@example.com>
    print(user.email.name)
    #> Fred Bloggs

    user = User(email='fred.bloggs@example.com')
    print(user.email)
    #> fred.bloggs <fred.bloggs@example.com>
    print(user.email.name)
    #> fred.bloggs
    ```
    namerc   rs   rn   rc   c                 C  s   || _ || _d S r4   rr   )r8   rs   rc   r9   r9   r:   __init__  s   
zNameEmail.__init__otherr
   r2   boolc                 C  s"   t |to| j| jf|j|jfkS r4   )
isinstancer   rs   rc   )r8   ru   r9   r9   r:   __eq__  s   "zNameEmail.__eq__r   rX   r_   r`   r   c                 C  ra   )Nrb   z
name-emailrd   rg   ri   r9   r9   r:   rk     rl   z&NameEmail.__get_pydantic_json_schema__rU   rV   rW   r   c                 C  s6   t   tj| jtjt| t gdddt dS )Nname_email_typezInput is not a valid NameEmail)custom_error_typecustom_error_messageserialization)rT   r   rY   rZ   union_schemais_instance_schemar[   to_string_ser_schemar\   r9   r9   r:   r^     s   z&NameEmail.__get_pydantic_core_schema___NameEmail__input_valueNameEmail | strc                 C  s$   t || r|S t|\}}| ||S r4   )rw   r)   )r]   r   rs   rc   r9   r9   r:   rZ     s   

zNameEmail._validatec                 C  s   | j  d| j dS )Nz <>rr   r7   r9   r9   r:   __str__  s   zNameEmail.__str__N)rs   rn   rc   rn   )ru   r
   r2   rv   rp   ro   )r   r   r2   r   )r2   rn   )r<   r=   r>   r?   	__slots__rt   rx   rq   rk   r^   rZ   r   r9   r9   r9   r:   r     s    #

r   c                   @  H   e Zd ZdZdZdddZedddZedddZedddZ	dS )r    a  Validate an IPv4 or IPv6 address.

    ```py
    from pydantic import BaseModel
    from pydantic.networks import IPvAnyAddress

    class IpModel(BaseModel):
        ip: IPvAnyAddress

    print(IpModel(ip='127.0.0.1'))
    #> ip=IPv4Address('127.0.0.1')

    try:
        IpModel(ip='http://www.example.com')
    except ValueError as e:
        print(e.errors())
        '''
        [
            {
                'type': 'ip_any_address',
                'loc': ('ip',),
                'msg': 'value is not a valid IPv4 or IPv6 address',
                'input': 'http://www.example.com',
            }
        ]
        '''
    ```
    r9   valuer
   r2   IPv4Address | IPv6Addressc                 C  B   zt |W S  ty   Y nw zt|W S  ty    tddw )z!Validate an IPv4 or IPv6 address.ip_any_addressz)value is not a valid IPv4 or IPv6 address)r   
ValueErrorr   r   r]   r   r9   r9   r:   __new__     


zIPvAnyAddress.__new__r   rX   r_   r`   r   c                 C     i }|j ddd |S )Nrb   ipvanyaddressrd   rg   ri   r9   r9   r:   rk        z*IPvAnyAddress.__get_pydantic_json_schema__rU   rV   rW   r   c                 C     t j| jt  dS Nr|   r    no_info_plain_validator_functionrZ   r   r\   r9   r9   r:   r^        
z*IPvAnyAddress.__get_pydantic_core_schema___IPvAnyAddress__input_valuec                 C     | |S r4   r9   )r]   r   r9   r9   r:   rZ   &     zIPvAnyAddress._validateN)r   r
   r2   r   rp   ro   )r   r
   r2   r   
r<   r=   r>   r?   r   r   rq   rk   r^   rZ   r9   r9   r9   r:   r      s    
	r    c                   @  r   )r!   #Validate an IPv4 or IPv6 interface.r9   r   r   r2   IPv4Interface | IPv6Interfacec                 C  r   )r   ip_any_interfacez+value is not a valid IPv4 or IPv6 interface)r   r   r   r   r   r9   r9   r:   r   0  r   zIPvAnyInterface.__new__r   rX   r_   r`   r   c                 C  r   )Nrb   ipvanyinterfacerd   rg   ri   r9   r9   r:   rk   <  r   z,IPvAnyInterface.__get_pydantic_json_schema__rU   rV   rW   r   c                 C  r   r   r   r\   r9   r9   r:   r^   D  r   z,IPvAnyInterface.__get_pydantic_core_schema___IPvAnyInterface__input_valuec                 C  r   r4   r9   )r]   r   r9   r9   r:   rZ   N  r   zIPvAnyInterface._validateN)r   r   r2   r   rp   ro   )r   r   r2   r   r   r9   r9   r9   r:   r!   +  s    
	r!   c                   @  r   )r"   !Validate an IPv4 or IPv6 network.r9   r   r   r2   IPv4Network | IPv6Networkc                 C  r   )r   ip_any_networkz)value is not a valid IPv4 or IPv6 network)r   r   r   r   r   r9   r9   r:   r   X  s   


zIPvAnyNetwork.__new__r   rX   r_   r`   r   c                 C  r   )Nrb   ipvanynetworkrd   rg   ri   r9   r9   r:   rk   f  r   z*IPvAnyNetwork.__get_pydantic_json_schema__rU   rV   rW   r   c                 C  r   r   r   r\   r9   r9   r:   r^   n  r   z*IPvAnyNetwork.__get_pydantic_core_schema___IPvAnyNetwork__input_valuec                 C  r   r4   r9   )r]   r   r9   r9   r:   rZ   x  r   zIPvAnyNetwork._validateN)r   r   r2   r   rp   ro   )r   r   r2   r   r   r9   r9   r9   r:   r"   S  s    
	r"   re.Pattern[str]c               	   C  s<   d} d|  d|  d}d}d}t d| d| d	| d
S )Nz[\w!#$%&\'*+\-/=?^_`{|}~]z((?:z+\s+)*z+)z"((?:[^"]|\")+)"z<\s*(.+)\s*>z\s*(?:|z)?\s*z\s*)recompile)
name_charsunquoted_name_groupquoted_name_groupemail_groupr9   r9   r:   _build_pretty_email_regex}  s
   r   i   r   rn   tuple[str, str]c              
   C  s   t du rt  t| tkrtddddt dit| }d}|r-| \}}} |p,|}|  }z	t j	|dd}W n t j
yU } ztdddt|jd	 i|d}~ww |j}|dus_J |pc|j}||fS )
a|  Email address validation using [email-validator](https://pypi.org/project/email-validator/).

    Note:
        Note that:

        * Raw IP address (literal) domain parts are not allowed.
        * `"John Doe <local_part@domain.com>"` style "pretty" email addresses are processed.
        * Spaces are striped from the beginning and end of addresses, but no error is raised.
    Nvalue_errorz,value is not a valid email address: {reason}reasonzLength must not exceed z charactersF)check_deliverabilityr   )rQ   rT   lenMAX_EMAIL_LENGTHr   pretty_email_regex	fullmatchgroupsstripr)   EmailNotValidErrorrn   args
normalized
local_part)r   mrs   unquoted_namequoted_namerc   partsrS   r9   r9   r:   r)     s8   


r)   )r2   rP   )r2   r   )r   rn   r2   r   )Dr?   
__future__r   _annotationsdataclasses_dataclassesr   	ipaddressr   r   r   r   r   r   typingr	   r
   pydantic_corer   r   r   r   typing_extensionsr   r   	_internalr   r   r   
_migrationr   annotated_handlersr   json_schemar   rQ   r   r@   __all__	dataclassPydanticMetadatar   r   r   r   r   r#   r$   r%   r&   r'   r(   r*   r+   rT   rn   r   Representationr   r    r!   r"   r   r   r   r)   r<   __getattr__r9   r9   r9   r:   <module>   s      J;

-RC(
*
)