##// END OF EJS Templates
Move sys.path.insert(0, '') from subclasses to InteractiveShellApp
Bradley M. Froehle -
Show More
@@ -117,9 +117,10 b' class InteractiveShellApp(Configurable):'
117 117
118 118 Provides configurables for loading extensions and executing files
119 119 as part of configuring a Shell environment.
120
121 Provides init_extensions() and init_code() methods, to be called
122 after init_shell(), which must be implemented by subclasses.
120
121 Provides init_path(), to be called before, and init_extensions() and
122 init_code() methods, to be called after init_shell(), which must be
123 implemented by subclasses.
123 124 """
124 125 extensions = List(Unicode, config=True,
125 126 help="A list of dotted module names of IPython extensions to load."
@@ -156,6 +157,11 b' class InteractiveShellApp(Configurable):'
156 157 )
157 158 shell = Instance('IPython.core.interactiveshell.InteractiveShellABC')
158 159
160 def init_path(self):
161 """Add current working directory, '', to sys.path"""
162 if sys.path[0] != '':
163 sys.path.insert(0, '')
164
159 165 def init_shell(self):
160 166 raise NotImplementedError("Override in subclasses")
161 167
@@ -314,6 +314,7 b' class TerminalIPythonApp(BaseIPythonApplication, InteractiveShellApp):'
314 314 # print self.extra_args
315 315 if self.extra_args and not self.something_to_run:
316 316 self.file_to_run = self.extra_args[0]
317 self.init_path()
317 318 # create the shell
318 319 self.init_shell()
319 320 # and draw the banner
@@ -325,10 +326,6 b' class TerminalIPythonApp(BaseIPythonApplication, InteractiveShellApp):'
325 326
326 327 def init_shell(self):
327 328 """initialize the InteractiveShell instance"""
328 # I am a little hesitant to put these into InteractiveShell itself.
329 # But that might be the place for them
330 sys.path.insert(0, '')
331
332 329 # Create an InteractiveShell instance.
333 330 # shell.display_banner should always be False for the terminal
334 331 # based app, because we call shell.show_banner() by hand below
@@ -597,6 +597,7 b' class IPKernelApp(KernelApp, InteractiveShellApp):'
597 597 @catch_config_error
598 598 def initialize(self, argv=None):
599 599 super(IPKernelApp, self).initialize(argv)
600 self.init_path()
600 601 self.init_shell()
601 602 self.init_extensions()
602 603 self.init_code()
@@ -640,10 +641,6 b' class IPKernelApp(KernelApp, InteractiveShellApp):'
640 641
641 642
642 643 def init_shell(self):
643 # I am a little hesitant to put these into InteractiveShell itself.
644 # But that might be the place for them
645 sys.path.insert(0, '')
646
647 644 self.shell = self.kernel.shell
648 645 self.shell.configurables.append(self)
649 646
General Comments 0
You need to be logged in to leave comments. Login now