;ς
>5‘@c           @   sΌ  d  k  Z  d  k Z d  k Z d  k Z d  k Z d  k Z d k l Z d Z d e i	 e i
 f d     YZ e e e e e e d  Z d   Z d   Z d d	 d
 d d d d g Z d d d d d d d g Z d d d d d d d d d d d  d! g Z d"   Z d#   Z e i d$  i Z e i d%  i Z e i d&  i Z d'   Z d(   Z e d)  Z e d*  Z e e e e e e d+  Z e e e e d,  Z d-   Z  e! d. j o e    n d  S(/   N(   s   up2dateErrorsi  s   MiscURLHandlerc           B   sA   t  Z d   Z d   Z d   Z d   Z d   Z e Z e Z RS(   Nc         C   s―   | d d j o
 | d j o |  i | | | | |  Sn | d d j o | d g j o |  i | | | | |  Sn d k l	 } | | | | i
    } | | _ | Sd  S(   Nid   i   i0  i   i  (   s
   addinfourl(   s   codes   selfs   http_error_302s   reqs   fps   msgs   headerss   http_error_404s   urllibs
   addinfourls   get_full_urls   infourls   status(   s   selfs   reqs   fps   codes   msgs   headerss   infourls
   addinfourl(    (    s6   /usr/share/rhn/up2date_client/repoBackends/urlUtils.pys   http_error_default   s    !	c         C   sG   t  i i |  | | | | |  } t
 | d  o | | _ n | Sd  S(   Ns   status(   s   urllib2s   HTTPRedirectHandlers   http_error_302s   selfs   reqs   fps   codes   msgs   headerss   infourls   hasattrs   status(   s   selfs   reqs   fps   codes   msgs   headerss   infourl(    (    s6   /usr/share/rhn/up2date_client/repoBackends/urlUtils.pys   http_error_302    s    !c         C   s2   t  i i |  | | | | |  } | | _
 | Sd  S(   N(   s   urllib2s   HTTPRedirectHandlers   http_error_301s   selfs   reqs   fps   codes   msgs   headerss   infourls   status(   s   selfs   reqs   fps   codes   msgs   headerss   infourl(    (    s6   /usr/share/rhn/up2date_client/repoBackends/urlUtils.pys   http_error_301'   s    !	c         C   s2   t  i i |  | | | | |  } | | _
 | Sd  S(   N(   s   urllib2s   HTTPDefaultErrorHandlers   http_error_defaults   selfs   reqs   fps   codes   msgs   headerss   infourls   status(   s   selfs   reqs   fps   codes   msgs   headerss   infourl(    (    s6   /usr/share/rhn/up2date_client/repoBackends/urlUtils.pys   http_error_404,   s    !	c         C   s2   t  i i |  | | | | |  } | | _
 | Sd  S(   N(   s   urllib2s   HTTPDefaultErrorHandlers   http_error_defaults   selfs   reqs   fps   codes   msgs   headerss   infourls   status(   s   selfs   reqs   fps   codes   msgs   headerss   infourl(    (    s6   /usr/share/rhn/up2date_client/repoBackends/urlUtils.pys   http_error_4031   s    !	(	   s   __name__s
   __module__s   http_error_defaults   http_error_302s   http_error_301s   http_error_404s   http_error_403s   http_error_300s   http_error_307(    (    (    s6   /usr/share/rhn/up2date_client/repoBackends/urlUtils.pys   MiscURLHandler   s   					c         C   sΥ  t  |  d  o |  Sn |  d j o t i Sn | o
 t } n t i |   }
 | o |
 i
 d |  n | o |
 i
 d t |   n |
 i
 d |  | o$ |
 i
 d |  |
 i
 d d  n d	 } | o
 | } n d
 } | o
 | } n | p | o) d | | f } | GH|
 i
 d |  n t i t    }	 g  |	 _ y |	 i |
  SWn7 t j
 o d |  GHn t j
 o d |  GHn Xy t |   SWn t i   GHt i GHn Xt i t |    Sd S(   sβ  
    URI, filename, or string --> stream

    This function lets you define parsers that take any input source
    (URL, pathname to local or network file, or actual data as a string)
    and deal with it in a uniform manner.  Returned object is guaranteed
    to have all the basic stdio read methods (read, readline, readlines).
    Just .close() the object when you're done with it.

    If the etag argument is supplied, it will be used as the value of an
    If-None-Match request header.

    If the modified argument is supplied, it must be a tuple of 9 integers
    as returned by gmtime() in the standard Python time module. This MUST
    be in GMT (Greenwich Mean Time). The formatted date/time will be used
    as the value of an If-Modified-Since request header.

    If the agent argument is supplied, it will be used as the value of a
    User-Agent request header.

    If the referrer argument is supplied, it will be used as the value of a
    Referer[sic] request header.
    s   reads   -s   If-None-Matchs   If-Modified-Sinces
   User-Agents   Referers   Accept-encodings   gzipi    s    s   bytes=%s-%ss   Ranges   %s not a valud URLs   %s is of an unknown URL typeN(   s   hasattrs   sources   syss   stdins   agents
   USER_AGENTs   urllib2s   Requests   requests   etags
   add_headers   modifieds   format_http_dates   referrers   starts
   startRanges   ends   endRanges   ranges   build_openers   MiscURLHandlers   openers
   addheaderss   opens   OSErrors
   ValueErrors   exc_infos   exc_types   StringIOs   str(   s   sources   etags   modifieds   agents   referrers
   startRanges   endRanges   ends   starts   openers   requests   range(    (    s6   /usr/share/rhn/up2date_client/repoBackends/urlUtils.pys   open_resource9   sV     


			c         C   s/   t  |  d  o |  i   i d  Sn t Sd S(   sμ   
    Get the ETag associated with a response returned from a call to 
    open_resource().

    If the resource was not returned from an HTTP server or the server did
    not specify an ETag for the resource, this will return None.
    s   infos   ETagN(   s   hasattrs   resources   infos	   getheaders   None(   s   resource(    (    s6   /usr/share/rhn/up2date_client/repoBackends/urlUtils.pys   get_etag   s     c         C   sF   t  |  d  o. |  i   i d  } | o t |  Sq> n t Sd S(   sn  
    Get the Last-Modified timestamp for a response returned from a call to
    open_resource().

    If the resource was not returned from an HTTP server or the server did
    not specify a Last-Modified timestamp, this function will return None.
    Otherwise, it returns a tuple of 9 integers as returned by gmtime() in
    the standard Python time module().
    s   infos   Last-ModifiedN(   s   hasattrs   resources   infos	   getheaders   last_modifieds   parse_http_dates   None(   s   resources   last_modified(    (    s6   /usr/share/rhn/up2date_client/repoBackends/urlUtils.pys   get_modified   s    	 s   Mons   Tues   Weds   Thus   Fris   Sats   Suns   Mondays   Tuesdays	   Wednesdays   Thursdays   Fridays   Saturdays   Sundays   Jans   Febs   Mars   Aprs   Mays   Juns   Juls   Augs   Seps   Octs   Novs   Decc      	   C   sI   d t  |  d |  d t |  d d |  d |  d |  d |  d f Sd	 S(
   s&  
    Formats a tuple of 9 integers into an RFC 1123-compliant timestamp as
    required in RFC 2616. We don't use time.strftime() since the %a and %b
    directives can be affected by the current locale (HTTP dates have to be
    in English). The date MUST be in GMT (Greenwich Mean Time).
    s#   %s, %02d %s %04d %02d:%02d:%02d GMTi   i   i   i    i   i   i   N(   s   short_weekdayss   dates   months(   s   date(    (    s6   /usr/share/rhn/up2date_client/repoBackends/urlUtils.pys   format_http_date―   s     c         C   sb   y t  i |  d  SWnG y t  i |  d  SWq^ y t  i |  d  SWqZ t SqZ Xq^ Xn Xd  S(   Ns   %a, %d %b %Y %H:%M:%S GMTs   %A, %d-%b-%y %H:%M:%S GMTs   %a %b %d %H:%M:%S %Y(   s   times   strptimes   dates   None(   s   date(    (    s6   /usr/share/rhn/up2date_client/repoBackends/urlUtils.pys   parse_http_date2Ή   s    s   (?P<weekday>[A-Z][a-z]{2}), (?P<day>\d{2}) (?P<month>[A-Z][a-z]{2}) (?P<year>\d{4}) (?P<hour>\d{2}):(?P<minute>\d{2}):(?P<second>\d{2}) GMTs   (?P<weekday>[A-Z][a-z]+), (?P<day>\d{2})-(?P<month>[A-Z][a-z]{2})-(?P<year>\d{2}) (?P<hour>\d{2}):(?P<minute>\d{2}):(?P<second>\d{2}) GMTs   (?P<weekday>[A-Z][a-z]{2}) (?P<month>[A-Z][a-z]{2})  ?(?P<day>\d\d?) (?P<hour>\d{2}):(?P<minute>\d{2}):(?P<second>\d{2}) (?P<year>\d{4})c      	   C   sΓ  t  |   }  d } t } t |   } | oC t |   } | o d } t } qo t	 |   } | o t
 Sqo n yB| t | i d   } t i | i d   d } t | i d   } t | i d   }
 t | i d   } t | i d	   } | i | i d
   } t d | d  }	 | d t d | d |	 d d d  t d | d |	 d  t d | d d  d d } d } | | | |
 | | | | | f	 SWn t
 Sn Xd S(   s  
    Parses any of the three HTTP date formats into a tuple of 9 integers as
    returned by time.gmtime(). This should not use time.strptime() since
    that function is not available on all platforms and could also be
    affected by the current locale.
    i    il  s   years   monthi   s   days   hours   minutes   seconds   weekdayi   i   i-}  i   i   i   i   i±: iΐ  i  iΏ  iϊ{  N(   s   strs   dates   years   short_weekdayss   weekdayss   rfc1123_matchs   ms   rfc850_matchs   long_weekdayss   asctime_matchs   Nones   ints   groups   monthss   indexs   months   days   hours   minutes   seconds   weekdays   as
   julian_days   daylight_savings_flag(   s   dates   years   months   seconds
   julian_days   weekdayss   daylight_savings_flags   days   minutes   as   hours   ms   weekday(    (    s6   /usr/share/rhn/up2date_client/repoBackends/urlUtils.pys   parse_http_dateΟ   s6     
d#c         C   sP   t  |  d  o8 |  i   i d  } | t j o | Sn t |  Sn t Sd  S(   Ns   infos   Content-Length(   s   hasattrs   resources   infos	   getheaders   sizes   Nones   long(   s   resources   size(    (    s6   /usr/share/rhn/up2date_client/repoBackends/urlUtils.pys   get_sizeφ   s    c         C   s   d } t |   } | t j o t Sn d } x` n oX |  i t  } t	 |  } | o Pn | | } | | } | o | | |  q0 q7 W| Sd  S(   Ns    i    i   (   s   bufs   get_sizes   fds   sizes   Nones	   size_reads   reads   BUFFER_SIZEs   chunks   lens   ls   progressCallback(   s   fds   progressCallbacks   chunks   ls	   size_reads   bufs   size(    (    s6   /usr/share/rhn/up2date_client/repoBackends/urlUtils.pys	   readFDBuf   s      

c         C   s9  d } t i   } | }
 t |   } d }	 xκ n oβ t i   } |  i	 t
  } t |  } | o Pn |	 | }	 | |	 } | o | |
 d j p
 | d j o` | }
 t | |  } | | | d } | d j o
 d } n | | } | |	 | | |  qn | i |  q4 W| i   | i d d  d Sd  S(   Ns    i    i   f9.9999999999999995e-07(   s   bufs   times	   startTimes   lastTimes   get_sizes   fds   sizes	   size_reads   curTimes   reads   BUFFER_SIZEs   chunks   lens   ls   amts   progressCallbacks   floats	   bytesReads   speeds   secss   writefds   writes   flushs   seek(   s   fds   writefds   progressCallbacks   curTimes	   bytesReads   chunks   ls   secss	   startTimes	   size_reads   lastTimes   bufs   amts   speeds   size(    (    s6   /usr/share/rhn/up2date_client/repoBackends/urlUtils.pys   readFDBufWriteFD  s6     




c   
   
   C   s€   t  |  d | d | d | d | }	 t |	 d  o |	 i d j o t	 SqP n t
 |	  } | o t i t i    } n t |	 |  } |	 i   | | f Sd  S(   Ns   modifieds   agents
   startRanges   endRanges   statusi0  (   s   open_resources   urls   lastModifieds   agents   starts   ends   fhs   hasattrs   statuss   Nones   get_modifieds   lmtimes   times   gmtimes	   readFDBufs   progressCallbacks   buffers   close(
   s   urls   progressCallbacks   msgCallbacks   lastModifieds   agents   starts   ends   lmtimes   buffers   fh(    (    s6   /usr/share/rhn/up2date_client/repoBackends/urlUtils.pys   fetchUrl@  s    
c   	      C   s   t  |  d | d | } t | d  o | i d j o t SqD n t |  } | o t
 i t
 i
    } n t | | |  } | i   | Sd  S(   Ns   modifieds   agents   statusi0  (   s   open_resources   urls   lastModifieds   agents   fhs   hasattrs   statuss   Nones   get_modifieds   lmtimes   times   gmtimes   readFDBufWriteFDs   writefds   progressCallbacks   rets   close(	   s   urls   writefds   progressCallbacks   msgCallbacks   lastModifieds   agents   lmtimes   fhs   ret(    (    s6   /usr/share/rhn/up2date_client/repoBackends/urlUtils.pys   fetchUrlAndWriteFDX  s    
c          C   s@   t  d d d }  |  GHt |  d  o d |  i GHn d GHd  S(   Ns1   http://www.japanairband.com/sdfsdfasdferwregsdfg/s   agents   foobars   statuss
   status: %ss	   no status(   s   open_resources   fhs   hasattrs   status(   s   fh(    (    s6   /usr/share/rhn/up2date_client/repoBackends/urlUtils.pys   maino  s    s   __main__("   s   syss   urllib2s   StringIOs   gzips   times   res   up2date_clients   up2dateErrorss   BUFFER_SIZEs   HTTPRedirectHandlers   HTTPDefaultErrorHandlers   MiscURLHandlers   Nones   open_resources   get_etags   get_modifieds   short_weekdayss   long_weekdayss   monthss   format_http_dates   parse_http_date2s   compiles   matchs   rfc1123_matchs   rfc850_matchs   asctime_matchs   parse_http_dates   get_sizes	   readFDBufs   readFDBufWriteFDs   fetchUrls   fetchUrlAndWriteFDs   mains   __name__(   s   fetchUrls   up2dateErrorss   parse_http_date2s   asctime_matchs   rfc850_matchs   BUFFER_SIZEs   get_modifieds   format_http_dates   MiscURLHandlers   get_etags   get_sizes   res   short_weekdayss   mains   urllib2s   syss   long_weekdayss   fetchUrlAndWriteFDs   readFDBufWriteFDs	   readFDBufs   StringIOs   monthss   rfc1123_matchs   parse_http_dates   times   gzips   open_resource(    (    s6   /usr/share/rhn/up2date_client/repoBackends/urlUtils.pys   ?   s8   						'T		*	
		'	
*	