forked from VimPlug/jedi
Move the module name searching to the subprocess
This commit is contained in:
@@ -1,8 +1,9 @@
|
||||
import sys
|
||||
import os
|
||||
import imp
|
||||
import pkgutil
|
||||
|
||||
from jedi._compatibility import find_module, cast_path
|
||||
from jedi._compatibility import find_module, cast_path, force_unicode
|
||||
from jedi.evaluate.compiled import access
|
||||
from jedi import parser_utils
|
||||
|
||||
@@ -54,6 +55,17 @@ def get_module_info(evaluator, sys_path=None, full_name=None, **kwargs):
|
||||
return code, cast_path(module_path), is_pkg
|
||||
|
||||
|
||||
def list_module_names(evaluator, search_path):
|
||||
return [
|
||||
name
|
||||
for module_loader, name, is_pkg in pkgutil.iter_modules(search_path)
|
||||
]
|
||||
|
||||
|
||||
def get_builtin_module_names(evaluator):
|
||||
return list(map(force_unicode, sys.builtin_module_names))
|
||||
|
||||
|
||||
def _get_init_path(directory_path):
|
||||
"""
|
||||
The __init__ file can be searched in a directory. If found return it, else
|
||||
|
||||
@@ -12,7 +12,6 @@ This module also supports import autocompletion, which means to complete
|
||||
statements like ``from datetim`` (curser at the end would return ``datetime``).
|
||||
"""
|
||||
import os
|
||||
import pkgutil
|
||||
import sys
|
||||
|
||||
from parso.python import tree
|
||||
@@ -383,15 +382,16 @@ class Importer(object):
|
||||
Get the names of all modules in the search_path. This means file names
|
||||
and not names defined in the files.
|
||||
"""
|
||||
|
||||
sub = self._evaluator.compiled_subprocess
|
||||
names = []
|
||||
# add builtin module names
|
||||
if search_path is None and in_module is None:
|
||||
names += [self._generate_name(name) for name in sys.builtin_module_names]
|
||||
names += [self._generate_name(name) for name in sub.get_builtin_module_names()]
|
||||
|
||||
if search_path is None:
|
||||
search_path = self.sys_path_with_modifications()
|
||||
for module_loader, name, is_pkg in pkgutil.iter_modules(search_path):
|
||||
|
||||
for name in sub.list_module_names(search_path):
|
||||
names.append(self._generate_name(name, in_module=in_module))
|
||||
return names
|
||||
|
||||
|
||||
Reference in New Issue
Block a user