##// END OF EJS Templates
Update notebook.rst...
Update notebook.rst Updating broken reference to notebook examples Since the notebook directory doesn't contain a readme anymore, updating to point to the index notebook rendered via nbviewer

File last commit:

r15415:4df28a74
r16399:18bf748d
Show More
completer.py
58 lines | 1.9 KiB | text/x-python | PythonLexer
Thomas Kluyver
Standardise some module docstring first lines
r13888 """Adapt readline completer interface to make ZMQ request.
"""
Omar Andres Zapata Mesa
-mworking in tab-completion
r5584 # -*- coding: utf-8 -*-
Thomas Kluyver
Update imports for Python 3...
r13354 try:
from queue import Empty # Py 3
except ImportError:
from Queue import Empty # Py 2
Thomas Kluyver
Minor tidy up of zmqterminal.completer
r5595
Matthias BUSSONNIER
Add configurability to tabcompletion timeout...
r11676 from IPython.config import Configurable
MinRK
ZMQCompleter inherits from IPCompleter...
r14878 from IPython.core.completer import IPCompleter
Matthias BUSSONNIER
Add configurability to tabcompletion timeout...
r11676 from IPython.utils.traitlets import Float
MinRK
use rlineimpl in terminal.console
r15415 import IPython.utils.rlineimpl as readline
Matthias BUSSONNIER
Add configurability to tabcompletion timeout...
r11676
MinRK
ZMQCompleter inherits from IPCompleter...
r14878 class ZMQCompleter(IPCompleter):
Omar Andres Zapata Mesa
-mworking in tab-completion
r5584 """Client-side completion machinery.
How it works: self.complete will be called multiple times, with
state=0,1,2,... When state=0 it should compute ALL the completion matches,
and then return them for each value of state."""
Matthias BUSSONNIER
Add configurability to tabcompletion timeout...
r11676
timeout = Float(5.0, config=True, help='timeout before completion abort')
Omar Andres Zapata Mesa
-mworking in tab-completion
r5584
Matthias BUSSONNIER
Add configurability to tabcompletion timeout...
r11676 def __init__(self, shell, client, config=None):
super(ZMQCompleter,self).__init__(config=config)
MinRK
zmqterminal subclasses TerminalInteractiveShell/IPApp...
r5600 self.shell = shell
MinRK
update terminal console to new KM / KC APIs
r10287 self.client = client
Omar Andres Zapata Mesa
-mworking in tab-completion
r5584 self.matches = []
def complete_request(self,text):
Omar Andres Zapata Mesa
tab completion is not working yet, unknow error
r5585 line = readline.get_line_buffer()
Thomas Kluyver
Simplify handling of messaging in zmqterminal.
r5597 cursor_pos = readline.get_endidx()
Omar Andres Zapata Mesa
tab completion is not working yet, unknow error
r5585 # send completion request to kernel
# Give the kernel up to 0.5s to respond
MinRK
update terminal console to new KM / KC APIs
r10287 msg_id = self.client.shell_channel.complete(text=text, line=line,
Thomas Kluyver
Simplify handling of messaging in zmqterminal.
r5597 cursor_pos=cursor_pos)
Matthias BUSSONNIER
Add configurability to tabcompletion timeout...
r11676 msg = self.client.shell_channel.get_msg(timeout=self.timeout)
MinRK
zmqterminal subclasses TerminalInteractiveShell/IPApp...
r5600 if msg['parent_header']['msg_id'] == msg_id:
return msg["content"]["matches"]
Thomas Kluyver
Refactor and simplification of zmqterminal.
r5596 return []
Omar Andres Zapata Mesa
-mworking in tab-completion
r5584
MinRK
zmqterminal subclasses TerminalInteractiveShell/IPApp...
r5600 def rlcomplete(self, text, state):
Thomas Kluyver
Minor tidy up of zmqterminal.completer
r5595 if state == 0:
try:
self.matches = self.complete_request(text)
Thomas Kluyver
Refactor and simplification of zmqterminal.
r5596 except Empty:
Matthias BUSSONNIER
Add configurability to tabcompletion timeout...
r11676 #print('WARNING: Kernel timeout on tab completion.')
pass
Thomas Kluyver
Minor tidy up of zmqterminal.completer
r5595
Thomas Kluyver
Replace tabs with spaces
r5591 try:
return self.matches[state]
except IndexError:
return None
MinRK
zmqterminal subclasses TerminalInteractiveShell/IPApp...
r5600
def complete(self, text, line, cursor_pos=None):
return self.rlcomplete(text, 0)