def _reporter_by_name(name): Reporter = _BUILT_IN_REPORTERS.get(name) if Reporter is not None: return Reporter() try: return named_any(name) except Exception: message = "{0!r} is not a known reporter".format(name) raise argparse.ArgumentTypeError(message)
def locate_by_name(self, name): """ Locate any tests found in the object referred to by the given name. The name should be a fully qualified object name. (E.g., the fully qualified object name of this function is ``virtue.locators.ObjectLocator.locate_by_name``\ ). """ obj = named_any(name) if ismethod(obj): class_name, dot, method_name = name.rpartition(".") cls = named_any(class_name) is_aliased = not isclass(cls) if is_aliased: cls, method_name = obj.im_class, obj.__name__ return [AttributeLoader(cls=cls, attr=method_name)] return self.locate_in(obj)
def convert(self, value, param, ctx): if not isinstance(value, str): return value Reporter = self._BUILT_IN.get(value) if Reporter is not None: return Reporter() try: return named_any(value) except Exception: raise click.BadParameter( "{0!r} is not a known reporter".format(value), )