summaryrefslogtreecommitdiff
path: root/buildstream/_yaml.py
diff options
context:
space:
mode:
authorbst-marge-bot <marge-bot@buildstream.build>2019-04-02 08:00:28 +0000
committerbst-marge-bot <marge-bot@buildstream.build>2019-04-02 08:00:28 +0000
commit9605f798022a02ff92f089d54f031c12bfbe6a00 (patch)
treefd61cb7b4c8942d4c79dac107588feb7c646c6f6 /buildstream/_yaml.py
parent6a965cd00b90a485ce88312ed7ac2d90286d7c26 (diff)
parentac17fe723644eaecbd1f5b35383ede277cdbd0df (diff)
downloadbuildstream-9605f798022a02ff92f089d54f031c12bfbe6a00.tar.gz
Merge branch 'kinnison/cleanups' into 'master'
Some small cleanups See merge request BuildStream/buildstream!1272
Diffstat (limited to 'buildstream/_yaml.py')
-rw-r--r--buildstream/_yaml.py10
1 files changed, 8 insertions, 2 deletions
diff --git a/buildstream/_yaml.py b/buildstream/_yaml.py
index 1512a3cb8..5184485de 100644
--- a/buildstream/_yaml.py
+++ b/buildstream/_yaml.py
@@ -334,6 +334,8 @@ def load(filename, shortname=None, copy_tree=False, *, project=None):
raise LoadError(LoadErrorReason.LOADING_DIRECTORY,
"{} is a directory. bst command expects a .bst file."
.format(filename)) from e
+ except LoadError as e:
+ raise LoadError(e.reason, "{}: {}".format(displayname, e)) from e
# Like load(), but doesnt require the data to be in a file
@@ -450,7 +452,6 @@ _sentinel = object()
def node_get(node, expected_type, key, indices=None, *, default_value=_sentinel, allow_none=False):
assert type(node) is Node
- path = key
if indices is None:
if default_value is _sentinel:
value = node[0].get(key, Node(default_value, None, 0, 0))
@@ -469,7 +470,6 @@ def node_get(node, expected_type, key, indices=None, *, default_value=_sentinel,
value = value[0][index]
if type(value) is not Node:
value = (value,)
- path += '[{:d}]'.format(index)
# Optionally allow None as a valid value for any type
if value[0] is None and (allow_none or default_value is None):
@@ -497,6 +497,12 @@ def node_get(node, expected_type, key, indices=None, *, default_value=_sentinel,
raise ValueError()
except (ValueError, TypeError):
provenance = node_get_provenance(node, key=key, indices=indices)
+ if indices:
+ path = [key]
+ path.extend("[{:d}]".format(i) for i in indices)
+ path = "".join(path)
+ else:
+ path = key
raise LoadError(LoadErrorReason.INVALID_DATA,
"{}: Value of '{}' is not of the expected type '{}'"
.format(provenance, path, expected_type.__name__))