o
    fX                     @  sL  U d Z ddlmZ ddlZddl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mZ ddlmZmZmZmZ ddlmZ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rnd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dgdf Z0	 eee,dddgdf Z1	 eee,dgdf Z2	 eee,dgdf Z3	 eee,dg ddf Z4	 eee,dg d df Z5	 eee,d!d"gdf Z6	 eee,d#d$gd%d&d'd(f Z7	 eee,d)d*gd+d,f Z8	 eee,d-gd%d.d/f Z9	 eee,g d0d%d1d/f Z:	 eee,g d2d3d,f Z;	 eee,g d4d3d,f Z<	 eee,d5d6gd%d7d/f Z=	 dRd:d;Z>er_ee?d<f Z@nG d=d> d>Z@G d?d@ d@ejAZBG dAdB dBZCG dCdD dDZDdEZEde(dF< ereEZFnG dGdH dHZFdSdJdKZGeG ZHdLZI	 dTdPdQZJe!eKZLdS )UzEThe networks module contains types for common network-related fields.    )annotationsN)version)IPv4AddressIPv4InterfaceIPv4NetworkIPv6AddressIPv6InterfaceIPv6Network)TYPE_CHECKINGAny)MultiHostUrlPydanticCustomErrorUrlcore_schema)	AnnotatedSelf	TypeAlias   )_fields_repr_schema_generation_shared)getattr_migration)GetCoreSchemaHandler)JsonSchemaValuez7str | bytes | int | tuple[str | bytes | int, str | int]r   NetworkType)AnyUrl
AnyHttpUrlFileUrlFtpUrlHttpUrlWebsocketUrlAnyWebsocketUrlUrlConstraintsEmailStr	NameEmailIPvAnyAddressIPvAnyInterfaceIPvAnyNetworkPostgresDsnCockroachDsnAmqpDsnRedisDsnMongoDsnKafkaDsnNatsDsnvalidate_emailMySQLDsn
MariaDBDsnClickHouseDsnc                   @  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)hashr3   r4   tupler5   r6   r7   r8   self r@   I/var/www/NoticeGen/venv/lib/python3.10/site-packages/pydantic/networks.py__hash__L   s   zUrlConstraints.__hash__)r9   r:   )__name__
__module____qualname____doc__r3   __annotations__r4   r5   r6   r7   r8   rB   r@   r@   r@   rA   r"   8   s   
 r"   httphttps)r4   i#  )r3   r4   wswssfileftpT)	postgres
postgresqlzpostgresql+asyncpgzpostgresql+pg8000zpostgresql+psycopgzpostgresql+psycopg2zpostgresql+psycopg2cffizpostgresql+py-postgresqlzpostgresql+pygresql)r5   r4   )cockroachdbzcockroachdb+psycopg2zcockroachdb+asyncpgamqpamqpsredisrediss	localhosti  z/0)r4   r6   r7   r8   mongodbzmongodb+srvii  )r4   r7   kafkai#  )r4   r6   r7   )natstlsrJ   i~  )mysqlzmysql+mysqlconnectorzmysql+aiomysqlzmysql+asyncmyzmysql+mysqldbzmysql+pymysqlzmysql+cymysqlzmysql+pyodbci  )mariadbzmariadb+mariadbconnectorzmariadb+pymysqlzclickhouse+nativezclickhouse+asynchi(#  r9   Nonec               
   C  sR   zdd l a W n ty }  ztd| d } ~ ww tddd dks'tdd S )Nr   zCemail-validator is not installed, run `pip install pydantic[email]`zemail-validator.2zKemail-validator version >= 2.0 required, run pip install -U email-validator)email_validatorImportErrorr   	partition)er@   r@   rA   import_email_validator  s   
rc   .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   r9   core_schema.CoreSchemac                 C  s   t   t| jt S r;   )rc   r    no_info_after_validator_function	_validate
str_schemaclsrd   rf   r@   r@   rA   __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rl   r   rn   field_schemar@   r@   rA   __get_pydantic_json_schema__     z%EmailStr.__get_pydantic_json_schema__input_valuestrc                C  s   t |d S )Nr   )r/   rl   r|   r@   r@   rA   ri     s   zEmailStr._validateNrd   re   rf   r   r9   rg   r   rg   rn   ro   r9   r   )r|   r}   r9   r}   )rC   rD   rE   rF   classmethodrm   rz   ri   r@   r@   r@   rA   r#     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
    ```
    namerr   r   r}   rr   c                 C  s   || _ || _d S r;   r   )r?   r   rr   r@   r@   rA   __init__  s   
zNameEmail.__init__otherr   r9   boolc                 C  s"   t |to| j| jf|j|jfkS r;   )
isinstancer$   r   rr   )r?   r   r@   r@   rA   __eq__  s   "zNameEmail.__eq__r   rg   rn   ro   r   c                 C  rp   )Nrq   z
name-emailrs   rv   rx   r@   r@   rA   rz     r{   z&NameEmail.__get_pydantic_json_schema__rd   re   rf   r   c              
   C  sB   t   t| jtjt 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)json_schemapython_schemaserialization)	rc   r   rh   ri   json_or_python_schemarj   union_schemais_instance_schemato_string_ser_schemark   r@   r@   rA   rm     s   z&NameEmail.__get_pydantic_core_schema__r|   
Self | strr   c                C  s$   t |trt|\}}| ||S |S r;   )r   r}   r/   )rl   r|   r   rr   r@   r@   rA   ri     s   

zNameEmail._validatec                 C  s4   d| j v rd| j  d| j dS | j  d| j dS )N@"z" <>z <r   r>   r@   r@   rA   __str__  s   
zNameEmail.__str__N)r   r}   rr   r}   )r   r   r9   r   r   r   )r|   r   r9   r   )r9   r}   )rC   rD   rE   rF   	__slots__r   r   r   rz   rm   ri   r   r@   r@   r@   rA   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',
            }
        ]
        '''
    ```
    r@   valuer   r9   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   rl   r   r@   r@   rA   __new__E     


zIPvAnyAddress.__new__r   rg   rn   ro   r   c                 C     i }|j ddd |S )Nrq   ipvanyaddressrs   rv   rx   r@   r@   rA   rz   Q     z*IPvAnyAddress.__get_pydantic_json_schema__rd   re   rf   r   c                 C     t j| jt  dS N)r   r    no_info_plain_validator_functionri   r   rk   r@   r@   rA   rm   Y     
z*IPvAnyAddress.__get_pydantic_core_schema__r|   c                C     | |S r;   r@   r~   r@   r@   rA   ri   c     zIPvAnyAddress._validateN)r   r   r9   r   r   r   )r|   r   r9   r   
rC   rD   rE   rF   r   r   r   rz   rm   ri   r@   r@   r@   rA   r%   %  s    
	r%   c                   @  r   )r&   #Validate an IPv4 or IPv6 interface.r@   r   r   r9   IPv4Interface | IPv6Interfacec                 C  r   )r   ip_any_interfacez+value is not a valid IPv4 or IPv6 interface)r   r   r   r   r   r@   r@   rA   r   m  r   zIPvAnyInterface.__new__r   rg   rn   ro   r   c                 C  r   )Nrq   ipvanyinterfacers   rv   rx   r@   r@   rA   rz   y  r   z,IPvAnyInterface.__get_pydantic_json_schema__rd   re   rf   r   c                 C  r   r   r   rk   r@   r@   rA   rm     r   z,IPvAnyInterface.__get_pydantic_core_schema__r|   c                C  r   r;   r@   r~   r@   r@   rA   ri     r   zIPvAnyInterface._validateN)r   r   r9   r   r   r   )r|   r   r9   r   r   r@   r@   r@   rA   r&   h  s    
	r&   zIPv4Network | IPv6NetworkIPvAnyNetworkTypec                   @  r   )r'   !Validate an IPv4 or IPv6 network.r@   r   r   r9   r   c                 C  r   )r   ip_any_networkz)value is not a valid IPv4 or IPv6 network)r   r   r	   r   r   r@   r@   rA   r     s   


zIPvAnyNetwork.__new__r   rg   rn   ro   r   c                 C  r   )Nrq   ipvanynetworkrs   rv   rx   r@   r@   rA   rz     r   z*IPvAnyNetwork.__get_pydantic_json_schema__rd   re   rf   r   c                 C  r   r   r   rk   r@   r@   rA   rm     r   z*IPvAnyNetwork.__get_pydantic_core_schema__r|   c                C  r   r;   r@   r~   r@   r@   rA   ri     r   zIPvAnyNetwork._validateN)r   r   r9   r   r   r   )r|   r   r9   r   r   r@   r@   r@   rA   r'     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_groupr@   r@   rA   _build_pretty_email_regex  s
   r   i   r   r}   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   )r_   rc   lenMAX_EMAIL_LENGTHr   pretty_email_regex	fullmatchgroupsstripr/   EmailNotValidErrorr}   args
normalized
local_part)r   mr   unquoted_namequoted_namerr   partsrb   r@   r@   rA   r/     s8   


r/   )r9   r\   )r9   r   )r   r}   r9   r   )MrF   
__future__r   _annotationsdataclasses_dataclassesr   importlib.metadatar   	ipaddressr   r   r   r   r   r	   typingr
   r   pydantic_corer   r   r   r   typing_extensionsr   r   r   	_internalr   r   r   
_migrationr   annotated_handlersr   r   r   r_   r   rG   __all__	dataclassPydanticMetadatar"   r   r   r   r!   r    r   r   r(   r)   r*   r+   r,   r-   r.   r0   r1   r2   rc   r}   r#   Representationr$   r%   r&   r   r'   r   r   r   r/   rC   __getattr__r@   r@   r@   rA   <module>   s      L;


-YC(
*
)