ó
h#ń]c           @   s>   d  Z  d d l Z d d l m Z d d d d d d  Z d S(   s   
backports.makefile
~~~~~~~~~~~~~~~~~~

Backports the Python 3 ``socket.makefile`` method for use with anything that
wants to create a "fake" socket object.
i˙˙˙˙N(   t   SocketIOt   rc         C   s  t  |  t  d d d g  k s7 t d | f   n  d | k } d | k pS | } | sh | sh t  d | k } d }	 | r |	 d 7}	 n  | r  |	 d 7}	 n  t |  |	  }
 |  j d 7_ | d
 k rÓ d } n  | d k  rë t j } n  | d k r| st d	   n  |
 S| r4| r4t j |
 |
 |  } n9 | rOt j	 |
 |  } n | s[t  t j
 |
 |  } | rw| St j | | | |  } | | _ | S(   s:   
    Backport of ``socket.makefile`` from Python 3.5.
    R   t   wt   bs&   invalid mode %r (only r, w, b allowed)t    i   i˙˙˙˙i    s!   unbuffered streams must be binaryN(   t   sett
   ValueErrort   AssertionErrorR    t   _makefile_refst   Nonet   iot   DEFAULT_BUFFER_SIZEt   BufferedRWPairt   BufferedReadert   BufferedWritert   TextIOWrappert   mode(   t   selfR   t	   bufferingt   encodingt   errorst   newlinet   writingt   readingt   binaryt   rawmodet   rawt   buffert   text(    (    sX   /data/av2000/b2b/venv/lib/python2.7/site-packages/urllib3/packages/backports/makefile.pyt   backport_makefile   sB    !		(   t   __doc__R
   t   socketR    R	   R   (    (    (    sX   /data/av2000/b2b/venv/lib/python2.7/site-packages/urllib3/packages/backports/makefile.pyt   <module>   s   	