def load_commands Iterate all user defined commands and populate globa

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
def load_commands():
"""
Iterate all user defined commands and populate global commands dict
"""
command_map = {}
for fname in os.listdir('commands'):
if fnmatch.fnmatch(fname, '*.py'):
cmd_name = fname.split('.', 1)[0]
if not '__init__' == cmd_name:
commands = __import__('commands', globals(), locals(), [cmd_name])
command = getattr(commands, cmd_name)
command_map[cmd_name] = command.command
return command_map