# Path: kano_profile/apps.py
# def load_app_state_variable(app_name, variable):
#     data = load_app_state(app_name)
#     if variable in data:
#         return data[variable]
# 
# def save_app_state_variable(app_name, variable, value):
#     """ Save a state variable to the user's Kano profile.
# 
#         :param app_name: The application that this variable is associated with.
#         :type app_name: str
#         :param variable: The name of the variable.
#         :type data: str
#         :param value: The variable data to be stored.
#         :type value: any
#     """
# 
#     msg = "save_app_state_variable {} {} {}".format(app_name, variable, value)
#     logger.debug(msg)
# 
#     data = load_app_state(app_name)
#     data[variable] = value
# 
#     save_app_state(app_name, data)


from kano_profile.apps import load_app_state_variable, save_app_state_variable
# cache_functions.py
#
# Copyright (C) 2015-2016 Kano Computing Ltd.
# License: http://www.gnu.org/licenses/gpl-2.0.txt GNU General Public License v2
#




def cache_data(category, value):
    if category in ['username', 'email']:
        save_app_state_variable('kano-avatar-registration', category, value)


def get_cached_data(category):

# Path: kano_profile/apps.py
# def load_app_state_variable(app_name, variable):
#     data = load_app_state(app_name)
#     if variable in data:
#         return data[variable]
# 
# def save_app_state_variable(app_name, variable, value):
#     """ Save a state variable to the user's Kano profile.
# 
#         :param app_name: The application that this variable is associated with.
#         :type app_name: str
#         :param variable: The name of the variable.
#         :type data: str
#         :param value: The variable data to be stored.
#         :type value: any
#     """
# 
#     msg = "save_app_state_variable {} {} {}".format(app_name, variable, value)
#     logger.debug(msg)
# 
#     data = load_app_state(app_name)
#     data[variable] = value
# 
#     save_app_state(app_name, data)


# Path: kano_registration_gui/cache_functions.py
from kano_profile.apps import load_app_state_variable, save_app_state_variable

# cache_functions.py
#
# Copyright (C) 2015-2016 Kano Computing Ltd.
# License: http://www.gnu.org/licenses/gpl-2.0.txt GNU General Public License v2
#




def cache_data(category, value):
    if category in ['username', 'email']:
        save_app_state_variable('kano-avatar-registration', category, value)


def get_cached_data(category):

    return load_app_state_variable('kano-avatar-registration', category)