Browse Source

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
Gabriele Cerami 6 months ago
parent
commit
5f582c6eb3
1 changed files with 5 additions and 1 deletions
  1. 5
    1
      zuul_sphinx/zuul.py

+ 5
- 1
zuul_sphinx/zuul.py View File

@@ -102,8 +102,12 @@ class ZuulDirective(Directive):
102 102
     def parse_zuul_d(self, path):
103 103
         layout = Layout()
104 104
         for conf in os.listdir(path):
105
-            with open(os.path.join(path, conf)) as f:
105
+            conf_path = os.path.join(path, conf)
106
+            with open(conf_path) as f:
106 107
                 data = yaml.load(f, Loader=ZuulSafeLoader)
108
+            if data is None:
109
+                raise SphinxError(
110
+                    "File %s in Zuul dir is empty", conf_path)
107 111
             for obj in data:
108 112
                 if 'job' in obj:
109 113
                     layout.jobs.append(obj['job'])

Loading…
Cancel
Save