forked from ungleich-public/cdist
DirectoryDictProperty: create directory before writing
Signed-off-by: Steven Armstrong <steven@icarus.ethz.ch>
This commit is contained in:
parent
48ae37e832
commit
d136a6dee3
1 changed files with 2 additions and 0 deletions
|
@ -221,6 +221,8 @@ class DirectoryDictProperty(DirectoryDict):
|
||||||
def __set__(self, obj, value):
|
def __set__(self, obj, value):
|
||||||
self._set_path(obj)
|
self._set_path(obj)
|
||||||
if value is not None:
|
if value is not None:
|
||||||
|
# create directory if it doesn't exist
|
||||||
|
os.makedirs(self.path, exist_ok=True)
|
||||||
for name in self.keys():
|
for name in self.keys():
|
||||||
del self[name]
|
del self[name]
|
||||||
self.update(value)
|
self.update(value)
|
||||||
|
|
Loading…
Reference in a new issue