From abdfc48b959ad93a1cffd437742acdfae80bcfcc Mon Sep 17 00:00:00 2001 From: Mark Veidemanis Date: Sun, 1 Nov 2020 03:38:47 +0000 Subject: [PATCH] Prepare command loader for reloading commands --- utils/loaders/command_loader.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/utils/loaders/command_loader.py b/utils/loaders/command_loader.py index 031f2aa..bc9ecf4 100644 --- a/utils/loaders/command_loader.py +++ b/utils/loaders/command_loader.py @@ -6,7 +6,7 @@ import commands from main import CommandMap -def loadCommands(): +def loadCommands(allowDup=False): for filename in listdir("commands"): if filename.endswith(".py") and filename != "__init__.py": commandName = filename[0:-3] @@ -17,6 +17,10 @@ def loadCommands(): CommandMap[commandName] = getattr(getattr(module, commandName), className) debug("Registered command: %s" % commandName) else: + if allowDup: + CommandMap[commandName] = getattr(getattr(module, commandName), className) + debug("Registered command: %s" % commandName) + error("Duplicate command: %s" % (commandName)) except Exception as err: error("Exception while loading command %s:\n%s" % (commandName, err))