
Vc           @   sW  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 Z d d l Z d d l Z y d d l m Z Wn! e k
 r d d l m Z n Xy d d l Z Wn e k
 re Z n Xe 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$ d d l m% Z% m& Z& m' Z' m( Z( e
 j) d  Z* d a, d e	 j- d d e d d  Z. d   Z/ d	 e0 f d
     YZ1 d e1 e f d     YZ2 e j3 d  Z4 d   Z5 d dD d     YZ6 d dE d     YZ7 d   Z8 d dF d     YZ9 d e9 f d     YZ: d e9 f d     YZ; d e9 f d     YZ< d   Z= d e9 f d     YZ> d dG d      YZ? d! e? f d"     YZ@ d# dH d$     YZA d% eA e9 f d&     YZB d' eA e9 f d(     YZC d)   ZD d* dI d+     YZE d, e9 eE f d-     YZF d. e9 eE f d/     YZG d0 e9 f d1     YZH d2 eH f d3     YZI eJ e d4  rd5 eH f d6     YZK n  d7 e9 f d8     YZL d9 e9 f d:     YZM d;   ZN d<   ZO d=   ZP d> e9 f d?     YZQ d@ e9 f dA     YZR dB eR f dC     YZS d S(J   s!  An extensible library for opening URLs using a variety of protocols

The simplest way to use this module is to call the urlopen function,
which accepts a string containing a URL or a Request object (described
below).  It opens the URL and returns the results as file-like
object; the returned object has some extra methods described below.

The OpenerDirector manages a collection of Handler objects that do
all the actual work.  Each Handler implements a particular protocol or
option.  The OpenerDirector is a composite object that invokes the
Handlers needed to open the requested URL.  For example, the
HTTPHandler performs HTTP GET and POST requests and deals with
non-error returns.  The HTTPRedirectHandler automatically deals with
HTTP 301, 302, 303 and 307 redirect errors, and the HTTPDigestAuthHandler
deals with digest authentication.

urlopen(url, data=None) -- Basic usage is the same as original
urllib.  pass the url and optionally data to post to an HTTP URL, and
get a file-like object back.  One difference is that you can also pass
a Request instance instead of URL.  Raises a URLError (subclass of
IOError); for HTTP errors, raises an HTTPError, which can also be
treated as a valid response.

build_opener -- Function that creates a new OpenerDirector instance.
Will install the default handlers.  Accepts one or more Handlers as
arguments, either instances or Handler classes that it will
instantiate.  If one of the argument is a subclass of the default
handler, the argument will be installed instead of the default.

install_opener -- Installs a new opener as the default opener.

objects of interest:

OpenerDirector -- Sets up the User Agent as the Python-urllib client and manages
the Handler classes, while dealing with requests and responses.

Request -- An object that encapsulates the state of a request.  The
state can be as simple as the URL.  It can also include extra HTTP
headers, e.g. a User-Agent.

BaseHandler --

exceptions:
URLError -- A subclass of IOError, individual protocols have their own
specific subclass.

HTTPError -- Also a valid HTTP response, so you can treat an HTTP error
as an exceptional event or valid response.

internals:
BaseHandler and parent
_call_chain conventions

Example usage:

import urllib2

# set up authentication info
authinfo = urllib2.HTTPBasicAuthHandler()
authinfo.add_password(realm='PDQ Application',
                      uri='https://mahler:8092/site-updates.py',
                      user='klem',
                      passwd='geheim$parole')

proxy_support = urllib2.ProxyHandler({"http" : "http://ahad-haam:3128"})

# build a new opener that adds authentication and caching FTP handlers
opener = urllib2.build_opener(proxy_support, authinfo, urllib2.CacheFTPHandler)

# install it
urllib2.install_opener(opener)

f = urllib2.urlopen('http://www.python.org/')


iN(   t   StringIO(   t   unwrapt   unquotet	   splittypet	   splithostt   quotet
   addinfourlt	   splitportt   splittagt   toBytest	   splitattrt
   ftpwrappert	   splitusert   splitpasswdt
   splitvalue(   t	   localhostt   url2pathnamet
   getproxiest   proxy_bypassi   c   	      C   s   | s | s | r | d  k	 r- t d   n  t sB t d   n  t j d t j j d | d |  } t d |  } t |  } nF | r t d |  } t |  } n" t	 d  k r t   a	 } n t	 } | j
 |  | |  S(   NsD   You can't pass both context and any of cafile, capath, and cadefaults   SSL support not availablet   purposet   cafilet   capatht   context(   t   Nonet
   ValueErrort	   _have_sslt   sslt   create_default_contextt   Purposet   SERVER_AUTHt   HTTPSHandlert   build_openert   _openert   open(	   t   urlt   datat   timeoutR   R   t	   cadefaultR   t   https_handlert   opener(    (    s;   /home/tom/ab/x64lucid-deps/install/lib/python2.7/urllib2.pyt   urlopen   s$    	c         C   s
   |  a  d  S(   N(   R    (   R'   (    (    s;   /home/tom/ab/x64lucid-deps/install/lib/python2.7/urllib2.pyt   install_opener   s    t   URLErrorc           B   s   e  Z d    Z d   Z RS(   c         C   s   | f |  _  | |  _ d  S(   N(   t   argst   reason(   t   selfR,   (    (    s;   /home/tom/ab/x64lucid-deps/install/lib/python2.7/urllib2.pyt   __init__   s    c         C   s   d |  j  S(   Ns   <urlopen error %s>(   R,   (   R-   (    (    s;   /home/tom/ab/x64lucid-deps/install/lib/python2.7/urllib2.pyt   __str__   s    (   t   __name__t
   __module__R.   R/   (    (    (    s;   /home/tom/ab/x64lucid-deps/install/lib/python2.7/urllib2.pyR*      s   	t	   HTTPErrorc           B   sA   e  Z d  Z e j Z d   Z d   Z e d    Z d   Z	 RS(   sB   Raised when HTTP error occurs, but also acts like non-error returnc         C   sV   | |  _  | |  _ | |  _ | |  _ | |  _ | d  k	 rR |  j | | | |  n  d  S(   N(   t   codet   msgt   hdrst   fpt   filenameR   t   _HTTPError__super_init(   R-   R"   R3   R4   R5   R6   (    (    s;   /home/tom/ab/x64lucid-deps/install/lib/python2.7/urllib2.pyR.      s    					c         C   s   d |  j  |  j f S(   Ns   HTTP Error %s: %s(   R3   R4   (   R-   (    (    s;   /home/tom/ab/x64lucid-deps/install/lib/python2.7/urllib2.pyR/      s    c         C   s   |  j  S(   N(   R4   (   R-   (    (    s;   /home/tom/ab/x64lucid-deps/install/lib/python2.7/urllib2.pyR,      s    c         C   s   |  j  S(   N(   R5   (   R-   (    (    s;   /home/tom/ab/x64lucid-deps/install/lib/python2.7/urllib2.pyt   info   s    (
   R0   R1   t   __doc__R   R.   R8   R/   t   propertyR,   R9   (    (    (    s;   /home/tom/ab/x64lucid-deps/install/lib/python2.7/urllib2.pyR2      s   			s   :\d+$c         C   s_   |  j    } t j |  d } | d k r@ |  j d d  } n  t j d | d  } | j   S(   s   Return request-host, as defined by RFC 2965.

    Variation from RFC: returned value is lowercased, for convenient
    comparison.

    i   t    t   Host(   t   get_full_urlt   urlparset
   get_headert   _cut_port_ret   subt   lower(   t   requestR"   t   host(    (    s;   /home/tom/ab/x64lucid-deps/install/lib/python2.7/urllib2.pyt   request_host   s    t   Requestc           B   s   e  Z d i  d e d   Z d   Z d   Z d   Z d   Z d   Z	 d   Z
 d   Z d   Z d	   Z d
   Z d   Z d   Z d   Z d   Z d   Z d   Z d d  Z d   Z RS(   c         C   s   t  |  |  _ t |  j  \ |  _ |  _ d  |  _ d  |  _ d  |  _ d  |  _ | |  _	 i  |  _
 x* | j   D] \ } } |  j | |  qm Wi  |  _ | d  k r t |   } n  | |  _ | |  _ d  S(   N(   R   t   _Request__originalR   t   _Request__fragmentR   t   typeRE   t   portt   _tunnel_hostR#   t   headerst   itemst
   add_headert   unredirected_hdrsRF   t   origin_req_hostt   unverifiable(   R-   R"   R#   RM   RQ   RR   t   keyt   value(    (    s;   /home/tom/ab/x64lucid-deps/install/lib/python2.7/urllib2.pyR.      s    								c         C   s^   | d  d k rQ | d } t  t d |  rQ t |  d |    t |  |  Sn  t |  d  S(   Ni   t   _Request__r_t   get_(   t   hasattrRG   t   getattrt   AttributeError(   R-   t   attrt   name(    (    s;   /home/tom/ab/x64lucid-deps/install/lib/python2.7/urllib2.pyt   __getattr__   s    
c         C   s   |  j    r d Sd Sd  S(   Nt   POSTt   GET(   t   has_data(   R-   (    (    s;   /home/tom/ab/x64lucid-deps/install/lib/python2.7/urllib2.pyt
   get_method  s    c         C   s   | |  _  d  S(   N(   R#   (   R-   R#   (    (    s;   /home/tom/ab/x64lucid-deps/install/lib/python2.7/urllib2.pyt   add_data
  s    c         C   s   |  j  d  k	 S(   N(   R#   R   (   R-   (    (    s;   /home/tom/ab/x64lucid-deps/install/lib/python2.7/urllib2.pyR_     s    c         C   s   |  j  S(   N(   R#   (   R-   (    (    s;   /home/tom/ab/x64lucid-deps/install/lib/python2.7/urllib2.pyt   get_data  s    c         C   s(   |  j  r d |  j |  j  f S|  j Sd  S(   Ns   %s#%s(   RI   RH   (   R-   (    (    s;   /home/tom/ab/x64lucid-deps/install/lib/python2.7/urllib2.pyR>     s    	c         C   sV   |  j  d  k rO t |  j  \ |  _  |  _ |  j  d  k rO t d |  j  qO n  |  j  S(   Ns   unknown url type: %s(   RJ   R   R   RH   t   _Request__r_typeR   (   R-   (    (    s;   /home/tom/ab/x64lucid-deps/install/lib/python2.7/urllib2.pyt   get_type  s
    c         C   sR   |  j  d  k rK t |  j  \ |  _  |  _ |  j  rK t |  j   |  _  qK n  |  j  S(   N(   RE   R   R   Rc   t   _Request__r_hostR   (   R-   (    (    s;   /home/tom/ab/x64lucid-deps/install/lib/python2.7/urllib2.pyt   get_host   s
    	c         C   s   |  j  S(   N(   Re   (   R-   (    (    s;   /home/tom/ab/x64lucid-deps/install/lib/python2.7/urllib2.pyt   get_selector'  s    c         C   sJ   |  j  d k r( |  j r( |  j |  _ n | |  _  |  j |  _ | |  _ d  S(   Nt   https(   RJ   RL   RE   RH   Re   (   R-   RE   RJ   (    (    s;   /home/tom/ab/x64lucid-deps/install/lib/python2.7/urllib2.pyt	   set_proxy*  s
    	c         C   s   |  j  |  j k S(   N(   Re   RH   (   R-   (    (    s;   /home/tom/ab/x64lucid-deps/install/lib/python2.7/urllib2.pyt	   has_proxy3  s    c         C   s   |  j  S(   N(   RQ   (   R-   (    (    s;   /home/tom/ab/x64lucid-deps/install/lib/python2.7/urllib2.pyt   get_origin_req_host6  s    c         C   s   |  j  S(   N(   RR   (   R-   (    (    s;   /home/tom/ab/x64lucid-deps/install/lib/python2.7/urllib2.pyt   is_unverifiable9  s    c         C   s   | |  j  | j   <d  S(   N(   RM   t
   capitalize(   R-   RS   t   val(    (    s;   /home/tom/ab/x64lucid-deps/install/lib/python2.7/urllib2.pyRO   <  s    c         C   s   | |  j  | j   <d  S(   N(   RP   Rm   (   R-   RS   Rn   (    (    s;   /home/tom/ab/x64lucid-deps/install/lib/python2.7/urllib2.pyt   add_unredirected_header@  s    c         C   s   | |  j  k p | |  j k S(   N(   RM   RP   (   R-   t   header_name(    (    s;   /home/tom/ab/x64lucid-deps/install/lib/python2.7/urllib2.pyt
   has_headerD  s    c         C   s"   |  j  j | |  j j | |   S(   N(   RM   t   getRP   (   R-   Rp   t   default(    (    s;   /home/tom/ab/x64lucid-deps/install/lib/python2.7/urllib2.pyR@   H  s    	c         C   s)   |  j  j   } | j |  j  | j   S(   N(   RP   t   copyt   updateRM   RN   (   R-   R5   (    (    s;   /home/tom/ab/x64lucid-deps/install/lib/python2.7/urllib2.pyt   header_itemsM  s    N(   R0   R1   R   t   FalseR.   R\   R`   Ra   R_   Rb   R>   Rd   Rf   Rg   Ri   Rj   Rk   Rl   RO   Ro   Rq   R@   Rv   (    (    (    s;   /home/tom/ab/x64lucid-deps/install/lib/python2.7/urllib2.pyRG      s(   																	t   OpenerDirectorc           B   sS   e  Z d    Z d   Z d   Z d   Z d e j d  Z	 d d  Z
 d   Z RS(   c         C   sM   d t  } d | f g |  _ g  |  _ i  |  _ i  |  _ i  |  _ i  |  _ d  S(   Ns   Python-urllib/%ss
   User-agent(   t   __version__t
   addheaderst   handlerst   handle_opent   handle_errort   process_responset   process_request(   R-   t   client_version(    (    s;   /home/tom/ab/x64lucid-deps/install/lib/python2.7/urllib2.pyR.   S  s    
				c         C   s  t  | d  s( t d t |    n  t } xet |  D]W} | d k rS q; n  | j d  } | |  } | | d } | j d  r | j d  | d } | | d } y t |  } Wn t k
 r n X|  j	 j
 | i   }	 |	 |  j	 | <n] | d	 k r| } |  j }	 n? | d
 k r3| } |  j }	 n! | d k r; | } |  j }	 n q; |	 j | g   }
 |
 rt j |
 |  n |
 j |  t } q; W| rt j |  j |  | j |   n  d  S(   Nt
   add_parents%   expected BaseHandler instance, got %rt   redirect_requestt   do_opent
   proxy_opent   _i   t   errorR!   t   responseRD   (   s   redirect_requests   do_opens
   proxy_open(   RW   t	   TypeErrorRJ   Rw   t   dirt   findt
   startswitht   intR   R}   Rr   R|   R~   R   t
   setdefaultt   bisectt   insortt   appendt   TrueR{   R   (   R-   t   handlert   addedt   metht   it   protocolt	   conditiont   jt   kindt   lookupR{   (    (    s;   /home/tom/ab/x64lucid-deps/install/lib/python2.7/urllib2.pyt   add_handler^  sJ    

c         C   s   d  S(   N(    (   R-   (    (    s;   /home/tom/ab/x64lucid-deps/install/lib/python2.7/urllib2.pyt   close  s    c   	      G   sR   | j  | d  } x9 | D]1 } t | |  } | |   } | d  k	 r | Sq Wd  S(   N(    (   Rr   RX   R   (	   R-   t   chainR   t	   meth_nameR+   R{   R   t   funct   result(    (    s;   /home/tom/ab/x64lucid-deps/install/lib/python2.7/urllib2.pyt   _call_chain  s    c   
      C   s   t  | t  r! t | |  } n" | } | d  k	 rC | j |  n  | | _ | j   } | d } x8 |  j j | g   D]! } t	 | |  } | |  } qx W|  j
 | |  }	 | d } x; |  j j | g   D]$ } t	 | |  } | | |	  }	 q W|	 S(   Nt   _requestt	   _response(   t
   isinstancet
   basestringRG   R   Ra   R$   Rd   R   Rr   RX   t   _openR~   (
   R-   t   fullurlR#   R$   t   reqR   R   t	   processorR   R   (    (    s;   /home/tom/ab/x64lucid-deps/install/lib/python2.7/urllib2.pyR!     s"    	

c         C   ss   |  j  |  j d d |  } | r% | S| j   } |  j  |  j | | d |  } | rZ | S|  j  |  j d d |  S(   NRs   t   default_openR   t   unknownt   unknown_open(   R   R|   Rd   (   R-   R   R#   R   R   (    (    s;   /home/tom/ab/x64lucid-deps/install/lib/python2.7/urllib2.pyR     s    c         G   s   | d
 k r< |  j  d } | d } d | } d } | } n |  j  } | d } d } | | | f | } |  j |   } | r | S| r | d d	 f | } |  j |   Sd  S(   Nt   httpRh   i   s   http_error_%si   t   _errori    Rs   t   http_error_default(   R   s   https(   R}   R   (   R-   t   protoR+   t   dictR   t   http_errt	   orig_argsR   (    (    s;   /home/tom/ab/x64lucid-deps/install/lib/python2.7/urllib2.pyR     s     

		
N(   R0   R1   R.   R   R   R   R   t   sockett   _GLOBAL_DEFAULT_TIMEOUTR!   R   R   (    (    (    s;   /home/tom/ab/x64lucid-deps/install/lib/python2.7/urllib2.pyRx   R  s   		/		c             sR  d d l      f d   } t   } t t t t t t t t	 g } t
 t d  ra | j t  n  t   } xl | D]d } x[ |  D]S } | |  r t | |  r | j |  q q~ t | |  r~ | j |  q~ q~ Wqq Wx | D] } | j |  q Wx | D] } | j |    q Wx3 |  D]+ } | |  r=|   } n  | j |  qW| S(   s+  Create an opener object from a list of handlers.

    The opener will use several default handlers, including support
    for HTTP, FTP and when applicable, HTTPS.

    If any of the handlers passed as arguments are subclasses of the
    default handlers, the default handlers will not be used.
    iNc            s   t  |    j t f  S(   N(   R   t	   ClassTypeRJ   (   t   obj(   t   types(    s;   /home/tom/ab/x64lucid-deps/install/lib/python2.7/urllib2.pyt   isclass  s    t   HTTPS(   R   Rx   t   ProxyHandlert   UnknownHandlert   HTTPHandlert   HTTPDefaultErrorHandlert   HTTPRedirectHandlert
   FTPHandlert   FileHandlert   HTTPErrorProcessorRW   t   httplibR   R   t   sett
   issubclasst   addR   t   removeR   (   R{   R   R'   t   default_classest   skipt   klasst   checkt   h(    (   R   s;   /home/tom/ab/x64lucid-deps/install/lib/python2.7/urllib2.pyR     s2    				t   BaseHandlerc           B   s)   e  Z d  Z d   Z d   Z d   Z RS(   i  c         C   s   | |  _  d  S(   N(   t   parent(   R-   R   (    (    s;   /home/tom/ab/x64lucid-deps/install/lib/python2.7/urllib2.pyR     s    c         C   s   d  S(   N(    (   R-   (    (    s;   /home/tom/ab/x64lucid-deps/install/lib/python2.7/urllib2.pyR     s    c         C   s#   t  | d  s t S|  j | j k  S(   Nt   handler_order(   RW   R   R   (   R-   t   other(    (    s;   /home/tom/ab/x64lucid-deps/install/lib/python2.7/urllib2.pyt   __lt__  s    (   R0   R1   R   R   R   R   (    (    (    s;   /home/tom/ab/x64lucid-deps/install/lib/python2.7/urllib2.pyR     s   		R   c           B   s#   e  Z d  Z d Z d   Z e Z RS(   s   Process HTTP error responses.i  c         C   sd   | j  | j | j   } } } d | k o7 d k  n s` |  j j d | | | | |  } n  | S(   Ni   i,  R   (   R3   R4   R9   R   R   (   R-   RD   R   R3   R4   R5   (    (    s;   /home/tom/ab/x64lucid-deps/install/lib/python2.7/urllib2.pyt   http_response  s
     	(   R0   R1   R:   R   R   t   https_response(    (    (    s;   /home/tom/ab/x64lucid-deps/install/lib/python2.7/urllib2.pyR     s   	R   c           B   s   e  Z d    Z RS(   c         C   s"   t  | j   | | | |   d  S(   N(   R2   R>   (   R-   R   R6   R3   R4   R5   (    (    s;   /home/tom/ab/x64lucid-deps/install/lib/python2.7/urllib2.pyR   -  s    (   R0   R1   R   (    (    (    s;   /home/tom/ab/x64lucid-deps/install/lib/python2.7/urllib2.pyR   ,  s   R   c           B   s:   e  Z d  Z d Z d   Z d   Z e Z Z Z d Z	 RS(   i   i
   c   	      C   s   | j    } | d k r$ | d k s< | d k r | d k r | j d d	  } t d
   | j j   D  } t | d | d | j   d t St | j	   | | | |   d S(   s  Return a Request or None in response to a redirect.

        This is called by the http_error_30x methods when a
        redirection response is received.  If a redirection should
        take place, return a new Request to allow http_error_30x to
        perform the redirect.  Otherwise, raise HTTPError if no-one
        else should try to handle this url.  Return None if you can't
        but another Handler might.
        i-  i.  i/  i3  R^   t   HEADR]   t    s   %20c         s   s3   |  ]) \ } } | j    d k r | | f Vq d S(   s   content-lengths   content-typeN(   s   content-lengths   content-type(   RC   (   t   .0t   kt   v(    (    s;   /home/tom/ab/x64lucid-deps/install/lib/python2.7/urllib2.pys	   <genexpr>L  s    	RM   RQ   RR   N(   i-  i.  i/  i3  (   s   GETR   (   i-  i.  i/  (
   R`   t   replaceR   RM   RN   RG   Rk   R   R2   R>   (	   R-   R   R6   R3   R4   RM   t   newurlt   mt
   newheaders(    (    s;   /home/tom/ab/x64lucid-deps/install/lib/python2.7/urllib2.pyR   8  s    
	c         C   s  d | k r" | j  d  d } n& d | k rD | j  d  d } n d  St j |  } | j sy t |  } d | d <n  t j |  } t j | j   |  } | j   } | j d  p | j d  p | j d  s t	 | | | d	 | | |   n  |  j
 | | | | | |  }	 |	 d  k r*d  St | d
  r| j }
 |	 _ |
 j | d  |  j k syt |
  |  j k rt	 | j   | |  j | | |   qn i  }
 |	 _ | _ |
 j | d  d |
 | <| j   | j   |  j j |	 d | j S(   Nt   locationi    t   urit   /i   s   http://s   https://s   ftp://s)    - Redirection to url '%s' is not allowedt   redirect_dicti   R$   (   t
   getheadersR?   t   patht   listt
   urlunparset   urljoinR>   RC   R   R2   R   R   RW   R   Rr   t   max_repeatst   lent   max_redirectionst   inf_msgt   readR   R   R!   R$   (   R-   R   R6   R3   R4   RM   R   t   urlpartst   newurl_lowert   newt   visited(    (    s;   /home/tom/ab/x64lucid-deps/install/lib/python2.7/urllib2.pyt   http_error_302Z  sB    		

so   The HTTP server returned a redirect error that would lead to an infinite loop.
The last 30x error message was:
(
   R0   R1   R   R   R   R   t   http_error_301t   http_error_303t   http_error_307R   (    (    (    s;   /home/tom/ab/x64lucid-deps/install/lib/python2.7/urllib2.pyR   0  s   	"	8c   	      C   s   t  |   \ } } | j d  s0 d } |  } nV | j d  sR t d |    n  | j d d  } | d k ry d } n  | d | !} t |  \ } } | d k	 r t |  \ } } n
 d } } | | | | f S(   s3  Return (scheme, user, password, host/port) given a URL or an authority.

    If a URL is supplied, it must have an authority (host:port) component.
    According to RFC 3986, having an authority component means the URL must
    have two slashes after the scheme:

    >>> _parse_proxy('file:/ftp.example.com/')
    Traceback (most recent call last):
    ValueError: proxy URL with no authority: 'file:/ftp.example.com/'

    The first three items of the returned tuple may be None.

    Examples of authority parsing:

    >>> _parse_proxy('proxy.example.com')
    (None, None, None, 'proxy.example.com')
    >>> _parse_proxy('proxy.example.com:3128')
    (None, None, None, 'proxy.example.com:3128')

    The authority component may optionally include userinfo (assumed to be
    username:password):

    >>> _parse_proxy('joe:password@proxy.example.com')
    (None, 'joe', 'password', 'proxy.example.com')
    >>> _parse_proxy('joe:password@proxy.example.com:3128')
    (None, 'joe', 'password', 'proxy.example.com:3128')

    Same examples, but with URLs instead:

    >>> _parse_proxy('http://proxy.example.com/')
    ('http', None, None, 'proxy.example.com')
    >>> _parse_proxy('http://proxy.example.com:3128/')
    ('http', None, None, 'proxy.example.com:3128')
    >>> _parse_proxy('http://joe:password@proxy.example.com/')
    ('http', 'joe', 'password', 'proxy.example.com')
    >>> _parse_proxy('http://joe:password@proxy.example.com:3128')
    ('http', 'joe', 'password', 'proxy.example.com:3128')

    Everything after the authority is ignored:

    >>> _parse_proxy('ftp://joe:password@proxy.example.com/rubbish:3128')
    ('ftp', 'joe', 'password', 'proxy.example.com')

    Test for no trailing '/' case:

    >>> _parse_proxy('http://joe:password@proxy.example.com')
    ('http', 'joe', 'password', 'proxy.example.com')

    R   s   //s   proxy URL with no authority: %ri   iN(   R   R   R   R   R   R   R   (	   t   proxyt   schemet   r_schemet	   authorityt   endt   userinfot   hostportt   usert   password(    (    s;   /home/tom/ab/x64lucid-deps/install/lib/python2.7/urllib2.pyt   _parse_proxy  s    2		
R   c           B   s#   e  Z d  Z d d  Z d   Z RS(   id   c         C   se   | d  k r t   } n  | |  _ x= | j   D]/ \ } } t |  d | | | |  j d   q. Wd  S(   Ns   %s_openc         S   s   | |  | |  S(   N(    (   t   rR   RJ   R   (    (    s;   /home/tom/ab/x64lucid-deps/install/lib/python2.7/urllib2.pyt   <lambda>  s    (   R   R   t   proxiesRN   t   setattrR   (   R-   R   RJ   R"   (    (    s;   /home/tom/ab/x64lucid-deps/install/lib/python2.7/urllib2.pyR.     s    	c         C   s   | j    } t |  \ } } } } | d  k r9 | } n  | j rU t | j  rU d  S| r | r d t |  t |  f }	 t j |	  j   }
 | j	 d d |
  n  t |  } | j
 | |  | | k s | d k r d  S|  j j | d | j Sd  S(   Ns   %s:%ss   Proxy-authorizations   Basic Rh   R$   (   Rd   R   R   RE   R   R   t   base64t	   b64encodet   stripRO   Ri   R   R!   R$   (   R-   R   R   RJ   t	   orig_typet
   proxy_typeR   R   R   t	   user_passt   creds(    (    s;   /home/tom/ab/x64lucid-deps/install/lib/python2.7/urllib2.pyR     s    	N(   R0   R1   R   R   R.   R   (    (    (    s;   /home/tom/ab/x64lucid-deps/install/lib/python2.7/urllib2.pyR     s   
t   HTTPPasswordMgrc           B   s8   e  Z d    Z d   Z d   Z e d  Z d   Z RS(   c         C   s   i  |  _  d  S(   N(   t   passwd(   R-   (    (    s;   /home/tom/ab/x64lucid-deps/install/lib/python2.7/urllib2.pyR.     s    c         C   s   t  | t  r | g } n  | |  j k r: i  |  j | <n  xV t t f D]H } t g  | D] } |  j | |  ^ qW  } | | f |  j | | <qG Wd  S(   N(   R   R   R	  R   Rw   t   tuplet
   reduce_uri(   R-   t   realmR   R   R	  t   default_portt   ut   reduced_uri(    (    s;   /home/tom/ab/x64lucid-deps/install/lib/python2.7/urllib2.pyt   add_password  s    (c   	      C   s   |  j  j | i   } xj t t f D]\ } |  j | |  } xA | j   D]3 \ } } x$ | D] } |  j | |  rZ | SqZ WqG Wq" Wd S(   N(   NN(   R	  Rr   R   Rw   R  t	   iteritemst	   is_suburiR   (	   R-   R  t   authurit   domainsR  t   reduced_authurit   urist   authinfoR   (    (    s;   /home/tom/ab/x64lucid-deps/install/lib/python2.7/urllib2.pyt   find_user_password  s    c   
      C   s   t  j |  } | d r@ | d } | d } | d p: d } n d
 } | } d } t |  \ } } | r | d
 k r | d
 k	 r i d d 6d d 6j |  }	 |	 d
 k	 r d	 | |	 f } q n  | | f S(   s@   Accept authority or URI and extract only the authority and path.i   i    i   R   iP   R   i  Rh   s   %s:%dN(   R?   t   urlsplitR   R   Rr   (
   R-   R   R  t   partsR   R   R   RE   RK   t   dport(    (    s;   /home/tom/ab/x64lucid-deps/install/lib/python2.7/urllib2.pyR  &  s     




	c         C   si   | | k r t  S| d | d k r( t St j | d | d f  } t |  t | d  k re t  St S(   sc   Check if test is below base in a URI tree

        Both args must be URIs in reduced form.
        i    i   (   R   Rw   t	   posixpatht   commonprefixR   (   R-   t   baset   testt   common(    (    s;   /home/tom/ab/x64lucid-deps/install/lib/python2.7/urllib2.pyR  =  s    (   R0   R1   R.   R  R  R   R  R  (    (    (    s;   /home/tom/ab/x64lucid-deps/install/lib/python2.7/urllib2.pyR    s
   			
t   HTTPPasswordMgrWithDefaultRealmc           B   s   e  Z d    Z RS(   c         C   sD   t  j |  | |  \ } } | d  k	 r1 | | f St  j |  d  |  S(   N(   R  R  R   (   R-   R  R  R   R   (    (    s;   /home/tom/ab/x64lucid-deps/install/lib/python2.7/urllib2.pyR  N  s
    
(   R0   R1   R  (    (    (    s;   /home/tom/ab/x64lucid-deps/install/lib/python2.7/urllib2.pyR!  L  s   t   AbstractBasicAuthHandlerc           B   s;   e  Z e j d  e j  Z d d  Z d   Z d   Z	 RS(   s1   (?:.*,)*[ 	]*([^ 	]+)[ 	]+realm=(["']?)([^"']*)\2c         C   s4   | d  k r t   } n  | |  _ |  j j |  _ d  S(   N(   R   R  R	  R  (   R-   t   password_mgr(    (    s;   /home/tom/ab/x64lucid-deps/install/lib/python2.7/urllib2.pyR.   d  s    	c   	      C   s   | j  | d   } | r t j j |  } | r | j   \ } } } | d k rg t j d t d  n  | j	   d k r |  j
 | | |  Sq n  d  S(   Nt   "t   's   Basic Auth Realm was unquotedi   t   basic(   R$  R%  (   Rr   R   R"  t   rxt   searcht   groupst   warningst   warnt   UserWarningRC   t   retry_http_basic_auth(	   R-   t   authreqRE   R   RM   t   moR   R   R  (    (    s;   /home/tom/ab/x64lucid-deps/install/lib/python2.7/urllib2.pyt   http_error_auth_reqedk  s    	c         C   s   |  j  j | |  \ } } | d  k	 r d | | f } d t j |  j   } | j |  j d   | k ro d  S| j |  j |  |  j	 j
 | d | j Sd  Sd  S(   Ns   %s:%ss   Basic %sR$   (   R	  R  R   R  R  R  R@   t   auth_headerRo   R   R!   R$   (   R-   RE   R   R  R   t   pwt   rawt   auth(    (    s;   /home/tom/ab/x64lucid-deps/install/lib/python2.7/urllib2.pyR-  {  s    N(
   R0   R1   t   ret   compilet   IR'  R   R.   R0  R-  (    (    (    s;   /home/tom/ab/x64lucid-deps/install/lib/python2.7/urllib2.pyR"  V  s
   		t   HTTPBasicAuthHandlerc           B   s   e  Z d  Z d   Z RS(   t   Authorizationc         C   s(   | j    } |  j d | | |  } | S(   Ns   www-authenticate(   R>   R0  (   R-   R   R6   R3   R4   RM   R"   R   (    (    s;   /home/tom/ab/x64lucid-deps/install/lib/python2.7/urllib2.pyt   http_error_401  s    	(   R0   R1   R1  R:  (    (    (    s;   /home/tom/ab/x64lucid-deps/install/lib/python2.7/urllib2.pyR8    s   t   ProxyBasicAuthHandlerc           B   s   e  Z d  Z d   Z RS(   s   Proxy-authorizationc         C   s(   | j    } |  j d | | |  } | S(   Ns   proxy-authenticate(   Rf   R0  (   R-   R   R6   R3   R4   RM   R   R   (    (    s;   /home/tom/ab/x64lucid-deps/install/lib/python2.7/urllib2.pyt   http_error_407  s    	(   R0   R1   R1  R<  (    (    (    s;   /home/tom/ab/x64lucid-deps/install/lib/python2.7/urllib2.pyR;    s   c         C   s}   t  j j d  r; t d  } | j |   } | j   | Sg  t |   D] } t t j	 d d   ^ qH } d j
 |  Sd S(   s   Return n random bytes.s   /dev/urandomi    i   R<   N(   t   osR   t   existsR!   R   R   t   ranget   chrt   randomt	   randranget   join(   t   nt   ft   sR   t   L(    (    s;   /home/tom/ab/x64lucid-deps/install/lib/python2.7/urllib2.pyt   randombytes  s    
1t   AbstractDigestAuthHandlerc           B   sS   e  Z d d   Z d   Z d   Z d   Z d   Z d   Z d   Z	 d   Z
 RS(	   c         C   sO   | d  k r t   } n  | |  _ |  j j |  _ d |  _ d |  _ d  |  _ d  S(   Ni    (   R   R  R	  R  t   retriedt   nonce_countt
   last_nonce(   R-   R	  (    (    s;   /home/tom/ab/x64lucid-deps/install/lib/python2.7/urllib2.pyR.     s    			c         C   s   d |  _  d  S(   Ni    (   RJ  (   R-   (    (    s;   /home/tom/ab/x64lucid-deps/install/lib/python2.7/urllib2.pyt   reset_retry_count  s    c         C   s   | j  | d   } |  j d k rB t | j   d d | d    n |  j d 7_ | r | j   d } | j   d k r |  j | |  Sn  d  S(   Ni   i  s   digest auth failedi   i    t   digest(   Rr   R   RJ  R2   R>   t   splitRC   t   retry_http_digest_auth(   R-   R1  RE   R   RM   R.  R   (    (    s;   /home/tom/ab/x64lucid-deps/install/lib/python2.7/urllib2.pyR0    s    c         C   s   | j  d d  \ } } t t |   } |  j | |  } | r d | } | j j |  j d   | k rn d  S| j |  j |  |  j	 j
 | d | j } | Sd  S(   NR   i   s	   Digest %sR$   (   RO  t   parse_keqv_listt   parse_http_listt   get_authorizationRM   Rr   R1  R   Ro   R   R!   R$   (   R-   R   R4  t   tokent	   challenget   chalt   auth_valt   resp(    (    s;   /home/tom/ab/x64lucid-deps/install/lib/python2.7/urllib2.pyRP    s    
c         C   s<   t  j d |  j | t j   t d  f  j   } | d  S(   Ns   %s:%s:%s:%si   i   (   t   hashlibt   sha1RK  t   timet   ctimeRH  t	   hexdigest(   R-   t   noncet   dig(    (    s;   /home/tom/ab/x64lucid-deps/install/lib/python2.7/urllib2.pyt
   get_cnonce  s    c         C   sd  yK | d } | d } | j  d  } | j  d d  } | j  d d   } Wn t k
 r_ d  SX|  j |  \ } }	 | d  k r d  S|  j j | | j    \ }
 } |
 d  k r d  S| j   r |  j | j	   |  } n d  } d |
 | | f } d | j
   | j   f } | d	 k r| |  j k r?|  j d
 7_ n d
 |  _ | |  _ d |  j } |  j |  } d | | | | | |  f } |	 | |  |  } nD | d  k r|	 | |  d | | |  f  } n t d |   d |
 | | | j   | f } | r| d | 7} n  | r5| d | 7} n  | d | 7} | r`| d | | f 7} n  | S(   NR  R^  t   qopt	   algorithmt   MD5t   opaques   %s:%s:%ss   %s:%sR4  i   s   %08xs   %s:%s:%s:%s:%ss   qop '%s' is not supported.s>   username="%s", realm="%s", nonce="%s", uri="%s", response="%s"s   , opaque="%s"s   , digest="%s"s   , algorithm="%s"s   , qop=auth, nc=%s, cnonce="%s"(   Rr   R   t   KeyErrort   get_algorithm_implsR	  R  R>   R_   t   get_entity_digestRb   R`   Rg   RL  RK  R`  R*   (   R-   R   RV  R  R^  Ra  Rb  Rd  t   Ht   KDR   R2  t   entdigt   A1t   A2t   ncvaluet   cnoncet   noncebitt   respdigR  (    (    s;   /home/tom/ab/x64lucid-deps/install/lib/python2.7/urllib2.pyRS    sV    

!		(
c            sU   | j    } | d k r$ d     n | d k r< d     n    f d   }   | f S(   NRc  c         S   s   t  j |   j   S(   N(   RY  t   md5R]  (   t   x(    (    s;   /home/tom/ab/x64lucid-deps/install/lib/python2.7/urllib2.pyR   0  s    t   SHAc         S   s   t  j |   j   S(   N(   RY  RZ  R]  (   Rr  (    (    s;   /home/tom/ab/x64lucid-deps/install/lib/python2.7/urllib2.pyR   2  s    c            s     d |  | f  S(   Ns   %s:%s(    (   RF  t   d(   Rh  (    s;   /home/tom/ab/x64lucid-deps/install/lib/python2.7/urllib2.pyR   4  s    (   t   upper(   R-   Rb  Ri  (    (   Rh  s;   /home/tom/ab/x64lucid-deps/install/lib/python2.7/urllib2.pyRf  +  s    c         C   s   d  S(   N(   R   (   R-   R#   RV  (    (    s;   /home/tom/ab/x64lucid-deps/install/lib/python2.7/urllib2.pyRg  7  s    N(   R0   R1   R   R.   RM  R0  RP  R`  RS  Rf  Rg  (    (    (    s;   /home/tom/ab/x64lucid-deps/install/lib/python2.7/urllib2.pyRI    s   					
	=	t   HTTPDigestAuthHandlerc           B   s#   e  Z d  Z d Z d Z d   Z RS(   s   An authentication protocol defined by RFC 2069

    Digest authentication improves on basic authentication because it
    does not transmit passwords in the clear.
    R9  i  c         C   s?   t  j  | j    d } |  j d | | |  } |  j   | S(   Ni   s   www-authenticate(   R?   R>   R0  RM  (   R-   R   R6   R3   R4   RM   RE   t   retry(    (    s;   /home/tom/ab/x64lucid-deps/install/lib/python2.7/urllib2.pyR:  F  s
    	
(   R0   R1   R:   R1  R   R:  (    (    (    s;   /home/tom/ab/x64lucid-deps/install/lib/python2.7/urllib2.pyRv  <  s   t   ProxyDigestAuthHandlerc           B   s   e  Z d  Z d Z d   Z RS(   s   Proxy-Authorizationi  c         C   s2   | j    } |  j d | | |  } |  j   | S(   Ns   proxy-authenticate(   Rf   R0  RM  (   R-   R   R6   R3   R4   RM   RE   Rw  (    (    s;   /home/tom/ab/x64lucid-deps/install/lib/python2.7/urllib2.pyR<  S  s
    	
(   R0   R1   R1  R   R<  (    (    (    s;   /home/tom/ab/x64lucid-deps/install/lib/python2.7/urllib2.pyRx  N  s   t   AbstractHTTPHandlerc           B   s/   e  Z d  d  Z d   Z d   Z d   Z RS(   i    c         C   s   | |  _  d  S(   N(   t   _debuglevel(   R-   t
   debuglevel(    (    s;   /home/tom/ab/x64lucid-deps/install/lib/python2.7/urllib2.pyR.   \  s    c         C   s   | |  _  d  S(   N(   Rz  (   R-   t   level(    (    s;   /home/tom/ab/x64lucid-deps/install/lib/python2.7/urllib2.pyt   set_http_debuglevel_  s    c   
      C   s:  | j    } | s! t d   n  | j   r | j   } | j d  s[ | j d d  n  | j d  s | j d d t |   q n  | } | j   r t | j	    \ } } t
 |  \ } } n  | j d  s | j d |  n  xH |  j j D]: \ } }	 | j   } | j |  s | j | |	  q q W| S(   Ns   no host givens   Content-types!   application/x-www-form-urlencodeds   Content-lengths   %dR=   (   Rf   R*   R_   Rb   Rq   Ro   R   Rj   R   Rg   R   R   Rz   Rm   (
   R-   RD   RE   R#   t   sel_hostR   t   selt   sel_pathR[   RT   (    (    s;   /home/tom/ab/x64lucid-deps/install/lib/python2.7/urllib2.pyt   do_request_b  s.    
c            s  | j    } | s! t d   n  | | d | j | } | j |  j  t | j      j t   f d   | j j	   D   d   d <t d     j	   D    | j
 r i  } d } |   k r   | | | <  | =n  | j | j
 d | n  y) | j | j   | j   | j    Wn, t j k
 rS} | j   t |   n7 Xy | j d	 t  }	 Wn t k
 r| j   }	 n X|	 j |	 _ t j |	 d t }
 t |
 |	 j | j    } |	 j | _ |	 j | _ | S(
   s  Return an addinfourl object for the request, using http_class.

        http_class must implement the HTTPConnection API from httplib.
        The addinfourl return value is a file-like object.  It also
        has methods and attributes including:
            - info(): return a mimetools.Message object for the headers
            - geturl(): return the original request URL
            - code: HTTP status code
        s   no host givenR$   c         3   s-   |  ]# \ } } |   k r | | f Vq d  S(   N(    (   R   R   R   (   RM   (    s;   /home/tom/ab/x64lucid-deps/install/lib/python2.7/urllib2.pys	   <genexpr>  s    	R   t
   Connectionc         s   s'   |  ] \ } } | j    | f Vq d  S(   N(   t   title(   R   R[   Rn   (    (    s;   /home/tom/ab/x64lucid-deps/install/lib/python2.7/urllib2.pys	   <genexpr>  s    s   Proxy-AuthorizationRM   t	   buffering(   Rf   R*   R$   t   set_debuglevelRz  R   RP   Ru   RM   RN   RL   t
   set_tunnelRD   R`   Rg   R#   R   R   R   t   getresponseR   R   R   t   recvt   _fileobjectR   R4   R>   t   statusR3   R,   (   R-   t
   http_classR   t   http_conn_argsRE   R   t   tunnel_headerst   proxy_auth_hdrt   errR   R6   RX  (    (   RM   s;   /home/tom/ab/x64lucid-deps/install/lib/python2.7/urllib2.pyR     s@    
,	
	
)
(   R0   R1   R.   R}  R  R   (    (    (    s;   /home/tom/ab/x64lucid-deps/install/lib/python2.7/urllib2.pyRy  Z  s   		R   c           B   s   e  Z d    Z e j Z RS(   c         C   s   |  j  t j |  S(   N(   R   R   t   HTTPConnection(   R-   R   (    (    s;   /home/tom/ab/x64lucid-deps/install/lib/python2.7/urllib2.pyt	   http_open  s    (   R0   R1   R  Ry  R  t   http_request(    (    (    s;   /home/tom/ab/x64lucid-deps/install/lib/python2.7/urllib2.pyR     s   	R   R   c           B   s)   e  Z d  d d  Z d   Z e j Z RS(   i    c         C   s   t  j |  |  | |  _ d  S(   N(   Ry  R.   t   _context(   R-   R{  R   (    (    s;   /home/tom/ab/x64lucid-deps/install/lib/python2.7/urllib2.pyR.     s    c         C   s   |  j  t j | d |  j S(   NR   (   R   R   t   HTTPSConnectionR  (   R-   R   (    (    s;   /home/tom/ab/x64lucid-deps/install/lib/python2.7/urllib2.pyt
   https_open  s    N(   R0   R1   R   R.   R  Ry  R  t   https_request(    (    (    s;   /home/tom/ab/x64lucid-deps/install/lib/python2.7/urllib2.pyR     s   	t   HTTPCookieProcessorc           B   s2   e  Z d d   Z d   Z d   Z e Z e Z RS(   c         C   s4   d d  l  } | d  k r' | j   } n  | |  _ d  S(   Ni(   t	   cookielibR   t	   CookieJart	   cookiejar(   R-   R  R  (    (    s;   /home/tom/ab/x64lucid-deps/install/lib/python2.7/urllib2.pyR.     s    c         C   s   |  j  j |  | S(   N(   R  t   add_cookie_header(   R-   RD   (    (    s;   /home/tom/ab/x64lucid-deps/install/lib/python2.7/urllib2.pyR    s    c         C   s   |  j  j | |  | S(   N(   R  t   extract_cookies(   R-   RD   R   (    (    s;   /home/tom/ab/x64lucid-deps/install/lib/python2.7/urllib2.pyR     s    N(   R0   R1   R   R.   R  R   R  R   (    (    (    s;   /home/tom/ab/x64lucid-deps/install/lib/python2.7/urllib2.pyR    s
   		R   c           B   s   e  Z d    Z RS(   c         C   s    | j    } t d |   d  S(   Ns   unknown url type: %s(   Rd   R*   (   R-   R   RJ   (    (    s;   /home/tom/ab/x64lucid-deps/install/lib/python2.7/urllib2.pyR     s    (   R0   R1   R   (    (    (    s;   /home/tom/ab/x64lucid-deps/install/lib/python2.7/urllib2.pyR     s   c         C   sm   i  } x` |  D]X } | j  d d  \ } } | d d k r[ | d d k r[ | d d !} n  | | | <q W| S(   s>   Parse list of key=value strings where keys are not duplicated.t   =i   i    R$  i(   RO  (   t   lt   parsedt   eltR   R   (    (    s;   /home/tom/ab/x64lucid-deps/install/lib/python2.7/urllib2.pyRQ    s     c         C   s   g  } d } t  } } x |  D] } | r? | | 7} t  } q n  | r | d k r] t } q n | d k rr t  } n  | | 7} q n  | d k r | j |  d } q n  | d k r t } n  | | 7} q W| r | j |  n  g  | D] } | j   ^ q S(   sp  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.  Neither commas nor quotes count if they are escaped.
    Only double-quotes count, not single-quotes.
    R<   s   \R$  t   ,(   Rw   R   R   R  (   RF  t   rest   partt   escapeR   t   cur(    (    s;   /home/tom/ab/x64lucid-deps/install/lib/python2.7/urllib2.pyRR    s4    	

	
	c         C   s-   y t  j |   SWn t  j k
 r( d  SXd  S(   N(   R   t   gethostbynamet   gaierrorR   (   RE   (    (    s;   /home/tom/ab/x64lucid-deps/install/lib/python2.7/urllib2.pyt   _safe_gethostbyname(  s    R   c           B   s)   e  Z d    Z d Z d   Z d   Z RS(   c         C   sq   | j    } | d  d k r` | d d !d k r` | j r` | j d k r` d | _ |  j j |  S|  j |  Sd  S(   Ni   s   //i   R   R   t   ftp(   Rg   RE   RJ   R   R!   t   open_local_file(   R-   R   R"   (    (    s;   /home/tom/ab/x64lucid-deps/install/lib/python2.7/urllib2.pyt	   file_open0  s    ,	c         C   s|   t  j d  k ru y7 t t j d  d t j t j    d  t  _ Wqu t j k
 rq t j d  f t  _ qu Xn  t  j S(   NR   i   (	   R   t   namesR   R
  R   t   gethostbyname_ext   gethostnameR  R  (   R-   (    (    s;   /home/tom/ab/x64lucid-deps/install/lib/python2.7/urllib2.pyt	   get_names;  s    $c         C   s[  d d  l  } d d  l } | j   } | j   } t |  } y t j |  } | j } | j j	 | j
 d t }	 | j |  d }
 t j t d |
 p d | |	 f   } | r t |  \ } } n  | s | r(t |  |  j   k r(| rd | | } n
 d | } t t | d  | |  SWn t k
 rJ} t |   n Xt d   d  S(	   Nit   usegmti    s6   Content-type: %s
Content-length: %d
Last-modified: %s
s
   text/plains   file://t   rbs   file not on local host(   t   email.utilst	   mimetypesRf   Rg   R   R=  t   statt   st_sizet   utilst
   formatdatet   st_mtimeR   t
   guess_typet	   mimetoolst   MessageR    R   R  R  R   R!   t   OSErrorR*   (   R-   R   t   emailR  RE   R7   t	   localfilet   statst   sizet   modifiedt   mtypeRM   RK   t   origurlR4   (    (    s;   /home/tom/ab/x64lucid-deps/install/lib/python2.7/urllib2.pyR  F  s0    		
N(   R0   R1   R  R   R  R  R  (    (    (    s;   /home/tom/ab/x64lucid-deps/install/lib/python2.7/urllib2.pyR   .  s   	
	R   c           B   s   e  Z d    Z d   Z RS(   c         C   s  d d  l  } d d  l } | j   } | s9 t d   n  t |  \ } } | d  k rc | j } n t |  } t |  \ } } | r t	 |  \ } } n d  } t
 |  } | p d } | p d } y t j |  } Wn" t j k
 r } t |   n Xt | j    \ }	 }
 |	 j d  } t t
 |  } | d  | d } } | rg| d rg| d } n  y/|  j | | | | | | j  } | rd pd } xM |
 D]E } t |  \ } } | j   d	 k r| d k r| j   } qqW| j | |  \ } } d } | j | j    d } | r;| d | 7} n  | d  k	 rd| d k rd| d | 7} n  t |  } t j |  } t | | | j    SWn0 | j k
 r} t d | t j    d  n Xd  S(   Nis   ftp error: no host givenR<   R   i    i   R7  t   DRJ   t   at   AR   Rt  s   Content-type: %s
s   Content-length: %d
s   ftp error: %si   (   R  R  R   R7  Rt  R  (!   t   ftplibR  Rf   R*   R   R   t   FTP_PORTR   R   R   R   R   R  R   R
   Rg   RO  t   mapt   connect_ftpR$   R   RC   Ru  t   retrfileR  R>   R    R  R  R   t
   all_errorst   syst   exc_info(   R-   R   R  R  RE   RK   R   R	  R4   R   t   attrst   dirst   filet   fwRJ   RZ   RT   R6   t   retrlenRM   R  t   sf(    (    s;   /home/tom/ab/x64lucid-deps/install/lib/python2.7/urllib2.pyt   ftp_openc  s\    !c      	   C   s%   t  | | | | | | d t } | S(   Nt
   persistent(   R   Rw   (   R-   R   R	  RE   RK   R  R$   R  (    (    s;   /home/tom/ab/x64lucid-deps/install/lib/python2.7/urllib2.pyR    s    	(   R0   R1   R  R  (    (    (    s;   /home/tom/ab/x64lucid-deps/install/lib/python2.7/urllib2.pyR   b  s   	5t   CacheFTPHandlerc           B   s>   e  Z d    Z d   Z d   Z d   Z d   Z d   Z RS(   c         C   s1   i  |  _  i  |  _ d |  _ d |  _ d |  _ d  S(   Ni    i<   i   (   t   cacheR$   t   soonestt   delayt	   max_conns(   R-   (    (    s;   /home/tom/ab/x64lucid-deps/install/lib/python2.7/urllib2.pyR.     s
    				c         C   s   | |  _  d  S(   N(   R  (   R-   t   t(    (    s;   /home/tom/ab/x64lucid-deps/install/lib/python2.7/urllib2.pyt
   setTimeout  s    c         C   s   | |  _  d  S(   N(   R  (   R-   R   (    (    s;   /home/tom/ab/x64lucid-deps/install/lib/python2.7/urllib2.pyt   setMaxConns  s    c         C   s   | | | d j  |  | f } | |  j k rJ t j   |  j |  j | <n< t | | | | | |  |  j | <t j   |  j |  j | <|  j   |  j | S(   NR   (   RC  R  R[  R  R$   R   t   check_cache(   R-   R   R	  RE   RK   R  R$   RS   (    (    s;   /home/tom/ab/x64lucid-deps/install/lib/python2.7/urllib2.pyR    s    "
c         C   s  t  j    } |  j | k rr xT |  j j   D]@ \ } } | | k  r+ |  j | j   |  j | =|  j | =q+ q+ Wn  t |  j j    |  _ t |  j  |  j	 k rxD |  j j   D]3 \ } } | |  j k r |  j | =|  j | =Pq q Wt |  j j    |  _ n  d  S(   N(
   R[  R  R$   RN   R  R   t   mint   valuesR   R  (   R-   R  R   R   (    (    s;   /home/tom/ab/x64lucid-deps/install/lib/python2.7/urllib2.pyR    s    


c         C   sB   x! |  j  j   D] } | j   q W|  j  j   |  j j   d  S(   N(   R  R  R   t   clearR$   (   R-   t   conn(    (    s;   /home/tom/ab/x64lucid-deps/install/lib/python2.7/urllib2.pyt   clear_cache  s    (   R0   R1   R.   R  R  R  R  R  (    (    (    s;   /home/tom/ab/x64lucid-deps/install/lib/python2.7/urllib2.pyR    s   				
	(    (    (    (    (    (    (T   R:   R  RY  R   R  R=  R  RA  R5  R   R  R[  R?   R   R*  t	   cStringIOR    t   ImportErrorR   Rw   R   R   t   urllibR   R   R   R   R   R   R   R   R	   R
   R   R   R   R   R   R   R   R   t   versionRy   R   R    R   R(   R)   t   IOErrorR*   R2   R6  RA   RF   RG   Rx   R   R   R   R   R   R   R   R  R!  R"  R8  R;  RH  RI  Rv  Rx  Ry  R   RW   R   R  R   RQ  RR  R  R   R   R  (    (    (    s;   /home/tom/ab/x64lucid-deps/install/lib/python2.7/urllib2.pyt   <module>L   s   
^"			r	'i	H+@
2	n	
	+	4<