Move file type info to utils.filetypes.

This commit is contained in:
Chris Hunt 2019-09-17 22:26:17 -04:00
parent 6a5bd723ec
commit 6a8b47d20b
7 changed files with 28 additions and 26 deletions

View File

@ -15,11 +15,8 @@ from pip._vendor.six.moves.urllib import parse as urllib_parse
from pip._vendor.six.moves.urllib import request as urllib_request
from pip._internal.models.link import Link
from pip._internal.utils.misc import (
ARCHIVE_EXTENSIONS,
path_to_url,
redact_auth_from_url,
)
from pip._internal.utils.filetypes import ARCHIVE_EXTENSIONS
from pip._internal.utils.misc import path_to_url, redact_auth_from_url
from pip._internal.utils.typing import MYPY_CHECK_RUNNING
from pip._internal.utils.urls import url_to_path
from pip._internal.vcs import is_url, vcs

View File

@ -24,12 +24,9 @@ from pip._internal.models.format_control import FormatControl
from pip._internal.models.link import Link
from pip._internal.models.selection_prefs import SelectionPreferences
from pip._internal.models.target_python import TargetPython
from pip._internal.utils.filetypes import WHEEL_EXTENSION
from pip._internal.utils.logging import indent_log
from pip._internal.utils.misc import (
SUPPORTED_EXTENSIONS,
WHEEL_EXTENSION,
build_netloc,
)
from pip._internal.utils.misc import SUPPORTED_EXTENSIONS, build_netloc
from pip._internal.utils.packaging import check_requires_python
from pip._internal.utils.typing import MYPY_CHECK_RUNNING
from pip._internal.utils.urls import url_to_path

View File

@ -3,8 +3,8 @@ import re
from pip._vendor.six.moves.urllib import parse as urllib_parse
from pip._internal.utils.filetypes import WHEEL_EXTENSION
from pip._internal.utils.misc import (
WHEEL_EXTENSION,
path_to_url,
redact_auth_from_url,
split_auth_from_netloc,

View File

@ -25,12 +25,8 @@ from pip._internal.models.index import PyPI, TestPyPI
from pip._internal.models.link import Link
from pip._internal.pyproject import make_pyproject_path
from pip._internal.req.req_install import InstallRequirement
from pip._internal.utils.misc import (
ARCHIVE_EXTENSIONS,
is_installable_dir,
path_to_url,
splitext,
)
from pip._internal.utils.filetypes import ARCHIVE_EXTENSIONS
from pip._internal.utils.misc import is_installable_dir, path_to_url, splitext
from pip._internal.utils.typing import MYPY_CHECK_RUNNING
from pip._internal.utils.urls import url_to_path
from pip._internal.vcs import is_url, vcs

View File

@ -0,0 +1,11 @@
"""Filetype information.
"""
WHEEL_EXTENSION = '.whl'
BZ2_EXTENSIONS = ('.tar.bz2', '.tbz')
XZ_EXTENSIONS = ('.tar.xz', '.txz', '.tlz', '.tar.lz', '.tar.lzma')
ZIP_EXTENSIONS = ('.zip', WHEEL_EXTENSION)
TAR_EXTENSIONS = ('.tar.gz', '.tgz', '.tar')
ARCHIVE_EXTENSIONS = (
ZIP_EXTENSIONS + BZ2_EXTENSIONS + TAR_EXTENSIONS + XZ_EXTENSIONS
)

View File

@ -41,6 +41,12 @@ from pip._internal.utils.compat import (
stdlib_pkgs,
str_to_display,
)
from pip._internal.utils.filetypes import (
BZ2_EXTENSIONS,
TAR_EXTENSIONS,
XZ_EXTENSIONS,
ZIP_EXTENSIONS,
)
from pip._internal.utils.marker_files import write_delete_marker_file
from pip._internal.utils.typing import MYPY_CHECK_RUNNING
from pip._internal.utils.virtualenv import (
@ -79,7 +85,7 @@ __all__ = ['rmtree', 'display_path', 'backup_dir',
'renames', 'get_prog',
'call_subprocess',
'captured_stdout', 'ensure_dir',
'ARCHIVE_EXTENSIONS', 'SUPPORTED_EXTENSIONS', 'WHEEL_EXTENSION',
'SUPPORTED_EXTENSIONS',
'get_installed_version', 'remove_auth_from_url']
@ -88,13 +94,6 @@ subprocess_logger = logging.getLogger('pip.subprocessor')
LOG_DIVIDER = '----------------------------------------'
WHEEL_EXTENSION = '.whl'
BZ2_EXTENSIONS = ('.tar.bz2', '.tbz')
XZ_EXTENSIONS = ('.tar.xz', '.txz', '.tlz', '.tar.lz', '.tar.lzma')
ZIP_EXTENSIONS = ('.zip', WHEEL_EXTENSION)
TAR_EXTENSIONS = ('.tar.gz', '.tgz', '.tar')
ARCHIVE_EXTENSIONS = (
ZIP_EXTENSIONS + BZ2_EXTENSIONS + TAR_EXTENSIONS + XZ_EXTENSIONS)
SUPPORTED_EXTENSIONS = ZIP_EXTENSIONS + TAR_EXTENSIONS
try:

View File

@ -14,11 +14,13 @@ import tarfile
import zipfile
from pip._internal.exceptions import InstallationError
from pip._internal.utils.misc import (
from pip._internal.utils.filetypes import (
BZ2_EXTENSIONS,
TAR_EXTENSIONS,
XZ_EXTENSIONS,
ZIP_EXTENSIONS,
)
from pip._internal.utils.misc import (
current_umask,
ensure_dir,
file_contents,