mirror of
https://github.com/Dvorinka/swingmusic-extended.git
synced 2026-06-03 20:13:02 +00:00
add --config flag to modify config path
+ use getters instead of constants in settings classes + refactor previous references + move get_xdg_config_dir() from settings.py to app.utils.xdg_utils.py
This commit is contained in:
+28
-1
@@ -1,7 +1,7 @@
|
||||
"""
|
||||
Handles arguments passed to the program.
|
||||
"""
|
||||
|
||||
import os.path
|
||||
import sys
|
||||
|
||||
from configparser import ConfigParser
|
||||
@@ -10,6 +10,10 @@ import PyInstaller.__main__ as bundler
|
||||
from app import settings
|
||||
from app.print_help import HELP_MESSAGE
|
||||
from app.utils.wintools import is_windows
|
||||
from app.logger import log
|
||||
from app.utils.xdg_utils import get_xdg_config_dir
|
||||
|
||||
# from app.api.imgserver import set_app_dir
|
||||
|
||||
config = ConfigParser()
|
||||
config.read("pyinstaller.config.ini")
|
||||
@@ -23,6 +27,7 @@ class HandleArgs:
|
||||
self.handle_build()
|
||||
self.handle_host()
|
||||
self.handle_port()
|
||||
self.handle_config_path()
|
||||
self.handle_no_feat()
|
||||
self.handle_remove_prod()
|
||||
self.handle_help()
|
||||
@@ -89,6 +94,28 @@ class HandleArgs:
|
||||
|
||||
settings.FLASKVARS.FLASK_HOST = host # type: ignore
|
||||
|
||||
@staticmethod
|
||||
def handle_config_path():
|
||||
"""
|
||||
Modifies the config path.
|
||||
"""
|
||||
if ALLARGS.config in ARGS:
|
||||
index = ARGS.index(ALLARGS.config)
|
||||
|
||||
try:
|
||||
config_path = ARGS[index + 1]
|
||||
|
||||
if os.path.exists(config_path):
|
||||
settings.Paths.set_config_dir(config_path)
|
||||
return
|
||||
|
||||
log.warn(f"Config path {config_path} doesn't exist")
|
||||
sys.exit(0)
|
||||
except IndexError:
|
||||
pass
|
||||
|
||||
settings.Paths.set_config_dir(get_xdg_config_dir())
|
||||
|
||||
@staticmethod
|
||||
def handle_no_feat():
|
||||
# if ArgsEnum.no_feat in ARGS:
|
||||
|
||||
Reference in New Issue
Block a user