diff options
author | Harmen Stoppels <harmenstoppels@gmail.com> | 2023-09-05 20:07:16 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-09-05 20:07:16 +0200 |
commit | f8676db7f48bd3c470e3c4c165b92f59bdfb8428 (patch) | |
tree | 38b11f245370a9bf9ef61167c63743fe217bdf3e /lib | |
parent | dd747c5c4892fd0c8f6831786c2140198394cc4b (diff) | |
download | spack-f8676db7f48bd3c470e3c4c165b92f59bdfb8428.tar.gz spack-f8676db7f48bd3c470e3c4c165b92f59bdfb8428.tar.bz2 spack-f8676db7f48bd3c470e3c4c165b92f59bdfb8428.tar.xz spack-f8676db7f48bd3c470e3c4c165b92f59bdfb8428.zip |
Revert ""spack config add": allow values with a ":" (#39279)" (#39825)
This reverts commit b72a268bc565d370bd64589e86929acfd73c08a1.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/spack/spack/config.py | 31 | ||||
-rw-r--r-- | lib/spack/spack/test/config.py | 6 |
2 files changed, 7 insertions, 30 deletions
diff --git a/lib/spack/spack/config.py b/lib/spack/spack/config.py index ea9d12d2bd..b3fb5648ac 100644 --- a/lib/spack/spack/config.py +++ b/lib/spack/spack/config.py @@ -863,7 +863,6 @@ def add(fullpath, scope=None): has_existing_value = True path = "" override = False - value = syaml.load_config(components[-1]) for idx, name in enumerate(components[:-1]): # First handle double colons in constructing path colon = "::" if override else ":" if path else "" @@ -884,14 +883,14 @@ def add(fullpath, scope=None): existing = get_valid_type(path) # construct value from this point down + value = syaml.load_config(components[-1]) for component in reversed(components[idx + 1 : -1]): value = {component: value} break - if override: - path += "::" - if has_existing_value: + path, _, value = fullpath.rpartition(":") + value = syaml.load_config(value) existing = get(path, scope=scope) # append values to lists @@ -1232,17 +1231,11 @@ def merge_yaml(dest, source, prepend=False, append=False): return copy.copy(source) +# +# Process a path argument to config.set() that may contain overrides ('::' or +# trailing ':') +# def process_config_path(path): - """Process a path argument to config.set() that may contain overrides ('::' or - trailing ':') - - Note: quoted value path components will be processed as a single value (escaping colons) - quoted path components outside of the value will be considered ill formed and will - raise. - e.g. `this:is:a:path:'value:with:colon'` will yield: - - [this, is, a, path, value:with:colon] - """ result = [] if path.startswith(":"): raise syaml.SpackYAMLError("Illegal leading `:' in path `{0}'".format(path), "") @@ -1269,16 +1262,6 @@ def process_config_path(path): front = syaml.syaml_str(front) front.append = True - quote = "['\"]" - not_quote = "[^'\"]" - - if re.match(f"^{quote}", path): - m = re.match(rf"^{quote}({not_quote}+){quote}$", path) - if not m: - raise ValueError("Quotes indicate value, but there are additional path entries") - result.append(m.group(1)) - break - result.append(front) return result diff --git a/lib/spack/spack/test/config.py b/lib/spack/spack/test/config.py index 1dbbba9cde..d3b5a544ba 100644 --- a/lib/spack/spack/test/config.py +++ b/lib/spack/spack/test/config.py @@ -277,12 +277,6 @@ def test_add_config_path(mutable_config): compilers = spack.config.get("packages")["all"]["compiler"] assert "gcc" in compilers - # Try with an escaped colon - path = 'config:install_tree:root:"C:/path/to/config.yaml"' - spack.config.add(path) - set_value = spack.config.get("config")["install_tree"]["root"] - assert set_value == "C:/path/to/config.yaml" - @pytest.mark.regression("17543,23259") def test_add_config_path_with_enumerated_type(mutable_config): |