diff options
author | Benjamin Schubert <ben.c.schubert@gmail.com> | 2019-07-05 15:59:25 +0100 |
---|---|---|
committer | bst-marge-bot <marge-bot@buildstream.build> | 2019-07-15 14:14:03 +0000 |
commit | 3729055b36ca4fca32f18416acc7dacc825ebb2c (patch) | |
tree | c909df4ae38482022a8faad7f043c07c24050fc4 | |
parent | 415dde7618ec3f33e17d70e7f70a171eaadd2344 (diff) | |
download | buildstream-3729055b36ca4fca32f18416acc7dacc825ebb2c.tar.gz |
types: rework dependency to always get a 'Node' as dep and remove provenance
The provenance can be constructed afterwards, so we don't need to
pre-calculate it.
-rw-r--r-- | src/buildstream/_loader/types.pyx | 13 |
1 files changed, 4 insertions, 9 deletions
diff --git a/src/buildstream/_loader/types.pyx b/src/buildstream/_loader/types.pyx index 5b8388e28..cd206cfb4 100644 --- a/src/buildstream/_loader/types.pyx +++ b/src/buildstream/_loader/types.pyx @@ -65,12 +65,11 @@ cdef class Dependency: cdef public str junction def __init__(self, - object dep, - _yaml.ProvenanceInformation provenance, + _yaml.Node dep, str default_dep_type=None): cdef str dep_type - self.provenance = provenance + self.provenance = _yaml.node_get_provenance(dep) if type(dep) is _yaml.ScalarNode: self.name = dep.as_str() @@ -100,7 +99,7 @@ cdef class Dependency: else: raise LoadError(LoadErrorReason.INVALID_DATA, - "{}: Dependency is not specified as a string or a dictionary".format(provenance)) + "{}: Dependency is not specified as a string or a dictionary".format(self.provenance)) # `:` characters are not allowed in filename if a junction was # explicitly specified @@ -140,13 +139,9 @@ cdef class Dependency: cdef void _extract_depends_from_node(_yaml.Node node, str key, str default_dep_type, list acc) except *: cdef _yaml.SequenceNode depends = node.get_sequence(key, []) cdef _yaml.Node dep_node - cdef _yaml.ProvenanceInformation dep_provenance for dep_node in depends: - # FIXME: the provenance information would be obtainable from the Node directly if we stop - # stripping provenance and have proper nodes for str elements - dep_provenance = <_yaml.ProvenanceInformation> _yaml.node_get_provenance(dep_node) - dependency = Dependency(dep_node, dep_provenance, default_dep_type=default_dep_type) + dependency = Dependency(dep_node, default_dep_type=default_dep_type) acc.append(dependency) # Now delete the field, we dont want it anymore |