-
-
Notifications
You must be signed in to change notification settings - Fork 103
Expand file tree
/
Copy pathregistry.py
More file actions
34 lines (23 loc) · 666 Bytes
/
registry.py
File metadata and controls
34 lines (23 loc) · 666 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
from .utils import qualname
try:
from django.utils.module_loading import autodiscover_modules
except ImportError: # pragma: no cover
# Not a django project
def autodiscover_modules(module_name: str):
pass
_REGISTRY = {}
_initialized = False
def register(cls):
_REGISTRY[qualname(cls)] = cls
return cls
def get_machine_cls(name):
init_registry()
return _REGISTRY[name]
def init_registry():
global _initialized
if not _initialized:
load_modules(["statemachine", "statemachines"])
_initialized = True
def load_modules(modules=None):
for module in modules:
autodiscover_modules(module)