diff options
| author | Robert Honz <exislow+github@gmail.com> | 2024-11-11 11:33:10 +0100 |
|---|---|---|
| committer | Robert Honz <exislow+github@gmail.com> | 2024-11-11 11:33:10 +0100 |
| commit | c985e50dc651ee055499bd0029579ce3bdca4793 (patch) | |
| tree | 809107443c4011e64f7ab718c0d6828f293c8431 | |
| parent | 9e75cc46566541fb69c8a43e53315e89bdaef1d7 (diff) | |
| download | tidal-dl-ng-c985e50dc651ee055499bd0029579ce3bdca4793.tar.gz | |
✨ Save JSON configs as pretty formatted files. Adresses #132
| -rw-r--r-- | tidal_dl_ng/config.py | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/tidal_dl_ng/config.py b/tidal_dl_ng/config.py index a3ab809..1d17953 100644 --- a/tidal_dl_ng/config.py +++ b/tidal_dl_ng/config.py @@ -1,3 +1,4 @@ +import json import os import shutil from collections.abc import Callable @@ -31,7 +32,9 @@ class BaseConfig: os.makedirs(self.path_base, exist_ok=True) with open(self.file_path, encoding="utf-8", mode="w") as f: - f.write(data_json) + # Save it in a pretty format + obj_json_config = json.loads(data_json) + json.dump(obj_json_config, f, indent=4) def set_option(self, key: str, value: Any) -> None: value_old: Any = getattr(self.data, key) |
