o
    ¾À•a¼  ã                   @   s‚   d Z g d¢ZG dd„ dƒZzddlmZ dd„ ZW n ey2   dZdZg d	¢Z	d
d„ Z
dd„ ZY nw dd„ Zdd„ Zdd„ ZdS )a^  
_url.py
websocket - WebSocket client library for Python

Copyright 2021 engn33r

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
)Ú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   ó   d S ©N© )Úselfr   r   ú2/usr/lib/python3/dist-packages/websocket/_utils.pyÚ	__enter__   ó   zNoLock.__enter__c                 C   r   r   r   )r   Úexc_typeÚ	exc_valueÚ	tracebackr   r   r	   Ú__exit__   r   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	   Ú_decodeB   s   ÿ
ÿr4   c                 C   s4   t }d}| D ]}t|||ƒ\}}|tkr dS qdS )Nr   FT)r0   r4   Ú_UTF8_REJECT)r   r1   r2   Úir   r   r	   r   K   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   V   s   r   c                 C   s   | j r| j d S d S r   )Úargs©Z	exceptionr   r   r	   r   _   s   
r   c                 C   s:   | j rt| j ƒdkrt| j d tƒr| j d S d S d S d S )Nr   r   )r7   ÚlenÚ
isinstanceÚintr8   r   r   r	   r   f   s   ÿr   N)Ú__doc__Ú__all__r   Zwsaccel.utf8validatorr   r   ÚImportErrorr0   r5   r/   r4   r   r   r   r   r   r   r	   Ú<module>   s     		Ü/	