diff options
author | Tristan Van Berkom <tristan.vanberkom@codethink.co.uk> | 2019-03-09 20:12:33 +0900 |
---|---|---|
committer | bst-marge-bot <marge-bot@buildstream.build> | 2019-03-12 07:14:58 +0000 |
commit | e202f90366a8bb7fc10afc1c3428fdc91463bdfb (patch) | |
tree | 04deb0cb6426ff0dc4494d6a85de68cd9878820a | |
parent | e317bd1d5db00ce71186048302c15aee58875d95 (diff) | |
download | buildstream-e202f90366a8bb7fc10afc1c3428fdc91463bdfb.tar.gz |
_loader/loader.py: Include provenance in missing file errors
This fixes issue #947
-rw-r--r-- | buildstream/_loader/loader.py | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/buildstream/_loader/loader.py b/buildstream/_loader/loader.py index 7ccb9a37c..84b0a17d8 100644 --- a/buildstream/_loader/loader.py +++ b/buildstream/_loader/loader.py @@ -187,11 +187,12 @@ class Loader(): # ticker (callable): A callback to report loaded filenames to the frontend # fetch_subprojects (bool): Whether to fetch subprojects while loading # yaml_cache (YamlCache): A yaml cache + # provenance (Provenance): The location from where the file was referred to, or None # # Returns: # (LoadElement): A loaded LoadElement # - def _load_file(self, filename, rewritable, ticker, fetch_subprojects, yaml_cache=None): + def _load_file(self, filename, rewritable, ticker, fetch_subprojects, yaml_cache=None, provenance=None): # Silently ignore already loaded files if filename in self._elements: @@ -212,6 +213,8 @@ class Loader(): # alternatives by stripping the element-path from the given # filename, and verifying that it exists. message = "Could not find element '{}' in elements directory '{}'".format(filename, self._basedir) + if provenance: + message = "{}: {}".format(provenance, message) detail = None elements_dir = os.path.relpath(self._basedir, self.project.directory) element_relpath = os.path.relpath(filename, elements_dir) @@ -223,6 +226,8 @@ class Loader(): # If a <directory>.bst file exists in the element path, # let's suggest this as a plausible alternative. message = str(e) + if provenance: + message = "{}: {}".format(provenance, message) detail = None if os.path.exists(os.path.join(self._basedir, filename + '.bst')): element_name = filename + '.bst' @@ -250,13 +255,14 @@ class Loader(): # Load all dependency files for the new LoadElement for dep in dependencies: if dep.junction: - self._load_file(dep.junction, rewritable, ticker, fetch_subprojects, yaml_cache) + self._load_file(dep.junction, rewritable, ticker, fetch_subprojects, yaml_cache, dep.provenance) loader = self._get_loader(dep.junction, rewritable=rewritable, ticker=ticker, fetch_subprojects=fetch_subprojects) else: loader = self - dep_element = loader._load_file(dep.name, rewritable, ticker, fetch_subprojects, yaml_cache) + dep_element = loader._load_file(dep.name, rewritable, ticker, + fetch_subprojects, yaml_cache, dep.provenance) if _yaml.node_get(dep_element.node, str, Symbol.KIND) == 'junction': raise LoadError(LoadErrorReason.INVALID_DATA, |