Skip to content

Commit cb74879

Browse files
Merge pull request #1299 from douglasjacobsen/str-case-expander
Allow expander to change case of strings
2 parents 3ee599f + e50a5c3 commit cb74879

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

lib/ramble/ramble/expander.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,14 @@ def _join_str(seq, sep=","):
3838
return sep.join(str(i) for i in seq)
3939

4040

41+
def _upper_str(in_str):
42+
return in_str.upper()
43+
44+
45+
def _lower_str(in_str):
46+
return in_str.lower()
47+
48+
4149
def _re_search(regex, s):
4250
return re.search(regex, s) is not None
4351

@@ -120,6 +128,8 @@ def _maybe(expander, var_name, default=""):
120128
"simplify_str": spack.util.naming.simplify_name,
121129
"join_str": _join_str,
122130
"re_search": _re_search,
131+
"upper_str": _upper_str,
132+
"lower_str": _lower_str,
123133
}
124134

125135
# Format Spec Regex:

lib/ramble/ramble/test/expander.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,8 @@ def build_variant_set():
146146
("math_sqrt(64)", "8.0", set(), 1),
147147
("math_log(9, 3)", "2.0", set(), 1),
148148
("math_not_exist(1)", "math_not_exist(1)", set(), 1),
149+
("upper_str('foo')", "FOO", set(), 1),
150+
("lower_str('FOO')", "foo", set(), 1),
149151
],
150152
)
151153
def test_expansions(input, output, no_expand_vars, passes):

0 commit comments

Comments
 (0)