MCPcopy Create free account
hub / github.com/fabioz/PyDev.Debugger / InterpreterInterface

Class InterpreterInterface

_pydev_bundle/pydev_ipython_console.py:15–95  ·  view source on GitHub ↗

The methods in this class should be registered in the xml-rpc server.

Source from the content-addressed store, hash-verified

13# InterpreterInterface
14# =======================================================================================================================
15class InterpreterInterface(BaseInterpreterInterface):
16 """
17 The methods in this class should be registered in the xml-rpc server.
18 """
19
20 def __init__(self, host, client_port, main_thread, show_banner=True, connect_status_queue=None):
21 BaseInterpreterInterface.__init__(self, main_thread, connect_status_queue)
22 self.client_port = client_port
23 self.host = host
24 self.interpreter = get_pydev_frontend(host, client_port)
25 self._input_error_printed = False
26 self.notification_succeeded = False
27 self.notification_tries = 0
28 self.notification_max_tries = 3
29 self.show_banner = show_banner
30
31 self.notify_about_magic()
32
33 def get_greeting_msg(self):
34 if self.show_banner:
35 self.interpreter.show_banner()
36 return self.interpreter.get_greeting_msg()
37
38 def do_add_exec(self, code_fragment):
39 self.notify_about_magic()
40 if code_fragment.text.rstrip().endswith("??"):
41 print("IPython-->")
42 try:
43 res = bool(self.interpreter.add_exec(code_fragment.text))
44 finally:
45 if code_fragment.text.rstrip().endswith("??"):
46 print("<--IPython")
47
48 return res
49
50 def get_namespace(self):
51 return self.interpreter.get_namespace()
52
53 def getCompletions(self, text, act_tok):
54 return self.interpreter.getCompletions(text, act_tok)
55
56 def close(self):
57 sys.exit(0)
58
59 def notify_about_magic(self):
60 if not self.notification_succeeded:
61 self.notification_tries += 1
62 if self.notification_tries > self.notification_max_tries:
63 return
64 completions = self.getCompletions("%", "%")
65 magic_commands = [x[0] for x in completions]
66
67 server = self.get_server()
68
69 if server is not None:
70 try:
71 server.NotifyAboutMagic(magic_commands, self.interpreter.is_automagic())
72 self.notification_succeeded = True

Callers 2

start_serverFunction · 0.90
get_interpreterFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected