🎨 Various code style / behaviour fixes

- Merged platform sources when possible
- Added URLExecutableSource class
- Moved replaced_by_schema_key to utils/decorators
- Better retryable exception handling in some managers
-  Split SteamHelper into SteamFileHelper and SteamAPIHelper
- Delegated SteamRateLimiter creation to SteamAPIManager init
- Using additional_data for appid in SteamAPIManager
- Added Windows support for Legendary
- Stylistic changed suggested by pylint
This commit is contained in:
GeoffreyCoulaud
2023-06-10 02:59:41 +02:00
parent 070d875ff8
commit 842f9fe522
17 changed files with 182 additions and 224 deletions

View File

@@ -5,13 +5,15 @@ from time import time
from src import shared
from src.game import Game
from src.importer.sources.source import (
LinuxSource,
Source,
SourceIterationResult,
SourceIterator,
WindowsSource,
URLExecutableSource,
)
from src.utils.decorators import (
replaced_by_env_path,
replaced_by_path,
replaced_by_schema_key,
)
from src.utils.decorators import replaced_by_env_path, replaced_by_path
class ItchSourceIterator(SourceIterator):
@@ -54,33 +56,17 @@ class ItchSourceIterator(SourceIterator):
yield (game, additional_data)
class ItchSource(Source):
class ItchSource(URLExecutableSource):
name = "Itch"
location_key = "itch-location"
def __iter__(self) -> SourceIterator:
return ItchSourceIterator(self)
class ItchLinuxSource(ItchSource, LinuxSource):
variant = "linux"
executable_format = "xdg-open itch://caves/{cave_id}/launch"
iterator_class = ItchSourceIterator
url_format = "itch://caves/{cave_id}/launch"
available_on = set(("linux", "win32"))
@property
@ItchSource.replaced_by_schema_key()
@replaced_by_schema_key
@replaced_by_path("~/.var/app/io.itch.itch/config/itch/")
@replaced_by_env_path("XDG_DATA_HOME", "itch/")
@replaced_by_path("~/.config/itch")
def location(self) -> Path:
raise FileNotFoundError()
class ItchWindowsSource(ItchSource, WindowsSource):
variant = "windows"
executable_format = "start itch://caves/{cave_id}/launch"
@property
@ItchSource.replaced_by_schema_key()
@replaced_by_env_path("appdata", "itch/")
def location(self) -> Path:
raise FileNotFoundError()