...
 
Commits (2)
...@@ -107,7 +107,7 @@ class ComparatorManager(object): ...@@ -107,7 +107,7 @@ class ComparatorManager(object):
self.classes = [] self.classes = []
for xs in self.COMPARATORS: for xs in self.COMPARATORS:
for x in xs: for idx, x in enumerate(xs):
package, klass_name = x.rsplit('.', 1) package, klass_name = x.rsplit('.', 1)
try: try:
...@@ -115,15 +115,16 @@ class ComparatorManager(object): ...@@ -115,15 +115,16 @@ class ComparatorManager(object):
'diffoscope.comparators.{}'.format(package) 'diffoscope.comparators.{}'.format(package)
) )
except ImportError: except ImportError:
continue if idx < len(xs) - 1:
continue
raise ImportError("Could not import {}: {}".format(
"any of comparators" if len(xs) > 1 else 'comparator',
', '.join(xs)
))
self.classes.append(getattr(mod, klass_name)) self.classes.append(getattr(mod, klass_name))
break break
else: # noqa
raise ImportError("Could not import {}{}".format(
"any of" if len(xs) > 1 else '',
', '.join(xs)
))
logger.debug("Loaded %d comparator classes", len(self.classes)) logger.debug("Loaded %d comparator classes", len(self.classes))
......