Writes the configuration file to a specified directory.
Source code in nbautoexport/sentinel.py
54
55
56
57
58
59
60
61
62
63
64
65
66
67 | def install_sentinel(directory: Path, config: NbAutoexportConfig, overwrite: bool):
"""Writes the configuration file to a specified directory."""
sentinel_path = directory / SAVE_PROGRESS_INDICATOR_FILE
if sentinel_path.exists() and (not overwrite):
raise FileExistsError(
f"""Detected existing autoexport configuration at {sentinel_path}. """
"""If you wish to overwrite, use the --overwrite flag."""
)
else:
logger.info(f"Creating configuration file at {sentinel_path}")
logger.info(f"\n{config.json(indent=2)}")
with sentinel_path.open("w", encoding="utf-8") as fp:
fp.write(config.json(indent=2))
|