Skip to content

Commit 7e53406

Browse files
committed
Verify format of regex_subs
1 parent 981e820 commit 7e53406

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

easybuild/tools/filetools.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1664,11 +1664,14 @@ def apply_regex_substitutions(paths, regex_subs, backup='.orig.eb',
16641664
on_missing_match = build_option('strict')
16651665
allowed_values = (ERROR, IGNORE, WARN)
16661666
if on_missing_match not in allowed_values:
1667-
raise EasyBuildError('Invalid value passed to on_missing_match: %s (allowed: %s)',
1668-
on_missing_match, ', '.join(allowed_values))
1667+
raise ValueError('Invalid value passed to on_missing_match: %s (allowed: %s)',
1668+
on_missing_match, ', '.join(allowed_values))
16691669

16701670
if isinstance(paths, string_type):
16711671
paths = [paths]
1672+
if (not isinstance(regex_subs, (list, tuple)) or
1673+
not all(isinstance(sub, (list, tuple)) and len(sub) == 2 for sub in regex_subs)):
1674+
raise ValueError('Parameter regex_subs must be a list of 2-element tuples. Got:', regex_subs)
16721675

16731676
flags = 0 if single_line else re.M
16741677
compiled_regex_subs = [(re.compile(regex, flags) if isinstance(regex, str) else regex, subtxt)

0 commit comments

Comments
 (0)