loader.py: Check whether the dir specified is also a <dir>.bst file
- Slight modification to the wording of existing error message.
- Closes #446
diff --git a/buildstream/_loader/loader.py b/buildstream/_loader/loader.py
index 42e7fee..07b0de9 100644
--- a/buildstream/_loader/loader.py
+++ b/buildstream/_loader/loader.py
@@ -229,6 +229,16 @@
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 0033628..0e090e2 100644
--- a/buildstream/_yaml.py
+++ b/buildstream/_yaml.py
@@ -186,7 +186,7 @@
"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