Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion easybuild/framework/easyblock.py
Original file line number Diff line number Diff line change
Expand Up @@ -1989,12 +1989,15 @@ def make_extension_string(self, name_version_sep='-', ext_sep=', ', sort=True):
exts_list = sorted(exts_list, key=str.lower)
return ext_sep.join(exts_list)

def make_extension_list(self):
def make_extension_list(self, formatted=True):
"""
Return a list of extension names and their versions included in this installation

Each entry should be a (name, version) tuple or just (name, ) if no version exists.
Custom EasyBlocks may override this to add extensions that cannot be found automatically.

:param formatted: boolean indicating whether the extension name should be formatted. If True, format using
the function defined by the exts_formatter parameter.
"""
# Each extension in exts_list is either a string or a list/tuple with name, version as first entries
# As name can be a templated value we must resolve templates
Expand All @@ -2010,6 +2013,15 @@ def make_extension_list(self):
else:
exts_list.append((resolve_template(ext[0], self.cfg.template_values),
resolve_template(ext[1], self.cfg.template_values)))

if formatted:
formatter = self.cfg.get('exts_formatter')
if formatter:

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can/should we check whether formatter is indeed a function, and throw a sensible error if not?

Without that, error messages produced when say exts_formatter = True is used will be quite nasty/confusing...

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done in 610c21c

if not callable(formatter):
raise EasyBuildError("Parameter exts_formatter should be a function that accepts the extension name"
"and returns the formatted name.")
exts_list = [(formatter(x), y) for (x, y) in exts_list]

return exts_list

def prepare_for_extensions(self):
Expand Down