Various changes

- Removed useless format manager
- Moved pipeline to its own file
- Fixed steam source next not returning game
- Changed pipeline order
This commit is contained in:
GeoffreyCoulaud
2023-05-24 19:34:07 +02:00
parent e7e30c8ac5
commit 1d2253ff94
8 changed files with 103 additions and 106 deletions

View File

@@ -4,6 +4,7 @@ from gi.repository import Adw, Gio, Gtk
from src import shared
from src.utils.task import Task
from src.store.pipeline import Pipeline
# pylint: disable=too-many-instance-attributes
@@ -83,6 +84,7 @@ class Importer:
if not source.is_installed:
logging.info("Source %s skipped, not installed", source.id)
return
logging.info("Scanning source %s", source.id)
# Initialize source iteration
iterator = iter(source)
@@ -104,19 +106,29 @@ class Importer:
continue
# Register game
logging.info("Imported %s (%s)", game.name, game.game_id)
shared.store.add_game(game)
self.n_games_added += 1
pipeline: Pipeline = shared.store.add_game(game)
if pipeline is not None:
logging.info("Imported %s (%s)", game.name, game.game_id)
pipeline.connect("manager-done", self.manager_done_callback)
self.n_games_added += 1
def source_task_callback(self, _obj, _result, data):
"""Source import callback"""
source, *_rest = data
logging.debug("Import done for source %s", source.id)
self.n_source_tasks_done += 1
# TODO remove, should be handled by manager_done_callback
self.update_progressbar()
if self.finished:
self.import_callback()
def manager_done_callback(self, pipeline: Pipeline):
"""Callback called when a pipeline for a game has advanced"""
# TODO (optional) update progress bar more precisely from here
# TODO get number of games really added here (eg. exlude blacklisted)
# TODO trigger import_callback only when all pipelines have finished
pass
def import_callback(self):
"""Callback called when importing has finished"""
logging.info("Import done")

View File

@@ -91,6 +91,8 @@ class SteamSourceIterator(SourceIterator):
if cover_path.is_file():
save_cover(game.game_id, resize_cover(cover_path))
return game
class SteamSource(Source):
name = "Steam"