DirectoryDictProperty: create directory before writing

Signed-off-by: Steven Armstrong <steven@icarus.ethz.ch>
This commit is contained in:
Steven Armstrong 2011-10-13 13:14:01 +02:00
parent 48ae37e832
commit d136a6dee3

View file

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