def METHOD_NAME(self, prompt, config):
    """Prompt for and return user input, retrying until valid input
    received.
    If the 'accept_defaults' options is enabled, return the default value
    for the prompt rather than prompting the user.
    """
    prompt = self.plugin.configure_prompt(prompt, config)
    if not prompt:
        return None
    if self.opts.accept_defaults:
        return prompt.validate(prompt.default)
    user_input = rinput(prompt.prompt).strip()
    if not user_input:
        return prompt.validate(prompt.default)
    try:
        return self.plugin.validate_input(user_input, prompt, config)
    except Exception as e:
        print(str(e))
        return self.METHOD_NAME(prompt, config)