From 5f582c6eb34a9e92fd0ffb09179ade469307bed1 Mon Sep 17 00:00:00 2001 From: Gabriele Cerami Date: Fri, 28 Sep 2018 13:51:51 +0100 Subject: [PATCH] Raise an error if a file in zuul.d is empty Currently if a file in zuul.d is empty loading it returns None and the command returns with a generic TypeError since data cannot be iterated. This change adds a more explicit error. Change-Id: I4928aac2488a92aed57018a3aa4d9f6f7650d38b --- zuul_sphinx/zuul.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/zuul_sphinx/zuul.py b/zuul_sphinx/zuul.py index 7fb3800..a174270 100644 --- a/zuul_sphinx/zuul.py +++ b/zuul_sphinx/zuul.py @@ -102,8 +102,12 @@ class ZuulDirective(Directive): def parse_zuul_d(self, path): layout = Layout() for conf in os.listdir(path): - with open(os.path.join(path, conf)) as f: + conf_path = os.path.join(path, conf) + with open(conf_path) as f: data = yaml.load(f, Loader=ZuulSafeLoader) + if data is None: + raise SphinxError( + "File %s in Zuul dir is empty", conf_path) for obj in data: if 'job' in obj: layout.jobs.append(obj['job'])