From 48848f4e69201b78524443dc34a77cf872e0ad6c Mon Sep 17 00:00:00 2001 From: James Ennis Date: Thu, 28 Jun 2018 18:34:47 +0100 Subject: loader.py: Check whether the dir specified is also a .bst file - Slight modification to the wording of existing error message. - Closes #446 --- buildstream/_loader/loader.py | 10 ++++++++++ buildstream/_yaml.py | 2 +- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/buildstream/_loader/loader.py b/buildstream/_loader/loader.py index 42e7feef5..07b0de996 100644 --- a/buildstream/_loader/loader.py +++ b/buildstream/_loader/loader.py @@ -229,6 +229,16 @@ class Loader(): detail = "Did you mean '{}'?".format(element_relpath) raise LoadError(LoadErrorReason.MISSING_FILE, message, detail=detail) from e + elif e.reason == LoadErrorReason.LOADING_DIRECTORY: + # If a .bst file exists in the element path, + # let's suggest this as a plausible alternative. + message = str(e) + detail = None + if os.path.exists(os.path.join(self._basedir, filename + '.bst')): + element_name = filename + '.bst' + detail = "Did you mean '{}'?\n".format(element_name) + raise LoadError(LoadErrorReason.LOADING_DIRECTORY, + message, detail=detail) from e else: raise self._options.process_node(node) diff --git a/buildstream/_yaml.py b/buildstream/_yaml.py index 00336281c..0e090e2e7 100644 --- a/buildstream/_yaml.py +++ b/buildstream/_yaml.py @@ -186,7 +186,7 @@ def load(filename, shortname=None, copy_tree=False): "Could not find file at {}".format(filename)) from e except IsADirectoryError as e: raise LoadError(LoadErrorReason.LOADING_DIRECTORY, - "{} is a directory. bst command is expecting a .bst file" + "{} is a directory. bst command expects a .bst file." .format(filename)) from e -- cgit v1.2.1