
    2Bf                        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y)    )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	y
)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passwordc                x    | j                   r| j                   }nd}| j                  r|d| j                  z   z  }|S )N/?)r   r   )selfresource_names     N/var/www/highfloat_scraper/venv/lib/python3.12/site-packages/websockets/uri.pyr   zWebSocketURI.resource_name'   s7    99 IIMM::S4::--M    c                h    | j                   y | j                  J | j                   | j                  fS )N)r   r   )r   s    r   	user_infozWebSocketURI.user_info1   s2    == }}(((t}}--r   )returnr   )r   zOptional[Tuple[str, str]])
__name__
__module____qualname____doc____annotations__r   r   propertyr   r    r   r   r	   r	      s\      L
I
I
IJ"Hm""Hm"  . .r   z:/?#[]@!$&'()*+,;=c           	        t         j                  j                  |       }|j                  dvrt	        j
                  | d      |j                  t	        j
                  | d      |j                  dk7  rt	        j
                  | d      |j                  dk(  }|j                  }|j                  xs |rdnd}|j                  }|j                  }|j                  }|j                  }||t	        j
                  | d	      	 | j                  d
       t%        |||||||      S # t        $ r |j                  d      j                         }t         j                  j!                  |t"              }t         j                  j!                  |t"              }|N|J t         j                  j!                  |t"              }t         j                  j!                  |t"              }Y w xY w)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 wssz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	   )	uriparsedr   r   r   r   r   r   r   s	            r   r   r   =   s    \\""3'F}}M)##C)ABB##C)BCC"##C)MNN]]e#F??D;;1&3bD;;DLLEHH  0##C)MNNA

7 dD%8LL  	A {{6"))+||!!$V!4""5v"6'''||))()@H||))()@H	As   D' 'CG,+G,)r:   r   r   r	   )
__future__r   dataclassesurllib.parser.   typingr   r   r)   r   __all__	dataclassr	   r9   r   r%   r   r   <module>rB      sM    "   "  
' (. (. (.X 
/Mr   