##// END OF EJS Templates
Replaced internal storage object with namedtuple.
epatters -
Show More
@@ -7,6 +7,7 b''
7 """
7 """
8
8
9 # Standard library imports
9 # Standard library imports
10 from collections import namedtuple
10 from subprocess import Popen
11 from subprocess import Popen
11
12
12 # System library imports
13 # System library imports
@@ -18,15 +19,6 b' from IPython.core.usage import default_banner'
18 from frontend_widget import FrontendWidget
19 from frontend_widget import FrontendWidget
19
20
20
21
21 class IPythonPromptBlock(object):
22 """ An internal storage object for IPythonWidget.
23 """
24 def __init__(self, block, length, number):
25 self.block = block
26 self.length = length
27 self.number = number
28
29
30 class IPythonWidget(FrontendWidget):
22 class IPythonWidget(FrontendWidget):
31 """ A FrontendWidget for an IPython kernel.
23 """ A FrontendWidget for an IPython kernel.
32 """
24 """
@@ -59,6 +51,10 b' class IPythonWidget(FrontendWidget):'
59 in_prompt = 'In [<span class="in-prompt-number">%i</span>]: '
51 in_prompt = 'In [<span class="in-prompt-number">%i</span>]: '
60 out_prompt = 'Out[<span class="out-prompt-number">%i</span>]: '
52 out_prompt = 'Out[<span class="out-prompt-number">%i</span>]: '
61
53
54 # A type used internally by IPythonWidget for storing prompt information.
55 _PromptBlock = namedtuple('_PromptBlock',
56 ['block', 'length', 'number'])
57
62 # FrontendWidget protected class variables.
58 # FrontendWidget protected class variables.
63 _input_splitter_class = IPythonInputSplitter
59 _input_splitter_class = IPythonInputSplitter
64
60
@@ -212,7 +208,7 b' class IPythonWidget(FrontendWidget):'
212 self._show_prompt(self._make_in_prompt(number), html=True)
208 self._show_prompt(self._make_in_prompt(number), html=True)
213 block = self._control.document().lastBlock()
209 block = self._control.document().lastBlock()
214 length = len(self._prompt)
210 length = len(self._prompt)
215 self._previous_prompt_obj = IPythonPromptBlock(block, length, number)
211 self._previous_prompt_obj = self._PromptBlock(block, length, number)
216
212
217 # Update continuation prompt to reflect (possibly) new prompt length.
213 # Update continuation prompt to reflect (possibly) new prompt length.
218 self._set_continuation_prompt(
214 self._set_continuation_prompt(
General Comments 0
You need to be logged in to leave comments. Login now