Skip to content

Commit 5cf4cac

Browse files
committed
Only print summary of replacements
1 parent 83c6208 commit 5cf4cac

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

easybuild/tools/filetools.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1507,6 +1507,7 @@ def apply_regex_substitutions(paths, regex_subs, backup='.orig.eb'):
15071507

15081508
if backup:
15091509
copy_file(path, path + backup)
1510+
replacement_msgs = []
15101511
with open_file(path, 'w') as out_file:
15111512
lines = txt_utf8.split('\n')
15121513
del txt_utf8
@@ -1515,11 +1516,15 @@ def apply_regex_substitutions(paths, regex_subs, backup='.orig.eb'):
15151516
match = regex.search(line)
15161517
if match:
15171518
origtxt = match.group(0)
1518-
_log.info("Replacing line %d in %s: '%s' -> '%s'",
1519-
(line_id + 1), path, origtxt, subtxt)
1519+
replacement_msgs.append("Replaced in line %d: '%s' -> '%s'" %
1520+
(line_id + 1, origtxt, subtxt))
15201521
line = regex.sub(subtxt, line)
15211522
lines[line_id] = line
15221523
out_file.write('\n'.join(lines))
1524+
if replacement_msgs:
1525+
_log.info('Applied the following substitutions to %s:\n%s', path, '\n'.join(replacement_msgs))
1526+
else:
1527+
_log.info('Nothing found to replace in %s:', path)
15231528

15241529
except (IOError, OSError) as err:
15251530
raise EasyBuildError("Failed to patch %s: %s", path, err)

0 commit comments

Comments
 (0)