Skip to content

Commit

Permalink
Merge pull request #22 from jcrivenaes/filepaths-substitute
Browse files Browse the repository at this point in the history
Support for / in names
  • Loading branch information
jcrivenaes authored Jun 17, 2020
2 parents 24fb713 + 18aeb48 commit 98990e4
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/fmu/config/configparserfmu.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down
28 changes: 28 additions & 0 deletions tests/test_snippets.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,3 +117,31 @@ def test_process_value2(tmp_path):
tmpl = ut.yaml_load(join(out, "s04.yml.tmpl"))

assert tmpl["global"]["WHATEVER"] == "<ONX>"


def test_filepath(tmp_path):
"""Test when filepath is present as substitute, s05"""

inp = b"""
global:
MYFILE: /tmp/fil ~ <FILE>
"""

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"] == "<FILE>"

0 comments on commit 98990e4

Please sign in to comment.