From 95a858c35085ae2218058de73ca589410977d213 Mon Sep 17 00:00:00 2001 From: Steven Armstrong Date: Tue, 18 Oct 2011 12:46:06 +0200 Subject: [PATCH] implement: fail if type does not exist on the filesystem Signed-off-by: Steven Armstrong --- lib/cdist/core/type.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/lib/cdist/core/type.py b/lib/cdist/core/type.py index ce37769e..678120aa 100644 --- a/lib/cdist/core/type.py +++ b/lib/cdist/core/type.py @@ -25,6 +25,15 @@ import os import cdist +class NoSuchTypeError(cdist.Error): + def __init__(self, type_path, type_absolute_path): + self.type_path = type_path + self.type_absolute_path = type_absolute_path + + def __str__(self): + return "Type '%' does not exist at %s" % (self.type_path, self.type_absolute_path) + + class Type(object): """Represents a cdist type. @@ -62,6 +71,8 @@ class Type(object): self.name = name self.path = self.name self.absolute_path = os.path.join(self.base_path, self.path) + if not os.path.isdir(self.absolute_path): + raise NoSuchTypeError(self.path, self.absolute_path) self.manifest_path = os.path.join(self.name, "manifest") self.explorer_path = os.path.join(self.name, "explorer") self.gencode_local_path = os.path.join(self.name, "gencode-local")