Show More
@@ -2,7 +2,7 b'' | |||
|
2 | 2 | """ |
|
3 | 3 | Classes for handling input/output prompts. |
|
4 | 4 | |
|
5 |
$Id: Prompts.py 2 |
|
|
5 | $Id: Prompts.py 2349 2007-05-15 16:20:35Z vivainio $""" | |
|
6 | 6 | |
|
7 | 7 | #***************************************************************************** |
|
8 | 8 | # Copyright (C) 2001-2006 Fernando Perez <fperez@colorado.edu> |
@@ -512,13 +512,6 b' class CachedOutput:' | |||
|
512 | 512 | if self.do_full_cache: |
|
513 | 513 | cout_write(outprompt) |
|
514 | 514 | |
|
515 | if isinstance(arg,Macro): | |
|
516 | print 'Executing Macro...' | |
|
517 | # in case the macro takes a long time to execute | |
|
518 | Term.cout.flush() | |
|
519 | self.shell.runlines(arg.value) | |
|
520 | return None | |
|
521 | ||
|
522 | 515 | # and now call a possibly user-defined print mechanism |
|
523 | 516 | manipulated_val = self.display(arg) |
|
524 | 517 |
@@ -7,20 +7,32 b'' | |||
|
7 | 7 | # the file COPYING, distributed as part of this software. |
|
8 | 8 | #***************************************************************************** |
|
9 | 9 | |
|
10 | import IPython.ipapi | |
|
11 | ||
|
12 | ||
|
13 | from IPython.genutils import Term | |
|
14 | ||
|
15 | ||
|
10 | 16 | class Macro: |
|
11 | 17 | """Simple class to store the value of macros as strings. |
|
12 | 18 | |
|
13 | This allows us to later exec them by checking when something is an | |
|
14 | instance of this class.""" | |
|
19 | Macro is just a callable that executes a string of IPython | |
|
20 | input when called. | |
|
21 | """ | |
|
15 | 22 | |
|
16 | 23 | def __init__(self,data): |
|
17 | 24 | |
|
18 | 25 | # store the macro value, as a single string which can be evaluated by |
|
19 | 26 | # runlines() |
|
20 | 27 | self.value = ''.join(data).rstrip()+'\n' |
|
21 | ||
|
28 | ||
|
22 | 29 | def __str__(self): |
|
23 | 30 | return self.value |
|
24 | 31 | |
|
25 | 32 | def __repr__(self): |
|
26 | return 'IPython.macro.Macro(%s)' % repr(self.value) No newline at end of file | |
|
33 | return 'IPython.macro.Macro(%s)' % repr(self.value) | |
|
34 | ||
|
35 | def __call__(self): | |
|
36 | Term.cout.flush() | |
|
37 | ip = IPython.ipapi.get() | |
|
38 | ip.runlines(self.value) No newline at end of file |
General Comments 0
You need to be logged in to leave comments.
Login now