diff --git a/src/utils/get_games.py b/src/utils/get_games.py index 2dd9d87..d073c7a 100644 --- a/src/utils/get_games.py +++ b/src/utils/get_games.py @@ -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 diff --git a/src/utils/heroic_parser.py b/src/utils/heroic_parser.py index 53c2141..d47ff28 100644 --- a/src/utils/heroic_parser.py +++ b/src/utils/heroic_parser.py @@ -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) diff --git a/src/utils/lutris_parser.py b/src/utils/lutris_parser.py index ef08abe..afa2834 100644 --- a/src/utils/lutris_parser.py +++ b/src/utils/lutris_parser.py @@ -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" diff --git a/src/utils/steam_parser.py b/src/utils/steam_parser.py index 9a88b71..711da06 100644 --- a/src/utils/steam_parser.py +++ b/src/utils/steam_parser.py @@ -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) diff --git a/src/window.py b/src/window.py index 4a80c2d..f324750 100644 --- a/src/window.py +++ b/src/window.py @@ -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 = {}