From 2fe4ed2e342289acf994bffe5f902fc59d58286c Mon Sep 17 00:00:00 2001 From: Jaroslav Henner Date: Tue, 4 Feb 2014 15:38:36 +0100 Subject: [PATCH] Toplevel collection typecheck. Change-Id: I4a59d1b9391adb84f4a29520a179f8cdbc61e18d --- jenkins_jobs/builder.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/jenkins_jobs/builder.py b/jenkins_jobs/builder.py index 0c9690436..0866df78a 100644 --- a/jenkins_jobs/builder.py +++ b/jenkins_jobs/builder.py @@ -120,6 +120,10 @@ class YamlParser(object): def parse(self, fn): data = yaml.load(open(fn)) if data: + if not isinstance(data, list): + raise JenkinsJobsException( + "The topmost collection in file '{fname}' must be a list," + " not a {cls}".format(fname=fn, cls=type(data))) for item in data: cls, dfn = item.items()[0] group = self.data.get(cls, {})