From 05a06acf8e5a538b4a431b6f73045093f7c4b988 Mon Sep 17 00:00:00 2001 From: Ivan Habunek Date: Mon, 15 Jan 2018 23:14:20 +0100 Subject: [PATCH] Create config folder if it does not exist fixes #40 --- CHANGELOG.md | 1 + toot/config.py | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index f7f8498..25db14a 100644 --- 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 index 9193564..c8860a5 100644 --- 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 {}".format(path)) + + # Ensure dir exists + os.makedirs(dirname(path), exist_ok=True) + with open(path, 'w') as f: json.dump(config, f, indent=True)