Cleanups
This commit is contained in:
@@ -28,12 +28,12 @@ def get_games(parent_widget, game_ids=None):
|
|||||||
return {}
|
return {}
|
||||||
|
|
||||||
if game_ids:
|
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:
|
else:
|
||||||
game_files = games_dir.iterdir()
|
game_files = games_dir.iterdir()
|
||||||
|
|
||||||
for game in game_files:
|
for game in game_files:
|
||||||
data = json.loads((games_dir / game).read_text())
|
data = json.loads(game.read_text())
|
||||||
games[data["game_id"]] = data
|
games[data["game_id"]] = data
|
||||||
|
|
||||||
return games
|
return games
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ def heroic_parser(parent_widget):
|
|||||||
)
|
)
|
||||||
elif os.name == "nt" and (Path(os.getenv("appdata")) / "heroic").exists():
|
elif os.name == "nt" and (Path(os.getenv("appdata")) / "heroic").exists():
|
||||||
schema.set_string(
|
schema.set_string(
|
||||||
"heroic-location", str(Path((os.getenv("appdata") / "heroic")))
|
"heroic-location", str(Path(os.getenv("appdata") / "heroic"))
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
return
|
return
|
||||||
@@ -196,7 +196,7 @@ def heroic_parser(parent_widget):
|
|||||||
/ "images-cache"
|
/ "images-cache"
|
||||||
/ hashlib.sha256(item["art_square"].encode()).hexdigest()
|
/ 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_cover(values["game_id"], image_path)
|
||||||
|
|
||||||
importer.save_game(values)
|
importer.save_game(values)
|
||||||
|
|||||||
@@ -50,8 +50,7 @@ def lutris_parser(parent_widget):
|
|||||||
else:
|
else:
|
||||||
return
|
return
|
||||||
|
|
||||||
database_path = Path(schema.get_string("lutris-location")) / "pga.db"
|
database_path = (Path(schema.get_string("lutris-location")) / "pga.db").expanduser()
|
||||||
database_path.expanduser()
|
|
||||||
cache_dir = Path(schema.get_string("lutris-cache-location")).expanduser()
|
cache_dir = Path(schema.get_string("lutris-cache-location")).expanduser()
|
||||||
|
|
||||||
db_cache_dir = parent_widget.cache_dir / "cartridges" / "lutris"
|
db_cache_dir = parent_widget.cache_dir / "cartridges" / "lutris"
|
||||||
|
|||||||
@@ -160,7 +160,7 @@ def steam_parser(parent_widget):
|
|||||||
schema.set_string("steam-location", "~/.steam/steam/")
|
schema.set_string("steam-location", "~/.steam/steam/")
|
||||||
elif (
|
elif (
|
||||||
os.name == "nt"
|
os.name == "nt"
|
||||||
and (Path((os.getenv("programfiles(x86)"))) / "Steam").exists()
|
and (Path(os.getenv("programfiles(x86)")) / "Steam").exists()
|
||||||
):
|
):
|
||||||
schema.set_string(
|
schema.set_string(
|
||||||
"steam-location", str(Path(os.getenv("programfiles(x86)")) / "Steam")
|
"steam-location", str(Path(os.getenv("programfiles(x86)")) / "Steam")
|
||||||
@@ -189,9 +189,8 @@ def steam_parser(parent_widget):
|
|||||||
|
|
||||||
for directory in steam_dirs:
|
for directory in steam_dirs:
|
||||||
for open_file in (directory / "steamapps").iterdir():
|
for open_file in (directory / "steamapps").iterdir():
|
||||||
path = directory / "steamapps" / open_file
|
if open_file.is_file() and "appmanifest" in open_file.name:
|
||||||
if path.is_file() and "appmanifest" in open_file.name:
|
appmanifests.append(open_file)
|
||||||
appmanifests.append(path)
|
|
||||||
|
|
||||||
importer = parent_widget.importer
|
importer = parent_widget.importer
|
||||||
importer.total_queue += len(appmanifests)
|
importer.total_queue += len(appmanifests)
|
||||||
|
|||||||
@@ -70,10 +70,20 @@ class CartridgesWindow(Adw.ApplicationWindow):
|
|||||||
super().__init__(**kwargs)
|
super().__init__(**kwargs)
|
||||||
|
|
||||||
self.data_dir = (
|
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.games = {}
|
||||||
self.visible_widgets = {}
|
self.visible_widgets = {}
|
||||||
|
|||||||
Reference in New Issue
Block a user