🚧 WIP new location system
TODO - Locations contain the schema key - Schema key overriden at location resolve - No need for callable candidates, but need to represent "this location's key"
This commit is contained in:
@@ -17,19 +17,18 @@
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
from shutil import rmtree
|
||||
from sqlite3 import connect
|
||||
from time import time
|
||||
|
||||
from src import shared
|
||||
from src.game import Game
|
||||
from src.importer.sources.location import Location
|
||||
from src.importer.sources.source import (
|
||||
SourceIterationResult,
|
||||
SourceIterator,
|
||||
URLExecutableSource,
|
||||
)
|
||||
from src.utils.decorators import replaced_by_path, replaced_by_schema_key
|
||||
from src.utils.sqlite import copy_db
|
||||
|
||||
|
||||
@@ -52,7 +51,7 @@ class LutrisSourceIterator(SourceIterator):
|
||||
;
|
||||
"""
|
||||
params = {"import_steam": shared.schema.get_boolean("lutris-import-steam")}
|
||||
db_path = copy_db(self.source.location / "pga.db")
|
||||
db_path = copy_db(self.source.data_location["pga.db"])
|
||||
connection = connect(db_path)
|
||||
cursor = connection.execute(request, params)
|
||||
|
||||
@@ -73,7 +72,7 @@ class LutrisSourceIterator(SourceIterator):
|
||||
game = Game(values, allow_side_effects=False)
|
||||
|
||||
# Get official image path
|
||||
image_path = self.source.location / "covers" / "coverart" / f"{row[2]}.jpg"
|
||||
image_path = self.source.cache_location["coverart"] / f"{row[2]}.jpg"
|
||||
additional_data = {"local_image_path": image_path}
|
||||
|
||||
# Produce game
|
||||
@@ -91,13 +90,32 @@ class LutrisSource(URLExecutableSource):
|
||||
url_format = "lutris:rungameid/{game_id}"
|
||||
available_on = set(("linux",))
|
||||
|
||||
# FIXME possible bug: location picks ~/.var... and cache_lcoation picks ~/.local...
|
||||
|
||||
data_location = Location(
|
||||
candidates=(
|
||||
lambda: shared.schema.get_string("lutris-location"),
|
||||
"~/.var/app/net.lutris.Lutris/data/lutris/",
|
||||
shared.data_dir / "lutris/",
|
||||
"~/.local/share/lutris/",
|
||||
),
|
||||
paths={
|
||||
"pga.db": (False, "pga.db"),
|
||||
},
|
||||
)
|
||||
|
||||
cache_location = Location(
|
||||
candidates=(
|
||||
lambda: shared.schema.get_string("lutris-cache-location"),
|
||||
"~/.var/app/net.lutris.Lutris/cache/lutris/",
|
||||
shared.cache_dir / "lutris/",
|
||||
"~/.cache/lutris",
|
||||
),
|
||||
paths={
|
||||
"coverart": (True, "coverart"),
|
||||
},
|
||||
)
|
||||
|
||||
@property
|
||||
def game_id_format(self):
|
||||
return super().game_id_format + "_{game_internal_id}"
|
||||
|
||||
@property
|
||||
@replaced_by_schema_key
|
||||
@replaced_by_path("~/.var/app/net.lutris.Lutris/data/lutris/")
|
||||
@replaced_by_path("~/.local/share/lutris/")
|
||||
def location(self):
|
||||
raise FileNotFoundError()
|
||||
|
||||
Reference in New Issue
Block a user