This commit is contained in:
kramo
2023-04-02 07:20:05 +02:00
parent 6899246d01
commit b511ce22b7
5 changed files with 21 additions and 13 deletions

View File

@@ -28,12 +28,12 @@ def get_games(parent_widget, game_ids=None):
return {}
if game_ids:
game_files = [f"{game_id}.json" for game_id in game_ids]
game_files = [games_dir / f"{game_id}.json" for game_id in game_ids]
else:
game_files = games_dir.iterdir()
for game in game_files:
data = json.loads((games_dir / game).read_text())
data = json.loads(game.read_text())
games[data["game_id"]] = data
return games

View File

@@ -44,7 +44,7 @@ def heroic_parser(parent_widget):
)
elif os.name == "nt" and (Path(os.getenv("appdata")) / "heroic").exists():
schema.set_string(
"heroic-location", str(Path((os.getenv("appdata") / "heroic")))
"heroic-location", str(Path(os.getenv("appdata") / "heroic"))
)
else:
return
@@ -196,7 +196,7 @@ def heroic_parser(parent_widget):
/ "images-cache"
/ hashlib.sha256(item["art_square"].encode()).hexdigest()
)
if image_path.extsts():
if image_path.exists():
importer.save_cover(values["game_id"], image_path)
importer.save_game(values)

View File

@@ -50,8 +50,7 @@ def lutris_parser(parent_widget):
else:
return
database_path = Path(schema.get_string("lutris-location")) / "pga.db"
database_path.expanduser()
database_path = (Path(schema.get_string("lutris-location")) / "pga.db").expanduser()
cache_dir = Path(schema.get_string("lutris-cache-location")).expanduser()
db_cache_dir = parent_widget.cache_dir / "cartridges" / "lutris"

View File

@@ -160,7 +160,7 @@ def steam_parser(parent_widget):
schema.set_string("steam-location", "~/.steam/steam/")
elif (
os.name == "nt"
and (Path((os.getenv("programfiles(x86)"))) / "Steam").exists()
and (Path(os.getenv("programfiles(x86)")) / "Steam").exists()
):
schema.set_string(
"steam-location", str(Path(os.getenv("programfiles(x86)")) / "Steam")
@@ -189,9 +189,8 @@ def steam_parser(parent_widget):
for directory in steam_dirs:
for open_file in (directory / "steamapps").iterdir():
path = directory / "steamapps" / open_file
if path.is_file() and "appmanifest" in open_file.name:
appmanifests.append(path)
if open_file.is_file() and "appmanifest" in open_file.name:
appmanifests.append(open_file)
importer = parent_widget.importer
importer.total_queue += len(appmanifests)

View File

@@ -70,10 +70,20 @@ class CartridgesWindow(Adw.ApplicationWindow):
super().__init__(**kwargs)
self.data_dir = (
Path(os.getenv("XDG_DATA_HOME")) or Path.home() / ".local" / "share"
Path(os.getenv("XDG_DATA_HOME"))
if "XDG_DATA_HOME" in os.environ
else Path.home() / ".local" / "share"
)
self.config_dir = (
Path(os.getenv("XDG_CONFIG_HOME"))
if "XDG_CONFIG_HOME" in os.environ
else Path.home() / ".config"
)
self.cache_dir = (
Path(os.getenv("XDG_CACHE_HOME"))
if "XDG_CACHE_HOME" in os.environ
else Path.home() / ".cache"
)
self.config_dir = Path(os.getenv("XDG_CONFIG_HOME")) or Path.home() / ".config"
self.cache_dir = Path(os.getenv("XDG_CACHE_HOME")) or Path.home() / ".cache"
self.games = {}
self.visible_widgets = {}