##// END OF EJS Templates
cleanup warning/error messages when nothing is found to %edit
MinRK -
Show More
@@ -282,7 +282,7 b' class CodeMagics(Magics):'
282 if filename is None:
282 if filename is None:
283 warn("Argument given (%s) can't be found as a variable "
283 warn("Argument given (%s) can't be found as a variable "
284 "or as a filename." % args)
284 "or as a filename." % args)
285 return
285 return (None, None, None)
286 use_temp = False
286 use_temp = False
287
287
288 except DataIsObject:
288 except DataIsObject:
@@ -318,7 +318,9 b' class CodeMagics(Magics):'
318 if filename is None:
318 if filename is None:
319 filename = make_filename(args)
319 filename = make_filename(args)
320 datafile = 1
320 datafile = 1
321 warn('Could not find file where `%s` is defined.\n'
321 if filename is not None:
322 # only warn about this if we get a real name
323 warn('Could not find file where `%s` is defined.\n'
322 'Opening a file named `%s`' % (args, filename))
324 'Opening a file named `%s`' % (args, filename))
323 # Now, make sure we can actually read the source (if it was
325 # Now, make sure we can actually read the source (if it was
324 # in a temp file it's gone by now).
326 # in a temp file it's gone by now).
@@ -328,9 +330,9 b' class CodeMagics(Magics):'
328 if lineno is None:
330 if lineno is None:
329 filename = make_filename(args)
331 filename = make_filename(args)
330 if filename is None:
332 if filename is None:
331 warn('The file `%s` where `%s` was defined '
333 warn('The file where `%s` was defined '
332 'cannot be read.' % (filename, data))
334 'cannot be read or found.' % data)
333 return
335 return (None, None, None)
334 use_temp = False
336 use_temp = False
335
337
336 if use_temp:
338 if use_temp:
@@ -508,6 +510,10 b' class CodeMagics(Magics):'
508 args = str(e.index)
510 args = str(e.index)
509 filename, lineno, is_temp = self._find_edit_target(self.shell,
511 filename, lineno, is_temp = self._find_edit_target(self.shell,
510 args, opts, last_call)
512 args, opts, last_call)
513 if filename is None:
514 # nothing was found, warnings have already been issued,
515 # just give up.
516 return
511
517
512 # do actual editing here
518 # do actual editing here
513 print 'Editing...',
519 print 'Editing...',
General Comments 0
You need to be logged in to leave comments. Login now