mirror of
https://github.com/pypa/pip
synced 2023-12-13 21:30:23 +01:00
General clean ups of the compat module
This commit is contained in:
parent
06913540f7
commit
20d77c62a4
|
@ -2,15 +2,11 @@
|
||||||
distributions."""
|
distributions."""
|
||||||
from __future__ import absolute_import
|
from __future__ import absolute_import
|
||||||
|
|
||||||
# flake8: noqa
|
|
||||||
|
|
||||||
import os
|
import os
|
||||||
import imp
|
import imp
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
|
from pip._vendor.six import text_type
|
||||||
uses_pycache = hasattr(imp, 'cache_from_source')
|
|
||||||
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
from logging.config import dictConfig as logging_dictConfig
|
from logging.config import dictConfig as logging_dictConfig
|
||||||
|
@ -18,6 +14,15 @@ except ImportError:
|
||||||
from pip.compat.dictconfig import dictConfig as logging_dictConfig
|
from pip.compat.dictconfig import dictConfig as logging_dictConfig
|
||||||
|
|
||||||
|
|
||||||
|
__all__ = [
|
||||||
|
"logging_dictConfig", "uses_pycache", "console_to_str", "native_str",
|
||||||
|
"get_path_uid", "stdlib_pkgs", "WINDOWS",
|
||||||
|
]
|
||||||
|
|
||||||
|
|
||||||
|
uses_pycache = hasattr(imp, 'cache_from_source')
|
||||||
|
|
||||||
|
|
||||||
if sys.version_info >= (3,):
|
if sys.version_info >= (3,):
|
||||||
def console_to_str(s):
|
def console_to_str(s):
|
||||||
try:
|
try:
|
||||||
|
@ -36,7 +41,7 @@ else:
|
||||||
|
|
||||||
def native_str(s, replace=False):
|
def native_str(s, replace=False):
|
||||||
# Replace is ignored -- unicode to UTF-8 can't fail
|
# Replace is ignored -- unicode to UTF-8 can't fail
|
||||||
if isinstance(s, unicode):
|
if isinstance(s, text_type):
|
||||||
return s.encode('utf-8')
|
return s.encode('utf-8')
|
||||||
return s
|
return s
|
||||||
|
|
||||||
|
@ -79,6 +84,7 @@ stdlib_pkgs = ['python', 'wsgiref']
|
||||||
if sys.version_info >= (2, 7):
|
if sys.version_info >= (2, 7):
|
||||||
stdlib_pkgs.extend(['argparse'])
|
stdlib_pkgs.extend(['argparse'])
|
||||||
|
|
||||||
|
|
||||||
# windows detection, covers cpython and ironpython
|
# windows detection, covers cpython and ironpython
|
||||||
WINDOWS = sys.platform.startswith("win") \
|
WINDOWS = (sys.platform.startswith("win")
|
||||||
or (sys.platform == 'cli' and os.name == 'nt')
|
or (sys.platform == 'cli' and os.name == 'nt'))
|
||||||
|
|
Loading…
Reference in a new issue