File size: 469 Bytes
3faa99b
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
from importlib import import_module
from pathlib import Path
from pkgutil import iter_modules

command_functions = []

package_dir = Path(__file__).resolve().parent
for _b, module_name, _p in iter_modules([str(package_dir)]):
    module = import_module(f"{__name__}.{module_name}")
    for attribute_name in dir(module):
        attribute = getattr(module, attribute_name)
        if attribute_name.endswith("_command"):
            command_functions.append(attribute)