o
    DRh5                     @  sV   d dl mZ d dlZd dlZddlmZ ddgZejG dd dZ	dZ
dddZdS )    )annotationsN   )
InvalidURI	parse_uriWebSocketURIc                   @  sn   e Zd ZU dZded< ded< ded< ded< ded	< d
Zded< d
Zded< edddZedddZ	d
S )r   a  
    WebSocket URI.

    Attributes:
        secure: :obj:`True` for a ``wss`` URI, :obj:`False` for a ``ws`` URI.
        host: Normalized to lower case.
        port: Always set even if it's the default.
        path: May be empty.
        query: May be empty if the URI doesn't include a query component.
        username: Available when the URI contains `User Information`_.
        password: Available when the URI contains `User Information`_.

    .. _User Information: https://datatracker.ietf.org/doc/html/rfc3986#section-3.2.1

    boolsecurestrhostintportpathqueryNz
str | Noneusernamepasswordreturnc                 C  s*   | j r| j }nd}| jr|d| j 7 }|S )N/?)r   r   )selfresource_name r   P/home/air/sanwanet/backup_V2/venv/lib/python3.10/site-packages/websockets/uri.pyr   &   s   zWebSocketURI.resource_nametuple[str, str] | Nonec                 C  s(   | j d u rd S | jd usJ | j | jfS )N)r   r   )r   r   r   r   	user_info0   s   
zWebSocketURI.user_info)r   r	   )r   r   )
__name__
__module____qualname____doc____annotations__r   r   propertyr   r   r   r   r   r   r      s   
 	z:/?#[]@!$&'()*+,;=urir	   r   c           	      C  s4  t j| }|jdvrt| d|jdu rt| d|jdkr$t| d|jdk}|j}|jp4|r3dnd	}|j}|j	}|j
}|j}|durN|du rNt| d
z| d W n: ty   |d }t jj|td}t jj|td}|dur|dus}J t jj|td}t jj|td}Y nw t|||||||S )z
    Parse and validate a WebSocket URI.

    Args:
        uri: WebSocket URI.

    Returns:
        Parsed WebSocket URI.

    Raises:
        InvalidURI: If ``uri`` isn't a valid WebSocket URI.

    )wswsszscheme isn't ws or wssNzhostname isn't provided z"fragment identifier is meaninglessr"   i  P   z"username provided without passwordasciiidna)safe)urllibparseurlparseschemer   hostnamefragmentr   r   r   r   r   encodeUnicodeEncodeErrordecodequoteDELIMSr   )	r    parsedr   r
   r   r   r   r   r   r   r   r   r   <   s:   







)r    r	   r   r   )
__future__r   dataclassesurllib.parser(   
exceptionsr   __all__	dataclassr   r2   r   r   r   r   r   <module>   s    ,