summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/buildstream/element.py13
-rw-r--r--src/buildstream/plugins/elements/script.py2
2 files changed, 7 insertions, 8 deletions
diff --git a/src/buildstream/element.py b/src/buildstream/element.py
index e6278b1e0..870e49e19 100644
--- a/src/buildstream/element.py
+++ b/src/buildstream/element.py
@@ -112,7 +112,7 @@ from .storage._casbaseddirectory import CasBasedDirectory
from .storage.directory import VirtualDirectoryError
if TYPE_CHECKING:
- from .node import MappingNode, ScalarNode
+ from .node import MappingNode, ScalarNode, SequenceNode
from .types import SourceRef
from typing import Set, Tuple
@@ -562,22 +562,21 @@ class Element(Plugin):
provenance = node.get_provenance()
raise LoadError('{}: {}'.format(provenance, e), e.reason, detail=e.detail) from e
- def node_subst_list(self, node: 'MappingNode[str, Any]', member_name: str) -> List[Any]:
- """Fetch a list from a node member, substituting any variables in the list
+ def node_subst_sequence_vars(self, node: 'SequenceNode[ScalarNode]') -> List[str]:
+ """Substitute any variables in the given sequence
Args:
- node: A MappingNode loaded from YAML
- member_name: The name of the member to fetch (a list)
+ node: A SequenceNode loaded from YAML
Returns:
- The list in *member_name*
+ The list with every variable replaced
Raises:
:class:`.LoadError`
"""
ret = []
- for value in node.get_sequence(member_name):
+ for value in node:
try:
ret.append(self.__variables.subst(value.as_str()))
except LoadError as e:
diff --git a/src/buildstream/plugins/elements/script.py b/src/buildstream/plugins/elements/script.py
index c63d0a04e..f3f0a2f7a 100644
--- a/src/buildstream/plugins/elements/script.py
+++ b/src/buildstream/plugins/elements/script.py
@@ -55,7 +55,7 @@ class ScriptElement(buildstream.ScriptElement):
'commands', 'root-read-only', 'layout'
])
- cmds = self.node_subst_list(node, "commands")
+ cmds = self.node_subst_sequence_vars(node.get_sequence("commands"))
self.add_commands("commands", cmds)
self.set_work_dir()