MCPcopy Create free account
hub / github.com/etingof/apacheconfig / dump

Method dump

apacheconfig/loader.py:472–496  ·  view source on GitHub ↗

Dumps the configuration in `dct` to a file. Args: filepath (Text): Filepath to write config to, in UTF-8 encoding. dct (dict): Configuration represented as a dictionary.

(self, filepath, dct)

Source from the content-addressed store, hash-verified

470 return self._dumpdict(dct)
471
472 def dump(self, filepath, dct):
473 """Dumps the configuration in `dct` to a file.
474
475 Args:
476 filepath (Text): Filepath to write config to, in UTF-8 encoding.
477 dct (dict): Configuration represented as a dictionary.
478 """
479 tmpf = tempfile.NamedTemporaryFile(dir=os.path.dirname(filepath),
480 delete=False)
481
482 try:
483 with io.open(tmpf.name, mode='w', encoding='utf-8') as f:
484 f.write(self.dumps(dct))
485
486 os.rename(tmpf.name, filepath)
487
488 except IOError as ex:
489 try:
490 os.unlink(tmpf.name)
491
492 except Exception:
493 pass
494
495 raise error.ApacheConfigError('File %s can\'t be written: %s'
496 % (filepath, ex))

Callers 1

testDumpWholeConfigMethod · 0.95

Calls 2

dumpsMethod · 0.95
openMethod · 0.80

Tested by 1

testDumpWholeConfigMethod · 0.76