
    &th                        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                      Zd	ZddZdS )    )annotationsN)OptionalTuple   )
exceptions	parse_uriWebSocketURIc                      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            Ze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                P    | j         r| j         }nd}| j        r|d| j        z   z  }|S )N/?)r   r   )selfresource_names     b/var/www/html/mycamper/aliexpress-site/backend/venv/lib/python3.11/site-packages/websockets/uri.pyr   zWebSocketURI.resource_name'   s;    9 	  IMMM: 	.S4:--M    Optional[Tuple[str, str]]c                B    | j         d S | j        J | j         | j        fS )N)r   r   )r   s    r   	user_infozWebSocketURI.user_info1   s,    = 4}(((t}--r   )r   r   )r   r   )
__name__
__module____qualname____doc____annotations__r   r   propertyr   r    r   r   r	   r	      s            LLLIIIIIIIIIJJJ"H"""""H""""   X . . . X. . .r   z:/?#[]@!$&'()*+,;=urir   r   c           	        t           j                            |           }|j        dvrt	          j        | d          |j        t	          j        | d          |j        dk    rt	          j        | d          |j        dk    }|j        }|j        p|rdnd	}|j	        }|j
        }|j        }|j        }||t	          j        | d
          	 |                     d           n# t          $ r |                    d                                          }t           j                            |t"                    }t           j                            |t"                    }|P|J t           j                            |t"                    }t           j                            |t"                    }Y nw xY w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   
InvalidURIhostnamefragmentr   r   r   r   r   encodeUnicodeEncodeErrordecodequoteDELIMSr	   )	r'   parsedr   r   r   r   r   r   r   s	            r   r   r   =   s    \""3''F}M))#C)ABBB#C)BCCC"#C)MNNN]e#F?D;1&033bD;DLEHH  0#C)MNNNA

7 	A 	A 	A {{6""))++|!!$V!44""5v"66'''|))()@@H|))()@@H	A dD%8LLLs   C% %CF76F7)r'   r   r   r	   )
__future__r   dataclassesurllib.parser0   typingr   r   r+   r   __all__	dataclassr	   r;   r   r&   r   r   <module>rC      s    " " " " " "         " " " " " " " "       
' (. (. (. (. (. (. (. (.X 
/M /M /M /M /M /Mr   