diff options
author | Tristan Van Berkom <tristan.vanberkom@codethink.co.uk> | 2017-07-05 22:17:32 +0900 |
---|---|---|
committer | Tristan Van Berkom <tristan.vanberkom@codethink.co.uk> | 2017-07-05 22:17:32 +0900 |
commit | 4f3a71f898ad550e98c1e74f96ffa1fd145c9980 (patch) | |
tree | 99e29180de06914cb713e9af9dfd723c584a7fc7 | |
parent | c8c5516c7f426b17cfc5c7ba4f29c09a0ba13d73 (diff) | |
download | buildstream-test-public-data.tar.gz |
Testingtest-public-data
-rw-r--r-- | buildstream/_yaml.py | 30 | ||||
-rw-r--r-- | buildstream/element.py | 6 |
2 files changed, 32 insertions, 4 deletions
diff --git a/buildstream/_yaml.py b/buildstream/_yaml.py index 93fae4903..c8151d501 100644 --- a/buildstream/_yaml.py +++ b/buildstream/_yaml.py @@ -602,3 +602,33 @@ def list_chain_copy(source): copy.append(item) return copy + + +def node_copy(source): + copy = {} + for key, value in source.items(): + if isinstance(value, collections.Mapping): + copy[key] = node_copy(value) + elif isinstance(value, list): + copy[key] = list_copy(value) + elif isinstance(value, Provenance): + copy[key] = value.clone() + + ensure_provenance(copy) + + return copy + + +def list_copy(source): + copy = [] + for item in source: + if isinstance(item, collections.Mapping): + copy.append(node_copy(item)) + elif isinstance(item, list): + copy.append(list_copy(item)) + elif isinstance(item, Provenance): + copy.append(item.clone()) + else: + copy.append(item) + + return copy diff --git a/buildstream/element.py b/buildstream/element.py index 1b0bf2b1e..ee8b86b49 100644 --- a/buildstream/element.py +++ b/buildstream/element.py @@ -435,7 +435,7 @@ class Element(Plugin): data = self.__dynamic_public.get(domain) if data is not None: - data = _yaml.node_chain_copy(data) + data = _yaml.node_copy(data) return data @@ -455,9 +455,7 @@ class Element(Plugin): self._load_public_data() if data is not None: - # Should we ensure provenance information here ? - # - data = copy.deepcopy(data) + data = _yaml.node_copy(data) self.__dynamic_public[domain] = data |