#NEWLINE# def _decode_value( stored_value , flags , do_unpickle ) : #NEWLINE# #INDENT# 'Utility function for decoding values retrieved from memcache.\n\n  Args:\n    stored_value: The value as a non-unicode string that was stored.\n    flags: An integer with bits set from the FLAG_* constants in this file\n      that indicate the encoding of the key and value.\n    do_unpickle: Callable that takes a non-unicode string object that contains\n      a pickled object and returns the pickled object.\n\n  Returns:\n    The original object that was stored, be it a normal string, a unicode\n    string, int, long, or a Python object that was pickled.\n\n  Raises:\n    pickle.UnpicklingError: If the value could not be unpickled.\n  ' #NEWLINE# assert isinstance ( stored_value , str ) #NEWLINE# assert isinstance ( flags , ( int , long ) ) #NEWLINE# type_number = ( flags & FLAG_TYPE_MASK ) #NEWLINE# value = stored_value #NEWLINE# if ( type_number == TYPE_STR ) : #NEWLINE# #INDENT# return value #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( type_number == TYPE_UNICODE ) : #NEWLINE# #INDENT# return value . decode ( 'utf-8' ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( type_number == TYPE_PICKLED ) : #NEWLINE# #INDENT# return do_unpickle ( value ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( type_number == TYPE_BOOL ) : #NEWLINE# #INDENT# return bool ( int ( value ) ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( type_number == TYPE_INT ) : #NEWLINE# #INDENT# return int ( stored_value ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( type_number == TYPE_LONG ) : #NEWLINE# #INDENT# return long ( value ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# assert False , 'Unknown stored type' #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# assert False , "Shouldn't get here."