🎨 Sorted imports, made pylint happy
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
from threading import Thread, Lock
|
||||
from gi.repository import Adw, Gtk, Gio
|
||||
from threading import Lock, Thread
|
||||
|
||||
from gi.repository import Adw, Gtk
|
||||
|
||||
from .game import Game
|
||||
from .steamgriddb import SGDBHelper
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@ class Importer:
|
||||
games_lock = None
|
||||
games = None
|
||||
|
||||
def __init__(self, win) -> None:
|
||||
def __init__(self, win):
|
||||
self.games = set()
|
||||
self.sources = set()
|
||||
self.counts = dict()
|
||||
@@ -77,12 +77,12 @@ class Importer:
|
||||
print(f"{source.full_name}, installed: {source.is_installed}")
|
||||
if not source.is_installed:
|
||||
continue
|
||||
t = Thread(target=self.__import_source__, args=tuple([source])) # fmt: skip
|
||||
threads.append(t)
|
||||
t.start()
|
||||
thread = Thread(target=self.__import_source__, args=tuple([source])) # fmt: skip
|
||||
threads.append(thread)
|
||||
thread.start()
|
||||
|
||||
for t in threads:
|
||||
t.join()
|
||||
for thread in threads:
|
||||
thread.join()
|
||||
|
||||
# Save games
|
||||
for game in self.games:
|
||||
@@ -95,11 +95,11 @@ class Importer:
|
||||
|
||||
self.close_dialog()
|
||||
|
||||
def __import_source__(self, *args, **kwargs):
|
||||
def __import_source__(self, *args, **_kwargs):
|
||||
"""Source import thread entry point"""
|
||||
# TODO error handling in source iteration
|
||||
# TODO add SGDB image (move to a game manager)
|
||||
source, *rest = args
|
||||
source, *_rest = args
|
||||
iterator = source.__iter__()
|
||||
with self.progress_lock:
|
||||
self.counts[source.id]["total"] = len(iterator)
|
||||
|
||||
@@ -38,41 +38,38 @@ class Source(Iterable):
|
||||
@property
|
||||
def full_name(self):
|
||||
"""The source's full name"""
|
||||
s = self.name
|
||||
full_name_ = self.name
|
||||
if self.variant is not None:
|
||||
s += f" ({self.variant})"
|
||||
return s
|
||||
full_name_ += f" ({self.variant})"
|
||||
return full_name_
|
||||
|
||||
@property
|
||||
def id(self):
|
||||
def id(self): # pylint: disable=invalid-name
|
||||
"""The source's identifier"""
|
||||
s = self.name.lower()
|
||||
id_ = self.name.lower()
|
||||
if self.variant is not None:
|
||||
s += f"_{self.variant.lower()}"
|
||||
return s
|
||||
id_ += f"_{self.variant.lower()}"
|
||||
return id_
|
||||
|
||||
@property
|
||||
def game_id_format(self):
|
||||
"""The string format used to construct game IDs"""
|
||||
f = self.name.lower()
|
||||
format_ = self.name.lower()
|
||||
if self.variant is not None:
|
||||
f += f"_{self.variant.lower()}"
|
||||
f += "_{game_id}"
|
||||
return f
|
||||
format_ += f"_{self.variant.lower()}"
|
||||
format_ += "_{game_id}"
|
||||
return format_
|
||||
|
||||
@property
|
||||
@abstractmethod
|
||||
def executable_format(self):
|
||||
"""The executable format used to construct game executables"""
|
||||
pass
|
||||
|
||||
@property
|
||||
@abstractmethod
|
||||
def is_installed(self):
|
||||
"""Whether the source is detected as installed"""
|
||||
pass
|
||||
|
||||
@abstractmethod
|
||||
def __iter__(self):
|
||||
"""Get the source's iterator, to use in for loops"""
|
||||
pass
|
||||
|
||||
@@ -2,10 +2,10 @@ from functools import cache
|
||||
from sqlite3 import connect
|
||||
from time import time
|
||||
|
||||
from .decorators import replaced_by_path, replaced_by_schema_key
|
||||
from .game import Game
|
||||
from .save_cover import resize_cover, save_cover
|
||||
from .source import Source, SourceIterator
|
||||
from .decorators import replaced_by_schema_key, replaced_by_path
|
||||
|
||||
|
||||
class LutrisSourceIterator(SourceIterator):
|
||||
@@ -128,7 +128,7 @@ class LutrisNativeSource(LutrisSource):
|
||||
|
||||
@property
|
||||
@replaced_by_schema_key("lutris-cache-location")
|
||||
@replaced_by_path("~/.local/share/lutris/covers")
|
||||
@replaced_by_path("~/.local/share/lutris/covers/")
|
||||
def cache_location(self):
|
||||
raise FileNotFoundError()
|
||||
|
||||
@@ -140,12 +140,12 @@ class LutrisFlatpakSource(LutrisSource):
|
||||
|
||||
@property
|
||||
@replaced_by_schema_key("lutris-flatpak-location")
|
||||
@replaced_by_path("~/.var/app/net.lutris.Lutris/data/lutris")
|
||||
@replaced_by_path("~/.var/app/net.lutris.Lutris/data/lutris/")
|
||||
def location(self):
|
||||
raise FileNotFoundError()
|
||||
|
||||
@property
|
||||
@replaced_by_schema_key("lutris-flatpak-cache-location")
|
||||
@replaced_by_path("~/.var/app/net.lutris.Lutris/data/lutris/covers")
|
||||
@replaced_by_path("~/.var/app/net.lutris.Lutris/data/lutris/covers/")
|
||||
def cache_location(self):
|
||||
raise FileNotFoundError()
|
||||
|
||||
@@ -18,18 +18,17 @@ from os import PathLike
|
||||
from functools import wraps
|
||||
|
||||
|
||||
def replaced_by_path(path: PathLike): # Decorator builder
|
||||
def replaced_by_path(override: PathLike): # Decorator builder
|
||||
"""Replace the method's returned path with the override
|
||||
if the override exists on disk"""
|
||||
|
||||
def decorator(original_function): # Built decorator (closure)
|
||||
@wraps(original_function)
|
||||
def wrapper(*args, **kwargs): # func's override
|
||||
p = Path(path).expanduser()
|
||||
if p.exists():
|
||||
return p
|
||||
else:
|
||||
return original_function(*args, **kwargs)
|
||||
path = Path(override).expanduser()
|
||||
if path.exists():
|
||||
return path
|
||||
return original_function(*args, **kwargs)
|
||||
|
||||
return wrapper
|
||||
|
||||
@@ -46,10 +45,9 @@ def replaced_by_schema_key(key: str): # Decorator builder
|
||||
schema = args[0].win.schema
|
||||
try:
|
||||
override = schema.get_string(key)
|
||||
except Exception:
|
||||
except Exception: # pylint: disable=broad-exception-caught
|
||||
return original_function(*args, **kwargs)
|
||||
else:
|
||||
return replaced_by_path(override)(original_function)(*args, **kwargs)
|
||||
return replaced_by_path(override)(original_function)(*args, **kwargs)
|
||||
|
||||
return wrapper
|
||||
|
||||
|
||||
Reference in New Issue
Block a user