handle missing parser class

This commit is contained in:
Alan Hamlett 2014-12-24 12:15:30 -06:00
parent f889863eea
commit 40c8067dbf

View file

@ -68,8 +68,11 @@ class DependencyParser(object):
module_name = self.lexer.__module__.split('.')[-1] module_name = self.lexer.__module__.split('.')[-1]
class_name = self.lexer.__class__.__name__.replace('Lexer', 'Parser', 1) class_name = self.lexer.__class__.__name__.replace('Lexer', 'Parser', 1)
module = import_module('.%s' % module_name, package=__package__) module = import_module('.%s' % module_name, package=__package__)
try:
self.parser = getattr(module, class_name) self.parser = getattr(module, class_name)
except ImportError as ex: except AttributeError:
log.debug(traceback.format_exc())
except ImportError:
log.debug(traceback.format_exc()) log.debug(traceback.format_exc())
def parse(self): def parse(self):