From 63e4676ca3bb29e73760ca42a48e853dd5568b98 Mon Sep 17 00:00:00 2001 From: Daniel Tsvetkov Date: Mon, 23 Sep 2019 20:50:24 +0200 Subject: [PATCH] create path if not exists --- tww.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tww.py b/tww.py index 854dbe9..4b7b247 100644 --- a/tww.py +++ b/tww.py @@ -93,6 +93,10 @@ def create_if_not_exists(fname): try: fh = open(fname, 'r') except FileNotFoundError: + import pathlib + + path = pathlib.Path(fname) + path.parent.mkdir(parents=True, exist_ok=True) fh = open(fname, 'w') fh.close()