a
   ÐflÌð™¿ã                   @   sŒ   d Z ddlZg d¢ZG dd„ deƒZzddlmZ dd„ ZW n2 eyn   dZ	d	Z
g d
¢Zdd„ Zdd„ ZY n0 dd„ Zdd„ Zdd„ ZdS )aK  
websocket - WebSocket client library for Python

Copyright (C) 2010 Hiroki Ohtani(liris)

    This library is free software; you can redistribute it and/or
    modify it under the terms of the GNU Lesser General Public
    License as published by the Free Software Foundation; either
    version 2.1 of the License, or (at your option) any later version.

    This library is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    Lesser General Public License for more details.

    You should have received a copy of the GNU Lesser General Public
    License along with this library; if not, write to the Free Software
    Foundation, Inc., 51 Franklin Street, Fifth Floor,
    Boston, MA 02110-1335  USA

é    N)ÚNoLockÚvalidate_utf8Úextract_err_messageÚextract_error_codec                   @   s   e Zd Zdd„ Zdd„ ZdS )r   c                 C   s   d S ©N© )Úselfr   r   ú4/usr/lib/python3.9/site-packages/websocket/_utils.pyÚ	__enter__   s    zNoLock.__enter__c                 C   s   d S r   r   )r   Úexc_typeÚ	exc_valueÚ	tracebackr   r   r	   Ú__exit__    s    zNoLock.__exit__N)Ú__name__Ú
__module__Ú__qualname__r
   r   r   r   r   r	   r      s   r   )ÚUtf8Validatorc                 C   s   t ƒ  | ¡d S ©Nr   )r   Zvalidate©Úutfbytesr   r   r	   Ú_validate_utf8)   s    r   é   (l  r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   é   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   é	   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   é   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   é   r   é   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   é
   é   r   r   r   r   r   r   r   r   r   r   r   é   r   r   é   é   r!   r!   é   r   r   r   r   r   r   r   r   r   r   r   r   r   é   é$   é<   é`   éT   r   r   r   é0   éH   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r#   r   r   r   r   r   r#   r   r#   r   r   r   r   r   r   r   r   r   r#   r   r   r   r   r   r#   r   r   r   r   r   r   r   r#   r   r   r   r   r   r   r   r   r   r$   r   r$   r   r   r   r$   r   r   r   r   r   r$   r   r$   r   r   r   r$   r   r   r   r   r   r   r   r   r   r   c                 C   sD   t | }| tkr |d@ |d> B n
d|? |@ }t d|  |  } | |fS )Né?   r!   éÿ   é   )Ú_UTF8DÚ_UTF8_ACCEPT)ÚstateÚcodepZchÚtpr   r   r	   Ú_decodeG   s    ÿ
ÿr2   c                 C   sB   t }d}| D ]0}tjrt|ƒ}t|||ƒ\}}|tkr dS qdS )Nr   FT)r.   ÚsixZPY2Úordr2   Ú_UTF8_REJECT)r   r/   r0   Úir   r   r	   r   P   s    c                 C   s   t | ƒS )zš
    validate utf8 byte string.
    utfbytes: utf byte string to check.
    return value: if valid utf8 string, return true. Otherwise, return false.
    )r   r   r   r   r	   r   ]   s    r   c                 C   s   | j r| j d S d S d S r   )Úargs©Ú	exceptionr   r   r	   r   f   s    
r   c                 C   s6   | j r2t| j ƒdkr2t| j d tƒr.| j d S d S d S )Nr   r   )r7   ÚlenÚ
isinstanceÚintr8   r   r   r	   r   m   s    r   )Ú__doc__r3   Ú__all__Úobjectr   Zwsaccel.utf8validatorr   r   ÚImportErrorr.   r5   r-   r2   r   r   r   r   r   r   r	   Ú<module>   s   			