³ò
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 d k Z d d k Z d d „ Z
 d „  Z d „  Z d „  Z d „  Z d d „ Z d	 „  Z d
 „  Z d d d „ Z d d „ Z d S(   s9   Invoke rdiff utility to make signatures, deltas, or patchiÿÿÿÿNc         C   sV   | p t  |  i ƒ  ƒ } n t i d |  i ƒ  | f d ƒ t i |  i d ƒ | ƒ S(   s5   Take signature of rpin file and return in file objects)   Getting signature of %s with blocksize %si   t   rb(   t   find_blocksizet   getsizet   logt   Logt   get_indexpatht   librsynct   SigFilet   open(   t   rpt	   blocksize(    (    s7   /var/lib/python-support/python2.5/rdiff_backup/Rdiff.pyt   get_signature   s
     	c         C   s4   |  d j  o d Sn t  t |  d ƒ d ƒ d Sd S(   sè   Return a reasonable block size to use on files of length file_len

	If the block size is too big, deltas will be bigger than is
	necessary.  If the block size is too small, making deltas and
	patching can take a really long time.

	i   i@   g      à?i   N(   t   longt   pow(   t   file_len(    (    s7   /var/lib/python-support/python2.5/rdiff_backup/Rdiff.pyR   !   s     c         C   s3   t  i d | i f d ƒ t i |  | i d ƒ ƒ S(   s0   Like get_delta but signature is in a file objects)   Getting delta of %s with signature streami   R    (   R   R   t   pathR   t	   DeltaFileR   (   t   sig_fileobjt   rp_new(    (    s7   /var/lib/python-support/python2.5/rdiff_backup/Rdiff.pyt   get_delta_sigfileobj-   s    c         C   sE   t  i d | i |  i ƒ  f d ƒ t i |  i d ƒ | i d ƒ ƒ S(   s6   Take signature rp and new rp, return delta file objects%   Getting delta of %s with signature %si   R    (   R   R   R   R   R   R   R   (   t   rp_signatureR   (    (    s7   /var/lib/python-support/python2.5/rdiff_backup/Rdiff.pyt   get_delta_sigrp2   s    	c         C   sN   t  i d | i |  i ƒ  f d ƒ t i |  i d ƒ t i | i d ƒ ƒ ƒ S(   s:   Like above but also calculate hash of new as close() values1   Getting delta (with hash) of %s with signature %si   R    (	   R   R   R   R   R   R   R   t   hasht   FileWrapper(   R   R   (    (    s7   /var/lib/python-support/python2.5/rdiff_backup/Rdiff.pyt   get_delta_sigrp_hash8   s    	c         C   s[   t  i d |  i | i | i f d ƒ t i t |  ƒ | i d ƒ ƒ } | i | | ƒ d S(   s+   Write rdiff delta which brings basis to news   Writing delta %s from %s -> %si   R    N(   R   R   R   R   R   R   R   t   write_from_fileobj(   t   basist   newt   deltat   compresst	   deltafile(    (    s7   /var/lib/python-support/python2.5/rdiff_backup/Rdiff.pyt   write_delta@   s    	!c         C   sC   t  i t i |  | ƒ | ƒ |  i ƒ  o | i ƒ  p t ‚ d S(   sA   Write patched file to out_fp given input fps.  Closes input filesN(   t   rpatht   copyfileobjR   t   PatchedFilet   closet   AssertionError(   t   basis_fpt   delta_fpt   out_fp(    (    s7   /var/lib/python-support/python2.5/rdiff_backup/Rdiff.pyt   write_patched_fpG   s    c         C   s2   t  i | ƒ } | i |  ƒ } t i | | ƒ | S(   s:   Write fileobj fp to rp by writing to tempfile and renaming(   t   TempFileR   R   R    t   rename(   t   fpR	   t   tft   retval(    (    s7   /var/lib/python-support/python2.5/rdiff_backup/Rdiff.pyt   write_via_tempfileL   s    c         C   sŠ   |  i  t i j p t ‚ | o | i d d ƒ } n | i d ƒ } t i |  i d ƒ | ƒ } | o | i | ƒ Sn t | |  ƒ Sd S(   s5  Patch routine that must be run locally, writes to outrp

	This should be run local to rp_basis because it needs to be a real
	file (librsync may need to seek around in it).  If outrp is None,
	patch rp_basis instead.

	The return value is the close value of the delta, so it can be
	used to produce hashes.

	R    i   N(	   t   connt   Globalst   local_connectionR$   R   R   R"   R   R.   (   t   rp_basist   rp_deltat   outrpt   delta_compressedR   t	   patchfile(    (    s7   /var/lib/python-support/python2.5/rdiff_backup/Rdiff.pyt   patch_localS   s      c         C   s…   | i  t i j p t ‚ |  i  i i t | ƒ |  i d ƒ ƒ } t i | i d ƒ | ƒ } | o | i	 | ƒ n t
 | | ƒ d S(   s@   Write rpnew == rpin using rpout as basis.  rpout and rpnew localR    N(   R/   R0   R1   R$   R   R   R   R   R"   R   R.   (   t   rpint   rpoutt   rpnewR   t   patched_file(    (    s7   /var/lib/python-support/python2.5/rdiff_backup/Rdiff.pyt
   copy_locale   s     (   t   __doc__t   osR   R0   R   t   staticR)   R    R   t   NoneR   R   R   R   R   R   R(   R.   R7   R<   (    (    (    s7   /var/lib/python-support/python2.5/rdiff_backup/Rdiff.pys   <module>   s   H						