def _substitute(self, template_string): """Replace path aliases with real paths.""" if template_string is None: logger.warning("No template string given") return "" replacements = { "GAMEDIR": self.target_path, "CACHE": self.cache_path, "HOME": os.path.expanduser("~"), "STEAM_DATA_DIR": steam.steam().steam_data_dir, "DISC": self.game_disc, "USER": os.getenv("USER"), "INPUT": self._get_last_user_input(), "VERSION": self.installer.version, "RESOLUTION": "x".join(self.current_resolution), "RESOLUTION_WIDTH": self.current_resolution[0], "RESOLUTION_HEIGHT": self.current_resolution[1], "WINEBIN": self.get_wine_path(), } replacements.update(self.installer.variables) # Add 'INPUT_<id>' replacements for user inputs with an id for input_data in self.user_inputs: alias = input_data["alias"] if alias: replacements[alias] = input_data["value"] replacements.update(self.game_files) if str(template_string).replace("-", "_") in self.game_files: template_string = template_string.replace("-", "_") return system.substitute(template_string, replacements)
def _substitute(self, template_string): """Replace path aliases with real paths.""" if str(template_string).lower() == 'true': return True if str(template_string).lower() == 'false': return False replacements = { "GAMEDIR": self.target_path, "CACHE": self.cache_path, "HOME": os.path.expanduser("~"), "STEAM_DATA_DIR": steam.steam().steam_data_dir, "DISC": self.game_disc, "USER": os.getenv('USER'), "INPUT": self._get_last_user_input(), "VERSION": self.version, } # Add 'INPUT_<id>' replacements for user inputs with an id for input_data in self.user_inputs: alias = input_data['alias'] if alias: replacements[alias] = input_data['value'] replacements.update(self.game_files) return system.substitute(template_string, replacements)
def _substitute(self, template_string): """ Replace path aliases with real paths """ replacements = { "GAMEDIR": self.target_path, "CACHE": settings.CACHE_DIR, "HOME": os.path.expanduser("~") } replacements.update(self.game_files) return substitute(template_string, replacements)
def _substitute(self, template_string): """Replace path aliases with real paths.""" if template_string is None: logger.warning("No template string given") return "" if str(template_string).replace("-", "_") in self.game_files: template_string = template_string.replace("-", "_") return system.substitute(template_string, self._get_string_replacements())
def _substitute(self, template_string): """ Replace path aliases with real paths """ replacements = { "GAMEDIR": self.target_path, "CACHE": settings.CACHE_DIR, "HOME": os.path.expanduser("~"), "DISC": self.game_disc } replacements.update(self.game_files) return substitute(template_string, replacements)
def _substitute(self, template_string): """Replace path aliases with real paths.""" replacements = { "GAMEDIR": self.target_path, "CACHE": self.cache_path, "HOME": os.path.expanduser("~"), "DISC": self.game_disc, "USER": os.getenv('USER'), "INPUT": self._get_last_user_input(), } # Add 'INPUT_<id>' replacements for user inputs with an id for input_data in self.user_inputs: alias = input_data['alias'] if alias: replacements[alias] = input_data['value'] replacements.update(self.game_files) return system.substitute(template_string, replacements)
def _substitute(self, template_string): """Replace path aliases with real paths.""" replacements = { "GAMEDIR": self.target_path, "CACHE": settings.CACHE_DIR, "HOME": os.path.expanduser("~"), "DISC": self.game_disc, "USER": os.getenv('USER'), "INPUT": self._get_last_user_input(), } # Add 'INPUT_<id>' replacements for user inputs with an id for input_data in self.user_inputs: alias = input_data['alias'] if alias: replacements[alias] = input_data['value'] replacements.update(self.game_files) return system.substitute(template_string, replacements)
def _substitute(self, template_string): """Replace path aliases with real paths.""" replacements = { "GAMEDIR": self.target_path, "CACHE": self.cache_path, "HOME": os.path.expanduser("~"), "STEAM_DATA_DIR": steam.steam().steam_data_dir, "DISC": self.game_disc, "USER": os.getenv("USER"), "INPUT": self._get_last_user_input(), "VERSION": self.version, "RESOLUTION": "x".join(self.current_resolution), "RESOLUTION_WIDTH": self.current_resolution[0], "RESOLUTION_HEIGHT": self.current_resolution[1], } # Add 'INPUT_<id>' replacements for user inputs with an id for input_data in self.user_inputs: alias = input_data["alias"] if alias: replacements[alias] = input_data["value"] replacements.update(self.game_files) return system.substitute(template_string, replacements)
def test_file_ids_are_substitued(self): fileid = '${foo-bar}' _files = {'foo-bar': "/foo/bar"} self.assertEqual(system.substitute(fileid, _files), "/foo/bar")
def test_can_sub_game_files_with_dashes_in_key(self): replacements = {'steam-data': '/tmp'} self.assertEqual(system.substitute('--path=$steam-data', replacements), '--path=/tmp')
def test_file_ids_are_substitued(self): fileid = '${foo-bar}' _files = { 'foo-bar': "/foo/bar" } self.assertEqual(system.substitute(fileid, _files), "/foo/bar")
def test_can_sub_game_files_with_dashes_in_key(self): replacements = {"steam-data": "/tmp"} self.assertEqual(system.substitute("--path=$steam-data", replacements), "--path=/tmp")