Lgndr: Add default implementation for get_boolean_choice
that returns False
This commit is contained in:
parent
9df3355200
commit
14087a3c6c
|
@ -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)
|
||||
|
|
|
@ -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"
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue