Ë
    €Ïï  ã                   ó†   — d Z ddlZg d¢Z G d„ de«      Z	 ddlmZ d„ Zd„ Zd„ Zd„ Zy# e$ r dZ	dZ
g d	¢Zd
„ Zd„ ZY Œw xY w)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                   ó   — e Zd Zd„ Zd„ Zy)r   c                  ó   — y ©N© )Úselfs    ú#lib/third_party/websocket/_utils.pyÚ	__enter__zNoLock.__enter__   ó   € Øó    c                  ó   — y r	   r
   )r   Úexc_typeÚ	exc_valueÚ	tracebacks       r   Ú__exit__zNoLock.__exit__    r   r   N)Ú__name__Ú
__module__Ú__qualname__r   r   r
   r   r   r   r      s   „ òór   r   )ÚUtf8Validatorc                 ó:   — t        «       j                  | «      d   S ©Nr   )r   Úvalidate©Úutfbytess    r   Ú_validate_utf8r   (   s   € Ü‹×'Ñ'¨Ó1°!Ñ4Ð4r   é   (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                 ór   — t         |   }| t        k7  r|dz  |dz  z  nd|z	  |z  }t         d| z   |z      } | |fS )Né?   r)   éÿ   é   )Ú_UTF8DÚ_UTF8_ACCEPT)ÚstateÚcodepÚchÚtps       r   Ú_decoder<   F   sU   € ÜB‰Zˆð ”\Ò!ð d‘˜u¨™zÒ*Ø)-°©°rÑ(9ð 	äs˜U‘{ RÑ'Ñ(ˆàeˆ|Ðr   c                 óŽ   — t         }d}| D ]8  }t        j                  rt        |«      }t	        |||«      \  }}|t
        k(  sŒ8 y y)Nr   FT)r7   ÚsixÚPY2Úordr<   Ú_UTF8_REJECT)r   r8   r9   Úis       r   r   r   O   sH   € ÜˆØˆÛˆAÜwŠwÜ˜“FÜ" 5¨%°Ó3‰LˆE5ØœÓ$Ùð ð r   c                 ó   — 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   s    r   r   r   \   s   € ô ˜(Ó#Ð#r   c                 ó:   — | j                   r| j                   d   S y r   )Úargs©Ú	exceptions    r   r   r   e   s   € Ø‡~‚~Ø~‰~˜aÑ Ð àr   c                 óª   — | j                   rGt        | j                   «      dkD  r.t        | j                   d   t        «      r| j                   d   S d S y y )Nr    r   )rE   ÚlenÚ
isinstanceÚintrF   s    r   r   r   l   sF   € Ø‡~‚~œ#˜iŸn™nÓ-°Ò1Ü$.¨y¯~©~¸aÑ/@Ä#Ô$Fˆy~‰~˜aÑ ÐPÈDÐPð 2€~r   )Ú__doc__r>   Ú__all__Úobjectr   Úwsaccel.utf8validatorr   r   ÚImportErrorr7   rA   r6   r<   r   r   r   r
   r   r   Ú<module>rQ      sp   ðñó* â
R€ôˆVô ð6õ 4ò5òh$òóQøðC ò .ð €LØ€Lò/€Fò(ô
ðI.ús   —	* ªA ¿A 