def run(self, cli, buffer, tokens): now = datetime.datetime.now() before = [(Token.Prompt, '%s:%s:%s' % (now.hour, now.minute, now.second)), (Token.Prompt, ' Enter something: ')] return before + tokens, lambda i: i + token_list_len(before)
def run(self, cli, buffer, tokens): now = datetime.datetime.now() before = [ (Token.Prompt, '%s:%s:%s' % (now.hour, now.minute, now.second)), (Token.Prompt, ' Enter something: ') ] return before + tokens, lambda i: i + token_list_len(before)
def _t(token_list): """ Center tokens on this line. """ length = token_list_len(token_list) return [(Token.Welcome, ' ' * int((WELCOME_MESSAGE_WIDTH - length) / 2))] \ + token_list + [(Token.Welcome, '\n')]
def apply_transformation(self, cli, document, lineno, source_to_display, tokens): if callable(self.hint): before = self.hint(cli) else: before = [ (Token.Prompt.Hint, '%s' % self.hint), (Token.Space, ' '), ] shift_position = token_list_len(before) return Transformation( tokens=before + tokens, source_to_display=lambda i: i + shift_position, display_to_source=lambda i: i - shift_position, )