예제 #1
0
파일: remote.py 프로젝트: demmerichs/law
 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)
예제 #2
0
파일: local.py 프로젝트: www3838438/law
 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)