mirror of https://github.com/pypa/pip
Replace compat shim with shutil.get_terminal_size()
This commit is contained in:
parent
9db97546b3
commit
add5cfa514
|
@ -7,6 +7,7 @@ from __future__ import absolute_import
|
|||
|
||||
import logging
|
||||
import optparse
|
||||
import shutil
|
||||
import sys
|
||||
import textwrap
|
||||
from distutils.util import strtobool
|
||||
|
@ -15,7 +16,6 @@ from pip._vendor.contextlib2 import suppress
|
|||
|
||||
from pip._internal.cli.status_codes import UNKNOWN_ERROR
|
||||
from pip._internal.configuration import Configuration, ConfigurationError
|
||||
from pip._internal.utils.compat import get_terminal_size
|
||||
from pip._internal.utils.misc import redact_auth_from_url
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
@ -28,7 +28,7 @@ class PrettyHelpFormatter(optparse.IndentedHelpFormatter):
|
|||
# help position must be aligned with __init__.parseopts.description
|
||||
kwargs['max_help_position'] = 30
|
||||
kwargs['indent_increment'] = 1
|
||||
kwargs['width'] = get_terminal_size()[0] - 2
|
||||
kwargs['width'] = shutil.get_terminal_size()[0] - 2
|
||||
optparse.IndentedHelpFormatter.__init__(self, *args, **kwargs)
|
||||
|
||||
def format_option_strings(self, option):
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
from __future__ import absolute_import
|
||||
|
||||
import logging
|
||||
import shutil
|
||||
import sys
|
||||
import textwrap
|
||||
from collections import OrderedDict
|
||||
|
@ -18,7 +19,6 @@ from pip._internal.cli.status_codes import NO_MATCHES_FOUND, SUCCESS
|
|||
from pip._internal.exceptions import CommandError
|
||||
from pip._internal.models.index import PyPI
|
||||
from pip._internal.network.xmlrpc import PipXmlrpcTransport
|
||||
from pip._internal.utils.compat import get_terminal_size
|
||||
from pip._internal.utils.logging import indent_log
|
||||
from pip._internal.utils.misc import get_distribution, write_output
|
||||
from pip._internal.utils.typing import MYPY_CHECK_RUNNING
|
||||
|
@ -64,7 +64,7 @@ class SearchCommand(Command, SessionCommandMixin):
|
|||
|
||||
terminal_width = None
|
||||
if sys.stdout.isatty():
|
||||
terminal_width = get_terminal_size()[0]
|
||||
terminal_width = shutil.get_terminal_size()[0]
|
||||
|
||||
print_results(hits, terminal_width=terminal_width)
|
||||
if pypi_hits:
|
||||
|
|
|
@ -11,13 +11,12 @@ import functools
|
|||
import locale
|
||||
import logging
|
||||
import os
|
||||
import shutil
|
||||
import sys
|
||||
|
||||
from pip._internal.utils.typing import MYPY_CHECK_RUNNING
|
||||
|
||||
if MYPY_CHECK_RUNNING:
|
||||
from typing import Callable, Optional, Protocol, Text, Tuple, TypeVar, Union
|
||||
from typing import Callable, Optional, Protocol, Text, TypeVar, Union
|
||||
|
||||
# Used in the @lru_cache polyfill.
|
||||
F = TypeVar('F')
|
||||
|
@ -40,7 +39,7 @@ except ImportError:
|
|||
|
||||
__all__ = [
|
||||
"ipaddress", "console_to_str",
|
||||
"get_path_uid", "stdlib_pkgs", "WINDOWS", "get_terminal_size",
|
||||
"get_path_uid", "stdlib_pkgs", "WINDOWS",
|
||||
]
|
||||
|
||||
|
||||
|
@ -190,15 +189,6 @@ WINDOWS = (sys.platform.startswith("win") or
|
|||
(sys.platform == 'cli' and os.name == 'nt'))
|
||||
|
||||
|
||||
def get_terminal_size():
|
||||
# type: () -> Tuple[int, int]
|
||||
"""
|
||||
Returns a tuple (x, y) representing the width(x) and the height(y)
|
||||
in characters of the terminal window.
|
||||
"""
|
||||
return tuple(shutil.get_terminal_size()) # type: ignore
|
||||
|
||||
|
||||
# Fallback to noop_lru_cache in Python 2
|
||||
# TODO: this can be removed when python 2 support is dropped!
|
||||
def noop_lru_cache(maxsize=None):
|
||||
|
|
Loading…
Reference in New Issue