mirror of
https://github.com/spalencsar/bearhub.git
synced 2026-07-07 02:24:16 +02:00
Modernize runtime compatibility and initialize Bearhub fork
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import inspect
|
||||
import importlib
|
||||
import os
|
||||
import pkgutil
|
||||
from logging import Logger
|
||||
from typing import List, Generator
|
||||
|
||||
@@ -49,11 +49,14 @@ def load_managers(locale: str, context: ApplicationContext, config: dict, defaul
|
||||
logger.warning(f"gem '{f.name}' could not be loaded because it was marked as forbidden in '{FORBIDDEN_GEMS_FILE}'")
|
||||
continue
|
||||
|
||||
loader = pkgutil.find_loader(f'bauh.gems.{f.name}.controller')
|
||||
module_name = f'bauh.gems.{f.name}.controller'
|
||||
|
||||
if loader:
|
||||
module = loader.load_module()
|
||||
try:
|
||||
module = importlib.import_module(module_name)
|
||||
except ModuleNotFoundError:
|
||||
module = None
|
||||
|
||||
if module:
|
||||
manager_class = find_manager(module)
|
||||
|
||||
if manager_class:
|
||||
|
||||
@@ -27,7 +27,7 @@ class DefaultMemoryCache(MemoryCache):
|
||||
|
||||
def _add(self, key: str, val: object):
|
||||
if key:
|
||||
self._cache[key] = {'val': val, 'expires_at': datetime.datetime.utcnow() + datetime.timedelta(seconds=self.expiration_time) if self.expiration_time > 0 else None}
|
||||
self._cache[key] = {'val': val, 'expires_at': datetime.datetime.now(UTC) + datetime.timedelta(seconds=self.expiration_time) if self.expiration_time > 0 else None}
|
||||
|
||||
def add_non_existing(self, key: str, val: object):
|
||||
if key and self. is_enabled():
|
||||
@@ -46,7 +46,7 @@ class DefaultMemoryCache(MemoryCache):
|
||||
if val:
|
||||
expiration = val.get('expires_at')
|
||||
|
||||
if expiration and expiration <= datetime.datetime.utcnow():
|
||||
if expiration and expiration <= datetime.datetime.now(UTC):
|
||||
if lock:
|
||||
self.lock.acquire()
|
||||
|
||||
@@ -86,3 +86,4 @@ class DefaultMemoryCacheFactory(MemoryCacheFactory):
|
||||
|
||||
def new(self, expiration: Optional[int] = None) -> MemoryCache:
|
||||
return DefaultMemoryCache(expiration if expiration is not None else self.expiration_time)
|
||||
UTC = datetime.timezone.utc
|
||||
|
||||
@@ -50,7 +50,7 @@ def get_locale_keys(key: str = None, locale_dir: str = resource.get_path('locale
|
||||
|
||||
if key is None:
|
||||
try:
|
||||
current_locale = locale.getdefaultlocale()
|
||||
current_locale = locale.getlocale()
|
||||
|
||||
if current_locale is None or current_locale[0] is None:
|
||||
current_locale = ('en', 'UTF-8')
|
||||
|
||||
Reference in New Issue
Block a user