Continually ask a question until the output_re is matched.
167459
def RetryQuestion(question_text, output_re="", default_val=None):
  """"""
  while True:
    if default_val is not None:
      new_text = "%s [%s]: " % (question_text, default_val)
    else:
      new_text = "%s: " % question_text
    # pytype: disable=wrong-arg-count
    output = builtins.input(new_text) or str(default_val)
    # pytype: enable=wrong-arg-count
    output = output.strip()
    if not output_re or re.match(output_re, output):
      break
    else:
      print("Invalid input, must match %s" % output_re)
  return output
1238033
def _no_answer_do_retry(self, pk, pattern):
        """"""
        logger.info('Resending for pattern %s', pattern)
        # Set the timer to None before trying to send again
        self.send_packet(pk, expected_reply=pattern, resend=True)
1109615
def cmd(send, msg, args):
    
    if not msg:
        send("What is your question?")
        # let people !8ball again if they screw up and forget the part where you ask a question.
        args['handler'].abuselist[args['nick']]['8ball'].pop()
        return
    answers = {
        "It is certain": "yes",
        "It is decidedly so": "yes",
        "Without a doubt": "yes",
        "Yes, definitely": "yes",
        "You may rely on it": "yes",
        "As I see it, yes": "yes",
        "Most likely": "yes",
        "Outlook good": "yes",
        "Yes": "yes",
        "Signs point to yes": "yes",
        "Reply hazy, try again": "maybe",
        "Ask again later": "maybe",
        "Better not tell you now": "maybe",
        "Cannot predict now": "maybe",
        "Concentrate and ask again": "maybe",
        "Don't count on it": "no",
        "My reply is no": "no",
        "My sources say no": "no",
        "Outlook not so good": "no",
        "Very doubtful": "no"
    }
    answer = choice(list(answers.keys()))
    send('says... %s' % answer, 'action')
1248239
def confirm(question, default=True):
    
    valid = {"": default, "yes": True, "y": True, "no": False, "n": False}
    while 1:
        choice = input(question + (" [Y/n] " if default else " [y/N] ")).lower()
        if choice in valid:
            return valid[choice]
        print("Please respond with 'y' or 'n' ")
1260780
def check_until(self, regex):
        
        return self.search_full(regex, return_string=True, advance_pointer=False)
1131905
def text_after(self, start, match_on):
        """"""
        text = ""
        index = start - 1
        while index > 0:
            text = self.code[index:start]
            if text.startswith(match_on):
                return text.lstrip(match_on)
            index -= 1

        return text.lstrip(match_on)
1197761
def wait_for_responses(self):
        

        self.thread.join(self.COMMAND_RESPONSE_TIMEOUT_S)
        self.running = False

        return self.responses
580718
def polling_loop(timeout, interval=1):
    """"""
    start_time = time.time()
    iteration = 0
    end_time = start_time + timeout
    while time.time() < end_time:
        yield iteration
        iteration += 1
        time.sleep(interval)
947108
def wait_until_done(self, timeout=None):
        """"""
        start = datetime.now()
        if not self.__th:
            raise IndraDBRestResponseError("There is no thread waiting to "
                                           "complete.")
        self.__th.join(timeout)
        now = datetime.now()
        dt = now - start
        if self.__th.is_alive():
            logger.warning("Timed out after %0.3f seconds waiting for "
                           "statement load to complete." % dt.total_seconds())
            ret = False
        else:
            logger.info("Waited %0.3f seconds for statements to finish loading."
                        % dt.total_seconds())
            ret = True
        return ret
69749
def req(self, timeout):
        ''''''
        self.connection.req(self.id, timeout)
        self.processed = True
346137
def ask(question, escape=True):
    ""
    answer = raw_input(question)
    if escape:
        answer.replace('"', '\\"')
    return answer.decode('utf')
535427
def confirm(self, question, default=False, true_answer_regex="(?i)^y"):
        
        return self._io.confirm(question, default, true_answer_regex)
1138283
def wait_process(self):
        """"""
        self.process.wait()
        if self.analyze_data:
            self.receiving_thread.join()
971164
def wait(self, pattern, timeout=10.0, safe=False, **match_kwargs):
        """"""
        t = time.time() + timeout
        while time.time() < t:
            ret = self.exists(pattern, **match_kwargs)
            if ret:
                return ret
            time.sleep(0.2)
        if not safe:
            raise errors.ImageNotFoundError('Not found image %s' %(pattern,))
599183
def wait_until(message='completed!')
      3.times { dot_and_sleep(1) }
      begin
        dot_and_sleep(2) until yield
      rescue Excon::Errors::SocketError => e
        # print out the error so the user can interrupt if necessary
        print "#{e.class}: #{e.message}! Retry:"
        sleep(1)
        retry
      end
      puts message
    end
612342
def loop(self):
        

        while True:
            text = compat.input('ctl > ')
            command, args = self.parse_input(text)
            if not command:
                continue
            response = self.call(command, *args)
            response.show()
1329224
def wait_for(scope, prompt):
    
    conn = scope.get('__connection__')
    conn.expect(prompt)
    scope.define(__response__=conn.response)
    return True