mirror of
https://github.com/davidhalter/jedi.git
synced 2025-12-09 07:14:48 +08:00
modules like PyQt4.QtGui are now importable, because the import works again. used a code snippet from the old builtin plugin
This commit is contained in:
@@ -14,10 +14,6 @@ from jedi.evaluate.sys_path import get_sys_path
|
|||||||
from . import fake
|
from . import fake
|
||||||
|
|
||||||
|
|
||||||
# TODO
|
|
||||||
# unbound methods such as pyqtSignals have no __name__
|
|
||||||
# if not hasattr(func, "__name__"):
|
|
||||||
|
|
||||||
class PyObject(Base):
|
class PyObject(Base):
|
||||||
# comply with the parser
|
# comply with the parser
|
||||||
start_pos = 0, 0
|
start_pos = 0, 0
|
||||||
@@ -158,6 +154,20 @@ def load_module(path, name):
|
|||||||
# sometimes there are endings like `_sqlite3.cpython-32mu`
|
# sometimes there are endings like `_sqlite3.cpython-32mu`
|
||||||
name = re.sub(r'\..*', '', name)
|
name = re.sub(r'\..*', '', name)
|
||||||
|
|
||||||
|
if path:
|
||||||
|
dot_path = []
|
||||||
|
p = path
|
||||||
|
# if path is not in sys.path, we need to make a well defined import
|
||||||
|
# like `from numpy.core import umath.`
|
||||||
|
while p and p not in sys.path:
|
||||||
|
p, sep, mod = p.rpartition(os.path.sep)
|
||||||
|
dot_path.insert(0, mod.partition('.')[0])
|
||||||
|
if p:
|
||||||
|
name = ".".join(dot_path)
|
||||||
|
path = p
|
||||||
|
else:
|
||||||
|
path = os.path.dirname(path)
|
||||||
|
|
||||||
sys_path = get_sys_path()
|
sys_path = get_sys_path()
|
||||||
if path:
|
if path:
|
||||||
sys_path.insert(0, path)
|
sys_path.insert(0, path)
|
||||||
@@ -172,7 +182,6 @@ def load_module(path, name):
|
|||||||
# directly. -> github issue #59
|
# directly. -> github issue #59
|
||||||
module = sys.modules[name]
|
module = sys.modules[name]
|
||||||
sys.path = temp
|
sys.path = temp
|
||||||
|
|
||||||
return PyObject(module)
|
return PyObject(module)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user