def read_user_config(): config_filename = search_in_steam_dirs("config/loginusers.vdf") if not system.path_exists(config_filename): return None with open(config_filename, "r") as steam_config_file: config = vdf_parse(steam_config_file, {}) return config
def read_library_folders(steam_data_dir): """Read the Steam Library Folders config and return it as an object""" def get_entry_case_insensitive(library_dict, path): for key, value in library_dict.items(): if key.lower() == path[0].lower(): if len(path) <= 1: return value return get_entry_case_insensitive(library_dict[key], path[1:]) raise KeyError(path[0]) if not steam_data_dir: return None library_filename = os.path.join(steam_data_dir, "config/libraryfolders.vdf") if not system.path_exists(library_filename): return None with open(library_filename, "r", encoding='utf-8') as steam_library_file: library = vdf_parse(steam_library_file, {}) # The contentstatsid key is unused and causes problems when looking for library paths. library["libraryfolders"].pop("contentstatsid") try: return get_entry_case_insensitive(library, ["libraryfolders"]) except KeyError as ex: logger.error("Steam libraryfolders %s is empty: %s", library_filename, ex)
def read_user_config(steam_data_dir): config_filename = os.path.join(steam_data_dir, "config/loginusers.vdf") if not system.path_exists(config_filename): return None with open(config_filename, "r") as steam_config_file: config = vdf_parse(steam_config_file, {}) return config
def __init__(self, appmanifest_path): self.appmanifest_path = appmanifest_path self.steamapps_path, filename = os.path.split(appmanifest_path) self.steamid = re.findall(r"(\d+)", filename)[-1] self.appmanifest_data = {} if path_exists(appmanifest_path): with open(appmanifest_path, "r", encoding='utf-8') as appmanifest_file: self.appmanifest_data = vdf_parse(appmanifest_file, {}) else: logger.error("Path to AppManifest file %s doesn't exist", appmanifest_path)
def read_config(steam_data_dir): """Read the Steam configuration and return it as an object""" config_filename = os.path.join(steam_data_dir, "config/config.vdf") if not system.path_exists(config_filename): return None with open(config_filename, "r") as steam_config_file: config = vdf_parse(steam_config_file, {}) try: return config["InstallConfigStore"]["Software"]["Valve"]["Steam"] except KeyError: try: return config["InstallConfigStore"]["Software"]["valve"]["Steam"] except KeyError as ex: logger.error("Steam config %s is empty: %s", config_filename, ex)
def read_config(steam_data_dir): """Read the Steam configuration and return it as an object""" config_filename = os.path.join(steam_data_dir, "config/config.vdf") if not system.path_exists(config_filename): return None with open(config_filename, "r") as steam_config_file: config = vdf_parse(steam_config_file, {}) try: return config["InstallConfigStore"]["Software"]["Valve"]["Steam"] except KeyError: try: return config["InstallConfigStore"]["Software"]["valve"]["Steam"] except KeyError as ex: logger.error("Steam config %s is empty: %s", config_filename, ex)
def read_config(steam_data_dir): """Read the Steam configuration and return it as an object""" def get_entry_case_insensitive(config_dict, path): for key, _value in config_dict.items(): if key.lower() == path[0].lower(): if len(path) <= 1: return config_dict[key] return get_entry_case_insensitive(config_dict[key], path[1:]) raise KeyError(path[0]) config_filename = os.path.join(steam_data_dir, "config/config.vdf") if not system.path_exists(config_filename): return None with open(config_filename, "r") as steam_config_file: config = vdf_parse(steam_config_file, {}) try: return get_entry_case_insensitive( config, ["InstallConfigStore", "Software", "Valve", "Steam"]) except KeyError as ex: logger.error("Steam config %s is empty: %s", config_filename, ex)