From 58e170dd28ac0fd4637176e1442052827398f965 Mon Sep 17 00:00:00 2001 From: Benjamin Schubert Date: Fri, 21 Jun 2019 09:21:02 +0100 Subject: _yaml: Remove useless calls to '_yaml.node_sanitize' Calling '_yaml.dump' will itself call '_yaml.node_sanitize', therefore we can remove all calls to it in places where we directly after call dump. --- src/buildstream/_artifact.py | 2 +- src/buildstream/testing/runcli.py | 1 - tests/artifactcache/config.py | 4 ++-- tests/artifactcache/junctions.py | 2 +- tests/artifactcache/pull.py | 4 ++-- tests/artifactcache/push.py | 4 ++-- tests/cachekey/cachekey.py | 2 +- tests/frontend/remote-caches.py | 2 +- tests/frontend/workspace.py | 2 +- tests/sourcecache/fetch.py | 6 +++--- tests/sourcecache/push.py | 6 +++--- tests/sources/git.py | 12 ++++++------ 12 files changed, 23 insertions(+), 24 deletions(-) diff --git a/src/buildstream/_artifact.py b/src/buildstream/_artifact.py index 90d25b4fe..ec80e6417 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(_yaml.node_sanitize(publicdata), tmp.name) + _yaml.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/testing/runcli.py b/src/buildstream/testing/runcli.py index 9efff4593..a77deeb9e 100644 --- a/src/buildstream/testing/runcli.py +++ b/src/buildstream/testing/runcli.py @@ -576,7 +576,6 @@ class CliIntegration(Cli): _yaml.composite_dict(base_config, project_config) - base_config = _yaml.node_sanitize(base_config) _yaml.dump(base_config, project_filename) else: diff --git a/tests/artifactcache/config.py b/tests/artifactcache/config.py index 591cc0e03..928a6c524 100644 --- a/tests/artifactcache/config.py +++ b/tests/artifactcache/config.py @@ -101,11 +101,11 @@ def test_artifact_cache_precedence(tmpdir, override_caches, project_caches, user project_config['name'] = 'test' user_config_file = str(tmpdir.join('buildstream.conf')) - _yaml.dump(_yaml.node_sanitize(user_config), filename=user_config_file) + _yaml.dump(user_config, filename=user_config_file) project_dir = tmpdir.mkdir('project') project_config_file = str(project_dir.join('project.conf')) - _yaml.dump(_yaml.node_sanitize(project_config), filename=project_config_file) + _yaml.dump(project_config, filename=project_config_file) context = Context() context.load(config=user_config_file) diff --git a/tests/artifactcache/junctions.py b/tests/artifactcache/junctions.py index 52d721baf..ab041ce27 100644 --- a/tests/artifactcache/junctions.py +++ b/tests/artifactcache/junctions.py @@ -35,7 +35,7 @@ def project_set_artifacts(project, url): 'url': url, 'push': True }) - _yaml.dump(_yaml.node_sanitize(project_config), filename=project_conf_file) + _yaml.dump(project_config, filename=project_conf_file) @pytest.mark.datafiles(DATA_DIR) diff --git a/tests/artifactcache/pull.py b/tests/artifactcache/pull.py index d5f2c1f06..0b57a6c9a 100644 --- a/tests/artifactcache/pull.py +++ b/tests/artifactcache/pull.py @@ -73,7 +73,7 @@ def test_pull(cli, tmpdir, datafiles): } # Write down the user configuration file - _yaml.dump(_yaml.node_sanitize(user_config), filename=user_config_file) + _yaml.dump(user_config, filename=user_config_file) # Ensure CLI calls will use it cli.configure(user_config) @@ -182,7 +182,7 @@ def test_pull_tree(cli, tmpdir, datafiles): } # Write down the user configuration file - _yaml.dump(_yaml.node_sanitize(user_config), filename=user_config_file) + _yaml.dump(user_config, filename=user_config_file) # Ensure CLI calls will use it cli.configure(user_config) diff --git a/tests/artifactcache/push.py b/tests/artifactcache/push.py index 1cf46a496..862393f35 100644 --- a/tests/artifactcache/push.py +++ b/tests/artifactcache/push.py @@ -66,7 +66,7 @@ def test_push(cli, tmpdir, datafiles): } # Write down the user configuration file - _yaml.dump(_yaml.node_sanitize(user_config), filename=user_config_file) + _yaml.dump(user_config, filename=user_config_file) # Fake minimal context context = Context() @@ -164,7 +164,7 @@ def test_push_message(tmpdir, datafiles): } # Write down the user configuration file - _yaml.dump(_yaml.node_sanitize(user_config), filename=user_config_file) + _yaml.dump(user_config, filename=user_config_file) queue = multiprocessing.Queue() # Use subprocess to avoid creation of gRPC threads in main BuildStream process diff --git a/tests/cachekey/cachekey.py b/tests/cachekey/cachekey.py index 7c5d90d1f..bbececb8c 100644 --- a/tests/cachekey/cachekey.py +++ b/tests/cachekey/cachekey.py @@ -198,7 +198,7 @@ def test_cache_key_fatal_warnings(cli, tmpdir, first_warnings, second_warnings, project_dir = tmpdir.mkdir(project_name) project_config_file = str(project_dir.join('project.conf')) - _yaml.dump(_yaml.node_sanitize(config), filename=project_config_file) + _yaml.dump(config, filename=project_config_file) elem_dir = project_dir.mkdir('elements') element_file = str(elem_dir.join('stack.bst')) diff --git a/tests/frontend/remote-caches.py b/tests/frontend/remote-caches.py index 089cf96e4..8a5ef9c7b 100644 --- a/tests/frontend/remote-caches.py +++ b/tests/frontend/remote-caches.py @@ -57,7 +57,7 @@ def test_source_artifact_caches(cli, tmpdir, datafiles): }, 'cachedir': cachedir } - _yaml.dump(_yaml.node_sanitize(user_config), filename=user_config_file) + _yaml.dump(user_config, filename=user_config_file) cli.configure(user_config) create_element_size('repo.bst', project_dir, element_path, [], 10000) diff --git a/tests/frontend/workspace.py b/tests/frontend/workspace.py index 82c24b7ad..5267f8e56 100644 --- a/tests/frontend/workspace.py +++ b/tests/frontend/workspace.py @@ -1134,7 +1134,7 @@ def test_external_track(cli, datafiles, tmpdir_factory, guess_element): # element has been tracked element_contents = _yaml.load(element_file) _yaml.node_del(_yaml.node_get(element_contents, dict, 'sources', [0]), 'ref') - _yaml.dump(_yaml.node_sanitize(element_contents), element_file) + _yaml.dump(element_contents, element_file) result = cli.run(project=project, args=['-C', workspace, 'source', 'track', *arg_elm]) result.assert_success() diff --git a/tests/sourcecache/fetch.py b/tests/sourcecache/fetch.py index 899e162aa..cd8a3e989 100644 --- a/tests/sourcecache/fetch.py +++ b/tests/sourcecache/fetch.py @@ -56,7 +56,7 @@ def test_source_fetch(cli, tmpdir, datafiles): }, 'cachedir': cache_dir, } - _yaml.dump(_yaml.node_sanitize(user_config), filename=user_config_file) + _yaml.dump(user_config, filename=user_config_file) cli.configure(user_config) repo = create_repo('git', str(tmpdir)) @@ -131,7 +131,7 @@ def test_fetch_fallback(cli, tmpdir, datafiles): }, 'cachedir': cache_dir, } - _yaml.dump(_yaml.node_sanitize(user_config), filename=user_config_file) + _yaml.dump(user_config, filename=user_config_file) cli.configure(user_config) repo = create_repo('git', str(tmpdir)) @@ -188,7 +188,7 @@ def test_pull_fail(cli, tmpdir, datafiles): }, 'cachedir': cache_dir, } - _yaml.dump(_yaml.node_sanitize(user_config), filename=user_config_file) + _yaml.dump(user_config, filename=user_config_file) cli.configure(user_config) repo = create_repo('git', str(tmpdir)) diff --git a/tests/sourcecache/push.py b/tests/sourcecache/push.py index 065047b1b..4c652d21e 100644 --- a/tests/sourcecache/push.py +++ b/tests/sourcecache/push.py @@ -56,7 +56,7 @@ def test_source_push(cli, tmpdir, datafiles): }, 'cachedir': cache_dir, } - _yaml.dump(_yaml.node_sanitize(user_config), filename=user_config_file) + _yaml.dump(user_config, filename=user_config_file) cli.configure(user_config) repo = create_repo('git', str(tmpdir)) @@ -116,7 +116,7 @@ def test_push_pull(cli, datafiles, tmpdir): }, 'cachedir': cache_dir, } - _yaml.dump(_yaml.node_sanitize(user_config), filename=user_config_file) + _yaml.dump(user_config, filename=user_config_file) cli.configure(user_config) # create repo to pull from @@ -162,7 +162,7 @@ def test_push_fail(cli, tmpdir, datafiles): }, 'cachedir': cache_dir, } - _yaml.dump(_yaml.node_sanitize(user_config), filename=user_config_file) + _yaml.dump(user_config, filename=user_config_file) cli.configure(user_config) # create repo to pull from diff --git a/tests/sources/git.py b/tests/sources/git.py index e01477c49..45a2b827a 100644 --- a/tests/sources/git.py +++ b/tests/sources/git.py @@ -786,7 +786,7 @@ def test_git_describe(cli, tmpdir, datafiles, ref_storage, tag_type): project_config = _yaml.load(os.path.join(project, 'project.conf')) _yaml.node_set(project_config, 'ref-storage', ref_storage) - _yaml.dump(_yaml.node_sanitize(project_config), os.path.join(project, 'project.conf')) + _yaml.dump(project_config, os.path.join(project, 'project.conf')) repofiles = os.path.join(str(tmpdir), 'repofiles') os.makedirs(repofiles, exist_ok=True) @@ -900,7 +900,7 @@ def test_git_describe_head_is_tagged(cli, tmpdir, datafiles, ref_storage, tag_ty project_config = _yaml.load(os.path.join(project, 'project.conf')) _yaml.node_set(project_config, 'ref-storage', ref_storage) - _yaml.dump(_yaml.node_sanitize(project_config), os.path.join(project, 'project.conf')) + _yaml.dump(project_config, os.path.join(project, 'project.conf')) repofiles = os.path.join(str(tmpdir), 'repofiles') os.makedirs(repofiles, exist_ok=True) @@ -1015,7 +1015,7 @@ def test_git_describe_relevant_history(cli, tmpdir, datafiles): project_config = _yaml.load(os.path.join(project, 'project.conf')) _yaml.node_set(project_config, 'ref-storage', 'project.refs') - _yaml.dump(_yaml.node_sanitize(project_config), os.path.join(project, 'project.conf')) + _yaml.dump(project_config, os.path.join(project, 'project.conf')) repofiles = os.path.join(str(tmpdir), 'repofiles') os.makedirs(repofiles, exist_ok=True) @@ -1095,7 +1095,7 @@ def test_default_do_not_track_tags(cli, tmpdir, datafiles): project_config = _yaml.load(os.path.join(project, 'project.conf')) _yaml.node_set(project_config, 'ref-storage', 'inline') - _yaml.dump(_yaml.node_sanitize(project_config), os.path.join(project, 'project.conf')) + _yaml.dump(project_config, os.path.join(project, 'project.conf')) repofiles = os.path.join(str(tmpdir), 'repofiles') os.makedirs(repofiles, exist_ok=True) @@ -1162,7 +1162,7 @@ def test_overwrite_rogue_tag_multiple_remotes(cli, tmpdir, datafiles): } } ]) - _yaml.dump(_yaml.node_sanitize(project_config), os.path.join(project, 'project.conf')) + _yaml.dump(project_config, os.path.join(project, 'project.conf')) repo.add_annotated_tag('tag', 'tag') @@ -1208,7 +1208,7 @@ def test_overwrite_rogue_tag_multiple_remotes(cli, tmpdir, datafiles): repodir, reponame = os.path.split(repo.repo) - _yaml.dump(_yaml.node_sanitize(project_config), os.path.join(project, 'project.conf')) + _yaml.dump(project_config, os.path.join(project, 'project.conf')) config = repo.source_config(ref=new_ref) del config['track'] -- cgit v1.2.1