Try to log some more information of why a module wasn't loaded

This commit is contained in:
Pedro Algarvio 2016-05-26 12:24:38 +01:00
parent d9a96c0e4c
commit 084341e1ac
No known key found for this signature in database
GPG Key ID: BB36BF6584A298FF

View File

@ -70,6 +70,14 @@ class LazyDict(collections.MutableMapping):
'''
return False
def missing_fun_string(self, function_name):
'''
Return the error string for a missing function.
Override this to return a more meaningfull error message if possible
'''
return '\'{0}\' is not available.'.format(function_name)
def __setitem__(self, key, val):
self._dict[key] = val
@ -86,10 +94,10 @@ class LazyDict(collections.MutableMapping):
if key not in self._dict and not self.loaded:
# load the item
if self._load(key):
log.debug('LazyLoaded {0}'.format(key))
log.debug('LazyLoaded %s', key)
return self._dict[key]
else:
log.debug('Could not LazyLoad {0}'.format(key))
log.debug('Could not LazyLoad %s: %s', key, self.missing_fun_string(key))
raise KeyError(key)
else:
return self._dict[key]