##// END OF EJS Templates
IPKernelApp now based on InteractiveShellApp
MinRK -
Show More
@@ -29,12 +29,16 b' import zmq'
29 29 from IPython.config.configurable import Configurable
30 30 from IPython.config.application import boolean_flag
31 31 from IPython.core.newapplication import ProfileDir
32 from IPython.core.shellapp import (
33 InteractiveShellApp, shell_flags, shell_aliases
34 )
32 35 from IPython.utils import io
33 36 from IPython.utils.jsonutil import json_clean
34 37 from IPython.lib import pylabtools
35 38 from IPython.utils.traitlets import (
36 39 List, Instance, Float, Dict, Bool, Int, Unicode, CaselessStrEnum
37 40 )
41
38 42 from entry_point import base_launch_kernel
39 43 from kernelapp import KernelApp, kernel_flags, kernel_aliases
40 44 from iostream import OutStream
@@ -559,53 +563,9 b' class GTKKernel(Kernel):'
559 563 #-----------------------------------------------------------------------------
560 564
561 565 flags = dict(kernel_flags)
566 flags.update(shell_flags)
562 567
563 568 addflag = lambda *args: flags.update(boolean_flag(*args))
564 addflag('automagic', 'InteractiveShell.automagic',
565 """Turn on the auto calling of magic commands. Type %%magic at the
566 IPython prompt for more information.""",
567 'Turn off the auto calling of magic commands.'
568 )
569 addflag('banner', 'InteractiveShell.display_banner',
570 "Display a banner upon starting IPython.",
571 "Don't display a banner upon starting IPython."
572 )
573 addflag('pdb', 'InteractiveShell.pdb',
574 "Enable auto calling the pdb debugger after every exception.",
575 "Disable auto calling the pdb debugger after every exception."
576 )
577 addflag('pprint', 'PlainTextFormatter.pprint',
578 "Enable auto pretty printing of results.",
579 "Disable auto auto pretty printing of results."
580 )
581 addflag('color-info', 'InteractiveShell.color_info',
582 """IPython can display information about objects via a set of func-
583 tions, and optionally can use colors for this, syntax highlighting
584 source code and various other elements. However, because this
585 information is passed through a pager (like 'less') and many pagers get
586 confused with color codes, this option is off by default. You can test
587 it and turn it on permanently in your ipython_config.py file if it
588 works for you. Test it and turn it on permanently if it works with
589 your system. The magic function %%color_info allows you to toggle this
590 inter- actively for testing.""",
591 "Disable using colors for info related things."
592 )
593 addflag('deep-reload', 'InteractiveShell.deep_reload',
594 """Enable deep (recursive) reloading by default. IPython can use the
595 deep_reload module which reloads changes in modules recursively (it
596 replaces the reload() function, so you don't need to change anything to
597 use it). deep_reload() forces a full reload of modules whose code may
598 have changed, which the default reload() function does not. When
599 deep_reload is off, IPython will use the normal reload(), but
600 deep_reload will still be available as dreload(). This fea- ture is off
601 by default [which means that you have both normal reload() and
602 dreload()].""",
603 "Disable deep (recursive) reloading by default."
604 )
605 addflag('readline', 'InteractiveShell.readline_use',
606 "Enable readline for command line usage.",
607 "Disable readline for command line usage."
608 )
609 569
610 570 flags['pylab'] = (
611 571 {'IPKernelApp' : {'pylab' : 'auto'}},
@@ -614,23 +574,10 b" flags['pylab'] = ("
614 574 )
615 575
616 576 aliases = dict(kernel_aliases)
577 aliases.update(shell_aliases)
617 578
618 579 # it's possible we don't want short aliases for *all* of these:
619 580 aliases.update(dict(
620 autocall='InteractiveShell.autocall',
621 cache_size='InteractiveShell.cache_size',
622 colors='InteractiveShell.colors',
623 logfile='InteractiveShell.logfile',
624 log_append='InteractiveShell.logappend',
625 pi1='InteractiveShell.prompt_in1',
626 pi2='InteractiveShell.prompt_in2',
627 po='InteractiveShell.prompt_out',
628 si='InteractiveShell.separate_in',
629 so='InteractiveShell.separate_out',
630 so2='InteractiveShell.separate_out2',
631 xmode='InteractiveShell.xmode',
632 c='IPKernelApp.code_to_run',
633 ext='IPKernelApp.extra_extension',
634 581 pylab='IPKernelApp.pylab',
635 582 ))
636 583
@@ -638,7 +585,7 b' aliases.update(dict('
638 585 # The IPKernelApp class
639 586 #-----------------------------------------------------------------------------
640 587
641 class IPKernelApp(KernelApp):
588 class IPKernelApp(KernelApp, InteractiveShellApp):
642 589 name = 'ipkernel'
643 590
644 591 aliases = Dict(aliases)
@@ -651,33 +598,11 b' class IPKernelApp(KernelApp):'
651 598 selecting a particular matplotlib backend and loop integration.
652 599 """
653 600 )
654 extensions = List(Unicode, config=True,
655 help="A list of dotted module names of IPython extensions to load."
656 )
657 extra_extension = Unicode('', config=True,
658 help="dotted module name of an IPython extension to load."
659 )
660 def _extra_extension_changed(self, name, old, new):
661 if new:
662 # add to self.extensions
663 self.extensions.append(new)
664
665 exec_files = List(Unicode, config=True,
666 help="""List of files to run at IPython startup."""
667 )
668 file_to_run = Unicode('', config=True,
669 help="""A file to be run""")
670 def _file_to_run_changed(self, name, old, new):
671 self.exec_files.append(new)
672
673 exec_lines = List(Unicode, config=True,
674 help="""lines of code to run at IPython startup."""
675 )
676 code_to_run = Unicode('', config=True,
677 help="Execute the given command string."
678 )
679 def _code_to_run_changed(self, name, old, new):
680 self.exec_lines.append(new)
601 def initialize(self, argv=None):
602 super(IPKernelApp, self).initialize(argv)
603 self.init_shell()
604 self.init_extensions()
605 self.init_code()
681 606
682 607 def init_kernel(self):
683 608 kernel_factory = Kernel
@@ -712,7 +637,9 b' class IPKernelApp(KernelApp):'
712 637 if self.pylab:
713 638 pylabtools.import_pylab(kernel.shell.user_ns, backend,
714 639 shell=kernel.shell)
715
640
641 def init_shell(self):
642 self.shell = self.kernel.shell
716 643
717 644
718 645 #-----------------------------------------------------------------------------
@@ -736,7 +663,7 b' def launch_kernel(*args, **kwargs):'
736 663
737 664
738 665 def main():
739 """Run a PyKernel as an application"""
666 """Run an IPKernel as an application"""
740 667 app = IPKernelApp()
741 668 app.initialize()
742 669 app.start()
General Comments 0
You need to be logged in to leave comments. Login now