Get rid of platforms module

This commit is contained in:
Mathieu Comandon 2021-01-23 01:16:58 -08:00
parent fd362d9065
commit de7beb0172
3 changed files with 13 additions and 19 deletions

View file

@ -3,7 +3,7 @@ from gettext import gettext as _
from gi.repository import GLib, GObject, Gtk, Pango
from lutris import platforms, runners, services
from lutris import runners, services
from lutris.database import categories as categories_db
from lutris.database import games as games_db
from lutris.game import Game
@ -275,7 +275,7 @@ class LutrisSidebar(Gtk.ListBox):
def on_realize(self, widget):
self.active_platforms = games_db.get_used_platforms()
self.runners = sorted(runners.__all__)
self.platforms = sorted(platforms.__all__)
self.platforms = sorted(runners.get_platforms())
self.categories = categories_db.get_categories()
self.add(

View file

@ -1,17 +0,0 @@
"""Generic platform functions."""
# Standard Library
from collections import defaultdict
from lutris import runners
# gets populated by _init_platforms()
__all__ = defaultdict(list)
def _init_platforms():
for runner_name in runners.__all__:
runner = runners.import_runner(runner_name)()
for platform in runner.platforms:
__all__[platform].append(runner_name)
_init_platforms()

View file

@ -1,4 +1,5 @@
"""Runner loaders"""
from collections import defaultdict
__all__ = [
# Native
@ -112,4 +113,14 @@ def get_runner_names():
}
def get_platforms():
"""Return a dictionary of all supported platforms with their runners"""
platforms = defaultdict(list)
for runner_name in __all__:
runner = import_runner(runner_name)()
for platform in runner.platforms:
platforms[platform].append(runner_name)
return platforms
RUNNER_NAMES = {} # This needs to be initialized at startup with get_runner_names