mirror of
https://github.com/pre-commit/pre-commit.git
synced 2026-02-19 17:14:43 +04:00
Merge pull request #348 from pre-commit/use_pyterminalsize
Use pyterminalsize for terminal sizing
This commit is contained in:
commit
3b28e8f807
2 changed files with 3 additions and 18 deletions
|
|
@ -1,29 +1,14 @@
|
||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
import os
|
|
||||||
import subprocess
|
|
||||||
import sys
|
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 color
|
||||||
from pre_commit import five
|
from pre_commit import five
|
||||||
|
|
||||||
|
|
||||||
def _get_cols_from_tput(): # pragma: no cover (fallback)
|
COLS = get_terminal_size((80, 0)).columns
|
||||||
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()
|
|
||||||
|
|
||||||
|
|
||||||
def get_hook_message(
|
def get_hook_message(
|
||||||
|
|
|
||||||
2
setup.py
2
setup.py
|
|
@ -41,11 +41,11 @@ setup(
|
||||||
install_requires=[
|
install_requires=[
|
||||||
'argparse',
|
'argparse',
|
||||||
'aspy.yaml',
|
'aspy.yaml',
|
||||||
'backports.shutil_get_terminal_size',
|
|
||||||
'cached-property',
|
'cached-property',
|
||||||
'jsonschema',
|
'jsonschema',
|
||||||
'nodeenv>=0.11.1',
|
'nodeenv>=0.11.1',
|
||||||
'ordereddict',
|
'ordereddict',
|
||||||
|
'pyterminalsize',
|
||||||
'pyyaml',
|
'pyyaml',
|
||||||
'virtualenv',
|
'virtualenv',
|
||||||
],
|
],
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue