benchbuild.utils.user_interface module

User interface helpers for benchbuild.

benchbuild.utils.user_interface.ask(question, default_answer=False, default_answer_str='no')[source]

Ask for user input.

This asks a yes/no question with a preset default. You can bypass the user-input and fetch the default answer, if you set

Parameters:
  • question – The question to ask on stdout.
  • default_answer – The default value to return.
  • default_answer_str – The default answer string that we present to the user.
Tests:
>>> os.putenv("TEST", "yes"); ask("Test?", default_answer=True)
True
>>> os.putenv("TEST", "yes"); ask("Test?", default_answer=False)
False
benchbuild.utils.user_interface.query_yes_no(question, default='yes')[source]

Ask a yes/no question via raw_input() and return their answer.

Parameters:
  • question (str) – Question hat is presented to the user.
  • default (str) – The presumed answer, if the user just hits <Enter>. It must be “yes” (the default), “no” or None (meaning an answer is required of the user).
Returns (boolean):
True, if ‘yes’, False otherwise.