mirror of
https://github.com/spalencsar/bearhub.git
synced 2026-07-08 06:14:16 +02:00
M3 namespace migration: complete Phase B, partial Phase D, docs and tests
- Native runtime under bearhub/ (api, commons, gems, view/util, view/core, view/qt) - bauh/ compatibility re-export shims for legacy imports - Phase D: canonical __version__/__app_name__ in bearhub/__init__.py; pyproject.toml and setup.py point at bearhub package - Native gem loader at bearhub/view/core/gems.py - Namespace compatibility tests (159 tests passing) - Documentation: CHANGELOG [Unreleased], NAMESPACE_MIGRATION, ROADMAP, README, CONTRIBUTING, docs/qt6-migration.md, packaging/aur/README.md
This commit is contained in:
1
bauh/view/core/__init__.py
Executable file → Normal file
1
bauh/view/core/__init__.py
Executable file → Normal file
@@ -0,0 +1 @@
|
||||
from bearhub.view.core import * # noqa: F401,F403
|
||||
|
||||
1
bauh/view/core/controller.py
Normal file
1
bauh/view/core/controller.py
Normal file
@@ -0,0 +1 @@
|
||||
from bearhub.view.core.controller import * # noqa: F401,F403
|
||||
1
bauh/view/core/downloader.py
Normal file
1
bauh/view/core/downloader.py
Normal file
@@ -0,0 +1 @@
|
||||
from bearhub.view.core.downloader import * # noqa: F401,F403
|
||||
@@ -1,81 +1 @@
|
||||
import inspect
|
||||
import importlib
|
||||
import os
|
||||
from logging import Logger
|
||||
from typing import List, Generator
|
||||
|
||||
from bauh import __app_name__, ROOT_DIR
|
||||
from bauh.api.abstract.controller import SoftwareManager, ApplicationContext
|
||||
from bauh.view.util import translation
|
||||
|
||||
FORBIDDEN_GEMS_FILE = f'/etc/{__app_name__}/gems.forbidden'
|
||||
|
||||
|
||||
def find_manager(member):
|
||||
if not isinstance(member, str):
|
||||
if inspect.isclass(member) and inspect.getmro(member)[1].__name__ == 'SoftwareManager':
|
||||
return member
|
||||
elif inspect.ismodule(member):
|
||||
for name, mod in inspect.getmembers(member):
|
||||
manager_found = find_manager(mod)
|
||||
if manager_found:
|
||||
return manager_found
|
||||
|
||||
|
||||
def read_forbidden_gems() -> Generator[str, None, None]:
|
||||
try:
|
||||
with open(FORBIDDEN_GEMS_FILE) as f:
|
||||
forbidden_lines = f.readlines()
|
||||
|
||||
for line in forbidden_lines:
|
||||
clean_line = line.strip()
|
||||
|
||||
if clean_line and not clean_line.startswith('#'):
|
||||
yield clean_line
|
||||
|
||||
except FileNotFoundError:
|
||||
pass
|
||||
|
||||
|
||||
def load_managers(locale: str, context: ApplicationContext, config: dict, default_locale: str, logger: Logger) -> List[SoftwareManager]:
|
||||
managers = []
|
||||
|
||||
forbidden_gems = {gem for gem in read_forbidden_gems()}
|
||||
|
||||
for f in os.scandir(f'{ROOT_DIR}/gems'):
|
||||
if f.is_dir() and f.name != '__pycache__':
|
||||
|
||||
if f.name in forbidden_gems:
|
||||
logger.warning(f"gem '{f.name}' could not be loaded because it was marked as forbidden in '{FORBIDDEN_GEMS_FILE}'")
|
||||
continue
|
||||
|
||||
module_name = f'bauh.gems.{f.name}.controller'
|
||||
|
||||
try:
|
||||
module = importlib.import_module(module_name)
|
||||
except ModuleNotFoundError:
|
||||
module = None
|
||||
|
||||
if module:
|
||||
manager_class = find_manager(module)
|
||||
|
||||
if manager_class:
|
||||
if locale:
|
||||
locale_path = f'{f.path}/resources/locale'
|
||||
|
||||
if os.path.exists(locale_path):
|
||||
context.i18n.current.update(translation.get_locale_keys(locale, locale_path)[1])
|
||||
|
||||
if default_locale and context.i18n.default:
|
||||
context.i18n.default.update(translation.get_locale_keys(default_locale, locale_path)[1])
|
||||
|
||||
man = manager_class(context=context)
|
||||
|
||||
if config['gems'] is None:
|
||||
man.set_enabled(man.is_default_enabled())
|
||||
else:
|
||||
man.set_enabled(f.name in config['gems'])
|
||||
|
||||
managers.append(man)
|
||||
|
||||
return managers
|
||||
from bearhub.view.core.gems import * # noqa: F401,F403
|
||||
|
||||
1
bauh/view/core/settings.py
Normal file
1
bauh/view/core/settings.py
Normal file
@@ -0,0 +1 @@
|
||||
from bearhub.view.core.settings import * # noqa: F401,F403
|
||||
1
bauh/view/core/suggestions.py
Normal file
1
bauh/view/core/suggestions.py
Normal file
@@ -0,0 +1 @@
|
||||
from bearhub.view.core.suggestions import * # noqa: F401,F403
|
||||
1
bauh/view/core/timeshift.py
Normal file
1
bauh/view/core/timeshift.py
Normal file
@@ -0,0 +1 @@
|
||||
from bearhub.view.core.timeshift import * # noqa: F401,F403
|
||||
1
bauh/view/core/tray_client.py
Normal file
1
bauh/view/core/tray_client.py
Normal file
@@ -0,0 +1 @@
|
||||
from bearhub.view.core.tray_client import * # noqa: F401,F403
|
||||
1
bauh/view/core/update.py
Normal file
1
bauh/view/core/update.py
Normal file
@@ -0,0 +1 @@
|
||||
from bearhub.view.core.update import * # noqa: F401,F403
|
||||
1
bauh/view/qt/__init__.py
Normal file
1
bauh/view/qt/__init__.py
Normal file
@@ -0,0 +1 @@
|
||||
from bearhub.view.qt import * # noqa: F401,F403
|
||||
1
bauh/view/qt/about.py
Normal file
1
bauh/view/qt/about.py
Normal file
@@ -0,0 +1 @@
|
||||
from bearhub.view.qt.about import * # noqa: F401,F403
|
||||
1
bauh/view/qt/apps_table.py
Normal file
1
bauh/view/qt/apps_table.py
Normal file
@@ -0,0 +1 @@
|
||||
from bearhub.view.qt.apps_table import * # noqa: F401,F403
|
||||
1
bauh/view/qt/commons.py
Normal file
1
bauh/view/qt/commons.py
Normal file
@@ -0,0 +1 @@
|
||||
from bearhub.view.qt.commons import * # noqa: F401,F403
|
||||
1
bauh/view/qt/components.py
Normal file
1
bauh/view/qt/components.py
Normal file
@@ -0,0 +1 @@
|
||||
from bearhub.view.qt.components import * # noqa: F401,F403
|
||||
1
bauh/view/qt/dialog.py
Normal file
1
bauh/view/qt/dialog.py
Normal file
@@ -0,0 +1 @@
|
||||
from bearhub.view.qt.dialog import * # noqa: F401,F403
|
||||
1
bauh/view/qt/history.py
Normal file
1
bauh/view/qt/history.py
Normal file
@@ -0,0 +1 @@
|
||||
from bearhub.view.qt.history import * # noqa: F401,F403
|
||||
1
bauh/view/qt/info.py
Normal file
1
bauh/view/qt/info.py
Normal file
@@ -0,0 +1 @@
|
||||
from bearhub.view.qt.info import * # noqa: F401,F403
|
||||
1
bauh/view/qt/prepare.py
Normal file
1
bauh/view/qt/prepare.py
Normal file
@@ -0,0 +1 @@
|
||||
from bearhub.view.qt.prepare import * # noqa: F401,F403
|
||||
1
bauh/view/qt/qt_utils.py
Normal file
1
bauh/view/qt/qt_utils.py
Normal file
@@ -0,0 +1 @@
|
||||
from bearhub.view.qt.qt_utils import * # noqa: F401,F403
|
||||
1
bauh/view/qt/root.py
Normal file
1
bauh/view/qt/root.py
Normal file
@@ -0,0 +1 @@
|
||||
from bearhub.view.qt.root import * # noqa: F401,F403
|
||||
1
bauh/view/qt/screenshots.py
Normal file
1
bauh/view/qt/screenshots.py
Normal file
@@ -0,0 +1 @@
|
||||
from bearhub.view.qt.screenshots import * # noqa: F401,F403
|
||||
1
bauh/view/qt/settings.py
Normal file
1
bauh/view/qt/settings.py
Normal file
@@ -0,0 +1 @@
|
||||
from bearhub.view.qt.settings import * # noqa: F401,F403
|
||||
1
bauh/view/qt/systray.py
Normal file
1
bauh/view/qt/systray.py
Normal file
@@ -0,0 +1 @@
|
||||
from bearhub.view.qt.systray import * # noqa: F401,F403
|
||||
1
bauh/view/qt/thread.py
Normal file
1
bauh/view/qt/thread.py
Normal file
@@ -0,0 +1 @@
|
||||
from bearhub.view.qt.thread import * # noqa: F401,F403
|
||||
1
bauh/view/qt/view_index.py
Normal file
1
bauh/view/qt/view_index.py
Normal file
@@ -0,0 +1 @@
|
||||
from bearhub.view.qt.view_index import * # noqa: F401,F403
|
||||
1
bauh/view/qt/view_model.py
Normal file
1
bauh/view/qt/view_model.py
Normal file
@@ -0,0 +1 @@
|
||||
from bearhub.view.qt.view_model import * # noqa: F401,F403
|
||||
1
bauh/view/qt/window.py
Normal file
1
bauh/view/qt/window.py
Normal file
@@ -0,0 +1 @@
|
||||
from bearhub.view.qt.window import * # noqa: F401,F403
|
||||
1
bauh/view/util/__init__.py
Normal file
1
bauh/view/util/__init__.py
Normal file
@@ -0,0 +1 @@
|
||||
from bearhub.view.util import * # noqa: F401,F403
|
||||
1
bauh/view/util/cache.py
Normal file
1
bauh/view/util/cache.py
Normal file
@@ -0,0 +1 @@
|
||||
from bearhub.view.util.cache import * # noqa: F401,F403
|
||||
1
bauh/view/util/disk.py
Normal file
1
bauh/view/util/disk.py
Normal file
@@ -0,0 +1 @@
|
||||
from bearhub.view.util.disk import * # noqa: F401,F403
|
||||
1
bauh/view/util/logs.py
Normal file
1
bauh/view/util/logs.py
Normal file
@@ -0,0 +1 @@
|
||||
from bearhub.view.util.logs import * # noqa: F401,F403
|
||||
1
bauh/view/util/resource.py
Normal file
1
bauh/view/util/resource.py
Normal file
@@ -0,0 +1 @@
|
||||
from bearhub.view.util.resource import * # noqa: F401,F403
|
||||
1
bauh/view/util/translation.py
Normal file
1
bauh/view/util/translation.py
Normal file
@@ -0,0 +1 @@
|
||||
from bearhub.view.util.translation import * # noqa: F401,F403
|
||||
1
bauh/view/util/util.py
Normal file
1
bauh/view/util/util.py
Normal file
@@ -0,0 +1 @@
|
||||
from bearhub.view.util.util import * # noqa: F401,F403
|
||||
Reference in New Issue
Block a user