Source code for dawsonia._config_snapshot
import shutil
from datetime import datetime
from pathlib import Path
[docs]
def save_config_snapshot(config_path, output_path, command_name):
"""
Save a timestamped copy of the config file in the output folder.
Example:
dawsonia_digitize_20260629_132405.toml
"""
if config_path is None:
return None
config_path = Path(config_path)
output_path = Path(output_path)
output_path.mkdir(parents=True, exist_ok=True)
timestamp = datetime.now().strftime("%Y%m%d_%H%M%S")
snapshot_name = f"{config_path.stem}_{command_name}_{timestamp}{config_path.suffix}"
snapshot_path = output_path / snapshot_name
shutil.copy2(config_path, snapshot_path)
return snapshot_path