def __call__(self): host = get_host_func(self.shell) files = host.listdir() def iterator(): for f in files: if host.stat(f).is_dir: yield colored(f, DirectoryType.color), len(f) else: yield f, len(f) console = Console(self.shell.pty) console.lesspipe(console.in_columns(iterator()))
def print_all_completions(self, all_completions): self.stdout.write('\r\n') # Create an iterator which yields all the comments (in their color), # and pass it through in_columns/lesspipe def column_items(): for w in all_completions: handler_type = w[1].handler_type text = '%s%s' % ( termcolor.colored(w[0], handler_type.color), termcolor.colored(handler_type.postfix, handler_type.postfix_color)) length = len(w[0]) + len(handler_type.postfix) yield text, length c = Console(self.pty) c.lesspipe(c.in_columns(column_items()))
def print_all_completions(self, all_completions): self.stdout.write('\r\n') # Create an iterator which yields all the comments (in their color), # and pass it through in_columns/lesspipe def column_items(): for w in all_completions: handler_type = w[1].handler_type text = '%s%s' % (termcolor.colored(w[0], handler_type.color), termcolor.colored(handler_type.postfix, handler_type.postfix_color)) length = len(w[0]) + len(handler_type.postfix) yield text, length c = Console(self.pty) c.lesspipe(c.in_columns(column_items()))
def __call__(self): files = self.shell.localhost.listdir() console = Console(self.shell.pty) console.lesspipe(console.in_columns(files))