Convert models to dataclasses.
This commit is contained in:
parent
23252fb0e2
commit
ed68eb66ad
1 changed files with 25 additions and 23 deletions
|
@ -1,36 +1,38 @@
|
||||||
import os
|
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:
|
class InstallOptionsModel:
|
||||||
def __init__(self, app_name: str, base_path: str = os.path.expanduser("~/legendary"),
|
app_name: str
|
||||||
max_workers: int = os.cpu_count() * 2, repair: bool = False, no_install: bool = False,
|
base_path: str = os.path.expanduser("~/legendary")
|
||||||
ignore_space_req: bool = False, force: bool = False, sdl_list: list = ['']
|
max_workers: int = os.cpu_count() * 2
|
||||||
):
|
repair: bool = False
|
||||||
self.app_name = app_name
|
no_install: bool = False
|
||||||
self.base_path = base_path
|
ignore_space_req: bool = False
|
||||||
self.max_workers = max_workers
|
force: bool = False
|
||||||
self.repair = repair
|
sdl_list: list[str] = field(default_factory=lambda: [''])
|
||||||
self.no_install = no_install
|
|
||||||
self.ignore_space_req = ignore_space_req
|
|
||||||
self.force = force
|
|
||||||
self.sdl_list = sdl_list
|
|
||||||
|
|
||||||
|
|
||||||
|
@dataclass
|
||||||
class InstallDownloadModel:
|
class InstallDownloadModel:
|
||||||
def __init__(self, dlmanager, analysis, game, igame, repair: bool, repair_file: str):
|
dlmanager: DLManager
|
||||||
self.dlmanager = dlmanager
|
analysis: AnalysisResult
|
||||||
self.analysis = analysis
|
game: Game
|
||||||
self.game = game
|
igame: InstalledGame
|
||||||
self.igame = igame
|
repair: bool
|
||||||
self.repair = repair
|
repair_file: str
|
||||||
self.repair_file = repair_file
|
|
||||||
|
|
||||||
|
|
||||||
|
@dataclass
|
||||||
class InstallQueueItemModel:
|
class InstallQueueItemModel:
|
||||||
def __init__(self, status_q=None, download: InstallDownloadModel = None, options: InstallOptionsModel = None):
|
status_q: Queue = None
|
||||||
self.status_q = status_q
|
download: InstallDownloadModel = None
|
||||||
self.download = download
|
options: InstallOptionsModel = None
|
||||||
self.options = options
|
|
||||||
|
|
||||||
def __bool__(self):
|
def __bool__(self):
|
||||||
return (self.status_q is not None) and (self.download is not None) and (self.options is not None)
|
return (self.status_q is not None) and (self.download is not None) and (self.options is not None)
|
||||||
|
|
Loading…
Reference in a new issue