create path if not exists

This commit is contained in:
Daniel Tsvetkov 2019-09-23 20:50:24 +02:00
parent c5773e559c
commit 63e4676ca3

4
tww.py
View File

@ -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()