diff options
author | Benjamin Schubert <ben.c.schubert@gmail.com> | 2019-06-28 17:06:43 +0100 |
---|---|---|
committer | Benjamin Schubert <ben.c.schubert@gmail.com> | 2019-07-01 22:38:51 +0100 |
commit | be5ee63758654ebfc6da169ada2ba65e3af33d60 (patch) | |
tree | 6c73a1276a24c81692243c97ba0a4e3271d264e5 | |
parent | 947fbd8bedb93185ff69db35fd3dce22efc80e8a (diff) | |
download | buildstream-be5ee63758654ebfc6da169ada2ba65e3af33d60.tar.gz |
_yaml: Decomission 'dump()'. 'roundtrip_dump' is an equivalent function now
Remove completely '_yaml.dump()' and replace all notions and call by
'roundtrip_dump'
-rwxr-xr-x | doc/bst2html.py | 2 | ||||
-rw-r--r-- | src/buildstream/_artifact.py | 2 | ||||
-rw-r--r-- | src/buildstream/_stream.py | 2 | ||||
-rw-r--r-- | src/buildstream/_workspaces.py | 4 | ||||
-rw-r--r-- | src/buildstream/_yaml.pyx | 15 | ||||
-rw-r--r-- | tests/format/include.py | 4 |
6 files changed, 7 insertions, 22 deletions
diff --git a/doc/bst2html.py b/doc/bst2html.py index 9d178bc18..71d497eda 100755 --- a/doc/bst2html.py +++ b/doc/bst2html.py @@ -197,7 +197,7 @@ def workdir(source_cache=None): 'sourcedir': source_cache, 'logdir': os.path.join(tempdir, 'logs'), } - _yaml.dump(config, bst_config_file) + _yaml.roundtrip_dump(config, bst_config_file) yield (tempdir, bst_config_file, source_cache) diff --git a/src/buildstream/_artifact.py b/src/buildstream/_artifact.py index ec80e6417..8f7ae9a1d 100644 --- a/src/buildstream/_artifact.py +++ b/src/buildstream/_artifact.py @@ -149,7 +149,7 @@ class Artifact(): # Store public data with tempfile.NamedTemporaryFile(dir=self._tmpdir) as tmp: - _yaml.dump(publicdata, tmp.name) + _yaml.roundtrip_dump(publicdata, tmp.name) public_data_digest = self._cas.add_object(path=tmp.name, link_directly=True) artifact.public_data.CopyFrom(public_data_digest) size += public_data_digest.size_bytes diff --git a/src/buildstream/_stream.py b/src/buildstream/_stream.py index 195be55ba..8a2e1d1eb 100644 --- a/src/buildstream/_stream.py +++ b/src/buildstream/_stream.py @@ -913,7 +913,7 @@ class Stream(): } workspaces.append(workspace_detail) - _yaml.dump({ + _yaml.roundtrip_dump({ 'workspaces': workspaces }) diff --git a/src/buildstream/_workspaces.py b/src/buildstream/_workspaces.py index 95c1817ce..ed50828a3 100644 --- a/src/buildstream/_workspaces.py +++ b/src/buildstream/_workspaces.py @@ -125,7 +125,7 @@ class WorkspaceProject(): # def write(self): os.makedirs(self._directory, exist_ok=True) - _yaml.dump(self.to_dict(), self.get_filename()) + _yaml.roundtrip_dump(self.to_dict(), self.get_filename()) # get_filename() # @@ -530,7 +530,7 @@ class Workspaces(): } } os.makedirs(self._bst_directory, exist_ok=True) - _yaml.dump(config, self._get_filename()) + _yaml.roundtrip_dump(config, self._get_filename()) # _load_config() # diff --git a/src/buildstream/_yaml.pyx b/src/buildstream/_yaml.pyx index 52a700235..f169e1af6 100644 --- a/src/buildstream/_yaml.pyx +++ b/src/buildstream/_yaml.pyx @@ -836,21 +836,6 @@ cpdef Node load_data(str data, int file_index=_SYNTHETIC_FILE_INDEX, str file_na return contents -# dump() -# -# Write a YAML node structure out to disk. -# -# This will always call `node_sanitize` on its input, so if you wanted -# to output something close to what you read in, consider using the -# `roundtrip_load` and `roundtrip_dump` function pair instead. -# -# Args: -# contents (any): Content to write out -# filename (str): The (optional) file name to write out to -def dump(object contents, str filename=None): - roundtrip_dump(node_sanitize(contents), file=filename) - - # node_get_provenance() # # Gets the provenance for a node diff --git a/tests/format/include.py b/tests/format/include.py index 3bb4e4d51..8902aa3eb 100644 --- a/tests/format/include.py +++ b/tests/format/include.py @@ -35,7 +35,7 @@ def test_include_missing_file(cli, tmpdir): tmpdir.join('project.conf').write('{"name": "test"}') element = tmpdir.join('include_missing_file.bst') - # Normally we would use dicts and _yaml.dump to write such things, but here + # Normally we would use dicts and _yaml.roundtrip_dump to write such things, but here # we want to be sure of a stable line and column number. element.write(textwrap.dedent(""" kind: manual @@ -55,7 +55,7 @@ def test_include_dir(cli, tmpdir): tmpdir.mkdir('subdir') element = tmpdir.join('include_dir.bst') - # Normally we would use dicts and _yaml.dump to write such things, but here + # Normally we would use dicts and _yaml.roundtrip_dump to write such things, but here # we want to be sure of a stable line and column number. element.write(textwrap.dedent(""" kind: manual |