More renaming to iterable + fixes to heroic
This commit is contained in:
@@ -80,7 +80,7 @@ class BottlesSource(URLExecutableSource):
|
|||||||
"""Generic Bottles source"""
|
"""Generic Bottles source"""
|
||||||
|
|
||||||
name = _("Bottles")
|
name = _("Bottles")
|
||||||
iterator_class = BottlesSourceIterable
|
iterable_class = BottlesSourceIterable
|
||||||
url_format = 'bottles:run/"{bottle_name}"/"{game_name}"'
|
url_format = 'bottles:run/"{bottle_name}"/"{game_name}"'
|
||||||
available_on = {"linux"}
|
available_on = {"linux"}
|
||||||
|
|
||||||
|
|||||||
@@ -115,7 +115,7 @@ class FlatpakSource(Source):
|
|||||||
"""Generic Flatpak source"""
|
"""Generic Flatpak source"""
|
||||||
|
|
||||||
name = _("Flatpak")
|
name = _("Flatpak")
|
||||||
iterator_class = FlatpakSourceIterable
|
iterable_class = FlatpakSourceIterable
|
||||||
executable_format = "flatpak run {flatpak_id}"
|
executable_format = "flatpak run {flatpak_id}"
|
||||||
available_on = {"linux"}
|
available_on = {"linux"}
|
||||||
|
|
||||||
|
|||||||
@@ -69,20 +69,20 @@ class HeroicLibraryEntry(TypedDict):
|
|||||||
art_square: str
|
art_square: str
|
||||||
|
|
||||||
|
|
||||||
class SubSource(Iterable):
|
class SubSourceIterable(Iterable):
|
||||||
"""Class representing a Heroic sub-source"""
|
"""Class representing a Heroic sub-source"""
|
||||||
|
|
||||||
source: "HeroicSource"
|
source: "HeroicSource"
|
||||||
source_iterator: "HeroicSourceIterable"
|
source_iterable: "HeroicSourceIterable"
|
||||||
name: str
|
name: str
|
||||||
service: str
|
service: str
|
||||||
image_uri_params: str = ""
|
image_uri_params: str = ""
|
||||||
relative_library_path: Path
|
relative_library_path: Path
|
||||||
library_json_entries_key: str = "library"
|
library_json_entries_key: str = "library"
|
||||||
|
|
||||||
def __init__(self, source, source_iterator) -> None:
|
def __init__(self, source, source_iterable) -> None:
|
||||||
self.source = source
|
self.source = source
|
||||||
self.source_iterator = source_iterator
|
self.source_iterable = source_iterable
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def library_path(self) -> Path:
|
def library_path(self) -> Path:
|
||||||
@@ -105,7 +105,7 @@ class SubSource(Iterable):
|
|||||||
service=self.service, game_id=app_name
|
service=self.service, game_id=app_name
|
||||||
),
|
),
|
||||||
"executable": self.source.executable_format.format(app_name=app_name),
|
"executable": self.source.executable_format.format(app_name=app_name),
|
||||||
"hidden": self.source_iterator.is_hidden(app_name),
|
"hidden": self.source_iterable.is_hidden(app_name),
|
||||||
}
|
}
|
||||||
game = Game(values)
|
game = Game(values)
|
||||||
|
|
||||||
@@ -120,7 +120,7 @@ class SubSource(Iterable):
|
|||||||
|
|
||||||
def __iter__(self):
|
def __iter__(self):
|
||||||
"""
|
"""
|
||||||
Iterate through the installed games with a generator
|
Iterate through the games with a generator
|
||||||
:raises InvalidLibraryFileError: on initial call if the library file is bad
|
:raises InvalidLibraryFileError: on initial call if the library file is bad
|
||||||
"""
|
"""
|
||||||
added_time = int(time())
|
added_time = int(time())
|
||||||
@@ -145,13 +145,13 @@ class SubSource(Iterable):
|
|||||||
continue
|
continue
|
||||||
|
|
||||||
|
|
||||||
class StoreSubSource(SubSource):
|
class StoreSubSourceIterable(SubSourceIterable):
|
||||||
"""
|
"""
|
||||||
Class representing a "store" sub source iterator.
|
Class representing a "store" sub source.
|
||||||
Games can be installed or not, this class does the check accordingly.
|
Games can be installed or not, this class does the check accordingly.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
relative_installed_path: Optional[Path]
|
relative_installed_path: Path
|
||||||
installed_app_names: set[str]
|
installed_app_names: set[str]
|
||||||
|
|
||||||
@property
|
@property
|
||||||
@@ -194,28 +194,27 @@ class StoreSubSource(SubSource):
|
|||||||
yield from super().__iter__()
|
yield from super().__iter__()
|
||||||
|
|
||||||
|
|
||||||
class SideloadIterable(SubSource):
|
class SideloadIterable(SubSourceIterable):
|
||||||
name = "sideload"
|
name = "sideload"
|
||||||
service = "sideload"
|
service = "sideload"
|
||||||
relative_library_path = Path("sideload_apps") / "library.json"
|
relative_library_path = Path("sideload_apps") / "library.json"
|
||||||
|
|
||||||
|
|
||||||
class LegendaryIterable(StoreSubSource):
|
class LegendaryIterable(StoreSubSourceIterable):
|
||||||
name = "legendary"
|
name = "legendary"
|
||||||
service = "epic"
|
service = "epic"
|
||||||
image_uri_params = "?h=400&resize=1&w=300"
|
image_uri_params = "?h=400&resize=1&w=300"
|
||||||
relative_library_path = Path("store_cache") / "legendary_library.json"
|
relative_library_path = Path("store_cache") / "legendary_library.json"
|
||||||
|
|
||||||
# TODO simplify Heroic 2.9 has been out for a while
|
# TODO simplify Heroic 2.9 has been out for a while
|
||||||
# (uncomment value and remove the library_path property override)
|
# (uncomment value and remove the installed_path property override)
|
||||||
#
|
#
|
||||||
# relative_installed_path = (
|
# relative_installed_path = (
|
||||||
# Path("legendary") / "legendaryConfig" / "legendary" / "installed.json"
|
# Path("legendary") / "legendaryConfig" / "legendary" / "installed.json"
|
||||||
# )
|
# )
|
||||||
relative_installed_path = None
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def library_path(self) -> Path:
|
def installed_path(self) -> Path:
|
||||||
"""Get the right path depending on the Heroic version"""
|
"""Get the right path depending on the Heroic version"""
|
||||||
heroic_config_path = self.source.config_location.root
|
heroic_config_path = self.source.config_location.root
|
||||||
if (path := heroic_config_path / "legendaryConfig").is_dir():
|
if (path := heroic_config_path / "legendaryConfig").is_dir():
|
||||||
@@ -243,7 +242,7 @@ class LegendaryIterable(StoreSubSource):
|
|||||||
) from error
|
) from error
|
||||||
|
|
||||||
|
|
||||||
class GogIterable(StoreSubSource):
|
class GogIterable(StoreSubSourceIterable):
|
||||||
name = "gog"
|
name = "gog"
|
||||||
service = "gog"
|
service = "gog"
|
||||||
library_json_entries_key = "games"
|
library_json_entries_key = "games"
|
||||||
@@ -263,7 +262,7 @@ class GogIterable(StoreSubSource):
|
|||||||
) from error
|
) from error
|
||||||
|
|
||||||
|
|
||||||
class NileIterable(StoreSubSource):
|
class NileIterable(StoreSubSourceIterable):
|
||||||
name = "nile"
|
name = "nile"
|
||||||
service = "amazon"
|
service = "amazon"
|
||||||
relative_library_path = Path("store_cache") / "nile_library.json"
|
relative_library_path = Path("store_cache") / "nile_library.json"
|
||||||
@@ -316,24 +315,23 @@ class HeroicSourceIterable(SourceIterable):
|
|||||||
if not shared.schema.get_boolean("heroic-import-" + sub_source.service):
|
if not shared.schema.get_boolean("heroic-import-" + sub_source.service):
|
||||||
logging.debug("Skipping Heroic %s: disabled", sub_source.service)
|
logging.debug("Skipping Heroic %s: disabled", sub_source.service)
|
||||||
continue
|
continue
|
||||||
|
|
||||||
try:
|
try:
|
||||||
sub_source_iterator = iter(sub_source)
|
sub_source_iterable = iter(sub_source)
|
||||||
|
yield from sub_source_iterable
|
||||||
except (InvalidLibraryFileError, InvalidInstalledFileError) as error:
|
except (InvalidLibraryFileError, InvalidInstalledFileError) as error:
|
||||||
logging.error(
|
logging.error(
|
||||||
"Skipping bad Heroic sub-source %s",
|
"Skipping bad Heroic sub-source %s",
|
||||||
sub_source.service,
|
sub_source.service,
|
||||||
exc_info=error,
|
exc_info=error,
|
||||||
)
|
)
|
||||||
|
continue
|
||||||
yield from sub_source_iterator
|
|
||||||
|
|
||||||
|
|
||||||
class HeroicSource(URLExecutableSource):
|
class HeroicSource(URLExecutableSource):
|
||||||
"""Generic Heroic Games Launcher source"""
|
"""Generic Heroic Games Launcher source"""
|
||||||
|
|
||||||
name = _("Heroic")
|
name = _("Heroic")
|
||||||
iterator_class = HeroicSourceIterable
|
iterable_class = HeroicSourceIterable
|
||||||
url_format = "heroic://launch/{app_name}"
|
url_format = "heroic://launch/{app_name}"
|
||||||
available_on = {"linux", "win32"}
|
available_on = {"linux", "win32"}
|
||||||
|
|
||||||
|
|||||||
@@ -76,7 +76,7 @@ class ItchSourceIterable(SourceIterable):
|
|||||||
|
|
||||||
class ItchSource(URLExecutableSource):
|
class ItchSource(URLExecutableSource):
|
||||||
name = _("itch")
|
name = _("itch")
|
||||||
iterator_class = ItchSourceIterable
|
iterable_class = ItchSourceIterable
|
||||||
url_format = "itch://caves/{cave_id}/launch"
|
url_format = "itch://caves/{cave_id}/launch"
|
||||||
available_on = {"linux", "win32"}
|
available_on = {"linux", "win32"}
|
||||||
|
|
||||||
|
|||||||
@@ -93,7 +93,7 @@ class LegendarySource(Source):
|
|||||||
executable_format = "legendary launch {app_name}"
|
executable_format = "legendary launch {app_name}"
|
||||||
available_on = {"linux"}
|
available_on = {"linux"}
|
||||||
|
|
||||||
iterator_class = LegendarySourceIterable
|
iterable_class = LegendarySourceIterable
|
||||||
config_location: Location = Location(
|
config_location: Location = Location(
|
||||||
schema_key="legendary-location",
|
schema_key="legendary-location",
|
||||||
candidates=(
|
candidates=(
|
||||||
|
|||||||
@@ -87,7 +87,7 @@ class LutrisSource(URLExecutableSource):
|
|||||||
"""Generic Lutris source"""
|
"""Generic Lutris source"""
|
||||||
|
|
||||||
name = _("Lutris")
|
name = _("Lutris")
|
||||||
iterator_class = LutrisSourceIterable
|
iterable_class = LutrisSourceIterable
|
||||||
url_format = "lutris:rungameid/{game_id}"
|
url_format = "lutris:rungameid/{game_id}"
|
||||||
available_on = {"linux"}
|
available_on = {"linux"}
|
||||||
|
|
||||||
|
|||||||
@@ -57,7 +57,7 @@ class Source(Iterable):
|
|||||||
data_location: Optional[Location] = None
|
data_location: Optional[Location] = None
|
||||||
cache_location: Optional[Location] = None
|
cache_location: Optional[Location] = None
|
||||||
config_location: Optional[Location] = None
|
config_location: Optional[Location] = None
|
||||||
iterator_class: type[SourceIterable]
|
iterable_class: type[SourceIterable]
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def full_name(self) -> str:
|
def full_name(self) -> str:
|
||||||
@@ -99,7 +99,7 @@ class Source(Iterable):
|
|||||||
if location is None:
|
if location is None:
|
||||||
continue
|
continue
|
||||||
location.resolve()
|
location.resolve()
|
||||||
return iter(self.iterator_class(self))
|
return iter(self.iterable_class(self))
|
||||||
|
|
||||||
|
|
||||||
# pylint: disable=abstract-method
|
# pylint: disable=abstract-method
|
||||||
|
|||||||
@@ -112,7 +112,7 @@ class SteamSourceIterable(SourceIterable):
|
|||||||
class SteamSource(URLExecutableSource):
|
class SteamSource(URLExecutableSource):
|
||||||
name = _("Steam")
|
name = _("Steam")
|
||||||
available_on = {"linux", "win32"}
|
available_on = {"linux", "win32"}
|
||||||
iterator_class = SteamSourceIterable
|
iterable_class = SteamSourceIterable
|
||||||
url_format = "steam://rungameid/{game_id}"
|
url_format = "steam://rungameid/{game_id}"
|
||||||
|
|
||||||
data_location = Location(
|
data_location = Location(
|
||||||
|
|||||||
Reference in New Issue
Block a user