# Path: src/helper.py
# def validate_function_key(slot_key):
# def get_output_folder():
# def get_models_folder():
# def get_dataset_folder():
# def get_home_folder():
# def pickle_object(data, name, directory=get_output_folder()):
# def generate_img_key(image):
# def get_tensor(image):
# def get_output_vector(presses):
# def get_key_state_from_vector(vector):


import logging
import pyautogui
from src import helper


logger = logging.getLogger(__name__)


def save_dolphin_state(slot_key):
    """ Save the current state of a running Dolphin emulator.

    Args:
        slot_key: Keyboard key corresponding to the Dolphin save state slot
            to save the current state of the emulator to.
    """
    try:
        helper.validate_function_key(slot_key)
        pyautogui.keyDown('shift')
        pyautogui.keyDown(slot_key)
        pyautogui.keyUp(slot_key)
        pyautogui.keyUp('shift')
    except (AssertionError, TypeError):
        logger.exception("Error saving state {}:".format(slot_key))


def load_dolphin_state(slot_key):
    """ Load a saved save state to a running Dolphin emulator.

    Args:
        slot_key: Keyboard key corresponding to the Dolphin save state slot
            to load from in the running Dolphin emulator.
    """
    try:

# Path: src/helper.py
# def validate_function_key(slot_key):
# def get_output_folder():
# def get_models_folder():
# def get_dataset_folder():
# def get_home_folder():
# def pickle_object(data, name, directory=get_output_folder()):
# def generate_img_key(image):
# def get_tensor(image):
# def get_output_vector(presses):
# def get_key_state_from_vector(vector):


# Path: src/dp_states.py
import logging
import pyautogui
from src import helper



logger = logging.getLogger(__name__)


def save_dolphin_state(slot_key):
    """ Save the current state of a running Dolphin emulator.

    Args:
        slot_key: Keyboard key corresponding to the Dolphin save state slot
            to save the current state of the emulator to.
    """
    try:
        helper.validate_function_key(slot_key)
        pyautogui.keyDown('shift')
        pyautogui.keyDown(slot_key)
        pyautogui.keyUp(slot_key)
        pyautogui.keyUp('shift')
    except (AssertionError, TypeError):
        logger.exception("Error saving state {}:".format(slot_key))


def load_dolphin_state(slot_key):
    """ Load a saved save state to a running Dolphin emulator.

    Args:
        slot_key: Keyboard key corresponding to the Dolphin save state slot
            to load from in the running Dolphin emulator.
    """
    try:

        helper.validate_function_key(slot_key)