mirror of
https://github.com/spalencsar/bearhub.git
synced 2026-07-07 20:54:15 +02:00
[api] refactoring: CONFIG_PATH constant renamed to CONFIG_DIR
This commit is contained in:
@@ -5,7 +5,7 @@ from bauh import __app_name__
|
|||||||
from bauh.api import user
|
from bauh.api import user
|
||||||
|
|
||||||
CACHE_PATH = f'/var/cache/{__app_name__}' if user.is_root() else f'{Path.home()}/.cache/{__app_name__}'
|
CACHE_PATH = f'/var/cache/{__app_name__}' if user.is_root() else f'{Path.home()}/.cache/{__app_name__}'
|
||||||
CONFIG_PATH = f'/etc/{__app_name__}' if user.is_root() else f'{Path.home()}/.config/{__app_name__}'
|
CONFIG_DIR = f'/etc/{__app_name__}' if user.is_root() else f'{Path.home()}/.config/{__app_name__}'
|
||||||
USER_THEMES_PATH = '{}/.local/share/bauh/themes'.format(str(Path.home()))
|
USER_THEMES_PATH = '{}/.local/share/bauh/themes'.format(str(Path.home()))
|
||||||
DESKTOP_ENTRIES_DIR = '{}/.local/share/applications'.format(str(Path.home()))
|
DESKTOP_ENTRIES_DIR = '{}/.local/share/applications'.format(str(Path.home()))
|
||||||
TEMP_DIR = f'/tmp/{__app_name__}@{getuser()}'
|
TEMP_DIR = f'/tmp/{__app_name__}@{getuser()}'
|
||||||
|
|||||||
@@ -7,13 +7,13 @@ from typing import Optional
|
|||||||
|
|
||||||
import yaml
|
import yaml
|
||||||
|
|
||||||
from bauh.api.paths import CONFIG_PATH
|
from bauh.api.paths import CONFIG_DIR
|
||||||
from bauh.commons import util
|
from bauh.commons import util
|
||||||
|
|
||||||
|
|
||||||
def read_config(file_path: str, template: dict, update_file: bool = False, update_async: bool = False) -> dict:
|
def read_config(file_path: str, template: dict, update_file: bool = False, update_async: bool = False) -> dict:
|
||||||
if not os.path.exists(file_path):
|
if not os.path.exists(file_path):
|
||||||
Path(CONFIG_PATH).mkdir(parents=True, exist_ok=True)
|
Path(CONFIG_DIR).mkdir(parents=True, exist_ok=True)
|
||||||
save_config(template, file_path)
|
save_config(template, file_path)
|
||||||
else:
|
else:
|
||||||
with open(file_path) as f:
|
with open(file_path) as f:
|
||||||
|
|||||||
@@ -2,15 +2,15 @@ import os
|
|||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from typing import Optional
|
from typing import Optional
|
||||||
|
|
||||||
from bauh.api.paths import CONFIG_PATH, TEMP_DIR, CACHE_PATH
|
from bauh.api.paths import CONFIG_DIR, TEMP_DIR, CACHE_PATH
|
||||||
from bauh.commons import resource
|
from bauh.commons import resource
|
||||||
|
|
||||||
ROOT_DIR = os.path.dirname(os.path.abspath(__file__))
|
ROOT_DIR = os.path.dirname(os.path.abspath(__file__))
|
||||||
LOCAL_PATH = '{}/.local/share/bauh/appimage'.format(str(Path.home()))
|
LOCAL_PATH = '{}/.local/share/bauh/appimage'.format(str(Path.home()))
|
||||||
INSTALLATION_PATH = LOCAL_PATH + '/installed/'
|
INSTALLATION_PATH = LOCAL_PATH + '/installed/'
|
||||||
SUGGESTIONS_FILE = 'https://raw.githubusercontent.com/vinifmor/bauh-files/master/appimage/suggestions.txt'
|
SUGGESTIONS_FILE = 'https://raw.githubusercontent.com/vinifmor/bauh-files/master/appimage/suggestions.txt'
|
||||||
CONFIG_FILE = f'{CONFIG_PATH}/appimage.yml'
|
CONFIG_FILE = f'{CONFIG_DIR}/appimage.yml'
|
||||||
APPIMAGE_CONFIG_DIR = f'{CONFIG_PATH}/appimage'
|
APPIMAGE_CONFIG_DIR = f'{CONFIG_DIR}/appimage'
|
||||||
UPDATES_IGNORED_FILE = f'{APPIMAGE_CONFIG_DIR}/updates_ignored.txt'
|
UPDATES_IGNORED_FILE = f'{APPIMAGE_CONFIG_DIR}/updates_ignored.txt'
|
||||||
SYMLINKS_DIR = '{}/.local/bin'.format(str(Path.home()))
|
SYMLINKS_DIR = '{}/.local/bin'.format(str(Path.home()))
|
||||||
URL_COMPRESSED_DATABASES = 'https://raw.githubusercontent.com/vinifmor/bauh-files/master/appimage/dbs.tar.gz'
|
URL_COMPRESSED_DATABASES = 'https://raw.githubusercontent.com/vinifmor/bauh-files/master/appimage/dbs.tar.gz'
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import os
|
import os
|
||||||
|
|
||||||
from bauh.api.paths import CONFIG_PATH, TEMP_DIR, CACHE_PATH
|
from bauh.api.paths import CONFIG_DIR, TEMP_DIR, CACHE_PATH
|
||||||
from bauh.commons import resource
|
from bauh.commons import resource
|
||||||
|
|
||||||
ROOT_DIR = os.path.dirname(os.path.abspath(__file__))
|
ROOT_DIR = os.path.dirname(os.path.abspath(__file__))
|
||||||
@@ -9,11 +9,11 @@ ARCH_CACHE_PATH = f'{CACHE_PATH}/arch'
|
|||||||
CATEGORIES_FILE_PATH = f'{ARCH_CACHE_PATH}/categories.txt'
|
CATEGORIES_FILE_PATH = f'{ARCH_CACHE_PATH}/categories.txt'
|
||||||
URL_CATEGORIES_FILE = 'https://raw.githubusercontent.com/vinifmor/bauh-files/master/arch/categories.txt'
|
URL_CATEGORIES_FILE = 'https://raw.githubusercontent.com/vinifmor/bauh-files/master/arch/categories.txt'
|
||||||
URL_GPG_SERVERS = 'https://raw.githubusercontent.com/vinifmor/bauh-files/master/arch/gpgservers.txt'
|
URL_GPG_SERVERS = 'https://raw.githubusercontent.com/vinifmor/bauh-files/master/arch/gpgservers.txt'
|
||||||
ARCH_CONFIG_DIR = f'{CONFIG_PATH}/arch'
|
ARCH_CONFIG_DIR = f'{CONFIG_DIR}/arch'
|
||||||
CUSTOM_MAKEPKG_FILE = f'{ARCH_CONFIG_DIR}/makepkg.conf'
|
CUSTOM_MAKEPKG_FILE = f'{ARCH_CONFIG_DIR}/makepkg.conf'
|
||||||
AUR_INDEX_FILE = f'{ARCH_CACHE_PATH}/aur/index.txt'
|
AUR_INDEX_FILE = f'{ARCH_CACHE_PATH}/aur/index.txt'
|
||||||
AUR_INDEX_TS_FILE = f'{ARCH_CACHE_PATH}/aur/index.ts'
|
AUR_INDEX_TS_FILE = f'{ARCH_CACHE_PATH}/aur/index.ts'
|
||||||
CONFIG_FILE = f'{CONFIG_PATH}/arch.yml'
|
CONFIG_FILE = f'{CONFIG_DIR}/arch.yml'
|
||||||
SUGGESTIONS_FILE = 'https://raw.githubusercontent.com/vinifmor/bauh-files/master/arch/aur_suggestions.txt'
|
SUGGESTIONS_FILE = 'https://raw.githubusercontent.com/vinifmor/bauh-files/master/arch/aur_suggestions.txt'
|
||||||
UPDATES_IGNORED_FILE = f'{ARCH_CONFIG_DIR}/updates_ignored.txt'
|
UPDATES_IGNORED_FILE = f'{ARCH_CONFIG_DIR}/updates_ignored.txt'
|
||||||
EDITABLE_PKGBUILDS_FILE = f'{ARCH_CONFIG_DIR}/aur/editable_pkgbuilds.txt'
|
EDITABLE_PKGBUILDS_FILE = f'{ARCH_CONFIG_DIR}/aur/editable_pkgbuilds.txt'
|
||||||
|
|||||||
@@ -3,13 +3,13 @@ from pathlib import Path
|
|||||||
|
|
||||||
from packaging.version import parse as parse_version
|
from packaging.version import parse as parse_version
|
||||||
|
|
||||||
from bauh.api.paths import CONFIG_PATH
|
from bauh.api.paths import CONFIG_DIR
|
||||||
from bauh.commons import resource
|
from bauh.commons import resource
|
||||||
|
|
||||||
ROOT_DIR = os.path.dirname(os.path.abspath(__file__))
|
ROOT_DIR = os.path.dirname(os.path.abspath(__file__))
|
||||||
SUGGESTIONS_FILE = 'https://raw.githubusercontent.com/vinifmor/bauh-files/master/flatpak/suggestions.txt'
|
SUGGESTIONS_FILE = 'https://raw.githubusercontent.com/vinifmor/bauh-files/master/flatpak/suggestions.txt'
|
||||||
CONFIG_FILE = f'{CONFIG_PATH}/flatpak.yml'
|
CONFIG_FILE = f'{CONFIG_DIR}/flatpak.yml'
|
||||||
FLATPAK_CONFIG_DIR = f'{CONFIG_PATH}/flatpak'
|
FLATPAK_CONFIG_DIR = f'{CONFIG_DIR}/flatpak'
|
||||||
UPDATES_IGNORED_FILE = f'{FLATPAK_CONFIG_DIR}/updates_ignored.txt'
|
UPDATES_IGNORED_FILE = f'{FLATPAK_CONFIG_DIR}/updates_ignored.txt'
|
||||||
EXPORTS_PATH = '{}/.local/share/flatpak/exports/share'.format(str(Path.home()))
|
EXPORTS_PATH = '{}/.local/share/flatpak/exports/share'.format(str(Path.home()))
|
||||||
VERSION_1_2 = parse_version('1.2')
|
VERSION_1_2 = parse_version('1.2')
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
import os
|
import os
|
||||||
|
|
||||||
from bauh.api.paths import CONFIG_PATH, CACHE_PATH
|
from bauh.api.paths import CONFIG_DIR, CACHE_PATH
|
||||||
from bauh.commons import resource
|
from bauh.commons import resource
|
||||||
|
|
||||||
ROOT_DIR = os.path.dirname(os.path.abspath(__file__))
|
ROOT_DIR = os.path.dirname(os.path.abspath(__file__))
|
||||||
SNAP_CACHE_PATH = f'{CACHE_PATH}/snap'
|
SNAP_CACHE_PATH = f'{CACHE_PATH}/snap'
|
||||||
CONFIG_FILE = f'{CONFIG_PATH}/snap.yml'
|
CONFIG_FILE = f'{CONFIG_DIR}/snap.yml'
|
||||||
CATEGORIES_FILE_PATH = f'{SNAP_CACHE_PATH}/categories.txt'
|
CATEGORIES_FILE_PATH = f'{SNAP_CACHE_PATH}/categories.txt'
|
||||||
URL_CATEGORIES_FILE = 'https://raw.githubusercontent.com/vinifmor/bauh-files/master/snap/categories.txt'
|
URL_CATEGORIES_FILE = 'https://raw.githubusercontent.com/vinifmor/bauh-files/master/snap/categories.txt'
|
||||||
SUGGESTIONS_FILE = 'https://raw.githubusercontent.com/vinifmor/bauh-files/master/snap/suggestions.txt'
|
SUGGESTIONS_FILE = 'https://raw.githubusercontent.com/vinifmor/bauh-files/master/snap/suggestions.txt'
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import os
|
import os
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
from bauh.api.paths import DESKTOP_ENTRIES_DIR, CONFIG_PATH, TEMP_DIR, CACHE_PATH
|
from bauh.api.paths import DESKTOP_ENTRIES_DIR, CONFIG_DIR, TEMP_DIR, CACHE_PATH
|
||||||
from bauh.commons import resource
|
from bauh.commons import resource
|
||||||
from bauh.commons.util import map_timestamp_file
|
from bauh.commons.util import map_timestamp_file
|
||||||
|
|
||||||
@@ -31,7 +31,7 @@ TEMP_PATH = f'{TEMP_DIR}/web'
|
|||||||
SEARCH_INDEX_FILE = f'{WEB_CACHE_PATH}/index.yml'
|
SEARCH_INDEX_FILE = f'{WEB_CACHE_PATH}/index.yml'
|
||||||
SUGGESTIONS_CACHE_FILE = f'{WEB_CACHE_PATH}/suggestions.yml'
|
SUGGESTIONS_CACHE_FILE = f'{WEB_CACHE_PATH}/suggestions.yml'
|
||||||
SUGGESTIONS_CACHE_TS_FILE = map_timestamp_file(SUGGESTIONS_CACHE_FILE)
|
SUGGESTIONS_CACHE_TS_FILE = map_timestamp_file(SUGGESTIONS_CACHE_FILE)
|
||||||
CONFIG_FILE = f'{CONFIG_PATH}/web.yml'
|
CONFIG_FILE = f'{CONFIG_DIR}/web.yml'
|
||||||
ENVIRONMENT_SETTINGS_CACHED_FILE = f'{WEB_CACHE_PATH}/environment.yml'
|
ENVIRONMENT_SETTINGS_CACHED_FILE = f'{WEB_CACHE_PATH}/environment.yml'
|
||||||
ENVIRONMENT_SETTINGS_TS_FILE = f'{WEB_CACHE_PATH}/environment.ts'
|
ENVIRONMENT_SETTINGS_TS_FILE = f'{WEB_CACHE_PATH}/environment.ts'
|
||||||
NATIVEFIER_BASE_URL = 'https://github.com/nativefier/nativefier/archive/v{version}.tar.gz'
|
NATIVEFIER_BASE_URL = 'https://github.com/nativefier/nativefier/archive/v{version}.tar.gz'
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ from colorama import Fore
|
|||||||
|
|
||||||
from bauh import __app_name__
|
from bauh import __app_name__
|
||||||
from bauh.api.abstract.controller import SoftwareManager
|
from bauh.api.abstract.controller import SoftwareManager
|
||||||
from bauh.api.paths import CONFIG_PATH, CACHE_PATH
|
from bauh.api.paths import CONFIG_DIR, CACHE_PATH
|
||||||
from bauh.commons.system import run_cmd
|
from bauh.commons.system import run_cmd
|
||||||
from bauh.view.util import resource
|
from bauh.view.util import resource
|
||||||
|
|
||||||
@@ -61,7 +61,7 @@ def clean_app_files(managers: List[SoftwareManager], logs: bool = True):
|
|||||||
if logs:
|
if logs:
|
||||||
print('[bauh] Cleaning configuration and cache files')
|
print('[bauh] Cleaning configuration and cache files')
|
||||||
|
|
||||||
for path in (CACHE_PATH, CONFIG_PATH):
|
for path in (CACHE_PATH, CONFIG_DIR):
|
||||||
if logs:
|
if logs:
|
||||||
print('[bauh] Deleting directory {}'.format(path))
|
print('[bauh] Deleting directory {}'.format(path))
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user