o
    :ÊÆh8(  ã                   @  sÖ  d Z ddlmZ ddlZddlmZ ddlmZmZm	Z	 ddlm
Z
 g d¢ZG d	d
„ d
eƒZG dd„ deƒZG dd„ deƒZG dd„ deƒZG dd„ deƒZG dd„ deƒZG dd„ deƒZG dd„ deƒZG dd„ deƒZG dd„ deƒZG dd„ deƒZG dd „ d eƒZG d!d"„ d"eƒZG d#d$„ d$eƒZG d%d&„ d&eƒZG d'd(„ d(eƒZG d)d*„ d*eƒZG d+d,„ d,eƒZG d-d.„ d.eƒZG d/d0„ d0eƒZ G d1d2„ d2ee!ƒZ"G d3d4„ d4eƒZ#G d5d6„ d6eƒZ$G d7d8„ d8eƒZ%e%Z&dS )9ay  
:mod:`websockets.exceptions` defines the following exception hierarchy:

* :exc:`WebSocketException`
    * :exc:`ConnectionClosed`
        * :exc:`ConnectionClosedError`
        * :exc:`ConnectionClosedOK`
    * :exc:`InvalidHandshake`
        * :exc:`SecurityError`
        * :exc:`InvalidMessage`
        * :exc:`InvalidHeader`
            * :exc:`InvalidHeaderFormat`
            * :exc:`InvalidHeaderValue`
            * :exc:`InvalidOrigin`
            * :exc:`InvalidUpgrade`
        * :exc:`InvalidStatus`
        * :exc:`InvalidStatusCode` (legacy)
        * :exc:`NegotiationError`
            * :exc:`DuplicateParameter`
            * :exc:`InvalidParameterName`
            * :exc:`InvalidParameterValue`
        * :exc:`AbortHandshake`
        * :exc:`RedirectHandshake`
    * :exc:`InvalidState`
    * :exc:`InvalidURI`
    * :exc:`PayloadTooBig`
    * :exc:`ProtocolError`

é    )ÚannotationsN)ÚOptionalé   )ÚdatastructuresÚframesÚhttp11)Ú
StatusLike)ÚWebSocketExceptionÚConnectionClosedÚConnectionClosedErrorÚConnectionClosedOKÚInvalidHandshakeÚSecurityErrorÚInvalidMessageÚInvalidHeaderÚInvalidHeaderFormatÚInvalidHeaderValueÚInvalidOriginÚInvalidUpgradeÚInvalidStatusÚInvalidStatusCodeÚNegotiationErrorÚDuplicateParameterÚInvalidParameterNameÚInvalidParameterValueÚAbortHandshakeÚRedirectHandshakeÚInvalidStateÚ
InvalidURIÚPayloadTooBigÚProtocolErrorÚWebSocketProtocolErrorc                   @  ó   e Zd ZdZdS )r	   z?
    Base class for all exceptions defined by websockets.

    N©Ú__name__Ú
__module__Ú__qualname__Ú__doc__© r(   r(   úb/var/www/html/HyperOracle/crypto_trader/venv/lib/python3.10/site-packages/websockets/exceptions.pyr	   E   ó    r	   c                   @  sD   e Zd ZdZ	ddd
d„Zddd„Zeddd„ƒZeddd„ƒZdS )r
   aG  
    Raised when trying to interact with a closed connection.

    Attributes:
        rcvd (Optional[Close]): if a close frame was received, its code and
            reason are available in ``rcvd.code`` and ``rcvd.reason``.
        sent (Optional[Close]): if a close frame was sent, its code and reason
            are available in ``sent.code`` and ``sent.reason``.
        rcvd_then_sent (Optional[bool]): if close frames were received and
            sent, this attribute tells in which order this happened, from the
            perspective of this side of the connection.

    NÚrcvdúOptional[frames.Close]ÚsentÚrcvd_then_sentúOptional[bool]ÚreturnÚNonec                 C  s   || _ || _|| _d S ©N©r+   r-   r.   )Úselfr+   r-   r.   r(   r(   r)   Ú__init__[   s   
zConnectionClosed.__init__Ústrc                 C  s¤   | j d u r!| jd u r| jd u sJ ‚dS | jd u sJ ‚d| j› d�S | jd u r4| jd u s-J ‚d| j › d�S | jd us;J ‚| jrHd| j › d| j› �S d| j› d| j › �S )Nzno close frame received or sentzsent z; no close frame receivedz	received z; no close frame sentz; then sent z; then received r3   ©r4   r(   r(   r)   Ú__str__e   s   


zConnectionClosed.__str__Úintc                 C  s   | j d u r	tjjS | j jS r2   )r+   r   Ú	CloseCodeÚABNORMAL_CLOSUREÚcoder7   r(   r(   r)   r<   z   s   
zConnectionClosed.codec                 C  s   | j d u rdS | j jS )NÚ )r+   Úreasonr7   r(   r(   r)   r>   €   s   
zConnectionClosed.reasonr2   )r+   r,   r-   r,   r.   r/   r0   r1   ©r0   r6   )r0   r9   )	r$   r%   r&   r'   r5   r8   Úpropertyr<   r>   r(   r(   r(   r)   r
   L   s    ü

r
   c                   @  r"   )r   zì
    Like :exc:`ConnectionClosed`, when the connection terminated with an error.

    A close frame with a code other than 1000 (OK) or 1001 (going away) was
    received or sent, or the closing handshake didn't complete properly.

    Nr#   r(   r(   r(   r)   r   ‡   r*   r   c                   @  r"   )r   z¹
    Like :exc:`ConnectionClosed`, when the connection terminated properly.

    A close code with code 1000 (OK) or 1001 (going away) or without a code was
    received and sent.

    Nr#   r(   r(   r(   r)   r   ‘   r*   r   c                   @  r"   )r   zK
    Raised during the handshake when the WebSocket connection fails.

    Nr#   r(   r(   r(   r)   r   ›   r*   r   c                   @  r"   )r   zs
    Raised when a handshake request or response breaks a security rule.

    Security limits are hard coded.

    Nr#   r(   r(   r(   r)   r   ¢   r*   r   c                   @  r"   )r   zD
    Raised when a handshake request or response is malformed.

    Nr#   r(   r(   r(   r)   r   «   r*   r   c                   @  s&   e Zd ZdZddd	d
„Zddd„ZdS )r   zK
    Raised when an HTTP header doesn't have a valid format or value.

    NÚnamer6   ÚvalueúOptional[str]r0   r1   c                 C  ó   || _ || _d S r2   ©rA   rB   ©r4   rA   rB   r(   r(   r)   r5   ¸   ó   
zInvalidHeader.__init__c                 C  sD   | j d u rd| j› d�S | j dkrd| j› d�S d| j› d| j › �S )Nzmissing z headerr=   zempty zinvalid z	 header: ©rB   rA   r7   r(   r(   r)   r8   ¼   s
   

zInvalidHeader.__str__r2   ©rA   r6   rB   rC   r0   r1   r?   ©r$   r%   r&   r'   r5   r8   r(   r(   r(   r)   r   ²   s    r   c                      s"   e Zd ZdZd‡ fd
d„Z‡  ZS )r   z€
    Raised when an HTTP header cannot be parsed.

    The format of the header doesn't match the grammar for that header.

    rA   r6   ÚerrorÚheaderÚposr9   r0   r1   c                   s"   t ƒ  ||› d|› d|› �¡ d S )Nz at z in ©Úsuperr5   )r4   rA   rK   rL   rM   ©Ú	__class__r(   r)   r5   Í   s   "zInvalidHeaderFormat.__init__)
rA   r6   rK   r6   rL   r6   rM   r9   r0   r1   ©r$   r%   r&   r'   r5   Ú__classcell__r(   r(   rP   r)   r   Å   s    r   c                   @  r"   )r   z
    Raised when an HTTP header has a wrong value.

    The format of the header is correct but a value isn't acceptable.

    Nr#   r(   r(   r(   r)   r   Ñ   r*   r   c                      s"   e Zd ZdZd‡ fdd„Z‡  ZS )	r   zD
    Raised when the Origin header in a request isn't allowed.

    ÚoriginrC   r0   r1   c                   s   t ƒ  d|¡ d S )NÚOriginrN   )r4   rT   rP   r(   r)   r5   à   ó   zInvalidOrigin.__init__)rT   rC   r0   r1   rR   r(   r(   rP   r)   r   Ú   s    r   c                   @  r"   )r   zF
    Raised when the Upgrade or Connection header isn't correct.

    Nr#   r(   r(   r(   r)   r   ä   r*   r   c                   @  s$   e Zd ZdZddd„Zdd	d
„ZdS )r   zJ
    Raised when a handshake response rejects the WebSocket upgrade.

    Úresponseúhttp11.Responser0   r1   c                 C  ó
   || _ d S r2   )rW   )r4   rW   r(   r(   r)   r5   ñ   ó   
zInvalidStatus.__init__r6   c                 C  s   d| j jd›�S )Nú+server rejected WebSocket connection: HTTP Úd)rW   Ústatus_coder7   r(   r(   r)   r8   ô   s   ÿÿzInvalidStatus.__str__N)rW   rX   r0   r1   r?   rJ   r(   r(   r(   r)   r   ë   ó    
r   c                   @  s$   e Zd ZdZddd	„Zddd„ZdS )r   zC
    Raised when a handshake response status code is invalid.

    r]   r9   Úheadersúdatastructures.Headersr0   r1   c                 C  rD   r2   )r]   r_   )r4   r]   r_   r(   r(   r)   r5     rG   zInvalidStatusCode.__init__r6   c                 C  ó   d| j › �S )Nr[   )r]   r7   r(   r(   r)   r8     ó   zInvalidStatusCode.__str__N)r]   r9   r_   r`   r0   r1   r?   rJ   r(   r(   r(   r)   r   û   ó    
r   c                   @  r"   )r   z6
    Raised when negotiating an extension fails.

    Nr#   r(   r(   r(   r)   r   	  r*   r   c                   @  ó$   e Zd ZdZddd„Zddd	„Zd
S )r   zK
    Raised when a parameter name is repeated in an extension header.

    rA   r6   r0   r1   c                 C  rY   r2   ©rA   ©r4   rA   r(   r(   r)   r5     rZ   zDuplicateParameter.__init__c                 C  ra   )Nzduplicate parameter: re   r7   r(   r(   r)   r8     rb   zDuplicateParameter.__str__N©rA   r6   r0   r1   r?   rJ   r(   r(   r(   r)   r     r^   r   c                   @  rd   )r   zJ
    Raised when a parameter name in an extension header is invalid.

    rA   r6   r0   r1   c                 C  rY   r2   re   rf   r(   r(   r)   r5   #  rZ   zInvalidParameterName.__init__c                 C  ra   )Nzinvalid parameter name: re   r7   r(   r(   r)   r8   &  rb   zInvalidParameterName.__str__Nrg   r?   rJ   r(   r(   r(   r)   r     r^   r   c                   @  s$   e Zd ZdZddd	„Zdd
d„ZdS )r   zK
    Raised when a parameter value in an extension header is invalid.

    rA   r6   rB   rC   r0   r1   c                 C  rD   r2   rE   rF   r(   r(   r)   r5   0  rG   zInvalidParameterValue.__init__c                 C  s@   | j d u rd| j› �S | j dkrd| j› �S d| j› d| j › �S )Nzmissing value for parameter r=   zempty value for parameter zinvalid value for parameter z: rH   r7   r(   r(   r)   r8   4  s
   

zInvalidParameterValue.__str__NrI   r?   rJ   r(   r(   r(   r)   r   *  rc   r   c                   @  s(   e Zd ZdZ	dddd„Zddd„ZdS )r   a�  
    Raised to abort the handshake on purpose and return an HTTP response.

    This exception is an implementation detail.

    The public API
    is :meth:`~websockets.server.WebSocketServerProtocol.process_request`.

    Attributes:
        status (~http.HTTPStatus): HTTP status code.
        headers (Headers): HTTP response headers.
        body (bytes): HTTP response body.
    ó    Ústatusr   r_   údatastructures.HeadersLikeÚbodyÚbytesr0   r1   c                 C  s"   t  |¡| _t |¡| _|| _d S r2   )ÚhttpÚ
HTTPStatusri   r   ÚHeadersr_   rk   )r4   ri   r_   rk   r(   r(   r)   r5   L  s   
zAbortHandshake.__init__r6   c                 C  s(   d| j d›dt| jƒ› dt| jƒ› d�S )NzHTTP r\   z, z
 headers, z bytes)ri   Úlenr_   rk   r7   r(   r(   r)   r8   W  s   ÿþÿzAbortHandshake.__str__N)rh   )ri   r   r_   rj   rk   rl   r0   r1   r?   rJ   r(   r(   r(   r)   r   =  s
    ür   c                   @  rd   )r   zd
    Raised when a handshake gets redirected.

    This exception is an implementation detail.

    Úurir6   r0   r1   c                 C  rY   r2   ©rq   )r4   rq   r(   r(   r)   r5   g  rZ   zRedirectHandshake.__init__c                 C  ra   )Nzredirect to rr   r7   r(   r(   r)   r8   j  rb   zRedirectHandshake.__str__N)rq   r6   r0   r1   r?   rJ   r(   r(   r(   r)   r   _  s    
r   c                   @  r"   )r   z¯
    Raised when an operation is forbidden in the current state.

    This exception is an implementation detail.

    It should never be raised in normal circumstances.

    Nr#   r(   r(   r(   r)   r   n  r*   r   c                   @  s$   e Zd ZdZddd„Zdd	d
„ZdS )r   zL
    Raised when connecting to a URI that isn't a valid WebSocket URI.

    rq   r6   Úmsgr0   r1   c                 C  rD   r2   ©rq   rs   )r4   rq   rs   r(   r(   r)   r5     rG   zInvalidURI.__init__c                 C  s   | j › d| j› �S )Nz isn't a valid URI: rt   r7   r(   r(   r)   r8   ƒ  rV   zInvalidURI.__str__N)rq   r6   rs   r6   r0   r1   r?   rJ   r(   r(   r(   r)   r   y  rc   r   c                   @  r"   )r   zS
    Raised when receiving a frame with a payload exceeding the maximum size.

    Nr#   r(   r(   r(   r)   r   ‡  r*   r   c                   @  r"   )r    z3
    Raised when a frame breaks the protocol.

    Nr#   r(   r(   r(   r)   r    Ž  r*   r    )'r'   Ú
__future__r   rm   Útypingr   r=   r   r   r   r   Ú__all__Ú	Exceptionr	   r
   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   ÚAssertionErrorr   r   r   r    r!   r(   r(   r(   r)   Ú<module>   s@    ;

		
"