#NEWLINE# def _CatchUp( self , bytes_to_read ) : #NEWLINE# #INDENT# 'Catches up hashes, but does not return data and uses little memory.\n\n    Before calling this function, digesters_current_mark should be updated\n    to the current location of the original stream and the self._digesters\n    should be current to that point (but no further).\n\n    Args:\n      bytes_to_read: Number of bytes to catch up from the original stream.\n    ' #NEWLINE# if ( self . _orig_fp . tell ( ) != self . _digesters_current_mark ) : #NEWLINE# #INDENT# raise CommandException ( ( 'Invalid mark when catching up hashes. Stream position %s, hash position %s' % ( self . _orig_fp . tell ( ) , self . _digesters_current_mark ) ) ) #NEWLINE# #UNINDENT# for alg in self . _digesters : #NEWLINE# #INDENT# if ( self >= MIN_SIZE_COMPUTE_LOGGING ) : #NEWLINE# #INDENT# self . _logger . info ( 'Catching up %s for %s...' , alg , self . _src_url . url_string ) #NEWLINE# #UNINDENT# self . _digesters_previous [ alg ] = self . _digesters [ alg ] . copy ( ) #NEWLINE# #UNINDENT# self . _digesters_previous_mark = self . _digesters_current_mark #NEWLINE# bytes_remaining = bytes_to_read #NEWLINE# bytes_this_round = min ( bytes_remaining , TRANSFER_BUFFER_SIZE ) #NEWLINE# while bytes_this_round : #NEWLINE# #INDENT# data = self . _orig_fp . read ( bytes_this_round ) #NEWLINE# bytes_remaining -= bytes_this_round #NEWLINE# for alg in self . _digesters : #NEWLINE# #INDENT# self . _digesters [ alg ] . update ( data ) #NEWLINE# #UNINDENT# bytes_this_round = min ( bytes_remaining , TRANSFER_BUFFER_SIZE ) #NEWLINE# #UNINDENT# self . _digesters_current_mark += bytes_to_read