🎨 SourceIterator is not sized anymore
This commit is contained in:
@@ -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"""
|
||||
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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"""
|
||||
|
||||
|
||||
Reference in New Issue
Block a user