🎨 Using absolute imports
This commit is contained in:
@@ -24,12 +24,13 @@ from time import time
|
|||||||
from gi.repository import Adw, Gio, GLib, Gtk
|
from gi.repository import Adw, Gio, GLib, Gtk
|
||||||
from PIL import Image
|
from PIL import Image
|
||||||
|
|
||||||
|
# TODO use SGDBHelper
|
||||||
from . import shared
|
from . import shared
|
||||||
from .create_dialog import create_dialog
|
from cartridges.game import Game
|
||||||
from .game import Game
|
from cartridges.game_cover import GameCover
|
||||||
from .game_cover import GameCover
|
from cartridges.utils.create_dialog import create_dialog
|
||||||
from .save_cover import resize_cover, save_cover
|
from cartridges.utils.save_cover import resize_cover, save_cover
|
||||||
from .steamgriddb import SGDBSave
|
from cartridges.utils.steamgriddb import SGDBSave
|
||||||
|
|
||||||
|
|
||||||
@Gtk.Template(resource_path="/hu/kramo/Cartridges/gtk/details_window.ui")
|
@Gtk.Template(resource_path="/hu/kramo/Cartridges/gtk/details_window.ui")
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ from time import time
|
|||||||
from gi.repository import Adw, Gio, Gtk
|
from gi.repository import Adw, Gio, Gtk
|
||||||
|
|
||||||
from . import shared
|
from . import shared
|
||||||
from .game_cover import GameCover
|
from cartridges.game_cover import GameCover
|
||||||
|
|
||||||
|
|
||||||
@Gtk.Template(resource_path="/hu/kramo/Cartridges/gtk/game.ui")
|
@Gtk.Template(resource_path="/hu/kramo/Cartridges/gtk/game.ui")
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
import logging
|
import logging
|
||||||
|
|
||||||
from requests import HTTPError
|
|
||||||
from gi.repository import Adw, Gio, Gtk
|
from gi.repository import Adw, Gio, Gtk
|
||||||
|
from requests import HTTPError
|
||||||
|
|
||||||
from .task import Task
|
from cartridges.utils.create_dialog import create_dialog
|
||||||
from .create_dialog import create_dialog
|
from cartridges.utils.steamgriddb import SGDBAuthError, SGDBError, SGDBHelper
|
||||||
from .steamgriddb import SGDBAuthError, SGDBError, SGDBHelper
|
from cartridges.utils.task import Task
|
||||||
|
|
||||||
|
|
||||||
class Importer:
|
class Importer:
|
||||||
|
|||||||
@@ -2,10 +2,10 @@ from functools import cache
|
|||||||
from sqlite3 import connect
|
from sqlite3 import connect
|
||||||
from time import time
|
from time import time
|
||||||
|
|
||||||
from .decorators import replaced_by_path, replaced_by_schema_key
|
from cartridges.game import Game
|
||||||
from .game import Game
|
from cartridges.importer.source import Source, SourceIterator
|
||||||
from .save_cover import resize_cover, save_cover
|
from cartridges.utils.decorators import replaced_by_path, replaced_by_schema_key
|
||||||
from .source import Source, SourceIterator
|
from cartridges.utils.save_cover import resize_cover, save_cover
|
||||||
|
|
||||||
|
|
||||||
class LutrisSourceIterator(SourceIterator):
|
class LutrisSourceIterator(SourceIterator):
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ from time import time
|
|||||||
import yaml
|
import yaml
|
||||||
|
|
||||||
from . import shared
|
from . import shared
|
||||||
from .check_install import check_install
|
from cartridges.utils.check_install import check_install
|
||||||
|
|
||||||
|
|
||||||
def bottles_installed(path=None):
|
def bottles_installed(path=None):
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ from pathlib import Path
|
|||||||
from time import time
|
from time import time
|
||||||
|
|
||||||
from . import shared
|
from . import shared
|
||||||
from .check_install import check_install
|
from cartridges.utils.check_install import check_install
|
||||||
|
|
||||||
|
|
||||||
def heroic_installed(path=None):
|
def heroic_installed(path=None):
|
||||||
|
|||||||
@@ -27,8 +27,8 @@ import requests
|
|||||||
from gi.repository import GdkPixbuf, Gio
|
from gi.repository import GdkPixbuf, Gio
|
||||||
|
|
||||||
from . import shared
|
from . import shared
|
||||||
from .check_install import check_install
|
from cartridges.utils.check_install import check_install
|
||||||
from .save_cover import resize_cover
|
from cartridges.utils.save_cover import resize_cover
|
||||||
|
|
||||||
|
|
||||||
def get_game(task, current_time, row):
|
def get_game(task, current_time, row):
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ from sqlite3 import connect
|
|||||||
from time import time
|
from time import time
|
||||||
|
|
||||||
from . import shared
|
from . import shared
|
||||||
from .check_install import check_install
|
from cartridges.utils.check_install import check_install
|
||||||
|
|
||||||
|
|
||||||
def lutris_installed(path=None):
|
def lutris_installed(path=None):
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ import requests
|
|||||||
from gi.repository import Gio
|
from gi.repository import Gio
|
||||||
|
|
||||||
from . import shared
|
from . import shared
|
||||||
from .check_install import check_install
|
from cartridges.utils.check_install import check_install
|
||||||
|
|
||||||
|
|
||||||
def update_values_from_data(content, values):
|
def update_values_from_data(content, values):
|
||||||
|
|||||||
17
src/main.py
17
src/main.py
@@ -17,9 +17,9 @@
|
|||||||
#
|
#
|
||||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
|
|
||||||
import sys
|
|
||||||
import os
|
|
||||||
import logging
|
import logging
|
||||||
|
import os
|
||||||
|
import sys
|
||||||
|
|
||||||
import gi
|
import gi
|
||||||
|
|
||||||
@@ -30,11 +30,14 @@ gi.require_version("Adw", "1")
|
|||||||
from gi.repository import Adw, Gio, GLib, Gtk
|
from gi.repository import Adw, Gio, GLib, Gtk
|
||||||
|
|
||||||
from . import shared
|
from . import shared
|
||||||
from .details_window import DetailsWindow
|
from cartridges.details_window import DetailsWindow
|
||||||
from .preferences import PreferencesWindow
|
from cartridges.importer.importer import Importer
|
||||||
from .window import CartridgesWindow
|
from cartridges.importer.sources.lutris_source import (
|
||||||
from .importer import Importer
|
LutrisFlatpakSource,
|
||||||
from .lutris_source import LutrisNativeSource, LutrisFlatpakSource
|
LutrisNativeSource,
|
||||||
|
)
|
||||||
|
from cartridges.preferences import PreferencesWindow
|
||||||
|
from cartridges.window import CartridgesWindow
|
||||||
|
|
||||||
|
|
||||||
class CartridgesApplication(Adw.Application):
|
class CartridgesApplication(Adw.Application):
|
||||||
|
|||||||
@@ -16,10 +16,11 @@ configure_file(
|
|||||||
install_dir: get_option('bindir')
|
install_dir: get_option('bindir')
|
||||||
)
|
)
|
||||||
|
|
||||||
# TODO move to absolute imports = keep real structure, do not flatten
|
install_subdir('importer', install_dir: moduledir)
|
||||||
|
install_subdir('importers', install_dir: moduledir)
|
||||||
cartridges_sources = [
|
install_subdir('utils', install_dir: moduledir)
|
||||||
'__init__.py',
|
install_data(
|
||||||
|
[
|
||||||
'main.py',
|
'main.py',
|
||||||
'window.py',
|
'window.py',
|
||||||
'preferences.py',
|
'preferences.py',
|
||||||
@@ -27,24 +28,6 @@ cartridges_sources = [
|
|||||||
'game.py',
|
'game.py',
|
||||||
'game_cover.py',
|
'game_cover.py',
|
||||||
'shared.py',
|
'shared.py',
|
||||||
'utils/steamgriddb.py',
|
],
|
||||||
'utils/save_cover.py',
|
install_dir: moduledir
|
||||||
'utils/create_dialog.py',
|
)
|
||||||
|
|
||||||
# Added
|
|
||||||
'importer/sources/lutris_source.py',
|
|
||||||
'importer/importer.py',
|
|
||||||
'importer/source.py',
|
|
||||||
'utils/decorators.py',
|
|
||||||
'utils/task.py',
|
|
||||||
|
|
||||||
# TODO remove before merge
|
|
||||||
'importers/bottles_importer.py',
|
|
||||||
'importers/heroic_importer.py',
|
|
||||||
'importers/itch_importer.py',
|
|
||||||
'importers/lutris_importer.py',
|
|
||||||
'importers/steam_importer.py',
|
|
||||||
'utils/check_install.py'
|
|
||||||
]
|
|
||||||
|
|
||||||
install_data(cartridges_sources, install_dir: moduledir)
|
|
||||||
@@ -25,12 +25,13 @@ from gi.repository import Adw, Gio, GLib, Gtk
|
|||||||
|
|
||||||
# pylint: disable=unused-import
|
# pylint: disable=unused-import
|
||||||
from . import shared
|
from . import shared
|
||||||
from .bottles_importer import bottles_installed
|
# TODO use the new sources
|
||||||
from .create_dialog import create_dialog
|
from cartridges.importers.bottles_importer import bottles_installed
|
||||||
from .heroic_importer import heroic_installed
|
from cartridges.importers.heroic_importer import heroic_installed
|
||||||
from .itch_importer import itch_installed
|
from cartridges.importers.itch_importer import itch_installed
|
||||||
from .lutris_importer import lutris_cache_exists, lutris_installed
|
from cartridges.importers.lutris_importer import lutris_cache_exists, lutris_installed
|
||||||
from .steam_importer import steam_installed
|
from cartridges.importers.steam_importer import steam_installed
|
||||||
|
from cartridges.utils.create_dialog import create_dialog
|
||||||
|
|
||||||
|
|
||||||
@Gtk.Template(resource_path="/hu/kramo/Cartridges/gtk/preferences.ui")
|
@Gtk.Template(resource_path="/hu/kramo/Cartridges/gtk/preferences.ui")
|
||||||
|
|||||||
@@ -20,6 +20,7 @@
|
|||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
|
|
||||||
|
# TODO delegate to the sources
|
||||||
def check_install(check, locations, setting=None, subdirs=(Path(),)):
|
def check_install(check, locations, setting=None, subdirs=(Path(),)):
|
||||||
for location in locations:
|
for location in locations:
|
||||||
for subdir in (Path(),) + subdirs:
|
for subdir in (Path(),) + subdirs:
|
||||||
|
|||||||
@@ -1,13 +1,13 @@
|
|||||||
|
import logging
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
import logging
|
|
||||||
import requests
|
import requests
|
||||||
from requests import HTTPError
|
|
||||||
from gi.repository import Gio
|
from gi.repository import Gio
|
||||||
|
from requests import HTTPError
|
||||||
|
|
||||||
from . import shared
|
from . import shared
|
||||||
from .create_dialog import create_dialog
|
from cartridges.utils.create_dialog import create_dialog
|
||||||
from .save_cover import save_cover, resize_cover
|
from cartridges.utils.save_cover import resize_cover, save_cover
|
||||||
|
|
||||||
|
|
||||||
class SGDBError(Exception):
|
class SGDBError(Exception):
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ from datetime import datetime
|
|||||||
from gi.repository import Adw, Gio, GLib, Gtk
|
from gi.repository import Adw, Gio, GLib, Gtk
|
||||||
|
|
||||||
from . import shared
|
from . import shared
|
||||||
from .game import Game
|
from cartridges.game import Game
|
||||||
|
|
||||||
|
|
||||||
@Gtk.Template(resource_path="/hu/kramo/Cartridges/gtk/window.ui")
|
@Gtk.Template(resource_path="/hu/kramo/Cartridges/gtk/window.ui")
|
||||||
|
|||||||
Reference in New Issue
Block a user