ó
´¼÷Xc           @   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 m Z m	 Z	 d „  Z
 d „  Z d „  Z d „  Z d	 „  Z d
 e f d „  ƒ  YZ d S(   iÿÿÿÿN(   t   CaseInsensitiveDicti   (   t   HTTPResponset   picklet	   text_typec         C   s   t  j |  ƒ j d ƒ S(   Nt   ascii(   t   base64t	   b64encodet   decode(   t   b(    (    s?   /tmp/pip-build-g7Urym/pip/pip/_vendor/cachecontrol/serialize.pyt   _b64_encode_bytes   s    c         C   s   t  |  j d ƒ ƒ S(   Nt   utf8(   R	   t   encode(   t   s(    (    s?   /tmp/pip-build-g7Urym/pip/pip/_vendor/cachecontrol/serialize.pyt   _b64_encode_str   s    c         C   s#   t  |  t ƒ r t |  ƒ St |  ƒ S(   N(   t
   isinstanceR   R   R	   (   R   (    (    s?   /tmp/pip-build-g7Urym/pip/pip/_vendor/cachecontrol/serialize.pyt   _b64_encode   s    
c         C   s   t  j |  j d ƒ ƒ S(   NR   (   R   t	   b64decodeR   (   R   (    (    s?   /tmp/pip-build-g7Urym/pip/pip/_vendor/cachecontrol/serialize.pyt   _b64_decode_bytes   s    c         C   s   t  |  ƒ j d ƒ S(   NR
   (   R   R   (   R   (    (    s?   /tmp/pip-build-g7Urym/pip/pip/_vendor/cachecontrol/serialize.pyt   _b64_decode_str   s    t
   Serializerc           B   sA   e  Z d d  „ Z d „  Z d „  Z d „  Z d „  Z d „  Z RS(   c      	   C   sx  t  | j ƒ } | d  k rB | j d t ƒ } t j | ƒ | _ n  i i t | ƒ 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 ƒ } x: | D]/ } | j ƒ  } | j j | d  ƒ | d
 | <qä Wn  t	 d „  | d
 j
 ƒ  Dƒ ƒ | d
 <d j d t j t j | d d d t ƒj d ƒ ƒ g ƒ S(   Nt   decode_contentt   bodyc         s   s-   |  ]# \ } } t  | ƒ t  | ƒ f Vq d  S(   N(   R   (   t   .0t   kt   v(    (    s?   /tmp/pip-build-g7Urym/pip/pip/_vendor/cachecontrol/serialize.pys	   <genexpr>9   s   t   headerst   statust   versiont   reasont   strictt   responset   varyt   ,c         s   s?   |  ]5 \ } } t  | ƒ | d  k	 r0 t  | ƒ n | f Vq d  S(   N(   R   t   None(   R   R   R   (    (    s?   /tmp/pip-build-g7Urym/pip/pip/_vendor/cachecontrol/serialize.pys	   <genexpr>N   s   s   cc=2t
   separatorst   :t	   sort_keysR
   (   R    R#   (   R    R   R!   t   readt   Falset   iot   BytesIOt   _fpR	   t   dictt   itemsR   R   R   R   R   R   t   splitt   stript   gett   joint   zlibt   compresst   jsont   dumpst   TrueR   (   t   selft   requestR   R   t   response_headerst   datat   varied_headerst   header(    (    s?   /tmp/pip-build-g7Urym/pip/pip/_vendor/cachecontrol/serialize.pyR3   #   s<    



$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{0}(   R,   t
   ValueErrorR   t   getattrt   formatt   AttributeError(   R5   R6   R8   t   ver(    (    s?   /tmp/pip-build-g7Urym/pip/pip/_vendor/cachecontrol/serialize.pyt   loads[   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   *R   NR   R   R8   R   s   transfer-encodingt    t   chunkedR
   t   preload_content(   R.   R+   R   R!   t   popR    R'   R(   t	   TypeErrorR   R   R&   (   R5   R6   t   cachedR:   t   valuet   body_rawR   R   (    (    s?   /tmp/pip-build-g7Urym/pip/pip/_vendor/cachecontrol/serialize.pyt   prepare_responsex   s$    %c         C   s   d  S(   N(    (   R5   R6   R8   (    (    s?   /tmp/pip-build-g7Urym/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   RA   R<   RK   (   R5   R6   R8   RH   (    (    s?   /tmp/pip-build-g7Urym/pip/pip/_vendor/cachecontrol/serialize.pyt	   _loads_v1¦   s
    c         C   sÒ   y% t  j t j | ƒ j d ƒ ƒ } Wn t k
 r9 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-g7Urym/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-g7Urym/pip/pip/_vendor/cachecontrol/serialize.pys	   <genexpr>À   s   R   (   R2   RA   R0   t
   decompressR   R<   R   R*   R+   R   RK   (   R5   R6   R8   RH   (    (    s?   /tmp/pip-build-g7Urym/pip/pip/_vendor/cachecontrol/serialize.pyt	   _loads_v2®   s    %#N(	   t   __name__t
   __module__R!   R3   RA   RK   RL   RM   RO   (    (    (    s?   /tmp/pip-build-g7Urym/pip/pip/_vendor/cachecontrol/serialize.pyR   !   s   8		(		(   R   R'   R2   R0   t   pip._vendor.requests.structuresR    t   compatR   R   R   R	   R   R   R   R   t   objectR   (    (    (    s?   /tmp/pip-build-g7Urym/pip/pip/_vendor/cachecontrol/serialize.pyt   <module>   s   					