summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJames Ennis <james.ennis@codethink.com>2018-06-28 18:34:47 +0100
committerJames Ennis <james.ennis@codethink.com>2018-06-29 09:45:12 +0100
commit48848f4e69201b78524443dc34a77cf872e0ad6c (patch)
treeeb6dcfb50fd27289003131750d20524908ab69f7
parent463698ec3203190aeac1f41ed3885f08e95bceae (diff)
downloadbuildstream-48848f4e69201b78524443dc34a77cf872e0ad6c.tar.gz
loader.py: Check whether the dir specified is also a <dir>.bst file
- Slight modification to the wording of existing error message. - Closes #446
-rw-r--r--buildstream/_loader/loader.py10
-rw-r--r--buildstream/_yaml.py2
2 files changed, 11 insertions, 1 deletions
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 <directory>.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