Merge branch 'cmdset_fallback' of git://github.com/TehomCD/evennia into TehomCD-cmdset_fallback

This commit is contained in:
Griatch 2017-08-13 15:58:34 +02:00
commit 2fa04162c3
2 changed files with 17 additions and 0 deletions

View file

@ -351,6 +351,17 @@ class CmdSetHandler(object):
elif path:
cmdset = self._import_cmdset(path)
if cmdset:
if cmdset.key == '_CMDSET_ERROR':
# If a cmdset fails to load, check if we have a fallback path to use
fallback_path = settings.CMDSET_FALLBACKS.get(path, None)
if fallback_path:
logger.log_err("Error encountered for cmdset at path %s. Replacing with: %s" % (
path, fallback_path))
cmdset = self._import_cmdset(fallback_path)
# If no cmdset is returned from the fallback, we can't go further
if not cmdset:
logger.log_err("Fallback path '%s' failed to generate a cmdset." % fallback_path)
continue
cmdset.permanent = cmdset.key != '_CMDSET_ERROR'
self.cmdset_stack.append(cmdset)