diff options
author | Benjamin Schubert <ben.c.schubert@gmail.com> | 2019-06-11 18:19:46 +0100 |
---|---|---|
committer | bst-marge-bot <marge-bot@buildstream.build> | 2019-07-15 14:14:02 +0000 |
commit | 7298136642010d4e02a607f4275ffe3ad5657a14 (patch) | |
tree | aab93ac4d78c6d7b85ac2b1de89eb11280829b21 /src/buildstream/_projectrefs.py | |
parent | ad5aa05826431b1b34c220f20e93bf6e05b292a0 (diff) | |
download | buildstream-7298136642010d4e02a607f4275ffe3ad5657a14.tar.gz |
_yaml: Introduce 'get_sequence()' and 'sequence_at()'/'mapping_at()'
- Adding 'get_sequence' on MappingNode to access sequences in a mapping
- Adding 'sequence_at' on SequenceNode to access sequences in a sequence
- Adding 'mapping_at' on SequenceNode to access mappings in a sequence
Using "*_at" in sequences allows us to quickly understand if we are
dealing with a sequence or a mapping.
Diffstat (limited to 'src/buildstream/_projectrefs.py')
-rw-r--r-- | src/buildstream/_projectrefs.py | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/src/buildstream/_projectrefs.py b/src/buildstream/_projectrefs.py index 847935c0b..f296858cf 100644 --- a/src/buildstream/_projectrefs.py +++ b/src/buildstream/_projectrefs.py @@ -133,16 +133,16 @@ class ProjectRefs(): # Fetch the element try: - element_list = _yaml.node_get(project_node, list, element) + element_list = project_node.get_sequence(element) except LoadError: if not ensure: return None - element_list = [] + element_list = _yaml.new_empty_list_node() _yaml.node_set(project_node, element, element_list) # Fetch the source index try: - node = element_list[source_index] + node = element_list.mapping_at(source_index) except IndexError: if not ensure: return None |