* add button for languages setting * build a web module for the dashboard - load all python module from local dir - initialize Blueprint and Babel * set a default key for secure cookies * add translations to docker container * improve translation build - clean target erases the *.pot - don't modify the resurt of url_for() calls - don't translate the language description * translate connection table, fix icon * build relative urls for HA ingress * fix unit test, increase coverage
26 lines
650 B
Python
26 lines
650 B
Python
import mimetypes
|
|
from importlib import import_module
|
|
from pathlib import Path
|
|
from collections.abc import Callable
|
|
|
|
|
|
class SourceFileLoader:
|
|
""" Represents a SouceFileLoader (__loader__)"""
|
|
name: str
|
|
get_resource_reader: Callable
|
|
|
|
|
|
def load_modules(loader: SourceFileLoader):
|
|
"""Load the entire modules from a SourceFileLoader (__loader__)"""
|
|
pkg = loader.name
|
|
for load in loader.get_resource_reader().contents():
|
|
|
|
if "python" not in str(mimetypes.guess_type(load)[0]):
|
|
continue
|
|
|
|
mod = Path(load).stem
|
|
if mod == "__init__":
|
|
continue
|
|
|
|
import_module(pkg + "." + mod, pkg)
|