ÿØÿà JFIF      ÿÛ „ 	 ( %!1"%)+...383-7(-.+



-%%--------+------------/----------------------------ÿÀ  ¶" ÿÄ               ÿÄ @       !1AQaq‘¡"±ÁÑð2’BRráS‚ñ3b¢CT²Ò #cÿÄ             ÿÄ '        1!AQ2a"‘±#ÿÚ   ? ò(/p‘—–¢·,M|¯G»R£üešT. ôŸEoCFñ‡ 4ÔkåóxR|µÁ¨ÓDà!Ç´µ˜‡p ÍQ‹§!þž^õWsŒy  åÁ§$á«%ºq˜™JyyË0y«^Ï
-3ÃÏËÈ£Æ\P’ä„s&•‹Üs üô'àWt¹pñCp$bÚF`·7.^)¾!)ÒÙ˜–ÅÏš^h¾ø³·ìe±ŒaeÖ—Í,e=B}Jéß¦$$½—šÙÜCC¯¶è8Î²–Åkèwx
LÉngT±æ¹£Ócœ¿Í/©Éÿ ‰ÚCÒ­mq;Tt¶–}0"zÖPcd1š­¤tˆ„ÐÓâqú[™öUCŠ2Þ¿Ø¯­É(¸ßúçšmW,Ò ºf‹Ån™ÄLêÃ8üÁkÁ€L¥ÍuJ1œôrÂSŒÓöt!7EUíïb)AËi¬â-ÙHk8òÁiXYwÅ)O^"ÇØriÛô{»wRUKÙÏÚlÓ¬€‚’×©T]
ªb—ÊîKC^×M“xùäñz¬zJ×{4[¹M'IÆeH1LCWÕ]œûº WDæà°OÅ‚¹c²ÞuA–rL`HšpCez‡V’— Ž‚Ë„–ñ­'µR0ÕÖ=À:±G»C\nÆÉ5*¢ †3šhQ4ýÒi$Õ1"Ü]¢p-q3zcQ$ªö¨¥æf›‘»´ÝÚHá„e²JÇ–iÊ:·à¬Øc5Åk»Laª*wi
[0Ówk ¦a¦0Õ²ÅÅ‚T¸’³q:Æ<¹ú	Ò˜Æ}2VE•Ð€p¡Ô3Úº …h³^Ç‡ºçì¥Ánó|˜ÖˆÎˆ+«¦dø‘Mº–d\ªDðÛ„Ì×LÝ——Ð9Ç|•FèçVm™¨€™3õS–9Äå¢<Ì‰Ìm¢±`·º˜&Z²ž Ë®D«¶»6™‰©­HÈÀá«h­i³04æ’hxœi3ï¨(ÓL·†‹¶ËpŒ
ƒÜÒ?	:õdsÀ–3æÓ·Üjâ¬9—]8n¼&]I F£¼…ì–—Œ0v°LÇÅfÛ2TÖ’aµ˜N@ÖBSÏ^à´4-±°b×nÈÈœÆD=KdŒø…ÄÈK,›ÖR§fjü$^ÔÎ!„6^ s:Üun\ôkCÞò÷<—Lúl
Í›G¹ÀPá¼Nc¡šÒ…ÙWÍ³œ±vÊáÐ„×9‹P‰cEØ‘™›µŸP<×g1
º©Ø¬wiÁ^l5×I/';Ë+´Z‡ÓÄFÕp[Èð’
HÄ	ó
9¬Dl4“é±Ï”V=^Hð;žLädÉa‚°Ë,#/Ž~²BÔÛ
QãñQtIeórVB,ÏÂf‹4#Îœc‹É3ZIÖ Œ¢¥·üxa‡Ãçè„jŠ[5 Ä!U?,3žÎ×…ðdÓ÷háŠA‰ìÄ4÷ÃÜZÃE{‰®+W\ZÍE[‰»µk»MÝ­`¢©†˜ÃV‹-f¢¡†¢a«eŠ%«Y¨©q%jâd,Ôq`) ¤¦…šˆ ¦E>0Ùb²t–Ÿ
÷jsÏ‚Ò’KÈcø(é›;k(’#ôŒQ
™C>
õ³M9óºÆµ¤çâ;uÀ)5>RÔ¸fÓ~È¦—’-$fe«"FâUˆÊwµPÏu
w+"åÉoÌ¨6s™Û9(À¨ù©hE°½†n`m~“@©›p!Vkhµ Á1šbEqqÊ@ºèl›2 –Yã%‘‚hÛ{a¶‡ÅÞM²¬çL34®Çl]®‹ŽØŒm'RÜe35æöˆ­Á­ cP9šeÁköo´L³Ì=p8]”‡B¶,šº|ÉdzXˆØk*ÇÚ{#ñ‰pã(€¶‡9ý'šÜ³½¯kƒ†Â’ëSOƒ•Å®H6+a¢µˆ‹Y¨b˜b+XˆÖ!°u!¢"µˆˆn2ˆ Å0Ä`Å Ô®c(ÓÜGº•Ä»Œ âWî%q.áÐÄ÷î%umÍ£+ÜQ,Vn¦-GphU¸¢X­&,Gt
·K¢ÅÅ·¥RÄÊÉbKn
N­R2g$VµÕó
Qr#–ÓZUÏð0ÎtÙÀœz
ëöo“Îk¯n„T°"SÞ+³/…€½"ižãO%Í%&Î”â‘ËØ´IˆÓ°Ë‰ÞM<J•›C=ìu*Ü§„Ã¤GËŠô;5ŒÁ£ñùä¬6Ì2¦‘žh¸Rº<Õš%÷ …Ç	‚g‡.
>3.™yçÁzit›`4C`k¢¼á!álÄï sÂ[×!¤l¾æo"ƒIÔ'@ªu)3›ô®“@Z
à¾]
üœ'‡4¸PÞkÁ-qÄH‰ÓÍBd´ÿ —¹°ÄA&ÊUC„öz‚‚RæŠtf¬>˜ÑidšEçÑL÷áý¡V±h§­c¿¥¨ƒ@g¼…Ýö^ÞËc.Å¾„æ“I[ª+·zÐÒÚ,½Ð»¶€C›7jk$à¹–€Ž¾ÅÙpp¶ÍþéÎ¤ ½ØÎŒq ñpæžÅ¥#Øâ49ÃÂK^MYV“,¶Éz_òæ:…;Õ«¦I3âJ£¤û5$7Èxün\â]Êe¯(Ÿ&Ž‹¶2<6Ä†f× æ¢Æ±qWÄ±[(ÙÂŽç‚T7¨@ÈÉÍß‚ïÙ"&3TYlGŽ†)†#5ŠA©^T2ÆÁ†)©†©†¤yGXÁ†©"†)©¼ÅV WS†#©]R–r‹q5ÕbâWþBh¯u+ªÅÄ×ü„nÑ^êkªÁj‰jeœWˆÕÕ`µDµ2Ì+Ä µDµµ5Ô{¤Þ0RF’H÷AÛ<ÊÁ§ Æˆæ0Ñ£ê4 öÚµ[¬/1²€â<-¬šö²r×0o×w ´xÐÒË„
g01¬„åEMè›‡Ã\6µE›‘fÙO	k÷CºnÓ1`iîÒ²áÂ!ÑLÄÿ 
³¬\õ*:M=Ç»c‹2[‰ØsÕLò\ŒK L^™üÄN\¶#»
Ç\……ßïIœÉ$¸ÎñÍ®ÔHÃ‡	Ûí/´>Li”„†g^$ 7NÍÑÑ2M2ªNg=k½Ð}Ÿl6‡	—JWˆ”ÞéT·+µ¦üÂFè¢Vs6ýÆ4»2+2IÝ9ô9®ÇGÙÇ1+Ä8;*Õ§ž½D*îÑWÚçá3Ma¤·ˆ¥t}š²Ü…Q+Æüµ8HíS”üxGéÁˆ¦Ël„éÈ	5 µÄƒ6äÜ(kIš¯S†fÖ&¸®×v|Äyˆ*ç¦ŒÉù@7-®Ä[]ÎÖ¿ê`º…=:…žJVnÝ³vðÖKE¼‚ »mà ÷f®:Ë™–4rð¡4` Ü¹çž~‹C=œ…¾Ïj|VDtK.ƒ"9	Ï
­–éXá³6WÒïIL-Ð‡
Ç
usr/lib/python2.7/site-packages/requests/utils.pyc                                                  0000644                 00000064352 15267247133 0016167 0                                                                                                    ustar 00                                                                                                                                                                                                                                                       ó
Ò/ec           @   sq  d  Z  d d l Z d d l Z d d l Z d d l Z d d l Z d d l Z d d l Z 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 d d l m Z d d l m Z m Z m Z m Z m Z m Z m Z m Z m Z m Z m Z m Z m  Z  m! Z! m" Z" d d	 l# m$ Z$ d d
 l% m& Z& d d l' m( Z( m) Z) m* Z* m+ Z+ dB Z, e j- ƒ  Z. i d d 6d d 6Z/ e j0 d k rºd „  Z1 d „  Z n  d „  Z2 d „  Z3 e4 d „ Z5 d „  Z6 d „  Z7 d „  Z8 d „  Z9 d „  Z: d „  Z; e4 d „ Z< d „  Z= d  „  Z> d! „  Z? d" „  Z@ d# „  ZA d$ „  ZB d% „  ZC d& „  ZD eE d' d( ƒ ZF d) „  ZG d* „  ZH d+ „  ZI d, „  ZJ d- „  ZK d. „  ZL e jM d/ „  ƒ ZN d0 „  ZO d d1 „ ZQ d2 „  ZR d3 d4 „ ZS d5 „  ZT d6 „  ZU d7 jV d8 ƒ ZW eW d9 ZX eW d: ZY d; „  ZZ d< „  Z[ d= „  Z\ e j] d> ƒ Z^ e j] d> ƒ Z_ d? „  Z` d@ „  Za dA „  Zb d S(C   s”   
requests.utils
~~~~~~~~~~~~~~

This module provides utility functions that are used within Requests
that are also useful for external consumption.
iÿÿÿÿNi   (   t   __version__(   t   certs(   t   to_native_string(   t   parse_http_list(   t   quotet   urlparset   bytest   strt   OrderedDictt   unquotet
   getproxiest   proxy_bypasst
   urlunparset
   basestringt   integer_typest   is_py3t   proxy_bypass_environmentt   getproxies_environmentt   Mapping(   t   cookiejar_from_dict(   t   CaseInsensitiveDict(   t
   InvalidURLt   InvalidHeadert   FileModeWarningt   UnrewindableBodyErrors   .netrct   _netrciP   t   httpi»  t   httpst   win32c         C   sA  y% t  r d d  l } n d d  l } Wn t k
 r9 t SXyK | j | j d ƒ } t | j | d ƒ d ƒ } | j | d ƒ d } Wn t	 k
 r™ t SX| s¨ | r¬ t S| j
 d ƒ } x | D]w } | d k rç d |  k rç t Sn  | j d d	 ƒ } | j d
 d ƒ } | j d d ƒ } t j | |  t j ƒ rÂ t SqÂ Wt S(   Niÿÿÿÿs;   Software\Microsoft\Windows\CurrentVersion\Internet Settingst   ProxyEnablei    t   ProxyOverridet   ;s   <local>t   .s   \.t   *s   .*t   ?(   R   t   winregt   _winregt   ImportErrort   Falset   OpenKeyt   HKEY_CURRENT_USERt   intt   QueryValueExt   OSErrort   splitt   Truet   replacet   ret   matcht   I(   t   hostR#   t   internetSettingst   proxyEnablet   proxyOverridet   test(    (    s2   /usr/lib/python2.7/site-packages/requests/utils.pyt   proxy_bypass_registry/   s8    		c         C   s!   t  ƒ  r t |  ƒ St |  ƒ Sd S(   sš   Return True, if the host should be bypassed.

        Checks proxy settings gathered from the environment, if specified,
        or the registry.
        N(   R   R   R7   (   R2   (    (    s2   /usr/lib/python2.7/site-packages/requests/utils.pyR   V   s    	
c         C   s"   t  |  d ƒ r |  j ƒ  }  n  |  S(   s/   Returns an internal sequence dictionary update.t   items(   t   hasattrR8   (   t   d(    (    s2   /usr/lib/python2.7/site-packages/requests/utils.pyt   dict_to_sequenceb   s    c         C   sš  d  } d } t |  d ƒ r* t |  ƒ } nˆ t |  d ƒ rE |  j } nm t |  d ƒ r² y |  j ƒ  } Wn t j k
 rz q² Xt j | ƒ j } d |  j	 k r² t
 j d t ƒ q² n  t |  d ƒ rty |  j ƒ  } Wn, t t f k
 rÿ | d  k	 rq| } qqqtXt |  d ƒ rt| d  k rty3 |  j d d	 ƒ |  j ƒ  } |  j | pId ƒ Wqqt t f k
 rmd } qqXqtn  | d  k r‰d } n  t d | | ƒ S(
   Ni    t   __len__t   lent   filenot   bs%  Requests has determined the content-length for this request using the binary size of the file: however, the file has been opened in text mode (i.e. without the 'b' flag in the mode). This may lead to an incorrect content-length. In Requests 3.0, support will be removed for files in text mode.t   tellt   seeki   (   t   NoneR9   R=   R>   t   iot   UnsupportedOperationt   ost   fstatt   st_sizet   modet   warningst   warnR   R@   R+   t   IOErrorRA   t   max(   t   ot   total_lengtht   current_positionR>   (    (    s2   /usr/lib/python2.7/site-packages/requests/utils.pyt	   super_lenk   s@    	c         C   se  yGd d l  m  } m } d } x^ t D]V } y t j j d j | ƒ ƒ } Wn t k
 r_ d SXt j j	 | ƒ r& | } Pq& q& W| d k r� d St
 |  ƒ } d } t |  t ƒ rÃ | j d ƒ } n  | j j | ƒ d }	 yG | | ƒ j |	 ƒ }
 |
 r|
 d rd n d } |
 | |
 d	 f SWn# | t f k
 rE| rF‚  qFn XWn t t f k
 r`n Xd S(
   s;   Returns the Requests tuple auth for a given url from netrc.iÿÿÿÿ(   t   netrct   NetrcParseErrors   ~/{}Nt   :t   asciii    i   i   (   RQ   RR   RB   t   NETRC_FILESRE   t   patht
   expandusert   formatt   KeyErrort   existsR   t
   isinstanceR   t   decodet   netlocR,   t   authenticatorsRK   R%   t   AttributeError(   t   urlt   raise_errorsRQ   RR   t
   netrc_patht   ft   loct   rit   splitstrR2   R   t   login_i(    (    s2   /usr/lib/python2.7/site-packages/requests/utils.pyt   get_netrc_auth¨   s8    c         C   s[   t  |  d d ƒ } | rW t | t ƒ rW | d d k rW | d d k rW t j j | ƒ Sd S(   s0   Tries to guess the filename of the given object.t   namei    t   <iÿÿÿÿt   >N(   t   getattrRB   R[   R   RE   RV   t   basename(   t   objRi   (    (    s2   /usr/lib/python2.7/site-packages/requests/utils.pyt   guess_filenameÛ   s    %c         C   s  t  j j |  ƒ r |  St  j j |  ƒ \ } } xJ | rz t  j j | ƒ rz t  j j | ƒ \ } } d j | | g ƒ } q1 Wt j | ƒ sŽ |  St j | ƒ } | | j ƒ  k r³ |  St	 j
 ƒ  } t  j j | | j d ƒ Œ } t  j j | ƒ s| j | d | ƒ} n  | S(   sÄ   Replace nonexistent paths that look like they refer to a member of a zip
    archive with the location of an extracted copy of the target, or else
    just return the provided path unchanged.
    t   /RV   (   RE   RV   RZ   R,   t   joint   zipfilet
   is_zipfilet   ZipFilet   namelistt   tempfilet
   gettempdirt   extract(   RV   t   archivet   membert   prefixt   zip_filet   tmpt   extracted_path(    (    s2   /usr/lib/python2.7/site-packages/requests/utils.pyt   extract_zipped_pathsã   s     c         C   sD   |  d k r d St |  t t t t f ƒ r: t d ƒ ‚ n  t |  ƒ S(   sÅ  Take an object and test to see if it can be represented as a
    dictionary. Unless it can not be represented as such, return an
    OrderedDict, e.g.,

    ::

        >>> from_key_val_list([('key', 'val')])
        OrderedDict([('key', 'val')])
        >>> from_key_val_list('string')
        ValueError: need more than 1 value to unpack
        >>> from_key_val_list({'key': 'val'})
        OrderedDict([('key', 'val')])

    :rtype: OrderedDict
    s+   cannot encode objects that are not 2-tuplesN(   RB   R[   R   R   t   boolR)   t
   ValueErrorR   (   t   value(    (    s2   /usr/lib/python2.7/site-packages/requests/utils.pyt   from_key_val_list  s
    c         C   sb   |  d k r d St |  t t t t f ƒ r: t d ƒ ‚ n  t |  t ƒ rX |  j ƒ  }  n  t	 |  ƒ S(   sŒ  Take an object and test to see if it can be represented as a
    dictionary. If it can be, return a list of tuples, e.g.,

    ::

        >>> to_key_val_list([('key', 'val')])
        [('key', 'val')]
        >>> to_key_val_list({'key': 'val'})
        [('key', 'val')]
        >>> to_key_val_list('string')
        ValueError: cannot encode objects that are not 2-tuples.

    :rtype: list
    s+   cannot encode objects that are not 2-tuplesN(
   RB   R[   R   R   R€   R)   R�   R   R8   t   list(   R‚   (    (    s2   /usr/lib/python2.7/site-packages/requests/utils.pyt   to_key_val_list  s    c         C   sh   g  } x[ t  |  ƒ D]M } | d  | d k o8 d k n rS t | d d !ƒ } n  | j | ƒ q W| S(   s  Parse lists as described by RFC 2068 Section 2.

    In particular, parse comma-separated lists where the elements of
    the list may include quoted-strings.  A quoted-string could
    contain a comma.  A non-quoted string could have quotes in the
    middle.  Quotes are removed automatically after parsing.

    It basically works like :func:`parse_set_header` just that items
    may appear multiple times and case sensitivity is preserved.

    The return value is a standard :class:`list`:

    >>> parse_list_header('token, "quoted value"')
    ['token', 'quoted value']

    To create a header from the :class:`list` again, use the
    :func:`dump_header` function.

    :param value: a string with a list header.
    :return: :class:`list`
    :rtype: list
    i   iÿÿÿÿt   "(   t   _parse_list_headert   unquote_header_valuet   append(   R‚   t   resultt   item(    (    s2   /usr/lib/python2.7/site-packages/requests/utils.pyt   parse_list_header8  s    $c         C   s™   i  } xŒ t  |  ƒ D]~ } d | k r5 d | | <q n  | j d d ƒ \ } }  |  d  |  d k ol d k n r‡ t |  d d !ƒ }  n  |  | | <q W| S(   s^  Parse lists of key, value pairs as described by RFC 2068 Section 2 and
    convert them into a python dict:

    >>> d = parse_dict_header('foo="is a fish", bar="as well"')
    >>> type(d) is dict
    True
    >>> sorted(d.items())
    [('bar', 'as well'), ('foo', 'is a fish')]

    If there is no value for a key it will be `None`:

    >>> parse_dict_header('key_without_value')
    {'key_without_value': None}

    To create a header from the :class:`dict` again, use the
    :func:`dump_header` function.

    :param value: a string with a dict header.
    :return: :class:`dict`
    :rtype: dict
    t   =i   iÿÿÿÿR†   N(   R‡   RB   R,   Rˆ   (   R‚   RŠ   R‹   Ri   (    (    s2   /usr/lib/python2.7/site-packages/requests/utils.pyt   parse_dict_headerX  s    
$c         C   sq   |  rm |  d |  d k o% d k n rm |  d d !}  | sN |  d  d k rm |  j  d d ƒ j  d d ƒ Sn  |  S(	   sç   Unquotes a header value.  (Reversal of :func:`quote_header_value`).
    This does not use the real unquoting but what browsers are actually
    using for quoting.

    :param value: the header value to unquote.
    :rtype: str
    i    iÿÿÿÿR†   i   i   s   \\s   \s   \"(   R.   (   R‚   t   is_filename(    (    s2   /usr/lib/python2.7/site-packages/requests/utils.pyRˆ   {  s
    *c         C   s+   i  } x |  D] } | j  | | j <q W| S(   s€   Returns a key/value dictionary from a CookieJar.

    :param cj: CookieJar object to extract cookies from.
    :rtype: dict
    (   R‚   Ri   (   t   cjt   cookie_dictt   cookie(    (    s2   /usr/lib/python2.7/site-packages/requests/utils.pyt   dict_from_cookiejar”  s    c         C   s   t  | |  ƒ S(   sÂ   Returns a CookieJar from a key/value dictionary.

    :param cj: CookieJar to insert cookies into.
    :param cookie_dict: Dict of key/values to insert into CookieJar.
    :rtype: CookieJar
    (   R   (   R�   R‘   (    (    s2   /usr/lib/python2.7/site-packages/requests/utils.pyt   add_dict_to_cookiejar£  s    c         C   sv   t  j d t ƒ t j d d t j ƒ} t j d d t j ƒ} t j d ƒ } | j |  ƒ | j |  ƒ | j |  ƒ S(   sl   Returns encodings from given content string.

    :param content: bytestring to extract encodings from.
    s¤   In requests 3.0, get_encodings_from_content will be removed. For more information, please see the discussion on issue #2266. (This warning should only appear once.)s!   <meta.*?charset=["\']*(.+?)["\'>]t   flagss+   <meta.*?content=["\']*;?charset=(.+?)["\'>]s$   ^<\?xml.*?encoding=["\']*(.+?)["\'>](   RI   RJ   t   DeprecationWarningR/   t   compileR1   t   findall(   t   contentt
   charset_ret	   pragma_ret   xml_re(    (    s2   /usr/lib/python2.7/site-packages/requests/utils.pyt   get_encodings_from_content®  s    c   
      C   sË   |  j  d ƒ } | d j ƒ  | d } } i  } d } xˆ | D]€ } | j ƒ  } | r= | t } } | j d ƒ }	 |	 d k rª | |	  j | ƒ } | |	 d j | ƒ } n  | | | j ƒ  <q= q= W| | f S(   s¦   Returns content type and parameters from given header

    :param header: string
    :return: tuple containing content type and dictionary of
         parameters
    R   i    i   s   "' R�   iÿÿÿÿ(   R,   t   stripR-   t   findt   lower(
   t   headert   tokenst   content_typet   paramst   params_dictt   items_to_stript   paramt   keyR‚   t   index_of_equals(    (    s2   /usr/lib/python2.7/site-packages/requests/utils.pyt   _parse_content_type_headerÂ  s    c         C   s\   |  j  d ƒ } | s d St | ƒ \ } } d | k rH | d j d ƒ Sd | k rX d Sd S(   s}   Returns encodings from given HTTP Header Dict.

    :param headers: dictionary to extract encoding from.
    :rtype: str
    s   content-typet   charsets   '"t   texts
   ISO-8859-1N(   t   getRB   Rª   Rž   (   t   headersR£   R¤   (    (    s2   /usr/lib/python2.7/site-packages/requests/utils.pyt   get_encoding_from_headersÛ  s    c         c   s™   | j  d k r) x |  D] } | Vq Wd St j | j  ƒ d d ƒ } x+ |  D]# } | j | ƒ } | rK | VqK qK W| j d d t ƒ} | r• | Vn  d S(   s   Stream decodes a iterator.Nt   errorsR.   t    t   final(   t   encodingRB   t   codecst   getincrementaldecoderR\   R-   (   t   iteratort   rR‹   t   decodert   chunkt   rv(    (    s2   /usr/lib/python2.7/site-packages/requests/utils.pyt   stream_decode_response_unicodeð  s    	c         c   sd   d } | d k s | d k r- t |  ƒ } n  x0 | t |  ƒ k  r_ |  | | | !V| | 7} q0 Wd S(   s    Iterate over slices of a string.i    N(   RB   R=   (   t   stringt   slice_lengtht   pos(    (    s2   /usr/lib/python2.7/site-packages/requests/utils.pyt   iter_slices  s    c         C   s™   t  j d t ƒ g  } t |  j ƒ } | rc y t |  j | ƒ SWqc t k
 r_ | j | ƒ qc Xn  y t |  j | d d ƒSWn t	 k
 r” |  j SXd S(   sâ   Returns the requested content back in unicode.

    :param r: Response object to get unicode content from.

    Tried:

    1. charset from content-type
    2. fall back and replace all unicode characters

    :rtype: str
    s£   In requests 3.0, get_unicode_from_response will be removed. For more information, please see the discussion on issue #2266. (This warning should only appear once.)R°   R.   N(
   RI   RJ   R–   R¯   R®   R   R™   t   UnicodeErrorR‰   t	   TypeError(   R·   t   tried_encodingsR³   (    (    s2   /usr/lib/python2.7/site-packages/requests/utils.pyt   get_unicode_from_response  s    t4   ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyzs   0123456789-._~c         C   sô   |  j  d ƒ } xÕ t d t | ƒ ƒ D]¾ } | | d d !} t | ƒ d k rÑ | j ƒ  rÑ y t t | d ƒ ƒ } Wn! t k
 r– t d | ƒ ‚ n X| t k r¼ | | | d | | <qã d | | | | <q% d | | | | <q% Wd j	 | ƒ S(   s¨   Un-escape any percent-escape sequences in a URI that are unreserved
    characters. This leaves all reserved, illegal and non-ASCII bytes encoded.

    :rtype: str
    t   %i   i    i   i   s%   Invalid percent-escape sequence: '%s'R±   (
   R,   t   rangeR=   t   isalnumt   chrR)   R�   R   t   UNRESERVED_SETRq   (   t   urit   partst   it   ht   c(    (    s2   /usr/lib/python2.7/site-packages/requests/utils.pyt   unquote_unreserved5  s    c         C   sK   d } d } y t  t |  ƒ d | ƒSWn t k
 rF t  |  d | ƒSXd S(   s¬   Re-quote the given URI.

    This function passes the given URI through an unquote/quote cycle to
    ensure that it is fully and consistently quoted.

    :rtype: str
    s   !#$%&'()*+,/:;=?@[]~s   !#$&'()*+,/:;=?@[]~t   safeN(   R   RÏ   R   (   RÊ   t   safe_with_percentt   safe_without_percent(    (    s2   /usr/lib/python2.7/site-packages/requests/utils.pyt   requote_uriM  s    c         C   s”   t  j d t j |  ƒ ƒ d } | j d ƒ \ } } t  j d t j t t | ƒ ƒ ƒ ƒ d } t  j d t j | ƒ ƒ d | @} | | @| | @k S(   sï   This function allows you to check if an IP belongs to a network subnet

    Example: returns True if ip = 192.168.1.1 and net = 192.168.1.0/24
             returns False if ip = 192.168.1.1 and net = 192.168.100.0/24

    :rtype: bool
    s   =Li    Rp   (   t   structt   unpackt   sockett	   inet_atonR,   t   dotted_netmaskR)   (   t   ipt   nett   ipaddrt   netaddrt   bitst   netmaskt   network(    (    s2   /usr/lib/python2.7/site-packages/requests/utils.pyt   address_in_networkc  s
    +#c         C   s/   d d d |  >d A} t  j t j d | ƒ ƒ S(   s�   Converts mask from /xx format to xxx.xxx.xxx.xxx

    Example: if mask is 24 function returns 255.255.255.0

    :rtype: str
    Iÿÿÿÿ    i   i    s   >I(   RÖ   t	   inet_ntoaRÔ   t   pack(   t   maskRÝ   (    (    s2   /usr/lib/python2.7/site-packages/requests/utils.pyRØ   r  s    c         C   s-   y t  j |  ƒ Wn t  j k
 r( t SXt S(   s   
    :rtype: bool
    (   RÖ   R×   t   errorR&   R-   (   t	   string_ip(    (    s2   /usr/lib/python2.7/site-packages/requests/utils.pyt   is_ipv4_address}  s
    c         C   s¤   |  j  d ƒ d k rœ y t |  j d ƒ d ƒ } Wn t k
 rF t SX| d k  s_ | d k rc t Sy t j |  j d ƒ d ƒ Wq  t j k
 r˜ t SXn t St S(   sV   
    Very simple check of the cidr format in no_proxy variable.

    :rtype: bool
    Rp   i   i    i    (	   t   countR)   R,   R�   R&   RÖ   R×   Rä   R-   (   t   string_networkRã   (    (    s2   /usr/lib/python2.7/site-packages/requests/utils.pyt   is_valid_cidrˆ  s    c         c   st   | d k	 } | r4 t j j |  ƒ } | t j |  <n  z	 d VWd | ro | d k r_ t j |  =qo | t j |  <n  Xd S(   sÎ   Set the environment variable 'env_name' to 'value'

    Save previous value, yield, and then restore the previous value stored in
    the environment variable 'env_name'.

    If 'value' is None, do nothingN(   RB   RE   t   environR­   (   t   env_nameR‚   t   value_changedt	   old_value(    (    s2   /usr/lib/python2.7/site-packages/requests/utils.pyt   set_environ   s    	c   	   
   C   s�  d „  } | } | d k r* | d ƒ } n  t |  ƒ } | j d k rI t S| r3d „  | j d d ƒ j d ƒ Dƒ } t | j ƒ rÏ xª | D]> } t | ƒ rµ t | j | ƒ rÈ t SqŠ | j | k rŠ t SqŠ Wq3| j } | j	 rú | d j
 | j	 ƒ 7} n  x6 | D]+ } | j j | ƒ s(| j | ƒ rt SqWn  t d | ƒ �; y t | j ƒ } Wn  t t j f k
 rxt } n XWd QX| r‰t St S(	   sL   
    Returns whether we should bypass proxies or not.

    :rtype: bool
    c         S   s(   t  j j |  ƒ p' t  j j |  j ƒ  ƒ S(   N(   RE   Rê   R­   t   upper(   t   k(    (    s2   /usr/lib/python2.7/site-packages/requests/utils.pyt   <lambda>¾  R±   t   no_proxyc         s   s   |  ] } | r | Vq d  S(   N(    (   t   .0R2   (    (    s2   /usr/lib/python2.7/site-packages/requests/utils.pys	   <genexpr>Ï  s    t    R±   t   ,s   :{}N(   RB   R   t   hostnameR-   R.   R,   Ræ   Ré   Rà   t   portRX   t   endswithRî   R   RÁ   RÖ   t   gaierrorR&   (	   R`   Rò   t	   get_proxyt   no_proxy_argt   parsedt   proxy_ipt   host_with_portR2   t   bypass(    (    s2   /usr/lib/python2.7/site-packages/requests/utils.pyt   should_bypass_proxies¶  s<    	%		!c         C   s!   t  |  d | ƒr i  St ƒ  Sd S(   sA   
    Return a dict of environment proxies.

    :rtype: dict
    Rò   N(   R   R
   (   R`   Rò   (    (    s2   /usr/lib/python2.7/site-packages/requests/utils.pyt   get_environ_proxiesó  s    c         C   s¢   | p	 i  } t  |  ƒ } | j d k rC | j | j | j d ƒ ƒ S| j d | j | j d | j d g } d } x( | D]  } | | k rz | | } Pqz qz W| S(   s­   Select a proxy for the url, if applicable.

    :param url: The url being for the request
    :param proxies: A dictionary of schemes or schemes and hosts to proxy URLs
    t   alls   ://s   all://N(   R   Rö   RB   R­   t   scheme(   R`   t   proxiest   urlpartst
   proxy_keyst   proxyt	   proxy_key(    (    s2   /usr/lib/python2.7/site-packages/requests/utils.pyt   select_proxyÿ  s    
	
s   python-requestsc         C   s   d |  t  f S(   sO   
    Return a string representing the default user agent.

    :rtype: str
    s   %s/%s(   R    (   Ri   (    (    s2   /usr/lib/python2.7/site-packages/requests/utils.pyt   default_user_agent  s    c           C   s2   t  i t ƒ  d 6d j d
 ƒ d 6d d 6d d	 6ƒ S(   s9   
    :rtype: requests.structures.CaseInsensitiveDict
    s
   User-Agents   , t   gzipt   deflates   Accept-Encodings   */*t   Accepts
   keep-alivet
   Connection(   R  R  (   R   R
  Rq   (    (    (    s2   /usr/lib/python2.7/site-packages/requests/utils.pyt   default_headers"  s
    
c   	      C   s
  g  } d } |  j  | ƒ }  |  s% | SxÞ t j d |  ƒ D]Ê } y | j d d ƒ \ } } Wn t k
 rz | d } } n Xi | j  d ƒ d 6} xa | j d ƒ D]P } y | j d ƒ \ } }  Wn t k
 rÔ Pn X|  j  | ƒ | | j  | ƒ <q¡ W| j | ƒ q8 W| S(	   s¼   Return a list of parsed link headers proxies.

    i.e. Link: <http:/.../front.jpeg>; rel=front; type="image/jpeg",<http://.../back.jpeg>; rel=back;type="image/jpeg"

    :rtype: list
    s    '"s   , *<R   i   R±   s   <> '"R`   R�   (   Rž   R/   R,   R�   R‰   (	   R‚   t   linkst   replace_charst   valR`   R¤   t   linkR§   R¨   (    (    s2   /usr/lib/python2.7/site-packages/requests/utils.pyt   parse_header_links.  s&     s    RT   i   i   c         C   s   |  d  } | t  j t  j f k r& d S| d  t  j k r= d S| d  t  j t  j f k r] d S| j t ƒ } | d k r| d S| d k rÅ | d	 d	 d … t k r¥ d
 S| d d	 d … t k rÅ d Sn  | d k rü | d  t	 k rå d S| d t	 k rü d Sn  d	 S(   s   
    :rtype: str
    i   s   utf-32i   s	   utf-8-sigi   s   utf-16i    s   utf-8Ns	   utf-16-bei   s	   utf-16-les	   utf-32-bes	   utf-32-le(   R´   t   BOM_UTF32_LEt   BOM_UTF32_BEt   BOM_UTF8t   BOM_UTF16_LEt   BOM_UTF16_BERç   t   _nullt   _null2t   _null3RB   (   t   datat   samplet	   nullcount(    (    s2   /usr/lib/python2.7/site-packages/requests/utils.pyt   guess_json_utfY  s*    
c         C   sS   t  |  | ƒ \ } } } } } } | s7 | | } } n  t | | | | | | f ƒ S(   sª   Given a URL that may or may not have a scheme, prepend the given scheme.
    Does not replace a present scheme with the one provided as an argument.

    :rtype: str
    (   R   R   (   R`   t
   new_schemeR  R]   RV   R¤   t   queryt   fragment(    (    s2   /usr/lib/python2.7/site-packages/requests/utils.pyt   prepend_scheme_if_neededy  s    !c         C   sR   t  |  ƒ } y" t | j ƒ t | j ƒ f } Wn t t f k
 rM d } n X| S(   s{   Given a url with authentication components, extract them into a tuple of
    username,password.

    :rtype: (str,str)
    R±   (   R±   R±   (   R   R	   t   usernamet   passwordR_   RÁ   (   R`   Rü   t   auth(    (    s2   /usr/lib/python2.7/site-packages/requests/utils.pyt   get_auth_from_urlŠ  s    "
s   ^\S[^\r\n]*$|^$c         C   s‡   |  \ } } t  | t ƒ r$ t } n t } y& | j | ƒ sO t d | ƒ ‚ n  Wn0 t k
 r‚ t d | | t | ƒ f ƒ ‚ n Xd S(   sÕ   Verifies that header value is a string which doesn't contain
    leading whitespace or return characters. This prevents unintended
    header injection.

    :param header: tuple, in the format (name, value).
    s7   Invalid return character or leading space in header: %ss>   Value for header {%s: %s} must be of type str or bytes, not %sN(   R[   R   t   _CLEAN_HEADER_REGEX_BYTEt   _CLEAN_HEADER_REGEX_STRR0   R   RÁ   t   type(   R¡   Ri   R‚   t   pat(    (    s2   /usr/lib/python2.7/site-packages/requests/utils.pyt   check_header_validityŸ  s    	c         C   sf   t  |  ƒ \ } } } } } } | s4 | | } } n  | j d d ƒ d } t | | | | | d f ƒ S(   sW   
    Given a url remove the fragment and the authentication part.

    :rtype: str
    t   @i   iÿÿÿÿR±   (   R   t   rsplitR   (   R`   R  R]   RV   R¤   R"  R#  (    (    s2   /usr/lib/python2.7/site-packages/requests/utils.pyt   urldefragauth´  s
    c         C   s}   t  |  j d d ƒ } | d k	 rm t |  j t ƒ rm y | |  j ƒ Wqy t t f k
 ri t d ƒ ‚ qy Xn t d ƒ ‚ d S(   sf   Move file pointer back to its recorded starting position
    so it can be read again on redirect.
    RA   s;   An error occurred when rewinding request body for redirect.s+   Unable to rewind request body for redirect.N(	   Rl   t   bodyRB   R[   t   _body_positionR   RK   R+   R   (   t   prepared_requestt	   body_seek(    (    s2   /usr/lib/python2.7/site-packages/requests/utils.pyt   rewind_bodyÅ  s    (   s   .netrcR   (c   t   __doc__R´   t
   contextlibRC   RE   R/   RÖ   RÔ   t   sysRv   RI   Rr   R    R±   R   t   _internal_utilsR   t   compatR   R‡   R   R   R   R   R   R	   R
   R   R   R   R   R   R   R   R   t   cookiesR   t
   structuresR   t
   exceptionsR   R   R   R   RU   t   wheret   DEFAULT_CA_BUNDLE_PATHt   DEFAULT_PORTSt   platformR7   R;   RP   R&   Rh   Ro   R   Rƒ   R…   RŒ   RŽ   Rˆ   R“   R”   R�   Rª   R¯   R»   R¿   RÃ   t	   frozensetRÉ   RÏ   RÓ   Rà   RØ   Ræ   Ré   t   contextmanagerRî   R   RB   R  R	  R
  R  R  t   encodeR  R  R  R   R$  R(  R—   R)  R*  R-  R0  R5  (    (    (    s2   /usr/lib/python2.7/site-packages/requests/utils.pyt   <module>	   sŠ   d"	'			=3		 			 	#							
	%							=				&

	 				                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      