def apply_default_settings(cls): cls.settings_dict = OrderedDict() # probably best to keep this ordered # noinspection PyTypeChecker for member in DefaultSettings: # convert default settings to ordered dict cls.settings_dict[str(member.name).lower()] = member.value FileTree.write_file(cls.settings_dict, AppMeta.SETTINGS_PATH.value ) # json.dumps handles OrderedDicts fine cls.load_settings()
def create_game_dict( ): # creates alphabetized OrderedDict of all games from games dir if FileTree.check_if_empty(AppMeta.DIRS.value["games"], file_type="*.json"): return None game_dict = OrderedDict() for file in FileTree.dir_contents(AppMeta.DIRS.value["games"], file_type="*.json"): file_json = FileTree.read_file(file) game_title = file_json["game_title"] game_path = file_json["game_path"] banner_name = file_json["banner_name"] platform = file_json["platform"] game_dict[game_title] = { "game_title": game_title, "game_path": game_path, "banner_name": banner_name, "platform": platform } return game_dict
def do_setup(): path_list = list(AppMeta.DIRS.value.values()) FileTree.create_dirs(path_list)
def open_manifest(cls, theme_manifest): return FileTree.read_file(theme_manifest)
def write_settings(cls): FileTree.write_file(cls.settings_dict, AppMeta.settings_path)
def load_settings( cls): # binds settings_dict to the settings file only once created cls.settings_dict = FileTree.read_file(AppMeta.SETTINGS_PATH.value)
def do_dump(self): FileTree.dump(self.string_to_dump, AppMeta.LOG_PATH.value, "a")