Skip to content

Commit

Permalink
enhance --fix-deprecated-easyconfigs to also switch to alternate easy…
Browse files Browse the repository at this point in the history
…config parameters in easyconfigs
  • Loading branch information
boegel committed Jun 5, 2024
1 parent 68e090e commit 07b8035
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions easybuild/framework/easyconfig/easyconfig.py
Original file line number Diff line number Diff line change
Expand Up @@ -2508,10 +2508,23 @@ def fix_deprecated_easyconfigs(paths):
# fix use of local variables with a name other than a single letter or 'local_*'
ec = EasyConfig(path, local_var_naming_check=LOCAL_VAR_NAMING_CHECK_LOG)
for key in ec.unknown_keys:
regexp = re.compile(r'\b(%s)\b' % key)
ectxt = regexp.sub(LOCAL_VAR_PREFIX + key, ectxt)
regex = re.compile(r'\b(%s)\b' % key)
ectxt = regex.sub(LOCAL_VAR_PREFIX + key, ectxt)
fixed = True

# replace renamed easyconfig parameters
for (new_param, old_param) in ALTERNATE_PARAMETERS.items():
# top-level easyconfig parameters
regex = re.compile(rf'^{old_param}\s*=\s*', re.M)
if regex.search(ectxt):
ectxt = regex.sub(rf'{new_param} = ', ectxt)
fixed = True
# parameters set for extensions
regex = re.compile(rf"""^(\s*["']){old_param}(["']\s*:\s*)""", re.M)
if regex.search(ectxt):
ectxt = regex.sub(rf"\1{new_param}\2", ectxt)
fixed = True

if fixed:
fixed_cnt += 1
backup_path = find_backup_name_candidate(path + '.orig')
Expand Down

0 comments on commit 07b8035

Please sign in to comment.