🚨 Fixed some pylint warnings
This commit is contained in:
@@ -8,6 +8,7 @@ from src.utils.steamgriddb import SGDBAuthError, SGDBError, SGDBHelper
|
|||||||
from src.utils.task import Task
|
from src.utils.task import Task
|
||||||
|
|
||||||
|
|
||||||
|
# pylint: disable=too-many-instance-attributes
|
||||||
class Importer:
|
class Importer:
|
||||||
"""A class in charge of scanning sources for games"""
|
"""A class in charge of scanning sources for games"""
|
||||||
|
|
||||||
@@ -87,9 +88,6 @@ class Importer:
|
|||||||
self.import_dialog.present()
|
self.import_dialog.present()
|
||||||
|
|
||||||
def update_progressbar(self):
|
def update_progressbar(self):
|
||||||
logging.debug(
|
|
||||||
"Progressbar updated (%f)", self.progress
|
|
||||||
) # TODO why progress not workie?
|
|
||||||
self.progressbar.set_fraction(self.progress)
|
self.progressbar.set_fraction(self.progress)
|
||||||
|
|
||||||
def source_task_thread_func(self, _task, _obj, data, _cancellable):
|
def source_task_thread_func(self, _task, _obj, data, _cancellable):
|
||||||
@@ -162,7 +160,7 @@ class Importer:
|
|||||||
except SGDBAuthError as error:
|
except SGDBAuthError as error:
|
||||||
cancellable.cancel()
|
cancellable.cancel()
|
||||||
self.sgdb_error = error
|
self.sgdb_error = error
|
||||||
except (HTTPError, SGDBError) as error:
|
except (HTTPError, SGDBError) as _error:
|
||||||
# TODO handle other SGDB errors
|
# TODO handle other SGDB errors
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ class SourceIterator(Iterator, Sized):
|
|||||||
class Source(Iterable):
|
class Source(Iterable):
|
||||||
"""Source of games. E.g an installed app with a config file that lists game directories"""
|
"""Source of games. E.g an installed app with a config file that lists game directories"""
|
||||||
|
|
||||||
win = None # TODO maybe not depend on that ?
|
win = None
|
||||||
|
|
||||||
name: str
|
name: str
|
||||||
variant: str
|
variant: str
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
from functools import cache
|
from functools import lru_cache
|
||||||
from sqlite3 import connect
|
from sqlite3 import connect
|
||||||
from time import time
|
from time import time
|
||||||
|
|
||||||
@@ -48,7 +48,7 @@ class LutrisSourceIterator(SourceIterator):
|
|||||||
self.db_games_request, self.db_request_params
|
self.db_games_request, self.db_request_params
|
||||||
)
|
)
|
||||||
|
|
||||||
@cache
|
@lru_cache(maxsize=1)
|
||||||
def __len__(self):
|
def __len__(self):
|
||||||
cursor = self.db_connection.execute(self.db_len_request, self.db_request_params)
|
cursor = self.db_connection.execute(self.db_len_request, self.db_request_params)
|
||||||
return cursor.fetchone()[0]
|
return cursor.fetchone()[0]
|
||||||
@@ -60,9 +60,9 @@ class LutrisSourceIterator(SourceIterator):
|
|||||||
row = None
|
row = None
|
||||||
try:
|
try:
|
||||||
row = self.db_cursor.__next__()
|
row = self.db_cursor.__next__()
|
||||||
except StopIteration as e:
|
except StopIteration as error:
|
||||||
self.db_connection.close()
|
self.db_connection.close()
|
||||||
raise e
|
raise error
|
||||||
|
|
||||||
# Create game
|
# Create game
|
||||||
values = {
|
values = {
|
||||||
@@ -99,16 +99,13 @@ class LutrisSource(Source):
|
|||||||
|
|
||||||
@property
|
@property
|
||||||
def is_installed(self):
|
def is_installed(self):
|
||||||
|
# pylint: disable=pointless-statement
|
||||||
try:
|
try:
|
||||||
self.location
|
self.location
|
||||||
self.cache_location
|
self.cache_location
|
||||||
except FileNotFoundError:
|
except FileNotFoundError:
|
||||||
return False
|
return False
|
||||||
else:
|
return True
|
||||||
return True
|
|
||||||
|
|
||||||
def __init__(self, *args, **kwargs):
|
|
||||||
super().__init__(*args, **kwargs)
|
|
||||||
|
|
||||||
def __iter__(self):
|
def __iter__(self):
|
||||||
return LutrisSourceIterator(source=self)
|
return LutrisSourceIterator(source=self)
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
from gi.repository import Gio
|
|
||||||
from functools import wraps
|
from functools import wraps
|
||||||
|
|
||||||
|
from gi.repository import Gio
|
||||||
|
|
||||||
|
|
||||||
def create_task_thread_func_closure(func, data):
|
def create_task_thread_func_closure(func, data):
|
||||||
"""Wrap a Gio.TaskThreadFunc with the given data in a closure"""
|
"""Wrap a Gio.TaskThreadFunc with the given data in a closure"""
|
||||||
@@ -17,8 +18,7 @@ def decorate_set_task_data(task):
|
|||||||
def decorator(original_method):
|
def decorator(original_method):
|
||||||
@wraps(original_method)
|
@wraps(original_method)
|
||||||
def new_method(task_data):
|
def new_method(task_data):
|
||||||
task.__task_data = task_data
|
task.task_data = task_data
|
||||||
pass
|
|
||||||
|
|
||||||
return new_method
|
return new_method
|
||||||
|
|
||||||
@@ -32,9 +32,7 @@ def decorate_run_in_thread(task):
|
|||||||
def decorator(original_method):
|
def decorator(original_method):
|
||||||
@wraps(original_method)
|
@wraps(original_method)
|
||||||
def new_method(task_thread_func):
|
def new_method(task_thread_func):
|
||||||
closure = create_task_thread_func_closure(
|
closure = create_task_thread_func_closure(task_thread_func, task.task_data)
|
||||||
task_thread_func, task.__task_data
|
|
||||||
)
|
|
||||||
original_method(closure)
|
original_method(closure)
|
||||||
|
|
||||||
return new_method
|
return new_method
|
||||||
@@ -42,6 +40,7 @@ def decorate_run_in_thread(task):
|
|||||||
return decorator
|
return decorator
|
||||||
|
|
||||||
|
|
||||||
|
# pylint: disable=too-few-public-methods
|
||||||
class Task:
|
class Task:
|
||||||
"""Wrapper around Gio.Task to patch task data not being passed"""
|
"""Wrapper around Gio.Task to patch task data not being passed"""
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user