diff options
author | Benjamin Schubert <contact@benschubert.me> | 2019-10-15 13:56:48 +0100 |
---|---|---|
committer | Benjamin Schubert <contact@benschubert.me> | 2019-10-16 13:58:57 +0100 |
commit | abc522cd6a292ef571cafb1b4d4288903690d730 (patch) | |
tree | 006d62357a47ee2899cc7fd7ccaf3f1181408456 /src/buildstream/element.py | |
parent | f0c928ed5e0fb61f3dd4e26891a39def0b40be81 (diff) | |
download | buildstream-abc522cd6a292ef571cafb1b4d4288903690d730.tar.gz |
element.py: Rework 'node_subst_list' to take the sequence directly
Also rename it to 'node_subst_sequence_vars' to mimic 'node_subst_vars'.
Diffstat (limited to 'src/buildstream/element.py')
-rw-r--r-- | src/buildstream/element.py | 13 |
1 files changed, 6 insertions, 7 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: |