mirror of
https://github.com/hoshikawa2/first_contas.git
synced 2026-07-09 18:24:20 +00:00
first commit
This commit is contained in:
28
legacy_reference/workflows/actions/discovery.py
Normal file
28
legacy_reference/workflows/actions/discovery.py
Normal file
@@ -0,0 +1,28 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import importlib
|
||||
import pkgutil
|
||||
from threading import Lock
|
||||
|
||||
_loaded_packages: set[str] = set()
|
||||
_lock = Lock()
|
||||
|
||||
|
||||
def _load_actions(package_name: str) -> None:
|
||||
package = importlib.import_module(package_name)
|
||||
package_path = getattr(package, "__path__", None)
|
||||
if package_path is None:
|
||||
return
|
||||
|
||||
for module in pkgutil.walk_packages(package_path, package_name + "."):
|
||||
importlib.import_module(module.name)
|
||||
|
||||
|
||||
def ensure_actions_loaded(
|
||||
package_name: str = "agente_contas_tim.workflows.actions",
|
||||
) -> None:
|
||||
with _lock:
|
||||
if package_name in _loaded_packages:
|
||||
return
|
||||
_load_actions(package_name)
|
||||
_loaded_packages.add(package_name)
|
||||
Reference in New Issue
Block a user