Moved schemas to shared module (#94)

This commit is contained in:
Geoffrey Coulaud
2023-05-21 16:34:22 +02:00
committed by GitHub
parent d6cda0c562
commit ab21e8b38b
12 changed files with 58 additions and 36 deletions

View File

@@ -22,13 +22,14 @@ from time import time
import yaml
from . import shared
from .check_install import check_install
def bottles_installed(win, path=None):
location_key = "bottles-location"
bottles_dir = (
path if path else Path(win.schema.get_string(location_key)).expanduser()
path if path else Path(shared.schema.get_string(location_key)).expanduser()
)
check = "library.yml"
@@ -42,7 +43,7 @@ def bottles_installed(win, path=None):
)
)
bottles_dir = check_install(check, locations, (win.schema, location_key))
bottles_dir = check_install(check, locations, (shared.schema, location_key))
return bottles_dir

View File

@@ -23,13 +23,14 @@ from hashlib import sha256
from pathlib import Path
from time import time
from . import shared
from .check_install import check_install
def heroic_installed(win, path=None):
location_key = "heroic-location"
heroic_dir = (
path if path else Path(win.schema.get_string(location_key)).expanduser()
path if path else Path(shared.schema.get_string(location_key)).expanduser()
)
check = "config.json"
@@ -46,7 +47,7 @@ def heroic_installed(win, path=None):
if os.name == "nt" and not path:
locations += (Path(os.getenv("appdata")) / "heroic",)
heroic_dir = check_install(check, locations, (win.schema, location_key))
heroic_dir = check_install(check, locations, (shared.schema, location_key))
return heroic_dir
@@ -60,7 +61,7 @@ def heroic_importer(win):
importer = win.importer
# Import Epic games
if not win.schema.get_boolean("heroic-import-epic"):
if not shared.schema.get_boolean("heroic-import-epic"):
pass
elif (heroic_dir / "store_cache" / "legendary_library.json").exists():
library = json.load(
@@ -113,7 +114,7 @@ def heroic_importer(win):
pass
# Import GOG games
if not win.schema.get_boolean("heroic-import-gog"):
if not shared.schema.get_boolean("heroic-import-gog"):
pass
elif (heroic_dir / "gog_store" / "installed.json").exists() and (
heroic_dir / "store_cache" / "gog_library.json"
@@ -163,7 +164,7 @@ def heroic_importer(win):
importer.save_game(values, image_path if image_path.exists() else None)
# Import sideloaded games
if not win.schema.get_boolean("heroic-import-sideload"):
if not shared.schema.get_boolean("heroic-import-sideload"):
pass
elif (heroic_dir / "sideload_apps" / "library.json").exists():
library = json.load((heroic_dir / "sideload_apps" / "library.json").open())

View File

@@ -26,6 +26,7 @@ from time import time
import requests
from gi.repository import GdkPixbuf, Gio
from . import shared
from .check_install import check_install
from .save_cover import resize_cover
@@ -120,7 +121,9 @@ def get_games_async(win, rows, importer):
def itch_installed(win, path=None):
location_key = "itch-location"
itch_dir = path if path else Path(win.schema.get_string(location_key)).expanduser()
itch_dir = (
path if path else Path(shared.schema.get_string(location_key)).expanduser()
)
check = Path("db") / "butler.db"
if not (itch_dir / check).is_file():
@@ -136,7 +139,7 @@ def itch_installed(win, path=None):
if os.name == "nt" and not path:
locations += (Path(os.getenv("appdata")) / "itch",)
itch_dir = check_install(check, locations, (win.schema, location_key))
itch_dir = check_install(check, locations, (shared.schema, location_key))
return itch_dir

View File

@@ -22,13 +22,14 @@ from shutil import copyfile
from sqlite3 import connect
from time import time
from . import shared
from .check_install import check_install
def lutris_installed(win, path=None):
location_key = "lutris-location"
lutris_dir = (
path if path else Path(win.schema.get_string(location_key)).expanduser()
path if path else Path(shared.schema.get_string(location_key)).expanduser()
)
check = "pga.db"
@@ -42,14 +43,14 @@ def lutris_installed(win, path=None):
)
)
lutris_dir = check_install(check, locations, (win.schema, location_key))
lutris_dir = check_install(check, locations, (shared.schema, location_key))
return lutris_dir
def lutris_cache_exists(win, path=None):
cache_key = "lutris-cache-location"
cache_dir = path if path else Path(win.schema.get_string(cache_key)).expanduser()
cache_dir = path if path else Path(shared.schema.get_string(cache_key)).expanduser()
cache_check = "coverart"
if not (cache_dir / cache_check).exists():
@@ -62,7 +63,9 @@ def lutris_cache_exists(win, path=None):
)
)
cache_dir = check_install(cache_check, cache_locations, (win.schema, cache_key))
cache_dir = check_install(
cache_check, cache_locations, (shared.schema, cache_key)
)
return cache_dir
@@ -105,7 +108,7 @@ def lutris_importer(win):
# No need to unlink temp files as they disappear when the connection is closed
database_tmp_path.unlink(missing_ok=True)
if not win.schema.get_boolean("lutris-import-steam"):
if not shared.schema.get_boolean("lutris-import-steam"):
rows = [row for row in rows if not row[3] == "steam"]
current_time = int(time())

View File

@@ -25,6 +25,7 @@ from time import time
import requests
from gi.repository import Gio
from . import shared
from .check_install import check_install
@@ -124,7 +125,7 @@ def get_games_async(win, appmanifests, steam_dir, importer):
def steam_installed(win, path=None):
location_key = "steam-location"
steam_dir = Path(win.schema.get_string(location_key)).expanduser()
steam_dir = Path(shared.schema.get_string(location_key)).expanduser()
check = "steamapps"
if not (steam_dir / check).is_file():
@@ -143,7 +144,9 @@ def steam_installed(win, path=None):
if os.name == "nt":
locations += (Path(os.getenv("programfiles(x86)")) / "Steam",)
steam_dir = check_install(check, locations, (win.schema, location_key), subdirs)
steam_dir = check_install(
check, locations, (shared.schema, location_key), subdirs
)
return steam_dir