³ò
OÉcIc        
   @   s¡  d  Z  d d k Z d d k Z d d k Z d d k Z d d k Z d d k Z d e f d „  ƒ  YZ h  d d <d d <d	 d
 <d d <d( d <d) d <d* d <Z	 e i
 d ƒ Z e i
 d ƒ Z e i
 d ƒ Z e i
 d ƒ Z e i
 d ƒ Z d a a d 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 d% „  Z  d d& „ Z! d d d' „ Z" d S(+   s-   Provide time related exceptions and functionsiÿÿÿÿNt   TimeExceptionc           B   s   e  Z RS(    (   t   __name__t
   __module__(    (    (    s6   /var/lib/python-support/python2.5/rdiff_backup/Time.pyR       s    i   t   si<   t   mi  t   hi€Q t   Di   t   Wi   t   Mim  t   Ys   ^[0-9]+$s	   ^[0-9]+B$s   ^([0-9]+)([smhDWMY])sD   ^(?P<year>[0-9]{4})[-/](?P<month>[0-9]{1,2})[-/](?P<day>[0-9]{1,2})$sD   ^(?P<month>[0-9]{1,2})[-/](?P<day>[0-9]{1,2})[-/](?P<year>[0-9]{4})$c         C   sA   |  p
 t  i  ƒ  } x' t i D] } | i i t | ƒ ƒ q Wd S(   s>   Sets the current time in curtime and curtimestr on all systemsN(   t   timet   Globalst   connectionst   Timet   setcurtime_localt   long(   t   curtimet   tt   conn(    (    s6   /var/lib/python-support/python2.5/rdiff_backup/Time.pyt
   setcurtime'   s    
 c         C   s   |  t  |  ƒ a a d S(   s!   Only set the current time locallyN(   t   timetostringR   t
   curtimestr(   t   timeinseconds(    (    s6   /var/lib/python-support/python2.5/rdiff_backup/Time.pyR   -   s    c         C   sf   d |  j  o
 t  j  n p t d |  f ‚ t |  ƒ } x$ t i D] } | i i |  | ƒ qE Wd S(   s6   Sets the previous inc time in prevtime and prevtimestri    s   Time %s is out of boundsN(   R   t   AssertionErrorR   R   R   R   t   setprevtime_local(   R   t   timestrR   (    (    s6   /var/lib/python-support/python2.5/rdiff_backup/Time.pyt   setprevtime2   s    !
 c         C   s   |  | a  a d S(   s/   Like setprevtime but only set the local versionN(   t   prevtimet   prevtimestr(   R   R   (    (    s6   /var/lib/python-support/python2.5/rdiff_backup/Time.pyR   :   s    c         C   s)   t  i d t  i |  ƒ ƒ } | t |  ƒ S(   s5   Return w3 datetime compliant listing of timeinsecondss   %Y-%m-%dT%H:%M:%S(   R
   t   strftimet	   localtimet   gettzd(   R   R   (    (    s6   /var/lib/python-support/python2.5/rdiff_backup/Time.pyR   ?   s    c         C   s¯  yˆ|  d  i  d ƒ \ } } t t | i  d ƒ ƒ \ } } } t t | i  d ƒ ƒ \ } } } d | j  o
 d j  n p
 t | ‚ d | j o
 d j n p t ‚ d | j o
 d	 j n p t ‚ d
 | j o
 d j n p t ‚ d
 | j o
 d j n p t ‚ d
 | j o
 d j n p t ‚ | | | | | | d d d
 f	 }	 t i |	 ƒ }
 t |
 ƒ t |  d ƒ SWn  t t	 t f j
 o d Sn Xd S(   s“   Return time in seconds from w3 timestring

	If there is an error parsing the string, or it doesn't look
	like a w3 datetime string, return None.

	i   t   Tt   -t   :il  i4  i   i   i   i    i   i;   i=   iÿÿÿÿN(   t   splitt   mapt   intR   t   calendart   timegmR   t   tzdtosecondst	   TypeErrort
   ValueErrort   None(   t
   timestringt   datet   daytimet   yeart   montht   dayt   hourt   minutet   secondt	   timetuplet   utc_in_secs(    (    s6   /var/lib/python-support/python2.5/rdiff_backup/Time.pyt   stringtotimeD   s    !!(%%%%%! c         C   s   t  i t  i |  ƒ ƒ S(   s   Return pretty version of time(   R
   t   asctimeR   (   R   (    (    s6   /var/lib/python-support/python2.5/rdiff_backup/Time.pyt   timetopretty[   s    c         C   s   t  t |  ƒ ƒ S(   s2   Return pretty version of time given w3 time string(   R9   R7   (   R,   (    (    s6   /var/lib/python-support/python2.5/rdiff_backup/Time.pyt   stringtopretty_   s    c         C   s8   y t  i t  i |  ƒ ƒ SWn t j
 o d Sn Xd S(   s=   Converts time like "Mon Jun 5 11:00:23" to epoch sec, or NoneN(   R
   t   mktimet   strptimeR*   R+   (   t   prettystring(    (    s6   /var/lib/python-support/python2.5/rdiff_backup/Time.pyt   prettytotimec   s      c         C   s:  g  } t  |  d ƒ \ } }  | d j o | i d | ƒ n | d j o | i d ƒ n t  |  d ƒ \ } }  | d j o | i d | ƒ n | d j o | i d ƒ n |  d j o | i d ƒ n` | p |  d j oJ t |  t ƒ p t |  t ƒ o | i d	 |  ƒ q-| i d
 |  ƒ n d i | ƒ S(   s9   Convert num of seconds to readable string like "2 hours".i  i   s   %d hourss   1 houri<   s
   %d minutess   1 minutes   1 seconds
   %s secondss   %.2f secondst    (   t   divmodt   appendt
   isinstanceR%   R   t   join(   t   secondst   partlistt   hourst   minutes(    (    s6   /var/lib/python-support/python2.5/rdiff_backup/Time.pyt   inttoprettyh   s$          c            sÖ   ‡  f d †  } t  ˆ  ƒ d j  o | ƒ  n d } xœ ˆ  o” t i ˆ  ƒ } | p | ƒ  n t | i d ƒ ƒ | i d ƒ } } | t j p | d j  o | ƒ  n | | t | 7} ˆ  | i d ƒ ‰  q6 W| S(   s@   Convert a string expressing an interval (e.g. "4D2s") to secondsc              s   t  d ˆ  ƒ ‚ d  S(   Ns¿   Bad interval string "%s"

Intervals are specified like 2Y (2 years) or 2h30m (2.5 hours).  The
allowed special characters are s, m, h, D, W, M, and Y.  See the man
page for more information.
(   R    (    (   t   interval_string(    s6   /var/lib/python-support/python2.5/rdiff_backup/Time.pyt   error|   s    i   i    i   (   t   lent   _interval_regexpt   matchR%   t   groupt   _interval_conv_dictt   end(   RI   RJ   t   totalRM   t   numt   ext(    (   RI   s6   /var/lib/python-support/python2.5/rdiff_backup/Time.pyt   intstringtosecondsz   s       % c         C   s  |  d
 j o t i ƒ  }  n t i o t i |  ƒ d } | o t i d } n t i d } | d j o
 d } n | d j  o
 d } n d St t t | d ƒ ƒ \ } } d | j o
 d j n p t	 ‚ d | j o
 d j n p t	 ‚ d	 | | | f S(   sô   Return w3's timezone identification string.

	Expresed as [+/-]hh:mm.  For instance, PDT is -07:00 during
	dayling savings and -08:00 otherwise.  Zone coincides with what
	localtime(), etc., use.  If no argument given, use the current
	time.

	i   i<   i    t   +R!   t   Zi   i;   s   %s%02d:%02dN(
   R+   R
   t   daylightR   t   altzonet   timezoneR$   t   absR@   R   (   R   t   dst_in_effectt   offsett   prefixRF   RG   (    (    s6   /var/lib/python-support/python2.5/rdiff_backup/Time.pyR      s    	   
 
%%c         C   s   |  d j o d Sn t  |  ƒ d j p t ‚ |  d d j p |  d d j o |  d d j p t ‚ d d	 t |  d  ƒ t |  d
 ƒ S(   s3   Given w3 compliant TZD, return how far ahead UTC isRV   i    i   R!   RU   i   R"   iÄÿÿÿi<   i   (   RK   R   R%   (   t   tzd(    (    s6   /var/lib/python-support/python2.5/rdiff_backup/Time.pyR(   ¥   s
     :c         C   s¦   t  |  ƒ t i j o$ t |  ƒ }  |  d j	 p t ‚ n t  | ƒ t i j o$ t | ƒ } | d j	 p t ‚ n |  | j  o d Sn |  | j o d Sn d Sd S(   s.   Compare time1 and time2 and return -1, 0, or 1iÿÿÿÿi    i   N(   t   typet   typest
   StringTypeR7   R+   R   (   t   time1t   time2(    (    s6   /var/lib/python-support/python2.5/rdiff_backup/Time.pyt   cmp¬   s      c         C   sN   t  i i i i i ƒ  } | i ƒ  t | ƒ |  j o | d Sn | |  d S(   s±   Return time in seconds of given backup

	The current mirror is session_num 0, the next oldest increment has
	number 1, etc.  Requires that the Globals.rbdir directory be set.

	i    i   (   R   t   rbdirR   t   restoret   MirrorStructt   get_increment_timest   sortRK   (   t   session_numt   rpt   session_times(    (    s6   /var/lib/python-support/python2.5/rdiff_backup/Time.pyt   time_from_session¹   s
    
c            s   | d	 j o t ƒ  d } n ˆ  d j o | Sn ‡  f d †  } t i ˆ  ƒ o t ˆ  ƒ Sn t ˆ  ƒ p t ˆ  t ƒ  ƒ } | o | Sn t i ˆ  ƒ o t t ˆ  d  ƒ | ƒ Sn t	 ˆ  ƒ } | d	 j	 o | Sn y | t
 ˆ  ƒ SWn t j
 o n Xt i ˆ  ƒ p t i ˆ  ƒ } | p | ƒ  n d | i d ƒ t | i d ƒ ƒ t | i d ƒ ƒ t ƒ  f ‰  t ˆ  ƒ } | d	 j	 o | Sn | ƒ  d	 S(
   sµ   Convert a generic time string to a time in seconds

	rp is used when the time is of the form "4B" or similar.  Then the
	times of the increments of that particular file are used.

	R   t   nowc              s   t  d ˆ  ƒ ‚ d  S(   Nsi  Bad time string "%s"

The acceptible time strings are intervals (like "3D64s"), w3-datetime
strings, like "2002-04-26T04:22:01-07:00" (strings like
"2002-04-26T04:22:01" are also acceptable - rdiff-backup will use the
current time zone), or ordinary dates like 2/4/1997 or 2001-04-23
(various combinations are acceptable, but the month always precedes
the day).(   R    (    (   R   (    s6   /var/lib/python-support/python2.5/rdiff_backup/Time.pyRJ   Ñ   s    iÿÿÿÿs   %s-%02d-%02dT00:00:00%sR/   R0   R1   N(   R+   t   globalst   _integer_regexpt   searchR%   R7   R   t   _session_regexpRm   R>   RT   R    t   _genstr_date_regexp1t   _genstr_date_regexp2RN   (   R   R   Rk   RJ   R   RM   (    (   R   s6   /var/lib/python-support/python2.5/rdiff_backup/Time.pyt   genstrtotimeÇ   s:            1 i€:	 i ' i€3á(#   t   __doc__R
   R`   t   ret   sysR&   R   t	   ExceptionR    RO   t   compileRp   Rr   RL   Rs   Rt   R+   R   R   R   R   R   R   R   R7   R9   R:   R>   RH   RT   R   R(   Rd   Rm   Ru   (    (    (    s6   /var/lib/python-support/python2.5/rdiff_backup/Time.pys   <module>   s6   <(
												