Exemplo n.º 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")],
     )
Exemplo n.º 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']
Exemplo n.º 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")],
     )
Exemplo n.º 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"]
Exemplo n.º 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"]
Exemplo n.º 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)
Exemplo n.º 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
                    )
Exemplo n.º 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')])
Exemplo n.º 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')])
Exemplo n.º 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'])
Exemplo n.º 11
0
 def test_single_dependency(self):
     string = 'quake'
     dependencies = strings.unpack_dependencies(string)
     self.assertEqual(dependencies, ['quake'])
Exemplo n.º 12
0
 def test_single_dependency(self):
     string = 'quake'
     dependencies = strings.unpack_dependencies(string)
     self.assertEqual(dependencies, ['quake'])
Exemplo n.º 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"])
Exemplo n.º 14
0
 def test_single_dependency(self):
     string = "quake"
     dependencies = strings.unpack_dependencies(string)
     self.assertEqual(dependencies, ["quake"])
Exemplo n.º 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')])
Exemplo n.º 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')])
Exemplo n.º 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'])