ya2 · news · projects · code · about

main component
authorFlavio Calva <f.calva@gmail.com>
Tue, 7 Jun 2022 18:24:30 +0000 (19:24 +0100)
committerFlavio Calva <f.calva@gmail.com>
Tue, 7 Jun 2022 18:24:30 +0000 (19:24 +0100)
main.py
main/__init__.py [new file with mode: 0644]
main/main.py [new file with mode: 0644]

diff --git a/main.py b/main.py
index 3d4b45f1e0dd286f7c0f806f1e63af1055019289..c9d577f977722e10c660298010816e3374e05b16 100644 (file)
--- a/main.py
+++ b/main.py
@@ -1,19 +1,6 @@
-'''This is the main file. This launches the application.'''
-import ya2.engine.log  # so logging's info/debug are logged
-from sys import argv
-from panda3d.core import load_prc_file_data
-if '--version' in argv:
-    load_prc_file_data('', 'window-type none')
 from os.path import exists
-from traceback import print_exc
-from game.app import PmachinesApp
-from p3d_appimage import AppImageBuilder
+import main.main
+
 
 if __name__ == '__main__' or exists('main.pyo'):
-    pmachines = PmachinesApp()
-    if pmachines.updating:
-        AppImageBuilder('pmachines').update()
-    elif not pmachines.version:
-        try: pmachines.base.run()
-        except Exception:
-            print_exc()
+    main.main.Main()
diff --git a/main/__init__.py b/main/__init__.py
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/main/main.py b/main/main.py
new file mode 100644 (file)
index 0000000..83c8adb
--- /dev/null
@@ -0,0 +1,21 @@
+import ya2.engine.log  # so logging's info/debug are logged
+from sys import argv
+from panda3d.core import load_prc_file_data
+if '--version' in argv:
+    load_prc_file_data('', 'window-type none')
+from os.path import exists
+from traceback import print_exc
+from game.app import PmachinesApp
+from p3d_appimage import AppImageBuilder
+
+
+class Main:
+
+    def __init__(self):
+        pmachines = PmachinesApp()
+        if pmachines.updating:
+            AppImageBuilder('pmachines').update()
+        elif not pmachines.version:
+            try: pmachines.base.run()
+            except Exception:
+                print_exc()