def reset_terminal_size(): size = pyterminalsize.get_terminal_size() yield for fd in (0, 1, 2): try: _pyterminalsize.set_terminal_size(fd, *size[:2]) except OSError: # pragma: no cover (windows) if fd != 0: raise
import sys import _pyterminalsize import pyterminalsize for fd in (0, 1, 2): try: # Allow this to fail, we're setting it on all the inputs / outputs _pyterminalsize.set_terminal_size(fd, 30, 40) except OSError: pass getattr(sys, sys.argv[1]).write(str(pyterminalsize.get_terminal_size()))
from __future__ import unicode_literals import sys from pyterminalsize import get_terminal_size from pre_commit import color from pre_commit import five COLS = get_terminal_size((80, 0)).columns def get_hook_message( start, postfix='', end_msg=None, end_len=0, end_color=None, use_color=None, cols=COLS, ): """Prints a message for running a hook. This currently supports three approaches: # Print `start` followed by dots, leaving 6 characters at the end >>> print_hook_message('start', end_len=6) start............................................................... # Print `start` followed by dots with the end message colored if coloring
from __future__ import unicode_literals import sys from pyterminalsize import get_terminal_size from pre_commit import color from pre_commit import five COLS = get_terminal_size((80, 0)).columns def get_hook_message( start, postfix='', end_msg=None, end_len=0, end_color=None, use_color=None, cols=COLS, ): """Prints a message for running a hook. This currently supports three approaches: # Print `start` followed by dots, leaving 6 characters at the end >>> print_hook_message('start', end_len=6) start............................................................... # Print `start` followed by dots with the end message colored if coloring # is specified and a newline afterwards
import pyterminalsize print(pyterminalsize.get_terminal_size((10, 20)))