fix imports
authorNiki Roo <niki@nikiroo.be>
Tue, 25 Mar 2025 11:45:42 +0000 (12:45 +0100)
committerNiki Roo <niki@nikiroo.be>
Tue, 25 Mar 2025 11:45:42 +0000 (12:45 +0100)
gamiki/__init__.py
gamiki/builder.py
gamiki/library.py
gamiki/support/__init__.py
gamiki/support/support.py
gamiki/support/support_dos.py
gamiki/support/support_ext.py
gamiki/support/support_gog.py
gamiki/support/support_win.py
gamiki/support/support_win31.py

index e3d79ef9992c3a1bf023ce878b47758d5c15994b..595436ad9b33d3fc900fc0cf2befa4bf791df0ca 100644 (file)
@@ -1,4 +1,5 @@
-from .library import Library
-from .game    import Game
-from .builder import Builder
-from .support import Support
+# Order the dependencies in the right way, and make public classes accessible
+from .game            import Game
+from .support         import Support
+from .library         import Library
+from .builder         import Builder
index 5eabd8ec1fd0e77f4c90b62e5c05014e05b8657b..45c84df5d356e5d966ee4f478b7fa36e7471d04d 100644 (file)
@@ -1,8 +1,9 @@
 from pathlib import Path, PurePath
 
-from .        import Library, Game
-from .support import Support, SupportDos, SupportWin31, SupportGog, SupportExt
-from .support import SupportWin
+from gamiki         import Game, Support, Library
+from gamiki.support import (
+    SupportDos, SupportWin31, SupportGog, SupportExt, SupportWin
+)
 
 class Builder:
     """Manage all the resources needed to run games."""
@@ -10,13 +11,6 @@ class Builder:
         self.libraries : list[Library] = []
         self.games     : list[Game]    = []
         
-        supports = []
-        supports.append(SupportGog())   # gameinfo
-        supports.append(SupportWin())   # wine.bat
-        supports.append(SupportWin31()) # start.conf + C/WINDOWS
-        supports.append(SupportDos())   # start.conf + no C/WINDOWS
-        supports.append(SupportExt())   # start.sh
-        
         targets = []
         config = Path("~/.games.cfg").expanduser()
         if (config.exists()):
@@ -28,19 +22,19 @@ class Builder:
             targets.append(Path("~/Games").expanduser())
         
         for target in targets:
-            self.load_libs(supports, target)
+            self.load_libs(target)
         
         for lib in self.libraries:
             for game in lib:
                 self.games.append(game)
     
-    def load_libs(self, supports: list[Support], dir: PurePath):
+    def load_libs(self, dir: PurePath):
         for path in dir.iterdir():
             if (not path.is_dir()):
                 continue
             
             try:
-                self.libraries.append(Library(path, supports))
+                self.libraries.append(Library(path))
             except FileNotFoundError:
                 pass
         
index 0522b65b3b65721dffa7687f87c9d8b5945d8bdc..54f40d5a59ba68ead45627132ff9dae91b14b5a6 100644 (file)
@@ -1,15 +1,13 @@
 from pathlib import PurePath
 
-from .support import Support
-from .game    import Game
+from gamiki import Game, Support
 
 class Library(list[Game]):
     """Manage a library (a folder) of Games."""
     
-    def __init__(self, dir: PurePath, supports: list[Support]):
+    def __init__(self, dir: PurePath):
         self.name             = dir.name
         self.dir              = dir
-        self.supports         = supports
         self.preferredSupport = None
         
         config = self.dir.joinpath("games.cfg")
@@ -22,7 +20,7 @@ class Library(list[Game]):
             if (not path.is_dir()):
                 continue
             game = Game(self, path)
-            for support in self.supports:
+            for support in Support.all:
                 if (support.supports(game)):
                     game.set_support(support)
                     break;
index c7e3aed184c186f84ae5478f8eff6760b476a47a..7b22862af630bf12eb758ce4c1645d2e08779779 100644 (file)
@@ -1,6 +1,15 @@
+# Order the dependencies in the right way, and make classes accessible
 from .support       import Support
 from .support_dos   import SupportDos
 from .support_win31 import SupportWin31
 from .support_gog   import SupportGog
 from .support_ext   import SupportExt
 from .support_win   import SupportWin
+
+Support.all = [ SupportGog()  ,  # gaminfo
+                SupportWin()  ,  # wine.bat
+                SupportWin31(),  # start.conf + C/WINDOWS
+                SupportDos()  ,  # start.conf + no C/WINDOWS
+                SupportExt()     # start.sh
+]
+
index 282a5b0897e9e3c6c9218696234c3a36cd118fe0..1f1eefff1a2390859610621424ff398898d59282 100644 (file)
@@ -1,7 +1,7 @@
 from subprocess import run
 from shutil     import which
 
-from ..game import Game
+from gamiki import Game
 
 class Support:    
     """Can detect and start games."""
index 05da421240903fe46f57869819482bacd374e755..851aae1a6987eda91661fcc6455ab40c762a0a58 100644 (file)
@@ -1,6 +1,6 @@
-from .         import Support
-from .commands import dosbox
-from ..game    import Game
+from gamiki                  import Game
+from gamiki.support          import Support
+from gamiki.support.commands import dosbox
 
 class SupportDos(Support):
     """Supports DOS games via DosBox."""
index 8eb1e929c57d6334852792117b877d15715d2d38..953c81ad59c2277c9ea462c818ac1200f14c5b9e 100644 (file)
@@ -1,6 +1,6 @@
-from .         import Support
-from .commands import start_sh
-from ..game    import Game
+from gamiki                  import Game
+from gamiki.support          import Support
+from gamiki.support.commands import start_sh
 
 class SupportExt(Support):
     """Supports external games via the 'games' docker or natively."""
index a71ef0b70ab8ce78edb376683511c890d8ab36df..0b1015446e6ae0b93f369e961cf4c6da10cee648 100644 (file)
@@ -1,6 +1,6 @@
-from .         import Support
-from .commands import start_sh
-from ..game    import Game
+from gamiki                  import Game
+from gamiki.support          import Support
+from gamiki.support.commands import start_sh
 
 class SupportGog(Support):
     """Supports GoG games via the 'games' docker or natively."""
index 6d6db08cd61bc910544d2d718b9d289518ca5775..09befddb43ca83503eb14b176f7859551b923858 100644 (file)
@@ -1,6 +1,6 @@
-from .         import Support
-from .commands import wine
-from ..game    import Game
+from gamiki                  import Game
+from gamiki.support          import Support
+from gamiki.support.commands import wine
 
 class SupportWin(Support):
     """Supports Windows games via wine."""
index a4a675195032503db211b8c525eb0e3e3ac73e6f..e89a8fa8080999aaaf8bc91af9a415781dc830d4 100644 (file)
@@ -1,6 +1,6 @@
-from .         import Support
-from .commands import dosbox
-from ..game    import Game
+from gamiki                  import Game
+from gamiki.support          import Support
+from gamiki.support.commands import dosbox
 
 class SupportWin31(Support):
     """Supports Windows 3.1 games via DosBox."""