mirror of
https://github.com/spalencsar/bearhub.git
synced 2026-07-07 02:24:16 +02:00
refactoring
This commit is contained in:
@@ -1,10 +1,10 @@
|
||||
import sys
|
||||
|
||||
import requests
|
||||
from PyQt5.QtGui import QIcon
|
||||
from PyQt5.QtWidgets import QApplication
|
||||
from fpakman_api.util.cache import Cache
|
||||
from fpakman_api.util.disk import DiskCacheLoaderFactory
|
||||
from fpakman_api.util.http import HttpClient
|
||||
|
||||
from fpakman import __version__, __app_name__, app_args
|
||||
from fpakman.core import resource, extensions
|
||||
@@ -17,13 +17,13 @@ from fpakman.view.qt.window import ManageWindow
|
||||
args = app_args.read()
|
||||
|
||||
locale_keys = util.get_locale_keys(args.locale)
|
||||
http_session = requests.Session()
|
||||
http_client = HttpClient()
|
||||
caches, cache_map = [], {}
|
||||
|
||||
managers = extensions.load_managers(caches=caches,
|
||||
cache_map=cache_map,
|
||||
locale_keys=locale_keys,
|
||||
http_session=http_session,
|
||||
http_client=http_client,
|
||||
app_args=args)
|
||||
|
||||
icon_cache = Cache(expiration_time=args.icon_exp)
|
||||
|
||||
@@ -16,7 +16,7 @@ SUGGESTIONS_LIMIT = 6
|
||||
class GenericApplicationManager(ApplicationManager):
|
||||
|
||||
def __init__(self, managers: List[ApplicationManager], disk_loader_factory: DiskCacheLoaderFactory, app_args: Namespace):
|
||||
super(GenericApplicationManager, self).__init__(app_args=app_args, app_cache=None, locale_keys=None, fpakman_root_dir=ROOT_DIR, http_session=None)
|
||||
super(GenericApplicationManager, self).__init__(app_args=app_args, app_cache=None, locale_keys=None, fpakman_root_dir=ROOT_DIR, http_client=None)
|
||||
self.managers = managers
|
||||
self.map = {m.get_app_type(): m for m in self.managers}
|
||||
self.disk_loader_factory = disk_loader_factory
|
||||
|
||||
@@ -6,6 +6,7 @@ from typing import List, Dict
|
||||
|
||||
from fpakman_api.abstract.controller import ApplicationManager
|
||||
from fpakman_api.util.cache import Cache
|
||||
from fpakman_api.util.http import HttpClient
|
||||
|
||||
from fpakman import ROOT_DIR
|
||||
from fpakman.util import util
|
||||
@@ -23,7 +24,7 @@ def find_manager(member):
|
||||
return manager_found
|
||||
|
||||
|
||||
def load_managers(caches: List[Cache], cache_map: Dict[type, Cache], locale_keys: Dict[str, str], app_args: Namespace, http_session) -> List[ApplicationManager]:
|
||||
def load_managers(caches: List[Cache], cache_map: Dict[type, Cache], locale_keys: Dict[str, str], app_args: Namespace, http_client: HttpClient) -> List[ApplicationManager]:
|
||||
managers = None
|
||||
|
||||
for m in pkgutil.iter_modules():
|
||||
@@ -44,7 +45,7 @@ def load_managers(caches: List[Cache], cache_map: Dict[type, Cache], locale_keys
|
||||
app_cache = Cache(expiration_time=app_args.cache_exp)
|
||||
man = manager_class(app_args=app_args,
|
||||
fpakman_root_dir=ROOT_DIR,
|
||||
http_session=http_session,
|
||||
http_client=http_client,
|
||||
locale_keys=locale_keys,
|
||||
app_cache=app_cache)
|
||||
cache_map[man.get_app_type()] = app_cache
|
||||
|
||||
Reference in New Issue
Block a user