summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTimothy Crosley <timothy.crosley@gmail.com>2016-03-27 19:59:02 -0700
committerTimothy Crosley <timothy.crosley@gmail.com>2016-03-27 19:59:02 -0700
commit9e384025d147ccd7b975e661b42cdb4f5363a918 (patch)
tree57a41ce5cca16ec9c6436e0c8a1e0b45316b598d
parent1b0ed2cd16c99294f793de5b5bcfb6f760a6453a (diff)
downloadisort-feature/fix-issue-227.tar.gz
Fix long standing issue where src is not included, sorry for the long delay @spookylukey!feature/fix-issue-227
-rw-r--r--isort/isort.py13
1 files changed, 7 insertions, 6 deletions
diff --git a/isort/isort.py b/isort/isort.py
index de2ed4a0..68e6e99f 100644
--- a/isort/isort.py
+++ b/isort/isort.py
@@ -214,11 +214,11 @@ class SortImports(object):
"""
for forced_separate in self.config['forced_separate']:
# Ensure all forced_separate patterns will match to end of string
- pathGlob = forced_separate
+ path_glob = forced_separate
if not forced_separate.endswith('*'):
- pathGlob = '%s*' % forced_separate
+ path_glob = '%s*' % forced_separate
- if fnmatch(module_name, pathGlob) or fnmatch(module_name, '.' + pathGlob):
+ if fnmatch(module_name, path_glob) or fnmatch(module_name, '.' + path_glob):
return forced_separate
if module_name.startswith("."):
@@ -237,17 +237,18 @@ class SortImports(object):
paths = PYTHONPATH
virtual_env = self.config.get('virtual_env') or os.environ.get('VIRTUAL_ENV')
if virtual_env:
- paths += [path for path in glob("{0}/lib/python*/site-packages".format(virtual_env))
+ paths += [path for path in glob('{0}/lib/python*/site-packages'.format(virtual_env))
if path not in paths]
+ paths += [path for path in glob('{0}/src/*'.format(virtual_env)) if os.path.isdir(path)]
for prefix in paths:
module_path = "/".join((prefix, module_name.replace(".", "/")))
package_path = "/".join((prefix, module_name.split(".")[0]))
if (os.path.exists(module_path + ".py") or os.path.exists(module_path + ".so") or
(os.path.exists(package_path) and os.path.isdir(package_path))):
- if "site-packages" in prefix or "dist-packages" in prefix:
+ if 'site-packages' in prefix or 'dist-packages' in prefix or 'src' in prefix:
return self.sections.THIRDPARTY
- elif "python2" in prefix.lower() or "python3" in prefix.lower():
+ elif 'python2' in prefix.lower() or 'python3' in prefix.lower():
return self.sections.STDLIB
else:
return self.config['default_section']