def print_line(self, line, index): if self.console_length is None: self.ctx.out(line) elif index % self.console_length == 0 and index: input = input("[Enter], [f]orward forever, or [q]uit: ") if input.lower() == 'q': sys.exit(0) elif input.lower() == 'f': self.console_length = None else: self.ctx.out(line)
def process(input): """ the main process :param input: """ _input = input.lower().strip() check_sub_command(_input)
def process(input): """ the main process :param input: """ _input = input.lower().strip() # check which command to execute check_sub_command(_input)
def ask(self, qst, default, answers=[], bool=False, password=False): """ Generate dialog on command line. """ if answers: info = "(" for i, answer in enumerate(answers): info += (", " if i != 0 else "") + str( (answer == default and "[{0}]".format(answer)) or answer) info += ")" elif bool: if default == self.yes: info = "([{0}]/{1})".format(self.yes, self.no) else: info = "({0}/[{1}])".format(self.yes, self.no) else: info = "[{0}]".format(default) if password: p1 = True p2 = False while p1 != p2: # getpass(_("Password: "******"Password: "******"") if len(p1) < 4: print(_("Password too short. Use at least 4 symbols")) continue sys.stdout.write(_("Password (again): ")) p2 = getpass("") if p1 == p2: return p1 else: print(_("Passwords did not match")) while True: input = eval(input(qst + " {0}: ".format(info))) input = input.decode(self.stdin_encoding) if input.strip() == "": input = default if bool: # l10n yes, true,t are inputs for booleans with value true if input.lower().strip() in [ self.yes, _("yes"), _("true"), _("t"), "yes" ]: return True # l10n no, false,f are inputs for booleans with value false elif input.lower().strip() in [ self.no, _("no"), _("false"), _("f"), "no" ]: return False else: print(_("Invalid Input")) continue if not answers: return input else: if input in answers: return input else: print(_("Invalid Input"))