From ed68eb66adfee869c48f2e556b66a31d42ebe5c6 Mon Sep 17 00:00:00 2001 From: Stelios Tsampas Date: Sat, 19 Jun 2021 17:22:30 +0300 Subject: [PATCH] Convert models to dataclasses. --- rare/utils/models.py | 48 +++++++++++++++++++++++--------------------- 1 file changed, 25 insertions(+), 23 deletions(-) diff --git a/rare/utils/models.py b/rare/utils/models.py index 44400ddc..2a52265b 100644 --- a/rare/utils/models.py +++ b/rare/utils/models.py @@ -1,36 +1,38 @@ import os +from dataclasses import field, dataclass +from custom_legendary.models.game import Game, InstalledGame +from custom_legendary.models.downloading import AnalysisResult +from custom_legendary.downloader.manager import DLManager +from multiprocessing import Queue +@dataclass class InstallOptionsModel: - def __init__(self, app_name: str, base_path: str = os.path.expanduser("~/legendary"), - max_workers: int = os.cpu_count() * 2, repair: bool = False, no_install: bool = False, - ignore_space_req: bool = False, force: bool = False, sdl_list: list = [''] - ): - self.app_name = app_name - self.base_path = base_path - self.max_workers = max_workers - self.repair = repair - self.no_install = no_install - self.ignore_space_req = ignore_space_req - self.force = force - self.sdl_list = sdl_list + app_name: str + base_path: str = os.path.expanduser("~/legendary") + max_workers: int = os.cpu_count() * 2 + repair: bool = False + no_install: bool = False + ignore_space_req: bool = False + force: bool = False + sdl_list: list[str] = field(default_factory=lambda: ['']) +@dataclass class InstallDownloadModel: - def __init__(self, dlmanager, analysis, game, igame, repair: bool, repair_file: str): - self.dlmanager = dlmanager - self.analysis = analysis - self.game = game - self.igame = igame - self.repair = repair - self.repair_file = repair_file + dlmanager: DLManager + analysis: AnalysisResult + game: Game + igame: InstalledGame + repair: bool + repair_file: str +@dataclass class InstallQueueItemModel: - def __init__(self, status_q=None, download: InstallDownloadModel = None, options: InstallOptionsModel = None): - self.status_q = status_q - self.download = download - self.options = options + status_q: Queue = None + download: InstallDownloadModel = None + options: InstallOptionsModel = None def __bool__(self): return (self.status_q is not None) and (self.download is not None) and (self.options is not None)