def _load_reporter(self): name = self._reporter_name.lower() if name in self._reporters: self.set_reporter(self._reporters[name]()) else: try: reporter_class = self._load_reporter_class() except (ImportError, AttributeError) as e: raise exceptions.InvalidReporterError(name) from e else: self.set_reporter(reporter_class())
def _load_reporter_by_name(self, reporter_name: str) -> reporters.BaseReporter: name = reporter_name.lower() if name in self._reporters: return self._reporters[name]() try: reporter_class = _load_reporter_by_class(reporter_name) except (ImportError, AttributeError) as e: raise exceptions.InvalidReporterError(name) from e else: return reporter_class()