Ask a question and prompt for yes or no

    :param question:                    Question to ask; answer is yes/no
    :return:                            :boolean
779139
def prompt_4_yes_no(question):
    
    while True:
        sys.stdout.write(question + ' (y/n)? ')
        try:
            choice = raw_input().lower()
        except:
            choice = input().lower()
        if choice == 'yes' or choice == 'y':
            return True
        elif choice == 'no' or choice == 'n':
            return False
        else:
            printError('\'%s\' is not a valid answer. Enter \'yes\'(y) or \'no\'(n).' % choice)
1243414
def ask(self,
            patch_stdout: bool = False,
            kbi_msg: str = DEFAULT_KBI_MESSAGE) -> Any:
        """"""

        if self.should_skip_question:
            return self.default

        try:
            return self.unsafe_ask(patch_stdout)
        except KeyboardInterrupt:
            print("\n{}\n".format(kbi_msg))
            return None
249280
def prompt(p, yes_no=false)
      puts #newline for newline's sake!

      loop do
        print p, ' '
        line = STDIN.readline.strip
        if yes_no
          return true if line =~ YES
          return false if line =~ NO
        else
          return line
        end
      end
    end
69107
def ask_yesno(query, default=None):
    """"""
    if default is None:
        default_q = ' [y/n]'
    elif default is True:
        default_q = ' [Y/n]'
    elif default is False:
        default_q = ' [y/N]'
    if sys.version_info[0] == 3:
        inp = raw_input("{query}{default_q} ".format(
            query=query, default_q=default_q)).strip()
    else:
        inp = raw_input("{query}{default_q} ".format(
            query=query, default_q=default_q).encode('utf-8')).strip()
    if inp:
        return inp.lower().startswith('y')
    elif default is not None:
        return default
    else:
        # Loop if no answer and no default.
        return ask_yesno(query, default)
139164
def input_yes_no(msg=''):
    
    print '\n'+msg
    while(True):
        i=raw_input('Input yes or no: ')
        i=i.lower()
        if i=='y' or i=='yes':
            return True
        elif i=='n' or i=='no':
            return False
        else:
            print 'ERROR: Bad input. Must enter y/n/yes/no'
535427
def confirm(self, question, default=False, true_answer_regex="(?i)^y"):
        
        return self._io.confirm(question, default, true_answer_regex)
96111
def confirm(prompt_str, default=False):
    
    if default:
        default_str = 'y'
        prompt = '%s [Y/n]' % prompt_str
    else:
        default_str = 'n'
        prompt = '%s [y/N]' % prompt_str

    ans = click.prompt(prompt, default=default_str, show_default=False)
    if ans.lower() in ('y', 'yes', 'yeah', 'yup', 'yolo'):
        return True

    return False
591882
def getargs():
    from argparse import ArgumentParser
    '''
    
    '''
    parser = ArgumentParser(description='Answer yes or no to a question.')
    parser.add_argument("question", type=str, help="A question to ask.")
    return parser.parse_args()
403407
def ask_string(*question: Token, default: Optional[str] = None) -> Optional[str]:
    
    tokens = get_ask_tokens(question)
    if default:
        tokens.append("(%s)" % default)
    info(*tokens)
    answer = read_input()
    if not answer:
        return default
    return answer
323434
def ask_yes_no(*question: Token, default: bool = False) -> bool:
    """"""
    while True:
        tokens = [green, "::", reset] + list(question) + [reset]
        if default:
            tokens.append("(Y/n)")
        else:
            tokens.append("(y/N)")
        info(*tokens)
        answer = read_input()
        if answer.lower() in ["y", "yes"]:
            return True
        if answer.lower() in ["n", "no"]:
            return False
        if not answer:
            return default
        warning("Please answer by 'y' (yes) or 'n' (no) ")
137880
def yn_choice(message, default='y', tries=None):
    
    # http://stackoverflow.com/questions/3041986/python-command-line-yes-no-input"""
    choices = 'Y/n' if default.lower() in ('y', 'yes') else 'y/N'
    if tries is None:
        choice = input("%s (%s) " % (message, choices))
        values = ('y', 'yes', '') if default == 'y' else ('y', 'yes')
        return True if choice.strip().lower() in values else False
    else:
        while tries > 0:
            choice = input(
                "%s (%s) (%s)" % (message, choices, "'q' to discard"))
            choice = choice.strip().lower()
            if choice in ['y', 'yes']:
                return True
            elif choice in ['n', 'no', 'q']:
                return False
            else:
                print("Invalid input...")
                tries -= 1
1322140
def prompt(test_input = None):
    
    if test_input != None:
        if type(test_input) == list and len(test_input):
            choice = test_input.pop(0)
        elif type(test_input) == list:
            choice = ''
        else:
            choice = test_input
    else:
        # Coverage: 4 missed statements
        try:
            choice = raw_input()
        except:
            choice = input()
    return choice
1123231
def ask(self, question, default=None):
        
        if isinstance(question, Question):
            return self._io.ask_question(question)

        return self._io.ask(question, default)
153239
function ask(question, cbk, skip) {
      if (skip) {
        cbk(skip);
        return;
      }
      self.prompt(question, function(answ) {
        if (String(answ.answer).trim() === "") {
          return ask(question, cbk);
        } else {
          cbk(answ.answer);
        }
      });
    }
580297
def ask_for_input_with_prompt(cls, ui, prompt='', **options):
        """"""
        return cls.get_appropriate_helper(ui).ask_for_input_with_prompt(prompt=prompt, **options)
817042
def to_bool(answer, default):
    
    answer = str(answer).lower()
    default = str(default).lower()

    if answer and answer in "yes":
        return True

    return False
1153424
def choice(self, question, choices, default=None, attempts=None, multiple=False):
        
        question = ChoiceQuestion(question, choices, default)

        question.set_max_attempts(attempts)
        question.set_multi_select(multiple)

        return self._io.ask_question(question)