Show More
@@ -1,7 +1,7 b'' | |||
|
1 | 1 | # -*- coding: utf-8 -*- |
|
2 | 2 | """Magic functions for InteractiveShell. |
|
3 | 3 | |
|
4 |
$Id: Magic.py 18 |
|
|
4 | $Id: Magic.py 1845 2006-10-27 20:35:47Z fptest $""" | |
|
5 | 5 | |
|
6 | 6 | #***************************************************************************** |
|
7 | 7 | # Copyright (C) 2001 Janko Hauser <jhauser@zscout.de> and |
@@ -26,7 +26,6 b' import inspect' | |||
|
26 | 26 | import os |
|
27 | 27 | import pdb |
|
28 | 28 | import pydoc |
|
29 | import shlex | |
|
30 | 29 | import sys |
|
31 | 30 | import re |
|
32 | 31 | import tempfile |
@@ -62,17 +61,6 b' def on_off(tag):' | |||
|
62 | 61 | |
|
63 | 62 | class Bunch: pass |
|
64 | 63 | |
|
65 | def arg_split(s,posix=True): | |
|
66 | """Split a command line's arguments in a shell-like manner. | |
|
67 | ||
|
68 | This is a modified version of the standard library's shlex.split() | |
|
69 | function, but with a default of posix=False for splitting, so that quotes | |
|
70 | in inputs are respected.""" | |
|
71 | ||
|
72 | lex = shlex.shlex(s, posix=posix) | |
|
73 | lex.whitespace_split = True | |
|
74 | return list(lex) | |
|
75 | ||
|
76 | 64 | #*************************************************************************** |
|
77 | 65 | # Main class implementing Magic functionality |
|
78 | 66 | class Magic: |
@@ -1489,7 +1477,7 b' Currently the magic system has the following functions:\\n"""' | |||
|
1489 | 1477 | # Since '%run foo' emulates 'python foo.py' at the cmd line, we must |
|
1490 | 1478 | # set the __file__ global in the script's namespace |
|
1491 | 1479 | prog_ns['__file__'] = filename |
|
1492 | ||
|
1480 | ||
|
1493 | 1481 | # pickle fix. See iplib for an explanation. But we need to make sure |
|
1494 | 1482 | # that, if we overwrite __main__, we replace it at the end |
|
1495 | 1483 | if prog_ns['__name__'] == '__main__': |
@@ -1553,7 +1541,8 b' Currently the magic system has the following functions:\\n"""' | |||
|
1553 | 1541 | nruns = 1 |
|
1554 | 1542 | if nruns == 1: |
|
1555 | 1543 | t0 = clock2() |
|
1556 |
runner(filename,prog_ns,prog_ns, |
|
|
1544 | runner(filename,prog_ns,prog_ns, | |
|
1545 | exit_ignore=exit_ignore) | |
|
1557 | 1546 | t1 = clock2() |
|
1558 | 1547 | t_usr = t1[0]-t0[0] |
|
1559 | 1548 | t_sys = t1[1]-t1[1] |
@@ -1564,7 +1553,8 b' Currently the magic system has the following functions:\\n"""' | |||
|
1564 | 1553 | runs = range(nruns) |
|
1565 | 1554 | t0 = clock2() |
|
1566 | 1555 | for nr in runs: |
|
1567 |
runner(filename,prog_ns,prog_ns, |
|
|
1556 | runner(filename,prog_ns,prog_ns, | |
|
1557 | exit_ignore=exit_ignore) | |
|
1568 | 1558 | t1 = clock2() |
|
1569 | 1559 | t_usr = t1[0]-t0[0] |
|
1570 | 1560 | t_sys = t1[1]-t1[1] |
@@ -5,7 +5,7 b' General purpose utilities.' | |||
|
5 | 5 | This is a grab-bag of stuff I find useful in most programs I write. Some of |
|
6 | 6 | these things are also convenient when working at the command line. |
|
7 | 7 | |
|
8 |
$Id: genutils.py 1 |
|
|
8 | $Id: genutils.py 1845 2006-10-27 20:35:47Z fptest $""" | |
|
9 | 9 | |
|
10 | 10 | #***************************************************************************** |
|
11 | 11 | # Copyright (C) 2001-2006 Fernando Perez. <fperez@colorado.edu> |
@@ -24,6 +24,7 b' import __main__' | |||
|
24 | 24 | import commands |
|
25 | 25 | import os |
|
26 | 26 | import re |
|
27 | import shlex | |
|
27 | 28 | import shutil |
|
28 | 29 | import sys |
|
29 | 30 | import tempfile |
@@ -233,6 +234,17 b' def timing(func,*args,**kw):' | |||
|
233 | 234 | #**************************************************************************** |
|
234 | 235 | # file and system |
|
235 | 236 | |
|
237 | def arg_split(s,posix=False): | |
|
238 | """Split a command line's arguments in a shell-like manner. | |
|
239 | ||
|
240 | This is a modified version of the standard library's shlex.split() | |
|
241 | function, but with a default of posix=False for splitting, so that quotes | |
|
242 | in inputs are respected.""" | |
|
243 | ||
|
244 | lex = shlex.shlex(s, posix=posix) | |
|
245 | lex.whitespace_split = True | |
|
246 | return list(lex) | |
|
247 | ||
|
236 | 248 | def system(cmd,verbose=0,debug=0,header=''): |
|
237 | 249 | """Execute a system command, return its exit status. |
|
238 | 250 |
General Comments 0
You need to be logged in to leave comments.
Login now