³ò
OÉcIc           @   sy   d  Z  d d k Z e i d ƒ d d k Z d d k Z d d d „  ƒ  YZ d d d „  ƒ  YZ d d	 „ Z d d
 „ Z d S(   s4   Contains a file wrapper that returns a hash on closeiÿÿÿÿNt   ignoret   FileWrapperc           B   s,   e  Z d  Z d „  Z d d „ Z d „  Z RS(   s  Wrapper around a file-like object

	Only use this with files that will be read through in a single
	pass and then closed.  (There is no seek().)  When you close it,
	return value will be a Report.

	Currently this just calculates a sha1sum of the datastream.

	c         C   s%   | |  _  t i ƒ  |  _ d |  _ d  S(   Ni    (   t   fileobjt   shat   newt   sha1t   closed(   t   selfR   (    (    s6   /var/lib/python-support/python2.5/rdiff_backup/hash.pyt   __init__(   s    	iÿÿÿÿc         C   s8   |  i  p t ‚ |  i i | ƒ } |  i i | ƒ | S(   N(   R   t   AssertionErrorR   t   readR   t   update(   R   t   lengtht   buf(    (    s6   /var/lib/python-support/python2.5/rdiff_backup/hash.pyR
   -   s    c         C   s   t  |  i i ƒ  |  i i ƒ  ƒ S(   N(   t   ReportR   t   closeR   t	   hexdigest(   R   (    (    s6   /var/lib/python-support/python2.5/rdiff_backup/hash.pyR   3   s    (   t   __name__t
   __module__t   __doc__R   R
   R   (    (    (    s6   /var/lib/python-support/python2.5/rdiff_backup/hash.pyR      s   		R   c           B   s   e  Z d  Z d „  Z RS(   s*   Hold final information about a byte streamc         C   s   | p t  ‚ | |  _ d  S(   N(   R	   t   sha1_digest(   R   t	   close_valR   (    (    s6   /var/lib/python-support/python2.5/rdiff_backup/hash.pyR   9   s    (   R   R   R   R   (    (    (    s6   /var/lib/python-support/python2.5/rdiff_backup/hash.pyR   7   s   i    c         C   sC   |  i  t i j p t ‚ t |  i d | ƒ ƒ } |  i | ƒ | S(   s'   Return the hex sha1 hash of given rpatht   r(   t   connt   Globalst   local_connectionR	   t   compute_sha1_fpt   opent   set_sha1(   t   rpt
   compressedt   digest(    (    s6   /var/lib/python-support/python2.5/rdiff_backup/hash.pyt   compute_sha1>   s    c         C   s=   t  i } t |  ƒ } x | i | ƒ p Pq q | i ƒ  i S(   s.   Return hex sha1 hash of given file-like object(   R   t	   blocksizeR   R
   R   R   (   t   fpR   R!   t   fw(    (    s6   /var/lib/python-support/python2.5/rdiff_backup/hash.pyR   E   s    	 (    (    (	   R   t   warningst   simplefilterR   R   R   R   R    R   (    (    (    s6   /var/lib/python-support/python2.5/rdiff_backup/hash.pys   <module>   s   