From 18aeb482914768595c0b485edc957727d47b80c6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20C=2E=20Riven=C3=A6s?= Date: Wed, 17 Jun 2020 11:03:23 +0200 Subject: [PATCH] Support for / in names --- src/fmu/config/configparserfmu.py | 2 +- tests/test_snippets.py | 28 ++++++++++++++++++++++++++++ 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/src/fmu/config/configparserfmu.py b/src/fmu/config/configparserfmu.py index 7d26792..4ac4c00 100644 --- a/src/fmu/config/configparserfmu.py +++ b/src/fmu/config/configparserfmu.py @@ -624,7 +624,7 @@ def _get_required_form(stream, template=False, ipl=False): def _get_tmpl_form(stream): """Get template form (<...> if present, not numbers).""" - pattern = "\\-*[\\-a-zA-Z0-9._]+~" + pattern = "\\-*[\\-a-zA-Z0-9._/]+~" # pdb.set_trace() diff --git a/tests/test_snippets.py b/tests/test_snippets.py index 71daf44..1024b62 100644 --- a/tests/test_snippets.py +++ b/tests/test_snippets.py @@ -117,3 +117,31 @@ def test_process_value2(tmp_path): tmpl = ut.yaml_load(join(out, "s04.yml.tmpl")) assert tmpl["global"]["WHATEVER"] == "" + + +def test_filepath(tmp_path): + """Test when filepath is present as substitute, s05""" + + inp = b""" + global: + MYFILE: /tmp/fil ~ + """ + + target = tmp_path / "generic.yml" + with target.open("w") as out: + out.write(inp.decode("utf-8")) + + cfg = fcfg.ConfigParserFMU() + cfg.parse(str(target)) + + out = str(tmp_path.resolve()) + + cfg.to_yaml(rootname="s05", destination=out, template=out) + + actual = ut.yaml_load(join(out, "s05.yml")) + + assert actual["global"]["MYFILE"] == "/tmp/fil" + + tmpl = ut.yaml_load(join(out, "s05.yml.tmpl")) + + assert tmpl["global"]["MYFILE"] == ""