³ò
OÉcIc           @   sæ   d  Z  d d k l Z d d k l 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 d k Z d e f d „  ƒ  YZ d „  Z d „  Z d	 „  Z d
 „  Z d „  Z d „  Z d d d „  ƒ  YZ d „  Z d S(   s-   list, delete, and otherwise manage incrementsiÿÿÿÿ(   t
   generators(   t   LogNt   ManageExceptionc           B   s   e  Z RS(    (   t   __name__t
   __module__(    (    (    s8   /var/lib/python-support/python2.5/rdiff_backup/manage.pyR      s    c         C   sG   |  i  ƒ  p d Sn/ |  i ƒ  o d Sn |  i ƒ  o d Sn d Sd S(   s?   Returns one of "regular", "directory", "missing", or "special".t   missingt	   directoryt   regulart   specialN(   t   lstatt   isdirt   isreg(   t   rp(    (    s8   /var/lib/python-support/python2.5/rdiff_backup/manage.pyt   get_file_type   s       c         C   s–   |  i  ƒ  p t ‚ |  i ƒ  } | d j o d Sn^ | d j o d SnI | d j o d Sn4 | d j o t |  ƒ Sn d p t d | f ‚ d S(	   s%   Return file type increment representst   dirR   t   diffR   R   t   snapshots   Unknown type %sN(   t	   isincfilet   AssertionErrort
   getinctypeR   t   None(   t   inct   type(    (    s8   /var/lib/python-support/python2.5/rdiff_backup/manage.pyt   get_inc_type$   s        c   	   	   C   s˜   g  } |  D] } | | i  ƒ  | f q ~ } | i ƒ  g  } | D]# \ } } | d | t | ƒ f qB ~ } | i d | t | ƒ f ƒ d i | ƒ S(   s;  Return a string parsable by computer describing the increments

	Each line is a time in seconds of the increment, and then the
	type of the file.  It will be sorted oldest to newest.  For example:

	10000 regular
	20000 directory
	30000 special
	40000 missing
	50000 regular    <- last will be the current mirror

	s   %s %ss   
(   t
   getinctimet   sortR   t   appendR   t   join(	   t   incst   mirror_timet   mirrorrpt   _[1]R   t   incpairst   _[2]t   timet   result(    (    s8   /var/lib/python-support/python2.5/rdiff_backup/manage.pyt   describe_incs_parsable.   s
    -
7c         C   s
  g  } |  D] } | | i  ƒ  | f q ~ } | i ƒ  d t | ƒ g } t i oN xŒ | D]? \ } } | i d t i | i ƒ  d ƒ t	 i
 | ƒ f ƒ q[ WnB x> | D]6 \ } } | i d | i ƒ  d t	 i
 | ƒ f ƒ q© W| i d t	 i
 | ƒ ƒ d i | ƒ S(   s6   Return a string describing all the the root incrementss   Found %d increments:s       %s   %si   s   Current mirror: %ss   
(   R   R   t   lent   Globalst   chars_to_quoteR   t   FilenameMappingt   unquotet   dirsplitt   Timet   timetoprettyR   (   R   R   R   R   R   R    R#   R"   (    (    s8   /var/lib/python-support/python2.5/rdiff_backup/manage.pyt   describe_incs_humanA   s    -

 	 	%c         C   s   |  i  i i |  | ƒ d S(   sî   Deleting increments older than time in directory baserp

	time is in seconds.  It will then delete any empty directories
	in the tree.  To process the entire backup area, the
	rdiff-backup-data directory should be the root of the tree.

	N(   t   connt   managet   delete_earlier_than_local(   t   baserpR"   (    (    s8   /var/lib/python-support/python2.5/rdiff_backup/manage.pyt   delete_earlier_thanS   s    c            s¡   |  i  t i j p t ‚ ‡  f d †  ‰  xq ˆ  |  ƒ D]c } | i ƒ  o | i ƒ  | j  p | i ƒ  o0 | i ƒ  o" t d | i	 d ƒ | i
 ƒ  q6 q6 Wd S(   s?   Like delete_earlier_than, but run on local connection for speedc         3   sV   |  i  ƒ  o@ x= |  i ƒ  D]+ } x" ˆ  |  i | ƒ ƒ D] } | Vq6 Wq Wn |  Vd  S(   N(   R
   t   listdirR   (   R   t   filenamet   sub_rp(   t   yield_files(    s8   /var/lib/python-support/python2.5/rdiff_backup/manage.pyR6   `   s      s   Deleting increment file %si   N(   R.   R&   t   local_connectionR   R   R   R
   R3   R   t   patht   delete(   R1   R"   R   (    (   R6   s8   /var/lib/python-support/python2.5/rdiff_backup/manage.pyR0   ]   s      t   IncObjc           B   s2   e  Z d  Z d „  Z d „  Z d „  Z d „  Z RS(   s2   Increment object - represent a completed incrementc         C   s@   | i  ƒ  p t d | i ƒ ‚ n | |  _ | i ƒ  |  _ d S(   s{   IncObj initializer

		incrp is an RPath of a path like increments.TIMESTR.dir
		standing for the root of the increment.

		s   %s is not an inc fileN(   R   R   R8   t   incrpR   R"   (   t   selfR;   (    (    s8   /var/lib/python-support/python2.5/rdiff_backup/manage.pyt   __init__p   s    	c         C   s   |  i  i ƒ  S(   s)   Return rp of the incrp without extensions(   R;   t
   getincbase(   R<   (    (    s8   /var/lib/python-support/python2.5/rdiff_backup/manage.pyt	   getbaserp|   s    c         C   s   t  i |  i ƒ S(   s(   Return a formatted version of inc's time(   R+   R,   R"   (   R<   (    (    s8   /var/lib/python-support/python2.5/rdiff_backup/manage.pyt   pretty_time€   s    c         C   s-   d |  i  i d |  i ƒ  g } d i | ƒ S(   s"   Return string describing increments   Increment file %ss   Date: %ss   
(   R;   R8   R@   R   (   R<   t   s(    (    s8   /var/lib/python-support/python2.5/rdiff_backup/manage.pyt   full_description„   s    (   R   R   t   __doc__R=   R?   R@   RB   (    (    (    s8   /var/lib/python-support/python2.5/rdiff_backup/manage.pyR:   n   s
   			c            sÞ   t  i ƒ  ‰ d „  } d „  } ‡  ‡ f d †  } ‡  f d †  } d „  } ‡ f d †  } | | ƒ  ƒ } | | ƒ  ƒ }	 | | |	 ƒ }
 d d d d | |
 d ƒ d g } x% |
 d D] } | i | | ƒ ƒ q´ Wd i | ƒ S(   s8   Return string summarizing the size of all the incrementsc         S   s+   d } x |  D] } | | i  ƒ  7} q W| S(   s.   Return the total size of everything in rp_iteri    (   t   getsize(   t   rp_itert   totalR   (    (    s8   /var/lib/python-support/python2.5/rdiff_backup/manage.pyt	   get_totalŽ   s
      c         S   so   h  } xb |  D]Z } | i  ƒ  p q n | i ƒ  } | i | ƒ p d | | <n | | c | i ƒ  7<q W| S(   s5   Return dictionary pairing times to total size of incsi    (   R   R   t   has_keyRD   (   t   inc_itert	   time_dictR   t   t(    (    s8   /var/lib/python-support/python2.5/rdiff_backup/manage.pyt   get_time_dict”   s       c             s=   ˆ i  ˆ  ƒ }  t i |  ƒ } ˆ  p | i ƒ  n | i ƒ  S(   s    Return iterator of mirror rpaths(   t	   new_indext	   selectiont   Selectt   parse_rbdir_excludet   set_iter(   t   mirror_baset   mirror_select(   t   indext   mirror_root(    s8   /var/lib/python-support/python2.5/rdiff_backup/manage.pyt   get_mirror_selectž   s
    c          3   st   t  i i d ˆ  ƒ }  x t i |  ƒ D] } | Vq% W|  i ƒ  o/ t i |  ƒ i ƒ  } x | D] } | Vq] Wn d S(   s#   Return iterator of increment rpathst
   incrementsN(	   R&   t   rbdirt   append_patht   restoret   get_inclistR
   RN   RO   RQ   (   t   inc_baset   base_inct
   inc_selectR   (   RT   (    s8   /var/lib/python-support/python2.5/rdiff_backup/manage.pyt   get_inc_select¦   s      	  c   	      S   s¬   g  } t  i i d ƒ } t i | ƒ d i ƒ  } | i | |  |  f ƒ | i ƒ  } | i ƒ  | i ƒ  |  } x8 | D]0 } | | } | | 7} | i | | | f ƒ qt W| S(   s4   Return list of triples (time, size, cumulative size)t   current_mirrori    (	   R&   RX   R   RZ   R[   R   t   keysR   t   reverse(	   t   mirror_totalRJ   t   triplest   cur_mir_baseR   t	   inc_timest   cumulative_sizet   inc_timet   size(    (    s8   /var/lib/python-support/python2.5/rdiff_backup/manage.pyt   get_summary_triples®   s    

 

c            s;   |  \ } } } d t  i | ƒ ˆ  i | ƒ ˆ  i | ƒ f S(   s    Convert triple to display strings   %24s   %13s   %15s(   R+   R,   t   get_byte_summary_string(   t   tripleR"   Ri   t   cum_size(   t   stat_obj(    s8   /var/lib/python-support/python2.5/rdiff_backup/manage.pyt   triple_to_lineÀ   s
    s   %12s %9s  %15s   %20sR+   t    t   Sizes   Cumulative sizet   -iM   i    s      (current mirror)i   s   
(   s   TimeRp   Rq   s   Cumulative size(   t
   statisticst   StatsObjR   R   (   RU   RT   RG   RL   RV   R_   Rj   Ro   Rc   RJ   Rd   t   lRl   (    (   RT   RU   Rn   s8   /var/lib/python-support/python2.5/rdiff_backup/manage.pyt   ListIncrementSizes‹   s"    		
	  (    (   RC   t
   __future__R    t   logR   R&   R+   t   staticRs   RZ   RN   R(   t	   ExceptionR   R   R   R$   R-   R2   R0   R:   Rv   (    (    (    s8   /var/lib/python-support/python2.5/rdiff_backup/manage.pys   <module>   s   T		
			
	