Пример #1
0
 def test_strips_extra_commas(self):
     string = ", , , ,, ,,,,quake,  quake-1,quake-steam | quake-gog|quake-humble |||| , |, | ,|,| ,  "
     dependencies = strings.unpack_dependencies(string)
     self.assertEqual(
         dependencies,
         ["quake", "quake-1", ("quake-steam", "quake-gog", "quake-humble")],
     )
Пример #2
0
 def _check_dependency(self):
     """When a game is a mod or an extension of another game, check that the base
     game is installed.
     If the game is available, install the game in the base game folder.
     The first game available listed in the dependencies is the one picked to base
     the installed on.
     """
     if self.extends:
         dependencies = [self.extends]
     else:
         dependencies = strings.unpack_dependencies(self.requires)
     error_message = "You need to install {} before"
     for index, dependency in enumerate(dependencies):
         if isinstance(dependency, tuple):
             dependency_choices = [
                 self._get_installed_dependency(dep) for dep in dependency
             ]
             installed_games = [dep for dep in dependency_choices if dep]
             if not installed_games:
                 raise ScriptingError(
                     error_message.format(' or '.join(dependency)))
             if index == 0:
                 self.target_path = installed_games[0]['directory']
                 self.requires = installed_games[0]['installer_slug']
         else:
             game = self._get_installed_dependency(dependency)
             if not game:
                 raise ScriptingError(error_message.format(dependency))
             if index == 0:
                 self.target_path = game['directory']
                 self.requires = game['installer_slug']
Пример #3
0
 def test_dependency_options(self):
     string = "quake,  quake-1,quake-steam | quake-gog|quake-humble   "
     dependencies = strings.unpack_dependencies(string)
     self.assertEqual(
         dependencies,
         ["quake", "quake-1", ("quake-steam", "quake-gog", "quake-humble")],
     )
Пример #4
0
 def _check_dependency(self):
     """When a game is a mod or an extension of another game, check that the base
     game is installed.
     If the game is available, install the game in the base game folder.
     The first game available listed in the dependencies is the one picked to base
     the installed on.
     """
     if self.installer.extends:
         dependencies = [self.installer.extends]
     else:
         dependencies = unpack_dependencies(self.installer.requires)
     error_message = _("You need to install {} before")
     for index, dependency in enumerate(dependencies):
         if isinstance(dependency, tuple):
             installed_games = [
                 dep for dep in
                 [self._get_game_dependency(dep) for dep in dependency]
                 if dep
             ]
             if not installed_games:
                 if len(dependency) == 1:
                     raise MissingGameDependency(slug=dependency)
                 raise ScriptingError(
                     error_message.format(_(" or ").join(dependency)))
             if index == 0:
                 self.target_path = installed_games[0]["directory"]
                 self.requires = installed_games[0]["installer_slug"]
         else:
             game = self._get_game_dependency(dependency)
             if not game:
                 raise MissingGameDependency(slug=dependency)
             if index == 0:
                 self.target_path = game["directory"]
                 self.requires = game["installer_slug"]
Пример #5
0
 def _check_dependency(self):
     """When a game is a mod or an extension of another game, check that the base
     game is installed.
     If the game is available, install the game in the base game folder.
     The first game available listed in the dependencies is the one picked to base
     the installed on.
     """
     if self.extends:
         dependencies = [self.extends]
     else:
         dependencies = unpack_dependencies(self.requires)
     error_message = "You need to install {} before"
     for index, dependency in enumerate(dependencies):
         if isinstance(dependency, tuple):
             installed_games = [
                 dep for dep in [
                     self._get_installed_dependency(dep) for dep in dependency
                 ]
                 if dep
             ]
             if not installed_games:
                 if len(dependency) == 1:
                     raise MissingGameDependency(slug=dependency)
                 else:
                     raise ScriptingError(error_message.format(" or ".join(dependency)))
             if index == 0:
                 self.target_path = installed_games[0]["directory"]
                 self.requires = installed_games[0]["installer_slug"]
         else:
             game = self._get_installed_dependency(dependency)
             if not game:
                 raise MissingGameDependency(slug=dependency)
             if index == 0:
                 self.target_path = game["directory"]
                 self.requires = game["installer_slug"]
Пример #6
0
    def _check_binary_dependencies(self):
        """Check if all required binaries are installed on the system.

        This reads a `require-binaries` entry in the script, parsed the same way as
        the `requires` entry.
        """
        binary_dependencies = unpack_dependencies(self.installer.script.get("require-binaries"))
        for dependency in binary_dependencies:
            if isinstance(dependency, tuple):
                installed_binaries = {
                    dependency_option: bool(system.find_executable(dependency_option))
                    for dependency_option in dependency
                }
                if not any(installed_binaries.values()):
                    raise ScriptingError("This installer requires %s on your system" % " or ".join(dependency))
            else:
                if not system.find_executable(dependency):
                    raise ScriptingError("This installer requires %s on your system" % dependency)
Пример #7
0
    def _check_binary_dependencies(self):
        """Check if all required binaries are installed on the system.

        This reads a `require-binaries` entry in the script, parsed the same way as
        the `requires` entry.
        """
        binary_dependencies = unpack_dependencies(self.script.get("require-binaries"))
        for dependency in binary_dependencies:
            if isinstance(dependency, tuple):
                installed_binaries = {
                    dependency_option: bool(system.find_executable(dependency_option))
                    for dependency_option in dependency
                }
                if not any(installed_binaries.values()):
                    raise ScriptingError(
                        "This installer requires %s on your system"
                        % " or ".join(dependency)
                    )
            else:
                if not system.find_executable(dependency):
                    raise ScriptingError(
                        "This installer requires %s on your system" % dependency
                    )
Пример #8
0
 def test_strips_extra_commas(self):
     string = ', , , ,, ,,,,quake,  quake-1,quake-steam | quake-gog|quake-humble |||| , |, | ,|,| ,  '
     dependencies = strings.unpack_dependencies(string)
     self.assertEqual(
         dependencies,
         ['quake', 'quake-1', ('quake-steam', 'quake-gog', 'quake-humble')])
Пример #9
0
 def test_dependency_options(self):
     string = 'quake,  quake-1,quake-steam | quake-gog|quake-humble   '
     dependencies = strings.unpack_dependencies(string)
     self.assertEqual(
         dependencies,
         ['quake', 'quake-1', ('quake-steam', 'quake-gog', 'quake-humble')])
Пример #10
0
 def test_multiple_dependencies(self):
     string = 'quake,  quake-1,quake-steam, quake-gog   '
     dependencies = strings.unpack_dependencies(string)
     self.assertEqual(dependencies,
                      ['quake', 'quake-1', 'quake-steam', 'quake-gog'])
Пример #11
0
 def test_single_dependency(self):
     string = 'quake'
     dependencies = strings.unpack_dependencies(string)
     self.assertEqual(dependencies, ['quake'])
Пример #12
0
 def test_single_dependency(self):
     string = 'quake'
     dependencies = strings.unpack_dependencies(string)
     self.assertEqual(dependencies, ['quake'])
Пример #13
0
 def test_multiple_dependencies(self):
     string = "quake,  quake-1,quake-steam, quake-gog   "
     dependencies = strings.unpack_dependencies(string)
     self.assertEqual(dependencies,
                      ["quake", "quake-1", "quake-steam", "quake-gog"])
Пример #14
0
 def test_single_dependency(self):
     string = "quake"
     dependencies = strings.unpack_dependencies(string)
     self.assertEqual(dependencies, ["quake"])
Пример #15
0
 def test_strips_extra_commas(self):
     string = ', , , ,, ,,,,quake,  quake-1,quake-steam | quake-gog|quake-humble |||| , |, | ,|,| ,  '
     dependencies = strings.unpack_dependencies(string)
     self.assertEqual(dependencies, ['quake', 'quake-1', ('quake-steam', 'quake-gog', 'quake-humble')])
Пример #16
0
 def test_dependency_options(self):
     string = 'quake,  quake-1,quake-steam | quake-gog|quake-humble   '
     dependencies = strings.unpack_dependencies(string)
     self.assertEqual(dependencies, ['quake', 'quake-1', ('quake-steam', 'quake-gog', 'quake-humble')])
Пример #17
0
 def test_multiple_dependencies(self):
     string = 'quake,  quake-1,quake-steam, quake-gog   '
     dependencies = strings.unpack_dependencies(string)
     self.assertEqual(dependencies, ['quake', 'quake-1', 'quake-steam', 'quake-gog'])