easybuild.tools.utilities module

Module with various utility functions

author:Kenneth Hoste (Ghent University)
easybuild.tools.utilities.flatten(lst)

Flatten a list of lists.

easybuild.tools.utilities.import_available_modules(namespace)

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.

easybuild.tools.utilities.quote_py_str(val)

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

easybuild.tools.utilities.remove_unwanted_chars(inputstring)

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.