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, tcl=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.

  • escape_newline – wrap strings that include a newline in triple quotes
  • prefer_single_quotes – if possible use single quotes
  • tcl – Boolean for whether we are quoting for Tcl syntax
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.