def initialize_config(self): """Init and load config files""" self.game_level = {"system": {}, self.runner_slug: {}, "game": {}} self.runner_level = {"system": {}, self.runner_slug: {}} self.system_level = {"system": {}} self.game_level.update(read_yaml_from_file(self.game_config_path)) self.runner_level.update(read_yaml_from_file(self.runner_config_path)) self.system_level.update(read_yaml_from_file(self.system_config_path)) self.update_cascaded_config() self.update_raw_config()
def __init__(self, runner_slug=None, game_config_id=None, level=None): self.game_config_id = game_config_id if runner_slug: self.runner_slug = str(runner_slug) else: self.runner_slug = runner_slug # Cascaded config sections (for reading) self.game_config = {} self.runner_config = {} self.system_config = {} # Raw (non-cascaded) sections (for writing) self.raw_game_config = {} self.raw_runner_config = {} self.raw_system_config = {} self.raw_config = {} # Set config level self.level = level if not level: if game_config_id: self.level = "game" elif runner_slug: self.level = "runner" else: self.level = "system" # Init and load config files self.game_level = {"system": {}, self.runner_slug: {}, "game": {}} self.runner_level = {"system": {}, self.runner_slug: {}} self.system_level = {"system": {}} self.game_level.update(read_yaml_from_file(self.game_config_path)) self.runner_level.update(read_yaml_from_file(self.runner_config_path)) self.system_level.update(read_yaml_from_file(self.system_config_path)) self.update_cascaded_config() self.update_raw_config()
def migrate(): config_dir = os.path.join(settings.CONFIG_DIR, "games") for config_file in os.listdir(config_dir): config_path = os.path.join(config_dir, config_file) config_data = read_yaml_from_file(config_path) if "wine" not in config_data and "winesteam" not in config_data: continue if "wine" in config_data: runner = "wine" else: runner = "winesteam" if "Desktop" in config_data[runner]: desktop_value = config_data[runner]["Desktop"] if desktop_value == "off": config_data[runner]["Desktop"] = False else: config_data[runner]["Desktop"] = True if "Desktop_res" in config_data[runner]: desktop_res_value = config_data[runner].pop("Desktop_res") config_data[runner]["WineDesktop"] = desktop_res_value config.write_yaml_to_file(config_path, config_data)