diff --git a/lib/ramble/docs/workspace_config.rst b/lib/ramble/docs/workspace_config.rst index 2e1049bde..7356c0dae 100644 --- a/lib/ramble/docs/workspace_config.rst +++ b/lib/ramble/docs/workspace_config.rst @@ -176,10 +176,14 @@ Supported functions are: * ``randint`` (from `random.randint`) * ``re_search(regex, str)`` (determine if ``str`` contains pattern ``regex``, based on ``re.search``) -Additionally, string slicing is supported: +String slicing is supported: * ``str[start:end:step]`` (string slicing) +Dictionary references are supported: + +* ``dict_name["key"]`` (dictionary subscript) + .. _ramble-escaped-variables: ~~~~~~~~~~~~~~~~~ diff --git a/lib/ramble/ramble/test/expander.py b/lib/ramble/ramble/test/expander.py index e1877fd82..6859f08ea 100644 --- a/lib/ramble/ramble/test/expander.py +++ b/lib/ramble/ramble/test/expander.py @@ -32,6 +32,7 @@ def exp_dict(): "size": '"0000.96"', # Escaped as a string "test_mask": '"0x0"', "max_len": 9, + "test_dict": {"test_key1": "test_val1", "test_key2": "test_val2"}, } @@ -85,6 +86,9 @@ def exp_dict(): ('"{env_name}"[:{max_len}:1]', "spack_foo", set(), 1), ("not_a_slice[0]", "not_a_slice[0]", set(), 1), ("not_a_valid_slice[0:a]", "not_a_valid_slice[0:a]", set(), 1), + ("{test_dict}", "{'test_key1': 'test_val1', 'test_key2': 'test_val2'}", set(), 1), + ("{test_dict['test_key1']}", "test_val1", set(), 1), + ("{test_dict['test_key2']}", "test_val2", set(), 1), ], ) def test_expansions(input, output, no_expand_vars, passes):