How to use:
- Create file <module_name>.py in directory modules
- In the <module_name>.py: from . import command
- Create a function, describe its name and command
- in init.py add to list modules <module_name>
- to import main models
- data = modules.load()
Result:
- data['commands'] - a list of teams with their names
- data['errors'] - a list of modules in which an import error occurred
Example: File main.py
import importlib
modules = importlib.import_module('modules')
File modules/__init__.py:
modules = [
'admins',
]
......
File modules/admins.py
from . import command
@command(name="Hello, world", command="hello")
def hello_world(*data, **kwargs):
print("Hello, world")