Show More
@@ -453,15 +453,10 b" def magic_history(self, parameter_s = ''):" | |||
|
453 | 453 | print('%s:%s' % (str(in_num).ljust(width), line_sep[multiline]), |
|
454 | 454 | file=outfile, end='') |
|
455 | 455 | if pyprompts: |
|
456 |
|
|
|
456 | print(">>> ", end="", file=outfile) | |
|
457 | 457 | if multiline: |
|
458 |
line |
|
|
459 |
|
|
|
460 | print('... ', file=outfile) | |
|
461 | else: | |
|
462 | print(inline, file=outfile) | |
|
463 | else: | |
|
464 | print(inline, file=outfile) | |
|
458 | inline = "\n... ".join(inline.splitlines()) + "\n..." | |
|
459 | print(inline, file=outfile) | |
|
465 | 460 | if print_outputs and output: |
|
466 | 461 | print(repr(output), file=outfile) |
|
467 | 462 |
@@ -57,7 +57,7 b' import IPython.utils.io' | |||
|
57 | 57 | from IPython.utils.path import get_py_filename |
|
58 | 58 | from IPython.utils.process import arg_split, abbrev_cwd |
|
59 | 59 | from IPython.utils.terminal import set_term_title |
|
60 |
from IPython.utils.text import LSString, SList, |
|
|
60 | from IPython.utils.text import LSString, SList, format_screen | |
|
61 | 61 | from IPython.utils.timing import clock, clock2 |
|
62 | 62 | from IPython.utils.warn import warn, error |
|
63 | 63 | from IPython.utils.ipstruct import Struct |
@@ -2284,9 +2284,10 b' Currently the magic system has the following functions:\\n"""' | |||
|
2284 | 2284 | |
|
2285 | 2285 | # by default this is done with temp files, except when the given |
|
2286 | 2286 | # arg is a filename |
|
2287 |
use_temp = |
|
|
2287 | use_temp = True | |
|
2288 | 2288 | |
|
2289 | if re.match(r'\d',args): | |
|
2289 | data = '' | |
|
2290 | if args[0].isdigit(): | |
|
2290 | 2291 | # Mode where user specifies ranges of lines, like in %macro. |
|
2291 | 2292 | # This means that you can't edit files whose names begin with |
|
2292 | 2293 | # numbers this way. Tough. |
@@ -2294,16 +2295,15 b' Currently the magic system has the following functions:\\n"""' | |||
|
2294 | 2295 | data = '\n'.join(self.extract_input_slices(ranges,opts_r)) |
|
2295 | 2296 | elif args.endswith('.py'): |
|
2296 | 2297 | filename = make_filename(args) |
|
2297 |
|
|
|
2298 | use_temp = 0 | |
|
2298 | use_temp = False | |
|
2299 | 2299 | elif args: |
|
2300 | 2300 | try: |
|
2301 | 2301 | # Load the parameter given as a variable. If not a string, |
|
2302 | 2302 | # process it as an object instead (below) |
|
2303 | 2303 | |
|
2304 | 2304 | #print '*** args',args,'type',type(args) # dbg |
|
2305 | data = eval(args,self.shell.user_ns) | |
|
2306 |
if not |
|
|
2305 | data = eval(args, self.shell.user_ns) | |
|
2306 | if not isinstance(data, basestring): | |
|
2307 | 2307 | raise DataIsObject |
|
2308 | 2308 | |
|
2309 | 2309 | except (NameError,SyntaxError): |
@@ -2313,13 +2313,11 b' Currently the magic system has the following functions:\\n"""' | |||
|
2313 | 2313 | warn("Argument given (%s) can't be found as a variable " |
|
2314 | 2314 | "or as a filename." % args) |
|
2315 | 2315 | return |
|
2316 | ||
|
2317 |
|
|
|
2318 | use_temp = 0 | |
|
2316 | use_temp = False | |
|
2317 | ||
|
2319 | 2318 | except DataIsObject: |
|
2320 | ||
|
2321 | 2319 | # macros have a special edit function |
|
2322 | if isinstance(data,Macro): | |
|
2320 | if isinstance(data, Macro): | |
|
2323 | 2321 | self._edit_macro(args,data) |
|
2324 | 2322 | return |
|
2325 | 2323 | |
@@ -2358,9 +2356,7 b' Currently the magic system has the following functions:\\n"""' | |||
|
2358 | 2356 | warn('The file `%s` where `%s` was defined cannot ' |
|
2359 | 2357 | 'be read.' % (filename,data)) |
|
2360 | 2358 | return |
|
2361 |
use_temp = |
|
|
2362 | else: | |
|
2363 | data = '' | |
|
2359 | use_temp = False | |
|
2364 | 2360 | |
|
2365 | 2361 | if use_temp: |
|
2366 | 2362 | filename = self.shell.mktempfile(data) |
@@ -2383,7 +2379,7 b' Currently the magic system has the following functions:\\n"""' | |||
|
2383 | 2379 | if args.strip() == 'pasted_block': |
|
2384 | 2380 | self.shell.user_ns['pasted_block'] = file_read(filename) |
|
2385 | 2381 | |
|
2386 |
if |
|
|
2382 | if 'x' in opts: # -x prevents actual execution | |
|
2387 | 2383 | |
|
2388 | 2384 | else: |
|
2389 | 2385 | print 'done. Executing edited code...' |
@@ -19,7 +19,6 b' import __main__' | |||
|
19 | 19 | import os |
|
20 | 20 | import re |
|
21 | 21 | import shutil |
|
22 | import types | |
|
23 | 22 | |
|
24 | 23 | from IPython.external.path import path |
|
25 | 24 | |
@@ -30,8 +29,6 b' from IPython.utils.data import flatten' | |||
|
30 | 29 | # Code |
|
31 | 30 | #----------------------------------------------------------------------------- |
|
32 | 31 | |
|
33 | StringTypes = types.StringTypes | |
|
34 | ||
|
35 | 32 | |
|
36 | 33 | def unquote_ends(istr): |
|
37 | 34 | """Remove a single pair of quotes from the endpoints of a string.""" |
@@ -325,7 +322,7 b' def qw(words,flat=0,sep=None,maxsplit=-1):' | |||
|
325 | 322 | ['a', 'b', '1', '2', 'm', 'n', 'p', 'q'] |
|
326 | 323 | """ |
|
327 | 324 | |
|
328 |
if |
|
|
325 | if isinstance(words, basestring): | |
|
329 | 326 | return [word.strip() for word in words.split(sep,maxsplit) |
|
330 | 327 | if word and not word.isspace() ] |
|
331 | 328 | if flat: |
@@ -345,7 +342,7 b' def qw_lol(indata):' | |||
|
345 | 342 | We need this to make sure the modules_some keys *always* end up as a |
|
346 | 343 | list of lists.""" |
|
347 | 344 | |
|
348 |
if |
|
|
345 | if isinstance(indata, basestring): | |
|
349 | 346 | return [qw(indata)] |
|
350 | 347 | else: |
|
351 | 348 | return qw(indata) |
@@ -18,7 +18,6 b' from __future__ import print_function' | |||
|
18 | 18 | # Stdlib |
|
19 | 19 | import inspect |
|
20 | 20 | import os |
|
21 | import re | |
|
22 | 21 | |
|
23 | 22 | # Our own |
|
24 | 23 | from IPython.core.interactiveshell import ( |
@@ -31,7 +30,6 b' from IPython.core.macro import Macro' | |||
|
31 | 30 | from IPython.core.payloadpage import install_payload_page |
|
32 | 31 | from IPython.utils import io |
|
33 | 32 | from IPython.utils.path import get_py_filename |
|
34 | from IPython.utils.text import StringTypes | |
|
35 | 33 | from IPython.utils.traitlets import Instance, Type, Dict |
|
36 | 34 | from IPython.utils.warn import warn |
|
37 | 35 | from IPython.zmq.session import extract_header |
@@ -433,9 +431,10 b' class ZMQInteractiveShell(InteractiveShell):' | |||
|
433 | 431 | |
|
434 | 432 | # by default this is done with temp files, except when the given |
|
435 | 433 | # arg is a filename |
|
436 |
use_temp = |
|
|
434 | use_temp = True | |
|
437 | 435 | |
|
438 | if re.match(r'\d',args): | |
|
436 | data = '' | |
|
437 | if args[0].isdigit(): | |
|
439 | 438 | # Mode where user specifies ranges of lines, like in %macro. |
|
440 | 439 | # This means that you can't edit files whose names begin with |
|
441 | 440 | # numbers this way. Tough. |
@@ -443,16 +442,15 b' class ZMQInteractiveShell(InteractiveShell):' | |||
|
443 | 442 | data = ''.join(self.extract_input_slices(ranges,opts_r)) |
|
444 | 443 | elif args.endswith('.py'): |
|
445 | 444 | filename = make_filename(args) |
|
446 |
|
|
|
447 | use_temp = 0 | |
|
445 | use_temp = False | |
|
448 | 446 | elif args: |
|
449 | 447 | try: |
|
450 | 448 | # Load the parameter given as a variable. If not a string, |
|
451 | 449 | # process it as an object instead (below) |
|
452 | 450 | |
|
453 | 451 | #print '*** args',args,'type',type(args) # dbg |
|
454 | data = eval(args,self.shell.user_ns) | |
|
455 |
if not |
|
|
452 | data = eval(args, self.shell.user_ns) | |
|
453 | if not isinstance(data, basestring): | |
|
456 | 454 | raise DataIsObject |
|
457 | 455 | |
|
458 | 456 | except (NameError,SyntaxError): |
@@ -462,13 +460,11 b' class ZMQInteractiveShell(InteractiveShell):' | |||
|
462 | 460 | warn("Argument given (%s) can't be found as a variable " |
|
463 | 461 | "or as a filename." % args) |
|
464 | 462 | return |
|
465 | ||
|
466 |
|
|
|
467 | use_temp = 0 | |
|
463 | use_temp = False | |
|
464 | ||
|
468 | 465 | except DataIsObject: |
|
469 | ||
|
470 | 466 | # macros have a special edit function |
|
471 | if isinstance(data,Macro): | |
|
467 | if isinstance(data, Macro): | |
|
472 | 468 | self._edit_macro(args,data) |
|
473 | 469 | return |
|
474 | 470 | |
@@ -507,9 +503,7 b' class ZMQInteractiveShell(InteractiveShell):' | |||
|
507 | 503 | warn('The file `%s` where `%s` was defined cannot ' |
|
508 | 504 | 'be read.' % (filename,data)) |
|
509 | 505 | return |
|
510 |
use_temp = |
|
|
511 | else: | |
|
512 | data = '' | |
|
506 | use_temp = False | |
|
513 | 507 | |
|
514 | 508 | if use_temp: |
|
515 | 509 | filename = self.shell.mktempfile(data) |
General Comments 0
You need to be logged in to leave comments.
Login now