a
    یxd                     @  sl   d dl mZ d dlZd dlZd dlmZmZ ddlm	Z	 ddgZ
ejG dd dZd	Zd
ddddZdS )    )annotationsN)OptionalTuple   )
exceptions	parse_uriWebSocketURIc                   @  sv   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dZed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://www.rfc-editor.org/rfc/rfc3986.html#section-3.2.1

    boolsecurestrhostintportpathqueryNzOptional[str]usernamepassword)returnc                 C  s*   | j r| j }nd}| jr&|d| j 7 }|S )N/?)r   r   )selfresource_name r   F/var/www/html/Ranjet/env/lib/python3.9/site-packages/websockets/uri.pyr   '   s    zWebSocketURI.resource_namezOptional[Tuple[str, str]]c                 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_info1   s    
zWebSocketURI.user_info)
__name__
__module____qualname____doc____annotations__r   r   propertyr   r   r   r   r   r   r      s   
	z:/?#[]@!$&'()*+,;=r   )urir   c           	      C  sB  t j| }|jdvr"t| d|jdu r8t| d|jdkrNt| d|jdk}|j}|jpn|rldnd	}|j	}|j
}|j}|j}|dur|du rt| d
z| d W nz 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0 t|||||||S )z
    Parse and validate a WebSocket URI.

    Args:
        uri: WebSocket URI.

    Returns:
        WebSocketURI: 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   Z
InvalidURIhostnamefragmentr   r   r   r   r   encodeUnicodeEncodeErrordecodequoteDELIMSr   )	r!   parsedr
   r   r   r   r   r   r   r   r   r   r   =   s6    




)
__future__r   dataclassesurllib.parser)   typingr   r   r$   r   __all__	dataclassr   r3   r   r   r   r   r   <module>   s   ,