def dump(self, path, formatter, *args, **kwargs): with self.open(path, "w", _yield_path=True) as lpath: if formatter == AUTO_FORMATTER: errors = [] for f in find_formatters(lpath, silent=False): try: return f.dump(lpath, *args, **kwargs) except ImportError as e: errors.append(str(e)) else: raise Exception("could not automatically dump '{}', errors:\n{}".format( lpath, "\n".join(errors))) else: return get_formatter(formatter, silent=False).dump(lpath, *args, **kwargs)
def dump(self, path, formatter, *args, **kwargs): path = self._unscheme(path) if formatter == AUTO_FORMATTER: errors = [] for f in find_formatters(path, silent=False): try: return f.dump(path, *args, **kwargs) except ImportError as e: errors.append(str(e)) else: raise Exception("could not automatically dump '{}', errors:\n{}".format( path, "\n".join(errors))) else: return get_formatter(formatter, silent=False).dump(path, *args, **kwargs)