##// END OF EJS Templates
Remove usage of prompt_manager
Thomas Kluyver -
Show More
@@ -56,7 +56,6 b' from IPython.core.macro import Macro'
56 from IPython.core.payload import PayloadManager
56 from IPython.core.payload import PayloadManager
57 from IPython.core.prefilter import PrefilterManager
57 from IPython.core.prefilter import PrefilterManager
58 from IPython.core.profiledir import ProfileDir
58 from IPython.core.profiledir import ProfileDir
59 from IPython.core.prompts import PromptManager
60 from IPython.core.usage import default_banner
59 from IPython.core.usage import default_banner
61 from IPython.testing.skipdoctest import skip_doctest_py2, skip_doctest
60 from IPython.testing.skipdoctest import skip_doctest_py2, skip_doctest
62 from IPython.utils import PyColorize
61 from IPython.utils import PyColorize
@@ -664,8 +663,6 b' class InteractiveShell(SingletonConfigurable):'
664 io.stderr = io.IOStream(sys.stderr)
663 io.stderr = io.IOStream(sys.stderr)
665
664
666 def init_prompts(self):
665 def init_prompts(self):
667 self.prompt_manager = PromptManager(shell=self, parent=self)
668 self.configurables.append(self.prompt_manager)
669 # Set system prompts, so that scripts can decide if they are running
666 # Set system prompts, so that scripts can decide if they are running
670 # interactively.
667 # interactively.
671 sys.ps1 = 'In : '
668 sys.ps1 = 'In : '
@@ -356,14 +356,6 b' Defaulting color scheme to \'NoColor\'"""'
356 # Will remove this check after switching to prompt_toolkit
356 # Will remove this check after switching to prompt_toolkit
357 new_scheme = 'NoColor'
357 new_scheme = 'NoColor'
358
358
359 # Set prompt colors
360 try:
361 shell.prompt_manager.color_scheme = new_scheme
362 except:
363 color_switch_err('prompt')
364 else:
365 shell.colors = \
366 shell.prompt_manager.color_scheme_table.active_scheme_name
367 # Set exception colors
359 # Set exception colors
368 try:
360 try:
369 shell.InteractiveTB.set_colors(scheme = new_scheme)
361 shell.InteractiveTB.set_colors(scheme = new_scheme)
@@ -435,7 +427,6 b' Defaulting color scheme to \'NoColor\'"""'
435
427
436 # Shorthands
428 # Shorthands
437 shell = self.shell
429 shell = self.shell
438 pm = shell.prompt_manager
439 meta = shell.meta
430 meta = shell.meta
440 disp_formatter = self.shell.display_formatter
431 disp_formatter = self.shell.display_formatter
441 ptformatter = disp_formatter.formatters['text/plain']
432 ptformatter = disp_formatter.formatters['text/plain']
@@ -457,16 +448,12 b' Defaulting color scheme to \'NoColor\'"""'
457
448
458 if not mode:
449 if not mode:
459 # turn on
450 # turn on
460 pm.in_template = '>>> '
461 pm.in2_template = '... '
462 pm.out_template = ''
463
451
464 # Prompt separators like plain python
452 # Prompt separators like plain python
465 shell.separate_in = ''
453 shell.separate_in = ''
466 shell.separate_out = ''
454 shell.separate_out = ''
467 shell.separate_out2 = ''
455 shell.separate_out2 = ''
468
456
469 pm.justify = False
470
457
471 ptformatter.pprint = False
458 ptformatter.pprint = False
472 disp_formatter.active_types = ['text/plain']
459 disp_formatter.active_types = ['text/plain']
@@ -474,15 +461,11 b' Defaulting color scheme to \'NoColor\'"""'
474 shell.magic('xmode Plain')
461 shell.magic('xmode Plain')
475 else:
462 else:
476 # turn off
463 # turn off
477 pm.in_template, pm.in2_template, pm.out_template = dstore.prompt_templates
478
479 shell.separate_in = dstore.rc_separate_in
464 shell.separate_in = dstore.rc_separate_in
480
465
481 shell.separate_out = dstore.rc_separate_out
466 shell.separate_out = dstore.rc_separate_out
482 shell.separate_out2 = dstore.rc_separate_out2
467 shell.separate_out2 = dstore.rc_separate_out2
483
468
484 pm.justify = dstore.rc_prompts_pad_left
485
486 ptformatter.pprint = dstore.rc_pprint
469 ptformatter.pprint = dstore.rc_pprint
487 disp_formatter.active_types = dstore.rc_active_types
470 disp_formatter.active_types = dstore.rc_active_types
488
471
@@ -205,13 +205,6 b' class TestMagicRunPass(tt.TempFileMixin):'
205 _ip = get_ipython()
205 _ip = get_ipython()
206 self.run_tmpfile()
206 self.run_tmpfile()
207 nt.assert_equal(type(_ip.user_ns['__builtins__']),type(sys))
207 nt.assert_equal(type(_ip.user_ns['__builtins__']),type(sys))
208
209 def test_prompts(self):
210 """Test that prompts correctly generate after %run"""
211 self.run_tmpfile()
212 _ip = get_ipython()
213 p2 = _ip.prompt_manager.render('in2').strip()
214 nt.assert_equal(p2[:3], '...')
215
208
216 def test_run_profile( self ):
209 def test_run_profile( self ):
217 """Test that the option -p, which invokes the profiler, do not
210 """Test that the option -p, which invokes the profiler, do not
@@ -898,7 +898,6 b' class IPythonDirective(Directive):'
898 if not self.state.document.current_source in self.seen_docs:
898 if not self.state.document.current_source in self.seen_docs:
899 self.shell.IP.history_manager.reset()
899 self.shell.IP.history_manager.reset()
900 self.shell.IP.execution_count = 1
900 self.shell.IP.execution_count = 1
901 self.shell.IP.prompt_manager.width = 0
902 self.seen_docs.add(self.state.document.current_source)
901 self.seen_docs.add(self.state.document.current_source)
903
902
904 # and attach to shell so we don't have to pass them around
903 # and attach to shell so we don't have to pass them around
@@ -614,7 +614,7 b' class TerminalInteractiveShell(InteractiveShell):'
614 self.hooks.pre_prompt_hook()
614 self.hooks.pre_prompt_hook()
615 if more:
615 if more:
616 try:
616 try:
617 prompt = self.prompt_manager.render('in2')
617 prompt = ' ...: '
618 except:
618 except:
619 self.showtraceback()
619 self.showtraceback()
620 if self.autoindent:
620 if self.autoindent:
@@ -622,7 +622,7 b' class TerminalInteractiveShell(InteractiveShell):'
622
622
623 else:
623 else:
624 try:
624 try:
625 prompt = self.separate_in + self.prompt_manager.render('in')
625 prompt = self.separate_in + 'In [{}]: '.format(self.execution_count)
626 except:
626 except:
627 self.showtraceback()
627 self.showtraceback()
628 try:
628 try:
@@ -24,7 +24,6 b' from IPython.core.completer import IPCompleter'
24 from IPython.core.crashhandler import CrashHandler
24 from IPython.core.crashhandler import CrashHandler
25 from IPython.core.formatters import PlainTextFormatter
25 from IPython.core.formatters import PlainTextFormatter
26 from IPython.core.history import HistoryManager
26 from IPython.core.history import HistoryManager
27 from IPython.core.prompts import PromptManager
28 from IPython.core.application import (
27 from IPython.core.application import (
29 ProfileDir, BaseIPythonApplication, base_flags, base_aliases
28 ProfileDir, BaseIPythonApplication, base_flags, base_aliases
30 )
29 )
@@ -195,7 +194,6 b' class TerminalIPythonApp(BaseIPythonApplication, InteractiveShellApp):'
195 InteractiveShellApp, # ShellApp comes before TerminalApp, because
194 InteractiveShellApp, # ShellApp comes before TerminalApp, because
196 self.__class__, # it will also affect subclasses (e.g. QtConsole)
195 self.__class__, # it will also affect subclasses (e.g. QtConsole)
197 TerminalInteractiveShell,
196 TerminalInteractiveShell,
198 PromptManager,
199 HistoryManager,
197 HistoryManager,
200 ProfileDir,
198 ProfileDir,
201 PlainTextFormatter,
199 PlainTextFormatter,
General Comments 0
You need to be logged in to leave comments. Login now