From 14087a3c6c7fe8cdc5212cdf6ce9d0196451a978 Mon Sep 17 00:00:00 2001 From: loathingKernel <142770+loathingKernel@users.noreply.github.com> Date: Tue, 12 Jul 2022 23:47:23 +0300 Subject: [PATCH] Lgndr: Add default implementation for `get_boolean_choice` that returns `False` --- rare/components/tabs/games/import_sync/import_group.py | 7 ++++++- rare/lgndr/api_arguments.py | 4 ++-- rare/lgndr/cli.py | 6 +++--- 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/rare/components/tabs/games/import_sync/import_group.py b/rare/components/tabs/games/import_sync/import_group.py index 90e54314..a19a9ed4 100644 --- a/rare/components/tabs/games/import_sync/import_group.py +++ b/rare/components/tabs/games/import_sync/import_group.py @@ -11,7 +11,7 @@ from PyQt5.QtCore import Qt, QModelIndex, pyqtSignal, QRunnable, QObject, QThrea from PyQt5.QtGui import QStandardItemModel from PyQt5.QtWidgets import QFileDialog, QGroupBox, QCompleter, QTreeView, QHeaderView, qApp, QMessageBox -from lgndr.api_arguments import LgndrImportGameArgs +from rare.lgndr.api_arguments import LgndrImportGameArgs from rare.lgndr.api_exception import LgndrException from rare.shared import LegendaryCLISingleton, LegendaryCoreSingleton, GlobalSignalsSingleton, ApiResultsSingleton from rare.ui.components.tabs.games.import_sync.import_group import Ui_ImportGroup @@ -105,11 +105,16 @@ class ImportWorker(QRunnable): # else: # return err + def get_boolean_choice(self, a0): + choice = QMessageBox.question(None, "Import DLCs?", a0) + return True if choice == QMessageBox.StandardButton.Yes else False + def __import_game(self, app_name: str, path: Path): cli = LegendaryCLISingleton() args = LgndrImportGameArgs( app_path=str(path), app_name=app_name, + get_boolean_choice=self.get_boolean_choice ) try: cli.import_game(args) diff --git a/rare/lgndr/api_arguments.py b/rare/lgndr/api_arguments.py index b3ce7d02..d1328ccd 100644 --- a/rare/lgndr/api_arguments.py +++ b/rare/lgndr/api_arguments.py @@ -25,7 +25,7 @@ class LgndrImportGameArgs: with_dlcs: bool = False yes: bool = False # Rare: Extra arguments - get_boolean_choice: Callable[[str], bool] = get_boolean_choice + get_boolean_choice: Callable[[str], bool] = lambda a0: False @dataclass @@ -70,7 +70,7 @@ class LgndrInstallGameArgs: disable_https: bool = False yes: bool = True # Rare: Extra arguments - get_boolean_choice: Callable[[str], bool] = get_boolean_choice + get_boolean_choice: Callable[[str], bool] = lambda a0: False sdl_prompt: Callable[[str, str], List[str]] = lambda a0, a1: [] verify_stdout: Callable[[int, int, float, float], None] = lambda a0, a1, a2, a3: print( f"Verification progress: {a0}/{a1} ({a2:.01f}%) [{a3:.1f} MiB/s]\t\r" diff --git a/rare/lgndr/cli.py b/rare/lgndr/cli.py index 643b8f79..4bccd8ea 100644 --- a/rare/lgndr/cli.py +++ b/rare/lgndr/cli.py @@ -44,7 +44,6 @@ class LegendaryCLI(legendary.cli.LegendaryCLI): try: return func(self, args, *oargs, **kwargs) except LgndrException as ret: - print(f'Caught exception in wrapped function {ret.message}') raise ret finally: legendary.cli.get_boolean_choice = old_choice @@ -111,7 +110,7 @@ class LegendaryCLI(legendary.cli.LegendaryCLI): if not os.path.exists(repair_file): logger.info('Game has not been verified yet.') if not args.yes: - if not get_boolean_choice(f'Verify "{game.app_name}" now ("no" will abort repair)?'): + if not args.get_boolean_choice(f'Verify "{game.app_name}" now ("no" will abort repair)?'): return try: self.verify_game(args, print_command=False, repair_mode=True, repair_online=args.repair_and_update) @@ -223,7 +222,8 @@ class LegendaryCLI(legendary.cli.LegendaryCLI): self.core.uninstall_tag(old_igame) self.core.install_game(old_igame) - def _handle_postinstall(self, postinstall, igame, yes=False): + @wrapped + def handle_postinstall(self, postinstall, igame, yes=False): super(LegendaryCLI, self)._handle_postinstall(postinstall, igame, yes) @wrapped