summaryrefslogtreecommitdiff
path: root/src/buildstream/element.py
diff options
context:
space:
mode:
authorBenjamin Schubert <contact@benschubert.me>2019-07-08 14:18:39 +0100
committerbst-marge-bot <marge-bot@buildstream.build>2019-07-15 14:14:03 +0000
commit099e3ebf3aad424be2f3488aef9d9d961b700483 (patch)
treeb1634644122751537e092caf8c35f8a1cee6cf9b /src/buildstream/element.py
parent695eddc069c9803eca5d004e80ca7be7defdd20c (diff)
downloadbuildstream-099e3ebf3aad424be2f3488aef9d9d961b700483.tar.gz
_yaml: Remove 'node_get_provenance' and add 'Node.get_provenance'
This replaces the helper method by adding a 'get_provenance' on the node directly - Adapt all call sites - Delay getting provenance wherever possible without major refactor
Diffstat (limited to 'src/buildstream/element.py')
-rw-r--r--src/buildstream/element.py13
1 files changed, 9 insertions, 4 deletions
diff --git a/src/buildstream/element.py b/src/buildstream/element.py
index 35d25562d..446b20352 100644
--- a/src/buildstream/element.py
+++ b/src/buildstream/element.py
@@ -514,7 +514,7 @@ class Element(Plugin):
try:
return self.__variables.subst(value)
except LoadError as e:
- provenance = _yaml.node_get_provenance(node, key=member_name)
+ provenance = node.get_scalar(member_name).get_provenance()
raise LoadError(e.reason, '{}: {}'.format(provenance, e), detail=e.detail) from e
def node_subst_list(self, node, member_name):
@@ -536,7 +536,7 @@ class Element(Plugin):
try:
ret.append(self.__variables.subst(value.as_str()))
except LoadError as e:
- provenance = _yaml.node_get_provenance(value)
+ provenance = value.get_provenance()
raise LoadError(e.reason, '{}: {}'.format(provenance, e), detail=e.detail) from e
return ret
@@ -2600,8 +2600,13 @@ class Element(Plugin):
variables._assert_fully_composited()
for var in ('project-name', 'element-name', 'max-jobs'):
- provenance = _yaml.node_get_provenance(variables, var)
- if provenance and not provenance.is_synthetic:
+ node = variables.get_node(var, allow_none=True)
+
+ if node is None:
+ continue
+
+ provenance = node.get_provenance()
+ if not provenance.is_synthetic:
raise LoadError(LoadErrorReason.PROTECTED_VARIABLE_REDEFINED,
"{}: invalid redefinition of protected variable '{}'"
.format(provenance, var))