def yesno(self): from presto.utils.utils import input while True: output("Rewrite '%s'? (y/n)" % value) yes_no = unicode(input()) if yes_no in ('Y', 'y', 'yes', '\n'): return True if yes_no in ('N', 'n', 'no'): return False
def question(self, text, default=None, ext_func=None, ext_param={}): from presto.utils.utils import input output("%s:" % text) if ext_func: ext_func(**ext_param) while True: value = unicode(input()).strip() try: value = self.validate(value) except AlreadyExist, e: self.output_func(e.messages) should_rewrite = self.yesno() if should_rewrite: return value else: raise except ValidationError, e: output(e.messages) continue