コード例 #1
0
 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)
コード例 #2
0
ファイル: interpreter.py プロジェクト: Tom-Todd/lutris
    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)
コード例 #3
0
ファイル: installer.py プロジェクト: nsteenv/lutris
 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)
コード例 #4
0
ファイル: interpreter.py プロジェクト: tannisroot/lutris
 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())
コード例 #5
0
 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)
コード例 #6
0
    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)
コード例 #7
0
ファイル: interpreter.py プロジェクト: prettyv/lutris
    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)
コード例 #8
0
    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)
コード例 #9
0
    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)
コード例 #10
0
 def test_file_ids_are_substitued(self):
     fileid = '${foo-bar}'
     _files = {'foo-bar': "/foo/bar"}
     self.assertEqual(system.substitute(fileid, _files), "/foo/bar")
コード例 #11
0
ファイル: test_utils.py プロジェクト: yunusem/lutris
 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')
コード例 #12
0
ファイル: test_utils.py プロジェクト: ERIIX/lutris
 def test_file_ids_are_substitued(self):
     fileid = '${foo-bar}'
     _files = {
         'foo-bar': "/foo/bar"
     }
     self.assertEqual(system.substitute(fileid, _files), "/foo/bar")
コード例 #13
0
ファイル: test_utils.py プロジェクト: sourcery-ai-bot/lutris
 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")
コード例 #14
0
ファイル: test_utils.py プロジェクト: Ryochan7/lutris
 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')