3232* Toon Willems (Ghent University)
3333"""
3434import base64
35- import copy
3635import getpass
3736import glob
3837import functools
@@ -1280,9 +1279,19 @@ def push_branch_to_github(git_repo, target_account, target_repo, branch):
12801279
12811280def is_patch_for (patch_name , ec ):
12821281 """Check whether specified patch matches any patch in the provided EasyConfig instance."""
1283- res = False
1282+ # Extract name from patch entry
1283+ def get_name (patch ):
1284+ if isinstance (patch , (tuple , list )):
1285+ patch = patch [0 ]
1286+ elif isinstance (patch , dict ):
1287+ try :
1288+ patch = patch ['name' ]
1289+ except KeyError :
1290+ raise EasyBuildError (f"Invalid patch spec in { ec .path } : Missing 'name' key" ,
1291+ exit_code = EasyBuildExit .VALUE_ERROR )
1292+ return patch
12841293
1285- patches = copy . copy ( ec ['patches' ])
1294+ patches = [ get_name ( p ) for p in ec ['patches' ]]
12861295
12871296 with ec .disable_templating ():
12881297 # take into account both list of extensions (via exts_list) and components (cfr. Bundle easyblock)
@@ -1294,17 +1303,9 @@ def is_patch_for(patch_name, ec):
12941303 'version' : entry [1 ],
12951304 }
12961305 options = entry [2 ]
1297- patches .extend (p [0 ] % templates if isinstance (p , (tuple , list )) else p % templates
1298- for p in options .get ('patches' , []))
1299-
1300- for patch in patches :
1301- if isinstance (patch , (tuple , list )):
1302- patch = patch [0 ]
1303- if patch == patch_name :
1304- res = True
1305- break
1306+ patches .extend (get_name (p ) % templates for p in options .get ('patches' , []))
13061307
1307- return res
1308+ return patch_name in patches
13081309
13091310
13101311def det_patch_specs (patch_paths , file_info , ec_dirs ):
@@ -1395,7 +1396,7 @@ def ec_key(path):
13951396 soft_name = ec ['ec' ]['name' ]
13961397 break
13971398 except EasyBuildError as err :
1398- _log .debug ("Ignoring easyconfig %s that fails to parse: %s" , path , err )
1399+ _log .warning ("Ignoring easyconfig %s that fails to parse: %s" , path , err )
13991400 sys .stdout .write ('\r %s of %s easyconfigs checked' % (idx + 1 , nr_of_ecs ))
14001401 sys .stdout .flush ()
14011402
0 commit comments