45
45
from easybuild .tools .run import run_shell_cmd
46
46
47
47
48
- def construct_exts_filter_cmds (exts_filter , ext ):
49
- """
50
- Resolve the exts_filter tuple by replacing the template values using the extension
51
- :param exts_filter: Tuple of (command, input) using template values (ext_name, ext_version, src)
48
+ def get_modulenames (ext , use_name_for_false ):
49
+ """Return a list of modulenames for the extension
52
50
:param ext: Instance of Extension or dictionary like with 'name' and optionally 'options', 'version', 'source' keys
53
- :return: (cmd, input) as a tuple of strings for each modulename. Might be empty if no filtering is intented
51
+ :param use_name_for_false: Whether to return a list with the name or an empty list when the modulename is False
54
52
"""
55
-
56
- if isinstance (exts_filter , str ) or len (exts_filter ) != 2 :
57
- raise EasyBuildError ('exts_filter should be a list or tuple of ("command","input")' )
58
-
59
- cmd , cmdinput = exts_filter
60
-
61
53
if not isinstance (ext , dict ):
62
- ext = {'name' : ext .name , 'version' : ext . version , 'src' : ext . src , ' options' : ext .options }
54
+ ext = {'name' : ext .name , 'options' : ext .options }
63
55
64
56
try :
65
57
modulenames = ext ['options' ]['modulename' ]
@@ -71,11 +63,31 @@ def construct_exts_filter_cmds(exts_filter, ext):
71
63
raise EasyBuildError (f"Empty modulename list for { ext ['name' ]} is not supported."
72
64
"Use `False` to skip checking the module!" )
73
65
elif modulenames is False :
74
- return [] # Skip any checks
66
+ return [ext [ 'name' ]] if use_name_for_false else []
75
67
elif not isinstance (modulenames , str ):
76
68
raise EasyBuildError (f"Wrong type of modulename for { ext ['name' ]} : { type (modulenames )} : { modulenames } " )
77
69
else :
78
70
modulenames = [modulenames ]
71
+ return modulenames
72
+
73
+
74
+ def construct_exts_filter_cmds (exts_filter , ext ):
75
+ """
76
+ Resolve the exts_filter tuple by replacing the template values using the extension
77
+ :param exts_filter: Tuple of (command, input) using template values (ext_name, ext_version, src)
78
+ :param ext: Instance of Extension or dictionary like with 'name' and optionally 'options', 'version', 'source' keys
79
+ :return: (cmd, input) as a tuple of strings for each modulename. Might be empty if no filtering is intented
80
+ """
81
+
82
+ if isinstance (exts_filter , str ) or len (exts_filter ) != 2 :
83
+ raise EasyBuildError ('exts_filter should be a list or tuple of ("command","input")' )
84
+
85
+ cmd , cmdinput = exts_filter
86
+
87
+ if not isinstance (ext , dict ):
88
+ ext = {'name' : ext .name , 'version' : ext .version , 'src' : ext .src , 'options' : ext .options }
89
+
90
+ modulenames = get_modulenames (ext , use_name_for_false = True )
79
91
80
92
result = []
81
93
for modulename in modulenames :
0 commit comments