ó
Ð²Ebc           @   s˜   d  d l  Z  d  d l Z d  d l Z d  d l Z d  d l m Z d  d l m Z d d l m	 Z	 m
 Z
 m Z d „  Z d „  Z d e f d	 „  ƒ  YZ d S(
   iÿÿÿÿN(   t   msgpack(   t   CaseInsensitiveDicti   (   t   HTTPResponset   picklet	   text_typec         C   s   t  j |  j d ƒ ƒ S(   Nt   ascii(   t   base64t	   b64decodet   encode(   t   b(    (    s?   /tmp/pip-build-UPPWic/pip/pip/_vendor/cachecontrol/serialize.pyt   _b64_decode_bytes   s    c         C   s   t  |  ƒ j d ƒ S(   Nt   utf8(   R
   t   decode(   t   s(    (    s?   /tmp/pip-build-UPPWic/pip/pip/_vendor/cachecontrol/serialize.pyt   _b64_decode_str   s    t
   Serializerc           B   sS   e  Z d d  „ Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z	 d „  Z
 RS(	   c   	      C   s]  t  | j ƒ } | d  k rB | j d t ƒ } t j | ƒ | _ n  i i | d 6t d „  | j j	 ƒ  Dƒ ƒ d 6| j
 d 6| j d 6t | j ƒ d 6| j d 6| j d	 6d
 6} i  | d <d | k r;| d j d ƒ } xa | D]V } t | ƒ j ƒ  } | j j | d  ƒ } | d  k	 r&t | ƒ } n  | | d | <qÞ Wn  d j d t j | d t ƒg ƒ S(   Nt   decode_contentu   bodyc         s   s-   |  ]# \ } } t  | ƒ t  | ƒ f Vq d  S(   N(   R   (   t   .0t   kt   v(    (    s?   /tmp/pip-build-UPPWic/pip/pip/_vendor/cachecontrol/serialize.pys	   <genexpr>3   s    u   headersu   statusu   versionu   reasonu   strictu   decode_contentu   responseu   varyt   ,s   cc=4t   use_bin_type(   R   t   headerst   Nonet   readt   Falset   iot   BytesIOt   _fpt   dictt   itemst   statust   versionR   t   reasont   strictR   t   splitt   stript   gett   joinR    t   dumpst   True(	   t   selft   requestt   responset   bodyt   response_headerst   datat   varied_headerst   headert   header_value(    (    s?   /tmp/pip-build-UPPWic/pip/pip/_vendor/cachecontrol/serialize.pyR'      s0    	



c         C   s¾   | s
 d  Sy | j  d d ƒ \ } } Wn t k
 r? d } n X| d  d k rc | | } d } n  | j  d d ƒ d j d ƒ } y# t |  d	 j | ƒ ƒ | | ƒ SWn t k
 r¹ d  SXd  S(
   NR   i   s   cc=0i   s   cc=t   =iÿÿÿÿR   s
   _loads_v{}(   R#   t
   ValueErrorR   t   getattrt   formatt   AttributeError(   R)   R*   R.   t   ver(    (    s?   /tmp/pip-build-UPPWic/pip/pip/_vendor/cachecontrol/serialize.pyt   loadsJ   s    

	#c         C   s  d | j  d i  ƒ k r d SxE | j  d i  ƒ j ƒ  D]+ \ } } | j j  | d ƒ | k r5 d Sq5 W| d j d ƒ } t d | d d ƒ } | j  d d	 ƒ d
 k r¶ | j d ƒ n  | | d d <y t j | ƒ } Wn) t k
 rt j | j	 d ƒ ƒ } n Xt
 d | d t | d  S(   s`   Verify our vary headers match and construct a real urllib3
        HTTPResponse object.
        t   *t   varyNR+   R,   R.   R   s   transfer-encodingt    t   chunkedR   t   preload_content(   R%   R   R   R   t   popR   R   R   t	   TypeErrorR   R   R   (   R)   R*   t   cachedR0   t   valuet   body_rawR   R,   (    (    s?   /tmp/pip-build-UPPWic/pip/pip/_vendor/cachecontrol/serialize.pyt   prepare_responseh   s    %c         C   s   d  S(   N(    (   R)   R*   R.   (    (    s?   /tmp/pip-build-UPPWic/pip/pip/_vendor/cachecontrol/serialize.pyt	   _loads_v0Ž   s    c         C   s8   y t  j | ƒ } Wn t k
 r' d  SX|  j | | ƒ S(   N(   R   R8   R3   RC   (   R)   R*   R.   R@   (    (    s?   /tmp/pip-build-UPPWic/pip/pip/_vendor/cachecontrol/serialize.pyt	   _loads_v1”   s
    c         C   sÛ   y% t  j t j | ƒ j d ƒ ƒ } Wn t t j f k
 rB d  SXt | d d ƒ | d d <t d „  | d d j	 ƒ  Dƒ ƒ | d d <t
 | d d ƒ | d d <t d „  | d j	 ƒ  Dƒ ƒ | d <|  j | | ƒ S(	   NR   R+   R,   c         s   s-   |  ]# \ } } t  | ƒ t  | ƒ f Vq d  S(   N(   R   (   R   R   R   (    (    s?   /tmp/pip-build-UPPWic/pip/pip/_vendor/cachecontrol/serialize.pys	   <genexpr>¥   s   R   R!   c         s   s?   |  ]5 \ } } t  | ƒ | d  k	 r0 t  | ƒ n | f Vq d  S(   N(   R   R   (   R   R   R   (    (    s?   /tmp/pip-build-UPPWic/pip/pip/_vendor/cachecontrol/serialize.pys	   <genexpr>ª   s   R:   (   t   jsonR8   t   zlibt
   decompressR   R3   t   errorR
   R   R   R   RC   (   R)   R*   R.   R@   (    (    s?   /tmp/pip-build-UPPWic/pip/pip/_vendor/cachecontrol/serialize.pyt	   _loads_v2œ   s    %#c         C   s   d  S(   N(    (   R)   R*   R.   (    (    s?   /tmp/pip-build-UPPWic/pip/pip/_vendor/cachecontrol/serialize.pyt	   _loads_v3°   s    c         C   s>   y t  j | d t ƒ} Wn t k
 r- d  SX|  j | | ƒ S(   Nt   raw(   R    R8   R   R3   RC   (   R)   R*   R.   R@   (    (    s?   /tmp/pip-build-UPPWic/pip/pip/_vendor/cachecontrol/serialize.pyt	   _loads_v4¶   s
    N(   t   __name__t
   __module__R   R'   R8   RC   RD   RE   RJ   RK   RM   (    (    (    s?   /tmp/pip-build-UPPWic/pip/pip/_vendor/cachecontrol/serialize.pyR      s   4		&				(   R   R   RF   RG   t   pip._vendorR    t   pip._vendor.requests.structuresR   t   compatR   R   R   R
   R   t   objectR   (    (    (    s?   /tmp/pip-build-UPPWic/pip/pip/_vendor/cachecontrol/serialize.pyt   <module>   s   		