mirror of
https://github.com/pre-commit/pre-commit.git
synced 2026-05-06 23:39:13 -05:00
Use pyterminalsize for terminal sizing
This commit is contained in:
+2
-17
@@ -1,29 +1,14 @@
|
||||
from __future__ import unicode_literals
|
||||
|
||||
import os
|
||||
import subprocess
|
||||
import sys
|
||||
|
||||
from backports.shutil_get_terminal_size import get_terminal_size
|
||||
from pyterminalsize import get_terminal_size
|
||||
|
||||
from pre_commit import color
|
||||
from pre_commit import five
|
||||
|
||||
|
||||
def _get_cols_from_tput(): # pragma: no cover (fallback)
|
||||
if not os.environ.get('TERM'):
|
||||
return 80
|
||||
else:
|
||||
return int(
|
||||
subprocess.Popen(
|
||||
('tput', 'cols'), stdout=subprocess.PIPE,
|
||||
).communicate()[0] or
|
||||
# Default in the case of no terminal
|
||||
80
|
||||
)
|
||||
|
||||
|
||||
COLS = get_terminal_size((0, 0)).columns or _get_cols_from_tput()
|
||||
COLS = get_terminal_size((80, 0)).columns
|
||||
|
||||
|
||||
def get_hook_message(
|
||||
|
||||
Reference in New Issue
Block a user