Moved files to subdirectory
This commit is contained in:
25
legacy/utils/loaders/single_loader.py
Normal file
25
legacy/utils/loaders/single_loader.py
Normal file
@@ -0,0 +1,25 @@
|
||||
import sys
|
||||
from importlib import reload
|
||||
from os import listdir
|
||||
|
||||
from main import CommandMap
|
||||
from utils.logging.debug import debug
|
||||
|
||||
|
||||
def loadSingle(commandName):
|
||||
if commandName + ".py" in listdir("commands"):
|
||||
className = commandName.capitalize() + "Command"
|
||||
try:
|
||||
if commandName in CommandMap.keys():
|
||||
reload(sys.modules["commands." + commandName])
|
||||
CommandMap[commandName] = getattr(sys.modules["commands." + commandName], className)
|
||||
debug("Reloaded command: %s" % commandName)
|
||||
return "RELOAD"
|
||||
module = __import__("commands.%s" % commandName)
|
||||
CommandMap[commandName] = getattr(getattr(module, commandName), className)
|
||||
debug("Registered command: %s" % commandName)
|
||||
return True
|
||||
|
||||
except Exception as err:
|
||||
return err
|
||||
return False
|
||||
Reference in New Issue
Block a user