plugin: Load all existing hooks to registry.
This commit is contained in:
parent
5566672cd6
commit
fd2830f483
1 changed files with 14 additions and 2 deletions
|
@ -63,6 +63,9 @@ class HookRegistry:
|
|||
*hook_names: str,
|
||||
package: Optional[str]=__module__, # type:ignore[name-defined]
|
||||
) -> None:
|
||||
if not hook_names:
|
||||
_, _, hook_name = mod_name.rpartition('.')
|
||||
hook_names = (hook_name.title().replace('_', ''),)
|
||||
module = importlib.import_module(mod_name, package)
|
||||
for hook_name in hook_names:
|
||||
self.add_hook(getattr(module, hook_name))
|
||||
|
@ -94,8 +97,17 @@ class HookRegistry:
|
|||
|
||||
|
||||
HOOK_REGISTRY = HookRegistry()
|
||||
HOOK_REGISTRY.import_hooks('.meta_expense_allocation', 'MetaExpenseAllocation')
|
||||
HOOK_REGISTRY.import_hooks('.meta_tax_implication', 'MetaTaxImplication')
|
||||
HOOK_REGISTRY.import_hooks('.meta_approval')
|
||||
HOOK_REGISTRY.import_hooks('.meta_entity')
|
||||
HOOK_REGISTRY.import_hooks('.meta_expense_allocation')
|
||||
HOOK_REGISTRY.import_hooks('.meta_income_type')
|
||||
HOOK_REGISTRY.import_hooks('.meta_invoice')
|
||||
HOOK_REGISTRY.import_hooks('.meta_project')
|
||||
HOOK_REGISTRY.import_hooks('.meta_receipt')
|
||||
HOOK_REGISTRY.import_hooks('.meta_receivable_documentation')
|
||||
HOOK_REGISTRY.import_hooks('.meta_repo_links')
|
||||
HOOK_REGISTRY.import_hooks('.meta_rt_links', 'MetaRTLinks')
|
||||
HOOK_REGISTRY.import_hooks('.meta_tax_implication')
|
||||
|
||||
def run(
|
||||
entries: List[Directive],
|
||||
|
|
Loading…
Reference in a new issue