#NEWLINE# def _parseHashEntry( self , hash_entry ) : #NEWLINE# #INDENT# 'Parse full-sized hash entry' #NEWLINE# hashes = { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } #NEWLINE# metadata = { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } #NEWLINE# while True : #NEWLINE# #INDENT# if ( not hash_entry ) : #NEWLINE# #INDENT# break #NEWLINE# #UNINDENT# has_metadata = False #NEWLINE# ( header , hash_entry ) = hash_entry . split ( '\n' , 1 ) #NEWLINE# opts = header . split ( ':' ) #NEWLINE# if ( len ( opts ) == 4 ) : #NEWLINE# #INDENT# if ( opts [ 3 ] == 'm' ) : #NEWLINE# #INDENT# has_metadata = True #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# raise RuntimeError ( ( 'Failed to parse full hash entry header "%s"' % header ) ) #NEWLINE# #UNINDENT# #UNINDENT# list_name = opts [ 0 ] #NEWLINE# entry_len = int ( opts [ 1 ] ) #NEWLINE# entry_count = int ( opts [ 2 ] ) #NEWLINE# hash_strings = [ ] #NEWLINE# metadata_strings = [ ] #NEWLINE# for i in xrange ( entry_count ) : #NEWLINE# #INDENT# hash_string = hash_entry [ ( entry_len * i ) : ( entry_len * ( i + 1 ) ) ] #NEWLINE# hash_strings . append ( hash_string ) #NEWLINE# #UNINDENT# hash_entry = hash_entry [ ( entry_count * entry_len ) : ] #NEWLINE# if has_metadata : #NEWLINE# #INDENT# for i in xrange ( entry_count ) : #NEWLINE# #INDENT# ( next_metadata_len , hash_entry ) = hash_entry . split ( '\n' , 1 ) #NEWLINE# next_metadata_len = int ( next_metadata_len ) #NEWLINE# metadata_str = hash_entry [ : next_metadata_len ] #NEWLINE# metadata_strings . append ( metadata_str ) #NEWLINE# hash_entry = hash_entry [ next_metadata_len : ] #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# if hash_entry : #NEWLINE# #INDENT# raise RuntimeError ( 'Hash length does not match header declaration (no metadata)' ) #NEWLINE# #UNINDENT# #UNINDENT# hashes [ list_name ] = hash_strings #NEWLINE# metadata [ list_name ] = metadata_strings #NEWLINE# #UNINDENT# return ( hashes , metadata )