From d136a6dee340b76ca883826301f03e266f75b887 Mon Sep 17 00:00:00 2001
From: Steven Armstrong <steven@icarus.ethz.ch>
Date: Thu, 13 Oct 2011 13:14:01 +0200
Subject: [PATCH] DirectoryDictProperty: create directory before writing

Signed-off-by: Steven Armstrong <steven@icarus.ethz.ch>
---
 lib/cdist/util/fsproperty.py | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/lib/cdist/util/fsproperty.py b/lib/cdist/util/fsproperty.py
index 68d5edaa..50b95ea2 100644
--- a/lib/cdist/util/fsproperty.py
+++ b/lib/cdist/util/fsproperty.py
@@ -221,6 +221,8 @@ class DirectoryDictProperty(DirectoryDict):
     def __set__(self, obj, value):
         self._set_path(obj)
         if value is not None:
+            # create directory if it doesn't exist
+            os.makedirs(self.path, exist_ok=True)
             for name in self.keys():
                 del self[name]
             self.update(value)