ó
Æ½òec           @   si   d  Z  d d l Td d l Z d d l Z d g Z e j Z e j e j f Z d e j	 f d „  ƒ  YZ
 d S(   s}   
SocketIO imported from socket module in Python 3.

Copyright (c) 2001-2013 Python Software Foundation; All Rights Reserved.
iÿÿÿÿ(   t   *Nt   SocketIOc           B   st   e  Z d  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z	 e
 d „  ƒ Z e
 d	 „  ƒ Z d
 „  Z RS(   s¬   Raw I/O implementation for stream sockets.

    This class supports the makefile() method on sockets.  It provides
    the raw I/O interface on top of a socket object.
    c         C   s…   | d	 k r t  d | ƒ ‚ n  t j j |  ƒ | |  _ d | k rQ | d 7} n  | |  _ d | k |  _ d | k |  _ t |  _	 d  S(
   Nt   rt   wt   rwt   rbt   wbt   rwbs   invalid mode: %rt   b(   R   R   R   R   R   R   (
   t
   ValueErrort   iot	   RawIOBaset   __init__t   _sockt   _modet   _readingt   _writingt   Falset   _timeout_occurred(   t   selft   sockt   mode(    (    s>   /navires/venv/lib/python2.7/site-packages/pymysql/_socketio.pyR   !   s    		c         C   sµ   |  j  ƒ  |  j ƒ  |  j r, t d ƒ ‚ n  x‚ t r° y |  j j | ƒ SWq/ t k
 rh t |  _ ‚  q/ t k
 r¬ } | j	 d } | t
 k r– q/ n  | t k r¦ d S‚  q/ Xq/ Wd S(   s3  Read up to len(b) bytes into the writable buffer *b* and return
        the number of bytes read.  If the socket is non-blocking and no bytes
        are available, None is returned.

        If *b* is non-empty, a 0 return value indicates that the connection
        was shutdown at the other end.
        s!   cannot read from timed out objecti    N(   t   _checkClosedt   _checkReadableR   t   IOErrort   TrueR   t	   recv_intot   timeoutt   errort   argst   EINTRt   _blocking_errnost   None(   R   R   t   et   n(    (    s>   /navires/venv/lib/python2.7/site-packages/pymysql/_socketio.pyt   readinto-   s"    

			c         C   s\   |  j  ƒ  |  j ƒ  y |  j j | ƒ SWn- t k
 rW } | j d t k rQ d S‚  n Xd S(   s  Write the given bytes or bytearray object *b* to the socket
        and return the number of bytes written.  This can be less than
        len(b) if not all data could be written.  If the socket is
        non-blocking and no bytes could be written None is returned.
        i    N(   R   t   _checkWritableR   t   sendR   R   R   R    (   R   R   R!   (    (    s>   /navires/venv/lib/python2.7/site-packages/pymysql/_socketio.pyt   writeG   s    

c         C   s   |  j  r t d ƒ ‚ n  |  j S(   s2   True if the SocketIO is open for reading.
        s   I/O operation on closed socket.(   t   closedR	   R   (   R   (    (    s>   /navires/venv/lib/python2.7/site-packages/pymysql/_socketio.pyt   readableW   s    	c         C   s   |  j  r t d ƒ ‚ n  |  j S(   s2   True if the SocketIO is open for writing.
        s   I/O operation on closed socket.(   R'   R	   R   (   R   (    (    s>   /navires/venv/lib/python2.7/site-packages/pymysql/_socketio.pyt   writable^   s    	c         C   s%   |  j  r t d ƒ ‚ n  t ƒ  j ƒ  S(   s2   True if the SocketIO is open for seeking.
        s   I/O operation on closed socket.(   R'   R	   t   supert   seekable(   R   (    (    s>   /navires/venv/lib/python2.7/site-packages/pymysql/_socketio.pyR+   e   s    	c         C   s   |  j  ƒ  |  j j ƒ  S(   s=   Return the file descriptor of the underlying socket.
        (   R   R   t   fileno(   R   (    (    s>   /navires/venv/lib/python2.7/site-packages/pymysql/_socketio.pyR,   l   s    
c         C   s   |  j  s |  j ƒ  Sd Sd  S(   Niÿÿÿÿ(   R'   R,   (   R   (    (    s>   /navires/venv/lib/python2.7/site-packages/pymysql/_socketio.pyt   namer   s    	
c         C   s   |  j  S(   N(   R   (   R   (    (    s>   /navires/venv/lib/python2.7/site-packages/pymysql/_socketio.pyR   y   s    c         C   s7   |  j  r d St j j |  ƒ |  j j ƒ  d |  _ d S(   s‡   Close the SocketIO object.  This doesn't close the underlying
        socket, except if all references to it have disappeared.
        N(   R'   R
   R   t   closeR   t   _decref_socketiosR    (   R   (    (    s>   /navires/venv/lib/python2.7/site-packages/pymysql/_socketio.pyR.   }   s
    	(   t   __name__t
   __module__t   __doc__R   R#   R&   R(   R)   R+   R,   t   propertyR-   R   R.   (    (    (    s>   /navires/venv/lib/python2.7/site-packages/pymysql/_socketio.pyR      s   							(   R2   t   socketR
   t   errnot   __all__R   t   EAGAINt   EWOULDBLOCKR   R   R   (    (    (    s>   /navires/venv/lib/python2.7/site-packages/pymysql/_socketio.pyt   <module>   s   
		