Create config folder if it does not exist - toot - Unnamed repository; edit thi… | |
Log | |
Files | |
Refs | |
LICENSE | |
--- | |
commit 05a06acf8e5a538b4a431b6f73045093f7c4b988 | |
parent ddd4326f7ec3ea764f66495aab5cbd51ecf3ec66 | |
Author: Ivan Habunek <[email protected]> | |
Date: Mon, 15 Jan 2018 23:14:20 +0100 | |
Create config folder if it does not exist | |
fixes #40 | |
Diffstat: | |
CHANGELOG.md | 1 + | |
toot/config.py | 5 +++++ | |
2 files changed, 6 insertions(+), 0 deletions(-) | |
--- | |
diff --git a/CHANGELOG.md b/CHANGELOG.md | |
@@ -3,6 +3,7 @@ Changelog | |
**0.17.1 (2017-01-15)** | |
+* Create config folder if it does not exist (#40) | |
* Fix packaging to include `toot.ui` package (#41) | |
**0.17.0 (2017-01-15)** | |
diff --git a/toot/config.py b/toot/config.py | |
@@ -4,6 +4,7 @@ import os | |
import json | |
from functools import wraps | |
+from os.path import dirname | |
from toot import User, App | |
from toot.config_legacy import load_legacy_config | |
@@ -47,6 +48,10 @@ def make_config(path): | |
} | |
print_out("Creating config file at <blue>{}</blue>".format(path)) | |
+ | |
+ # Ensure dir exists | |
+ os.makedirs(dirname(path), exist_ok=True) | |
+ | |
with open(path, 'w') as f: | |
json.dump(config, f, indent=True) | |