##// END OF EJS Templates
Support running directories with __main__.py files...
The-Penultimate-Defenestrator -
Show More
@@ -100,7 +100,7 b" shell_aliases['cache-size'] = 'InteractiveShell.cache_size'"
100 100
101 101 class InteractiveShellApp(Configurable):
102 102 """A Mixin for applications that start InteractiveShell instances.
103
103
104 104 Provides configurables for loading extensions and executing files
105 105 as part of configuring a Shell environment.
106 106
@@ -126,7 +126,7 b' class InteractiveShellApp(Configurable):'
126 126
127 127 # Extensions that are always loaded (not configurable)
128 128 default_extensions = List(Unicode(), [u'storemagic']).tag(config=False)
129
129
130 130 hide_initial_ns = Bool(True,
131 131 help="""Should variables loaded at startup (by startup files, exec_lines, etc.)
132 132 be hidden from tools like %who?"""
@@ -166,7 +166,7 b' class InteractiveShellApp(Configurable):'
166 166 pylab_import_all = Bool(True,
167 167 help="""If true, IPython will populate the user namespace with numpy, pylab, etc.
168 168 and an ``import *`` is done from numpy and pylab, when using pylab mode.
169
169
170 170 When False, pylab mode should not import any names into the user namespace.
171 171 """
172 172 ).tag(config=True)
@@ -174,7 +174,7 b' class InteractiveShellApp(Configurable):'
174 174 allow_none=True)
175 175 # whether interact-loop should start
176 176 interact = Bool(True)
177
177
178 178 user_ns = Instance(dict, args=None, allow_none=True)
179 179 @observe('user_ns')
180 180 def _user_ns_changed(self, change):
@@ -203,10 +203,10 b' class InteractiveShellApp(Configurable):'
203 203 elif self.gui:
204 204 enable = shell.enable_gui
205 205 key = self.gui
206
206
207 207 if not enable:
208 208 return
209
209
210 210 try:
211 211 r = enable(key)
212 212 except ImportError:
@@ -217,7 +217,7 b' class InteractiveShellApp(Configurable):'
217 217 self.log.warning("GUI event loop or pylab initialization failed")
218 218 self.shell.showtraceback()
219 219 return
220
220
221 221 if isinstance(r, tuple):
222 222 gui, backend = r[:2]
223 223 self.log.info("Enabling GUI event loop integration, "
@@ -263,16 +263,16 b' class InteractiveShellApp(Configurable):'
263 263 self._run_startup_files()
264 264 self._run_exec_lines()
265 265 self._run_exec_files()
266
266
267 267 # Hide variables defined here from %who etc.
268 268 if self.hide_initial_ns:
269 269 self.shell.user_ns_hidden.update(self.shell.user_ns)
270
270
271 271 # command-line execution (ipython -i script.py, ipython -m module)
272 272 # should *not* be excluded from %whos
273 273 self._run_cmd_line_code()
274 274 self._run_module()
275
275
276 276 # flush output, so itwon't be attached to the first cell
277 277 sys.stdout.flush()
278 278 sys.stderr.flush()
@@ -333,7 +333,7 b' class InteractiveShellApp(Configurable):'
333 333 """Run files from profile startup directory"""
334 334 startup_dir = self.profile_dir.startup_dir
335 335 startup_files = []
336
336
337 337 if self.exec_PYTHONSTARTUP and os.environ.get('PYTHONSTARTUP', False) and \
338 338 not (self.file_to_run or self.code_to_run or self.module_to_run):
339 339 python_startup = os.environ['PYTHONSTARTUP']
@@ -343,12 +343,12 b' class InteractiveShellApp(Configurable):'
343 343 except:
344 344 self.log.warning("Unknown error in handling PYTHONSTARTUP file %s:", python_startup)
345 345 self.shell.showtraceback()
346
346
347 347 startup_files += glob.glob(os.path.join(startup_dir, '*.py'))
348 348 startup_files += glob.glob(os.path.join(startup_dir, '*.ipy'))
349 349 if not startup_files:
350 350 return
351
351
352 352 self.log.debug("Running startup files from %s...", startup_dir)
353 353 try:
354 354 for fname in sorted(startup_files):
@@ -388,6 +388,8 b' class InteractiveShellApp(Configurable):'
388 388 # Like Python itself, ignore the second if the first of these is present
389 389 elif self.file_to_run:
390 390 fname = self.file_to_run
391 if os.path.isdir(fname):
392 fname = os.path.join(fname, "__main__.py")
391 393 try:
392 394 self._exec_file(fname, shell_futures=True)
393 395 except:
General Comments 0
You need to be logged in to leave comments. Login now