mirror of
https://github.com/spalencsar/bearhub.git
synced 2026-07-09 18:54:16 +02:00
improvement -> all suported types now display a 'Checking configuration file' task during the initialization process
This commit is contained in:
@@ -1,80 +1,73 @@
|
||||
from pathlib import Path
|
||||
|
||||
import yaml
|
||||
|
||||
from bauh import __app_name__
|
||||
from bauh.commons.config import read_config as read
|
||||
from bauh.commons.config import YAMLConfigManager
|
||||
|
||||
CONFIG_PATH = '{}/.config/{}'.format(Path.home(), __app_name__)
|
||||
FILE_PATH = '{}/config.yml'.format(CONFIG_PATH)
|
||||
FILE_PATH = '{}/.config/{}/config.yml'.format(str(Path.home()), __app_name__)
|
||||
|
||||
|
||||
def read_config(update_file: bool = False) -> dict:
|
||||
default = {
|
||||
'gems': None,
|
||||
'memory_cache': {
|
||||
'data_expiration': 60 * 60,
|
||||
'icon_expiration': 60 * 5
|
||||
},
|
||||
'locale': None,
|
||||
'updates': {
|
||||
'check_interval': 30,
|
||||
'ask_for_reboot': True
|
||||
},
|
||||
'system': {
|
||||
'notifications': True,
|
||||
'single_dependency_checking': False
|
||||
},
|
||||
'suggestions': {
|
||||
'enabled': True,
|
||||
'by_type': 10
|
||||
},
|
||||
'ui': {
|
||||
'table': {
|
||||
'max_displayed': 50
|
||||
class CoreConfigManager(YAMLConfigManager):
|
||||
|
||||
def __init__(self):
|
||||
super(CoreConfigManager, self).__init__(config_file_path=FILE_PATH)
|
||||
|
||||
def get_default_config(self) -> dict:
|
||||
return {
|
||||
'gems': None,
|
||||
'memory_cache': {
|
||||
'data_expiration': 60 * 60,
|
||||
'icon_expiration': 60 * 5
|
||||
},
|
||||
'tray': {
|
||||
'default_icon': None,
|
||||
'updates_icon': None
|
||||
'locale': None,
|
||||
'updates': {
|
||||
'check_interval': 30,
|
||||
'ask_for_reboot': True
|
||||
},
|
||||
'qt_style': 'fusion',
|
||||
'hdpi': True,
|
||||
"auto_scale": False,
|
||||
"scale_factor": 1.0,
|
||||
'theme': 'light',
|
||||
'system_theme': False
|
||||
'system': {
|
||||
'notifications': True,
|
||||
'single_dependency_checking': False
|
||||
},
|
||||
'suggestions': {
|
||||
'enabled': True,
|
||||
'by_type': 10
|
||||
},
|
||||
'ui': {
|
||||
'table': {
|
||||
'max_displayed': 50
|
||||
},
|
||||
'tray': {
|
||||
'default_icon': None,
|
||||
'updates_icon': None
|
||||
},
|
||||
'qt_style': 'fusion',
|
||||
'hdpi': True,
|
||||
"auto_scale": False,
|
||||
"scale_factor": 1.0,
|
||||
'theme': 'light',
|
||||
'system_theme': False
|
||||
|
||||
},
|
||||
'download': {
|
||||
'multithreaded': True,
|
||||
'multithreaded_client': None,
|
||||
'icons': True
|
||||
},
|
||||
'store_root_password': True,
|
||||
'disk': {
|
||||
'trim': {
|
||||
'after_upgrade': False
|
||||
},
|
||||
'download': {
|
||||
'multithreaded': True,
|
||||
'multithreaded_client': None,
|
||||
'icons': True
|
||||
},
|
||||
'store_root_password': True,
|
||||
'disk': {
|
||||
'trim': {
|
||||
'after_upgrade': False
|
||||
}
|
||||
},
|
||||
'backup': {
|
||||
'enabled': True,
|
||||
'install': None,
|
||||
'uninstall': None,
|
||||
'downgrade': None,
|
||||
'upgrade': None,
|
||||
'mode': 'incremental',
|
||||
'type': 'rsync'
|
||||
},
|
||||
'boot': {
|
||||
'load_apps': True
|
||||
}
|
||||
},
|
||||
'backup': {
|
||||
'enabled': True,
|
||||
'install': None,
|
||||
'uninstall': None,
|
||||
'downgrade': None,
|
||||
'upgrade': None,
|
||||
'mode': 'incremental',
|
||||
'type': 'rsync'
|
||||
},
|
||||
'boot': {
|
||||
'load_apps': True
|
||||
}
|
||||
|
||||
}
|
||||
return read(FILE_PATH, default, update_file=update_file, update_async=True)
|
||||
|
||||
|
||||
def save(config: dict):
|
||||
Path(CONFIG_PATH).mkdir(parents=True, exist_ok=True)
|
||||
|
||||
with open(FILE_PATH, 'w+') as f:
|
||||
f.write(yaml.safe_dump(config))
|
||||
|
||||
Reference in New Issue
Block a user