Debian Codegraph @

jedi/inference/compiled/subprocess/__main__.py

raw symbols SCIP
1 import os
2 import sys
3 from importlib.abc import MetaPathFinder
4 from importlib.machinery import PathFinder
5
6
7 def _get_paths():
8 # Get the path to jedi.
9 _d = os.path.dirname
10 _jedi_path = _d(_d(_d(_d(_d(__file__)))))
11 _parso_path = sys.argv[1]
12 # The paths are the directory that jedi and parso lie in.
13 return {'jedi': _jedi_path, 'parso': _parso_path}
14
15
16 class _ExactImporter(MetaPathFinder):
17 def __init__(self, path_dct):
18 self._path_dct = path_dct
19
20 def find_spec(self, fullname, path=None, target=None):
21 if path is None and fullname in self._path_dct:
22 p = self._path_dct[fullname]
23 spec = PathFinder.find_spec(fullname, path=[p], target=target)
24 return spec
25 return None
26
27
28 # Try to import jedi/parso.
29 sys.meta_path.insert(0, _ExactImporter(_get_paths()))
30 from jedi.inference.compiled import subprocess # noqa: E402
31 sys.meta_path.pop(0)
32
33 # Retrieve the pickle protocol.
34 host_sys_version = [int(x) for x in sys.argv[2].split('.')]
35 # And finally start the client.
36 subprocess.Listener().listen()