From f94093c975043092dcf30f31d71038ba3039e93f Mon Sep 17 00:00:00 2001 From: Michael Aydinbas Date: Sun, 29 Oct 2023 21:40:57 +0100 Subject: [PATCH] fix problem with config dir creation during setup --- src/pystatis/config.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/pystatis/config.py b/src/pystatis/config.py index a197805..f40625d 100644 --- a/src/pystatis/config.py +++ b/src/pystatis/config.py @@ -107,6 +107,10 @@ def write_config(config_file: Path | None = None) -> None: if not config_file.parent.exists(): config_file.parent.mkdir(parents=True) + cache_dir = Path(get_cache_dir()) + if not cache_dir.exists(): + cache_dir.mkdir() + with open(config_file, "w", encoding="utf-8") as fp: config.write(fp) @@ -134,11 +138,8 @@ def create_default_config() -> ConfigParser: "doku": "https://ergebnisse2011.zensus2022.de/datenbank/misc/ZENSUS-Webservices_Einfuehrung.pdf", } - config["DATA"] = {"cache_dir": str(Path(CUSTOM_CONFIG_DIR) / "data")} - - cache_dir = Path(config["DATA"]["cache_dir"]) - if not cache_dir.exists(): - cache_dir.mkdir() + cache_dir = Path(CUSTOM_CONFIG_DIR) / "data" + config["DATA"] = {"cache_dir": str(cache_dir)} return config