use pathlib everywhere

This commit is contained in:
Jörg Thalheim
2024-09-02 18:25:17 +02:00
parent 9de48de991
commit 1fa0e72bea
28 changed files with 88 additions and 113 deletions

View File

@@ -82,7 +82,7 @@ def config_for_machine(flake_dir: Path, machine_name: str) -> dict:
settings_path = machine_settings_file(flake_dir, machine_name)
if not settings_path.exists():
return {}
with open(settings_path) as f:
with settings_path.open() as f:
return json.load(f)
@@ -102,7 +102,7 @@ def set_config_for_machine(flake_dir: Path, machine_name: str, config: dict) ->
# write the config to a json file located at {flake}/machines/{machine_name}/settings.json
settings_path = machine_settings_file(flake_dir, machine_name)
settings_path.parent.mkdir(parents=True, exist_ok=True)
with open(settings_path, "w") as f:
with settings_path.open("w") as f:
json.dump(config, f)
if flake_dir is not None: