create path if not exists
This commit is contained in:
parent
c5773e559c
commit
63e4676ca3
4
tww.py
4
tww.py
@ -93,6 +93,10 @@ def create_if_not_exists(fname):
|
|||||||
try:
|
try:
|
||||||
fh = open(fname, 'r')
|
fh = open(fname, 'r')
|
||||||
except FileNotFoundError:
|
except FileNotFoundError:
|
||||||
|
import pathlib
|
||||||
|
|
||||||
|
path = pathlib.Path(fname)
|
||||||
|
path.parent.mkdir(parents=True, exist_ok=True)
|
||||||
fh = open(fname, 'w')
|
fh = open(fname, 'w')
|
||||||
fh.close()
|
fh.close()
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user