diff options
Diffstat (limited to 'isort/isort.py')
-rw-r--r-- | isort/isort.py | 21 |
1 files changed, 5 insertions, 16 deletions
diff --git a/isort/isort.py b/isort/isort.py index 16b40b73..e0cddf76 100644 --- a/isort/isort.py +++ b/isort/isort.py @@ -32,7 +32,8 @@ import itertools import os import re import sys -from collections import namedtuple +import sysconfig +from collections import OrderedDict, namedtuple from datetime import datetime from difflib import unified_diff from fnmatch import fnmatch @@ -40,7 +41,7 @@ from glob import glob from . import settings from .natural import nsorted -from .pie_slice import OrderedDict, OrderedSet, input, itemsview +from .pie_slice import OrderedSet, input, itemsview KNOWN_SECTION_MAPPING = { 'STDLIB': 'STANDARD_LIBRARY', @@ -261,7 +262,7 @@ class SortImports(object): virtual_env_src = '{0}/src/'.format(virtual_env) # handle case-insensitive paths on windows - stdlib_lib_prefix = os.path.normcase(get_stdlib_path()) + stdlib_lib_prefix = os.path.normcase(sysconfig.get_paths()['stdlib']) for prefix in paths: module_path = "/".join((prefix, module_name.replace(".", "/"))) @@ -485,7 +486,7 @@ class SortImports(object): lines = import_statement.split("\n") line_count = len(lines) if len(lines) > 1: - minimum_length = min([len(line) for line in lines[:-1]]) + minimum_length = min(len(line) for line in lines[:-1]) else: minimum_length = 0 new_import_statement = import_statement @@ -940,18 +941,6 @@ def coding_check(fname, default='utf-8'): return coding -def get_stdlib_path(): - """Returns the path to the standard lib for the current path installation. - - This function can be dropped and "sysconfig.get_paths()" used directly once Python 2.6 support is dropped. - """ - if sys.version_info >= (2, 7): - import sysconfig - return sysconfig.get_paths()['stdlib'] - else: - return os.path.join(sys.prefix, 'lib') - - def exists_case_sensitive(path): """ Returns if the given path exists and also matches the case on Windows. |