mirror of
https://github.com/PR0M3TH3AN/SeedPass.git
synced 2026-11-04 03:42:04 +00:00
Refactor GUI backend config to constants.py
Extracts the hardcoded BeeWare GUI backend configuration (package names, versions, and SHA256 hashes) from `src/seedpass/cli/__init__.py` into a new `GUI_BACKEND_CONFIG` dictionary in `src/constants.py`. This improves maintainability by centralizing configuration and simplifying the CLI logic. - Adds `GUI_BACKEND_CONFIG` to `src/constants.py`. - Updates `src/seedpass/cli/__init__.py` to import and use `GUI_BACKEND_CONFIG`. Co-authored-by: PR0M3TH3AN <[email protected]>
This commit is contained in:
1 parent
ece0dda09f
commit
9e08e5082b
2 files changed
+30
-13
No files matched your search
@@ -55,6 +55,27 @@ INACTIVITY_TIMEOUT = 15 * 60 # 15 minutes
|
|||||||
# Duration in seconds that a notification remains active
|
# Duration in seconds that a notification remains active
|
||||||
NOTIFICATION_DURATION = 10
|
NOTIFICATION_DURATION = 10
|
||||||
|
|
||||||
|
# -----------------------------------
|
||||||
|
# GUI Backend Configuration
|
||||||
|
# -----------------------------------
|
||||||
|
GUI_BACKEND_CONFIG = {
|
||||||
|
"linux": {
|
||||||
|
"pkg": "toga-gtk",
|
||||||
|
"version": "0.5.2",
|
||||||
|
"sha256": "15b346ac1a2584de5effe5e73a3888f055c68c93300aeb111db9d64186b31646",
|
||||||
|
},
|
||||||
|
"win32": {
|
||||||
|
"pkg": "toga-winforms",
|
||||||
|
"version": "0.5.2",
|
||||||
|
"sha256": "83181309f204bcc4a34709d23fdfd68467ae8ecc39c906d13c661cb9a0ef581b",
|
||||||
|
},
|
||||||
|
"darwin": {
|
||||||
|
"pkg": "toga-cocoa",
|
||||||
|
"version": "0.5.2",
|
||||||
|
"sha256": "a4d5d1546bf92372a6fb1b450164735fb107b2ee69d15bf87421fec3c78465f9",
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
# -----------------------------------
|
# -----------------------------------
|
||||||
# Additional Constants (if any)
|
# Additional Constants (if any)
|
||||||
# -----------------------------------
|
# -----------------------------------
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ import typer
|
|||||||
|
|
||||||
from .common import _get_services
|
from .common import _get_services
|
||||||
from seedpass.core.errors import SeedPassError
|
from seedpass.core.errors import SeedPassError
|
||||||
|
from constants import GUI_BACKEND_CONFIG
|
||||||
|
|
||||||
app = typer.Typer(
|
app = typer.Typer(
|
||||||
help="SeedPass command line interface",
|
help="SeedPass command line interface",
|
||||||
@@ -110,25 +111,20 @@ def gui(
|
|||||||
confirmation.
|
confirmation.
|
||||||
"""
|
"""
|
||||||
if not _gui_backend_available():
|
if not _gui_backend_available():
|
||||||
if sys.platform.startswith("linux"):
|
platform_key = "linux" if sys.platform.startswith("linux") else sys.platform
|
||||||
pkg = "toga-gtk"
|
backend_info = GUI_BACKEND_CONFIG.get(platform_key)
|
||||||
version = "0.5.2"
|
|
||||||
sha256 = "15b346ac1a2584de5effe5e73a3888f055c68c93300aeb111db9d64186b31646"
|
if not backend_info:
|
||||||
elif sys.platform == "win32":
|
|
||||||
pkg = "toga-winforms"
|
|
||||||
version = "0.5.2"
|
|
||||||
sha256 = "83181309f204bcc4a34709d23fdfd68467ae8ecc39c906d13c661cb9a0ef581b"
|
|
||||||
elif sys.platform == "darwin":
|
|
||||||
pkg = "toga-cocoa"
|
|
||||||
version = "0.5.2"
|
|
||||||
sha256 = "a4d5d1546bf92372a6fb1b450164735fb107b2ee69d15bf87421fec3c78465f9"
|
|
||||||
else:
|
|
||||||
typer.echo(
|
typer.echo(
|
||||||
f"Unsupported platform '{sys.platform}' for BeeWare GUI.",
|
f"Unsupported platform '{sys.platform}' for BeeWare GUI.",
|
||||||
err=True,
|
err=True,
|
||||||
)
|
)
|
||||||
raise typer.Exit(1)
|
raise typer.Exit(1)
|
||||||
|
|
||||||
|
pkg = backend_info["pkg"]
|
||||||
|
version = backend_info["version"]
|
||||||
|
sha256 = backend_info["sha256"]
|
||||||
|
|
||||||
if not install:
|
if not install:
|
||||||
typer.echo(
|
typer.echo(
|
||||||
f"BeeWare GUI backend not found. Please install {pkg} manually or rerun "
|
f"BeeWare GUI backend not found. Please install {pkg} manually or rerun "
|
||||||
|
|||||||
Reference in new issue
Block a user