-
Notifications
You must be signed in to change notification settings - Fork 5
/
ep_jedi.py
54 lines (49 loc) · 1.34 KB
/
ep_jedi.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
"""
Experimental Jedi Completions fetcher
"""
import os
import shlex
import sys
import io
import re
import site
import time
import subprocess
def get_completions(source, row, col, script_path=""):
return []
def real(source, row, col, script_path=""):
completions = []
try:
script = jedi.Script(source, row, col+1, script_path)
completion_objects = script.complete()
completions = [x.name for x in completion_objects]
except Exception as err:
pass
finally:
return completions
# WHY:
# Only supports windows for now, we have full control cause we bundle everything!
if os.name == "nt":
# WHY:
# This is because we are embedding python and jedi tries to open expressPython.exe
# Thinking it is python.exe
try:
import jedi
except ImportError:
pass
else:
d = os.path.dirname
python_location = os.path.join(d(d(d(d(jedi.__file__)))), "python.exe")
if os.path.exists(python_location):
sys.executable = python_location
get_completions = real
if os.name == "posix":
try:
import jedi
except ImportError:
pass
else:
d = os.path.dirname
python_location = os.path.join(d(d(d(d(jedi.__file__)))), "python3.8")
if os.path.exists(python_location):
get_completions = real