0c27d7ac86
- Implemented `excel_export.py` for generating library item exports in Excel format. - Created `pdf_export.py` for generating audit reports compliant with DIN 5008 standards, including detailed event tables and signature blocks. - Developed `generate_user.py` for interactive user creation with validation for usernames and passwords. - Introduced `module_registry.py` for managing module states and path matching. - Added a basic `__init__.py` in the `terminplaner` module for initialization.
27 lines
856 B
Python
27 lines
856 B
Python
from typing import Dict, Any
|
|
|
|
class ModuleRegistry:
|
|
def __init__(self):
|
|
self._modules: Dict[str, Any] = {}
|
|
self._path_matchers = {}
|
|
|
|
def register(self, name: str, settings_bool, path_matcher=lambda path: False):
|
|
self._modules[name] = settings_bool
|
|
self._path_matchers[name] = path_matcher
|
|
|
|
def is_enabled(self, name: str) -> bool:
|
|
if name not in self._modules:
|
|
return False
|
|
return bool(self._modules[name])
|
|
|
|
def get_all_status(self) -> Dict[str, bool]:
|
|
return {name: bool(sys_bool) for name, sys_bool in self._modules.items()}
|
|
|
|
def get_module_for_path(self, path: str) -> str:
|
|
for name, matcher in self._path_matchers.items():
|
|
if self.is_enabled(name) and matcher(path):
|
|
return name
|
|
return None
|
|
|
|
registry = ModuleRegistry()
|