From a213abe4da0e16c3e1ff8cca9b79517f2e03eb37 Mon Sep 17 00:00:00 2001 From: GeoffreyCoulaud Date: Wed, 31 May 2023 18:18:58 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=8E=A8=20SourceIterator=20is=20not=20size?= =?UTF-8?q?d=20anymore?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/importer/sources/lutris_source.py | 17 ----------------- src/importer/sources/source.py | 8 ++------ src/importer/sources/steam_source.py | 3 --- 3 files changed, 2 insertions(+), 26 deletions(-) diff --git a/src/importer/sources/lutris_source.py b/src/importer/sources/lutris_source.py index 850c4d5..8e3dcf2 100644 --- a/src/importer/sources/lutris_source.py +++ b/src/importer/sources/lutris_source.py @@ -16,17 +16,6 @@ class LutrisSourceIterator(SourceIterator): db_connection = None db_cursor = None db_location = None - db_len_request = """ - SELECT count(*) - FROM 'games' - WHERE - name IS NOT NULL - AND slug IS NOT NULL - AND configPath IS NOT NULL - AND installed - AND (runner IS NOT "steam" OR :import_steam) - ; - """ db_games_request = """ SELECT id, name, slug, runner, hidden FROM 'games' @@ -46,16 +35,10 @@ class LutrisSourceIterator(SourceIterator): self.db_location = self.source.location / "pga.db" self.db_connection = connect(self.db_location) self.db_request_params = {"import_steam": self.import_steam} - self.__len__() # Init iterator length self.db_cursor = self.db_connection.execute( self.db_games_request, self.db_request_params ) - @lru_cache(maxsize=1) - def __len__(self): - cursor = self.db_connection.execute(self.db_len_request, self.db_request_params) - return cursor.fetchone()[0] - def __next__(self): """Produce games""" diff --git a/src/importer/sources/source.py b/src/importer/sources/source.py index 921a8c0..2506edb 100644 --- a/src/importer/sources/source.py +++ b/src/importer/sources/source.py @@ -1,11 +1,11 @@ from abc import abstractmethod -from collections.abc import Iterable, Iterator, Sized +from collections.abc import Iterable, Iterator from typing import Optional from src.game import Game -class SourceIterator(Iterator, Sized): +class SourceIterator(Iterator): """Data producer for a source of games""" source: "Source" = None @@ -17,10 +17,6 @@ class SourceIterator(Iterator, Sized): def __iter__(self) -> "SourceIterator": return self - @abstractmethod - def __len__(self) -> int: - """Get a rough estimate of the number of games produced by the source""" - @abstractmethod def __next__(self) -> Optional[Game]: """Get the next generated game from the source. diff --git a/src/importer/sources/steam_source.py b/src/importer/sources/steam_source.py index af79195..0ce0d54 100644 --- a/src/importer/sources/steam_source.py +++ b/src/importer/sources/steam_source.py @@ -51,9 +51,6 @@ class SteamSourceIterator(SourceIterator): self.manifests_iterator = iter(self.manifests) - def __len__(self): - return len(self.manifests) - def __next__(self): """Produce games"""