forked from VimPlug/jedi
Refactor the way module_path, module_file and is_package are computed to be a bit more legible
This commit is contained in:
@@ -25,18 +25,18 @@ def find_module_py33(string, path=None):
|
|||||||
raise ImportError("Couldn't find a loader for {0}".format(string))
|
raise ImportError("Couldn't find a loader for {0}".format(string))
|
||||||
|
|
||||||
try:
|
try:
|
||||||
if (loader.is_package(string)):
|
is_package = loader.is_package(string)
|
||||||
mod_info = (None, os.path.dirname(loader.path), True)
|
if is_package:
|
||||||
|
module_path = os.path.dirname(loader.path)
|
||||||
|
module_file = None
|
||||||
else:
|
else:
|
||||||
filename = loader.get_filename(string)
|
module_path = loader.get_filename(string)
|
||||||
if filename and os.path.exists(filename):
|
module_file = open(module_path)
|
||||||
mod_info = (open(filename, 'U'), filename, False)
|
|
||||||
else:
|
|
||||||
mod_info = (None, filename, False)
|
|
||||||
except AttributeError:
|
except AttributeError:
|
||||||
mod_info = (None, loader.load_module(string).__name__, False)
|
module_path = loader.load_module(string).__name__
|
||||||
|
module_file = None
|
||||||
|
|
||||||
return mod_info
|
return module_file, module_path, is_package
|
||||||
|
|
||||||
|
|
||||||
def find_module_pre_py33(string, path=None):
|
def find_module_pre_py33(string, path=None):
|
||||||
|
|||||||
Reference in New Issue
Block a user