easybuild.tools.utilities module

Module with various utility functions

author:Kenneth Hoste (Ghent University)

Flatten a list of lists.


Import all available module in the specified namespace.

Parameters:namespace – The namespace to import modules from.
easybuild.tools.utilities.only_if_module_is_available(modnames, pkgname=None, url=None)

Decorator to guard functions/methods against missing required module with specified name.


Version of quote_str specific for generating use in Python context (e.g., easyconfig parameters).

easybuild.tools.utilities.quote_str(val, escape_newline=False, prefer_single_quotes=False)

Obtain a new value to be used in string replacement context.

For non-string values, it just returns the exact same value.

For string values, it tries to escape the string in quotes, e.g., foo becomes ‘foo’, foo’bar becomes “foo’bar”, foo’bar”baz becomes “”“foo’bar”baz”“”, etc.

Parameters:escape_newline – wrap strings that include a newline in triple quotes
easybuild.tools.utilities.read_environment(env_vars, strict=False)

NO LONGER SUPPORTED: use read_environment from easybuild.tools.environment instead


Remove unwanted characters from the given string and return a copy

All non-letter and non-numeral characters are considered unwanted except for underscore (‘_’), see UNWANTED_CHARS.

easybuild.tools.utilities.trace_msg(message, silent=False)

Print trace message.