
    8'h+                        d dl mZ d dlZd dlmZ ej
                  sd dlZnd dlmZ ddgZ	ej                  j                  e	       ej                  j                  e	       ej                  j                  e	       ej                  j                  e	       ej                  j                  e	       dZed
d       Zed	        Zy)    )absolute_importN)public)parsersrss)
create_url	parse_urlc                 *   t        |      t        k(  sJ | dk(  rd|z  }n\|+t        |      t        j                  v r|t	        dd      v sJ |d| |fz  }n%|rdj                  |       }ndj                  |       }|rd}nd	}d
j                  ||      S )a  
    Create a RawSocket URL from components.

    :param hostname: RawSocket server hostname (for TCP/IP sockets) or
        filesystem path (for Unix domain sockets).
    :type hostname: str

    :param port: For TCP/IP sockets, RawSocket service port or ``None`` (to select default
        ports ``80`` or ``443`` depending on ``isSecure``. When ``hostname=="unix"``,
        this defines the path to the Unix domain socket instead of a TCP/IP network socket.
    :type port: int or str

    :param isSecure: Set ``True`` for secure RawSocket (``rss`` scheme).
    :type isSecure: bool

    :returns: Constructed RawSocket URL.
    :rtype: str
    unixzunix:%sr     z%s:%dz{}:443z{}:80r   r   z{}://{})typeboolsixinteger_typesrangeformat)hostnameportisSecurenetlocschemes        S/var/www/html/trade_iq/venv/lib/python3.12/site-packages/autobahn/rawsocket/util.pyr   r   =   s    * >T!!!6d"|T
c.?.? ?DERSUZOD[\\4 00F"))(3!2VV,,    c                    t        j                   |       }|j                  dvr$t        dj                  |j                              |j                  r|j                  dk(  rt        d      |j
                  3|j
                  dk7  r$t        dj                  |j
                              |j                  3|j                  dk7  r$t        dj                  |j                              |j                  dk(  rI|j                  |j                  z   }|j                  d      d	   }|j                  d
k(  |j                  |fS |j                  3|j                  dk7  r$t        dj                  |j                              |j                  |j                  dk(  r|j                  dk(  rd}nd}nt        |j                        }|d	k  s|dkD  rt        dj                  |            |j                  d
k(  |j                  |fS )a  
    Parses as RawSocket URL into it's components and returns a tuple:

     - ``isSecure`` is a flag which is ``True`` for ``rss`` URLs.
     - ``host`` is the hostname or IP from the URL.

    and for TCP/IP sockets:

     - ``tcp_port`` is the port from the URL or standard port derived from
       scheme (``rs`` => ``80``, ``rss`` => ``443``).

    or for Unix domain sockets:

     - ``uds_path`` is the path on the local host filesystem.

    :param url: A valid RawSocket URL, i.e. ``rs://localhost:9000`` for TCP/IP sockets or
        ``rs://unix:/tmp/file.sock`` for Unix domain sockets (UDS).
    :type url: str

    :returns: A 3-tuple ``(isSecure, host, tcp_port)`` (TCP/IP) or ``(isSecure, host, uds_path)`` (UDS).
    :rtype: tuple
    )r   r   z@invalid RawSocket URL: protocol scheme '{}' is not for RawSocket z'invalid RawSocket URL: missing hostnamez+invalid RawSocket URL: non-empty query '{}'z.invalid RawSocket URL: non-empty fragment '{}'r   :   r   z*invalid RawSocket URL: non-empty path '{}'r   P   i  r   zinvalid port {})urlparser   	Exceptionr   r   queryfragmentr   pathsplitr   int)urlparsedfpuds_pathtcp_ports        r   r	   r	   j   s   0 s#F}}M)Zaabhbobopqq??foo3ABB||FLLB$6ELLV\\Z[["v"'<HOOPVP_P_`aa'! ]]V[[(88C=#
 }}%v@@
 ;;"v{{b'8HOOPVP[P[\]];;&++"3}}$6;;'Ha<8e+-44X>??}}%v@@r   )NF)
__future__r   r   autobahn.utilr   PY3r   urllibr   	wsschemesuses_relativeextenduses_netlocuses_params
uses_queryuses_fragment__all__r   r	    r   r   <module>r8      s   6 ' 
   ww )5M	     i (     I &     I &     9 %     i ( )- )-X BA BAr   