Coverage for lutris.util.steam : 25%

Hot-keys on this page
r m x p toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
userconfig = OrderedDict() userconfig['name'] = name userconfig['gameid'] = appid
appstate = OrderedDict() appstate['appID'] = appid appstate['Universe'] = "1" appstate['StateFlags'] = "4" appstate['installdir'] = name appstate['UserConfig'] = userconfig return {'AppState': appstate}
""" Given a steam configuration steam, parse the content and return it as a dict. """ line = " " while line: line = steam_config_file.readline() if not line or line.strip() == "}": return config line_elements = line.strip().split("\"") if len(line_elements) == 3: key = line_elements[1] steam_config_file.readline() # skip '{' config[key] = vdf_parse(steam_config_file, {}) else: config[line_elements[1]] = line_elements[3] return config
""" Convert a dictionnary to Steam config file format. """ else:
vdf_data = to_vdf(config) with open(vdf_path, "w") as vdf_file: vdf_file.write(vdf_data)
config_filename = os.path.join(path_prefix, 'config/config.vdf') if not os.path.exists(config_filename): return with open(config_filename, "r") as steam_config_file: config = vdf_parse(steam_config_file, {}) return config['InstallConfigStore']['Software']['Valve']['Steam']
""" Given a steam config, return path for game 'appid' """ if not config or 'apps' not in config: return False game_config = config["apps"].get(appid) if not game_config: return False if game_config.get('HasAllLocalContent'): installdir = game_config['installdir'].replace("\\\\", "/") if not installdir: return False if installdir.startswith('C'): installdir = os.path.join(os.path.expanduser('~'), '.wine/drive_c', installdir[3:]) elif installdir[1] == ':': # Trim Windows path installdir = installdir[2:] logger.debug("Steam game found at %s" % installdir) if os.path.exists(installdir): return installdir elif os.path.exists(installdir.replace('steamapps', 'SteamApps')): return installdir.replace('steamapps', 'SteamApps') else: logger.debug("Path %s not found" % installdir) return False
appmanifest_path = os.path.join(steam_path, "SteamApps/appmanifest_%s.acf" % appid) if not os.path.exists(appmanifest_path): logger.debug("No appmanifest file %s" % appmanifest_path) return
with open(appmanifest_path, "r") as appmanifest_file: config = vdf_parse(appmanifest_file, {}) installdir = config.get('AppState', {}).get('installdir') install_path = os.path.join(steam_path, "SteamApps/common/%s" % installdir) if installdir and os.path.exists(install_path): return install_path |