def _decode_value(stored_value, flags, do_unpickle):
 assert isinstance(stored_value, str)
 assert isinstance(flags, (int, long))
 type_number = (flags & FLAG_TYPE_MASK)
 value = stored_value
 if (type_number == TYPE_STR):
  return value
 elif (type_number == TYPE_UNICODE):
  return value.decode('utf-8')
 elif (type_number == TYPE_PICKLED):
  return do_unpickle(value)
 elif (type_number == TYPE_BOOL):
  return bool(int(value))
 elif (type_number == TYPE_INT):
  return int(value)
 elif (type_number == TYPE_LONG):
  return long(value)
 else:
  assert False, 'Unknown stored type'
 assert False, "Shouldn't get here."

def _decode_value ( stored_value , flags , do_unpickle ) : assert isinstance ( stored_value , str ) assert isinstance ( flags , ( int , long ) ) type_number = ( flags & FLAG_TYPE_MASK ) value = stored_value if ( type_number == TYPE_STR ) : return value elif ( type_number == TYPE_UNICODE ) : return value . decode ( 'utf-8' ) elif ( type_number == TYPE_PICKLED ) : return do_unpickle ( value ) elif ( type_number == TYPE_BOOL ) : return bool ( int ( value ) ) elif ( type_number == TYPE_INT ) : return int ( value ) elif ( type_number == TYPE_LONG ) : return long ( value ) else : assert False , 'Unknown stored type' assert False , "Shouldn't get here."
utility function for decoding values retrieved from memcache .