From 904396f6a5031c06790190a2d46df0ffe1b5af64 Mon Sep 17 00:00:00 2001 From: Steven Armstrong Date: Tue, 11 Oct 2011 10:29:06 +0200 Subject: [PATCH] new method to create object on the file system Signed-off-by: Steven Armstrong --- lib/cdist/core/object.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/lib/cdist/core/object.py b/lib/cdist/core/object.py index f3099e1d..acef8079 100644 --- a/lib/cdist/core/object.py +++ b/lib/cdist/core/object.py @@ -102,3 +102,13 @@ class Object(object): def exists(self): """Checks wether this cdist object exists on the file systems.""" return os.path.exists(self.absolute_path) + + def create(self): + """Create this cdist object on the filesystem. + """ + try: + os.makedirs(self.absolute_path, exist_ok=False) + absolute_parameter_path = os.path.join(self.base_path, self.parameter_path) + os.makedirs(absolute_parameter_path, exist_ok=False) + except EnvironmentError as error: + raise cdist.Error('Error creating directories for cdist object: %s: %s' % (self, error))