Models: Move installation related models into their own file
This commit is contained in:
parent
7fba2259ed
commit
f51563ea93
|
@ -17,7 +17,7 @@ from rare.lgndr.core import LegendaryCore
|
|||
from rare.shared import LegendaryCLISingleton, LegendaryCoreSingleton, ApiResultsSingleton, ArgumentsSingleton
|
||||
from rare.ui.components.dialogs.install_dialog import Ui_InstallDialog
|
||||
from rare.utils.extra_widgets import PathEdit
|
||||
from rare.utils.models import InstallDownloadModel, InstallQueueItemModel
|
||||
from rare.models.install import InstallDownloadModel, InstallQueueItemModel
|
||||
from rare.utils.utils import get_size
|
||||
|
||||
|
||||
|
|
|
@ -20,7 +20,7 @@ from rare.components.dialogs.install_dialog import InstallDialog
|
|||
from rare.components.tabs.downloads.dl_queue_widget import DlQueueWidget, DlWidget
|
||||
from rare.components.tabs.downloads.download_thread import DownloadThread
|
||||
from rare.ui.components.tabs.downloads.downloads_tab import Ui_DownloadsTab
|
||||
from rare.utils.models import InstallOptionsModel, InstallQueueItemModel
|
||||
from rare.models.install import InstallOptionsModel, InstallQueueItemModel
|
||||
from rare.utils.utils import get_size
|
||||
|
||||
logger = getLogger("Download")
|
||||
|
|
|
@ -10,7 +10,7 @@ from PyQt5.QtWidgets import (
|
|||
QWidget,
|
||||
)
|
||||
|
||||
from rare.utils.models import InstallQueueItemModel
|
||||
from rare.models.install import InstallQueueItemModel
|
||||
from rare.utils.utils import icon
|
||||
|
||||
logger = getLogger("QueueWidget")
|
||||
|
|
|
@ -12,7 +12,7 @@ from legendary.core import LegendaryCore
|
|||
from legendary.models.downloading import WriterTask
|
||||
|
||||
from rare.shared import GlobalSignalsSingleton
|
||||
from rare.utils.models import InstallQueueItemModel
|
||||
from rare.models.install import InstallQueueItemModel
|
||||
from rare.utils.utils import create_desktop_link
|
||||
from rare.lgndr.downloading import UIUpdate
|
||||
|
||||
|
|
|
@ -7,7 +7,7 @@ from rare.shared import LegendaryCoreSingleton, GlobalSignalsSingleton
|
|||
from rare.shared.image_manager import ImageManagerSingleton, ImageSize
|
||||
from rare.ui.components.tabs.games.game_info.game_dlc import Ui_GameDlc
|
||||
from rare.ui.components.tabs.games.game_info.game_dlc_widget import Ui_GameDlcWidget
|
||||
from rare.utils.models import InstallOptionsModel
|
||||
from rare.models.install import InstallOptionsModel
|
||||
from rare.widgets.image_widget import ImageWidget
|
||||
|
||||
|
||||
|
|
|
@ -37,7 +37,7 @@ from rare.shared.image_manager import ImageManagerSingleton, ImageSize
|
|||
from rare.ui.components.tabs.games.game_info.game_info import Ui_GameInfo
|
||||
from rare.utils.extra_widgets import PathEdit
|
||||
from rare.utils.legendary_utils import VerifyWorker
|
||||
from rare.utils.models import InstallOptionsModel
|
||||
from rare.models.install import InstallOptionsModel
|
||||
from rare.utils.steam_grades import SteamWorker
|
||||
from rare.utils.utils import get_size
|
||||
from rare.widgets.image_widget import ImageWidget
|
||||
|
|
|
@ -15,7 +15,7 @@ from rare.shared.image_manager import ImageManagerSingleton, ImageSize
|
|||
from rare.ui.components.tabs.games.game_info.game_info import Ui_GameInfo
|
||||
from rare.utils.extra_widgets import SideTabWidget
|
||||
from rare.utils.json_formatter import QJsonModel
|
||||
from rare.utils.models import InstallOptionsModel
|
||||
from rare.models.install import InstallOptionsModel
|
||||
from rare.utils.steam_grades import SteamWorker
|
||||
from rare.widgets.image_widget import ImageWidget
|
||||
|
||||
|
|
|
@ -9,7 +9,7 @@ from PyQt5.QtWidgets import QGroupBox, QMessageBox
|
|||
from legendary.utils import eos
|
||||
from rare.shared import LegendaryCoreSingleton, GlobalSignalsSingleton
|
||||
from rare.ui.components.tabs.settings.widgets.eos_widget import Ui_EosWidget
|
||||
from rare.utils.models import InstallOptionsModel
|
||||
from rare.models.install import InstallOptionsModel
|
||||
|
||||
logger = getLogger("EOS")
|
||||
|
||||
|
|
61
rare/models/install.py
Normal file
61
rare/models/install.py
Normal file
|
@ -0,0 +1,61 @@
|
|||
import os
|
||||
import platform as pf
|
||||
from dataclasses import dataclass
|
||||
from typing import List, Optional, Callable, Dict
|
||||
|
||||
from legendary.downloader.mp.manager import DLManager
|
||||
from legendary.models.downloading import AnalysisResult, ConditionCheckResult
|
||||
from legendary.models.game import Game, InstalledGame
|
||||
|
||||
|
||||
@dataclass
|
||||
class InstallOptionsModel:
|
||||
app_name: str
|
||||
base_path: str = ""
|
||||
shared_memory: int = 1024
|
||||
max_workers: int = os.cpu_count() * 2
|
||||
force: bool = False
|
||||
platform: str = "Windows"
|
||||
install_tag: Optional[List[str]] = None
|
||||
order_opt: bool = False
|
||||
repair_mode: bool = False
|
||||
repair_and_update: bool = False
|
||||
no_install: bool = False
|
||||
ignore_space: bool = False
|
||||
# Rare's internal arguments
|
||||
# FIXME: Do we really need all of these?
|
||||
create_shortcut: bool = True
|
||||
overlay: bool = False
|
||||
update: bool = False
|
||||
silent: bool = False
|
||||
install_preqs: bool = pf.system() == "Windows"
|
||||
|
||||
def __post_init__(self):
|
||||
self.sdl_prompt: Callable[[str, str], list] = lambda app_name, title: self.install_tag
|
||||
|
||||
def as_install_kwargs(self) -> Dict:
|
||||
return {
|
||||
k: getattr(self, k)
|
||||
for k in self.__dict__
|
||||
if k not in ["update", "silent", "create_shortcut", "overlay", "install_preqs"]
|
||||
}
|
||||
|
||||
|
||||
@dataclass
|
||||
class InstallDownloadModel:
|
||||
dlmanager: DLManager
|
||||
analysis: AnalysisResult
|
||||
igame: InstalledGame
|
||||
game: Game
|
||||
repair: bool
|
||||
repair_file: str
|
||||
res: ConditionCheckResult
|
||||
|
||||
|
||||
@dataclass
|
||||
class InstallQueueItemModel:
|
||||
download: Optional[InstallDownloadModel] = None
|
||||
options: Optional[InstallOptionsModel] = None
|
||||
|
||||
def __bool__(self):
|
||||
return (self.download is not None) and (self.options is not None)
|
|
@ -1,6 +1,6 @@
|
|||
from PyQt5.QtCore import QObject, pyqtSignal
|
||||
|
||||
from rare.utils.models import InstallOptionsModel
|
||||
from .install import InstallOptionsModel
|
||||
|
||||
|
||||
class GlobalSignals(QObject):
|
||||
|
|
|
@ -1,66 +1,7 @@
|
|||
import os
|
||||
import platform as pf
|
||||
from dataclasses import field, dataclass
|
||||
from multiprocessing import Queue
|
||||
from typing import Union, List, Optional, Callable, Dict
|
||||
from typing import Union, List
|
||||
|
||||
from legendary.core import LegendaryCore
|
||||
from legendary.downloader.mp.manager import DLManager
|
||||
from legendary.models.downloading import AnalysisResult, ConditionCheckResult
|
||||
from legendary.models.game import Game, InstalledGame
|
||||
|
||||
|
||||
@dataclass
|
||||
class InstallOptionsModel:
|
||||
app_name: str
|
||||
base_path: str = ""
|
||||
shared_memory: int = 1024
|
||||
max_workers: int = os.cpu_count() * 2
|
||||
force: bool = False
|
||||
platform: str = "Windows"
|
||||
install_tag: Optional[List[str]] = None
|
||||
order_opt: bool = False
|
||||
repair_mode: bool = False
|
||||
repair_and_update: bool = False
|
||||
no_install: bool = False
|
||||
ignore_space: bool = False
|
||||
# Rare's internal arguments
|
||||
# FIXME: Do we really need all of these?
|
||||
create_shortcut: bool = True
|
||||
overlay: bool = False
|
||||
update: bool = False
|
||||
silent: bool = False
|
||||
install_preqs: bool = pf.system() == "Windows"
|
||||
|
||||
def __post_init__(self):
|
||||
self.sdl_prompt: Callable[[str, str], list] = lambda app_name, title: self.install_tag
|
||||
|
||||
def as_install_kwargs(self) -> Dict:
|
||||
return {
|
||||
k: getattr(self, k)
|
||||
for k in self.__dict__
|
||||
if k not in ["update", "silent", "create_shortcut", "overlay", "install_preqs"]
|
||||
}
|
||||
|
||||
|
||||
@dataclass
|
||||
class InstallDownloadModel:
|
||||
dlmanager: DLManager
|
||||
analysis: AnalysisResult
|
||||
igame: InstalledGame
|
||||
game: Game
|
||||
repair: bool
|
||||
repair_file: str
|
||||
res: ConditionCheckResult
|
||||
|
||||
|
||||
@dataclass
|
||||
class InstallQueueItemModel:
|
||||
download: Optional[InstallDownloadModel] = None
|
||||
options: Optional[InstallOptionsModel] = None
|
||||
|
||||
def __bool__(self):
|
||||
return (self.download is not None) and (self.options is not None)
|
||||
|
||||
|
||||
class PathSpec:
|
||||
|
|
Loading…
Reference in a new issue