diff --git a/IPython/Prompts.py b/IPython/Prompts.py index 7cf62b1..1bd3d24 100644 --- a/IPython/Prompts.py +++ b/IPython/Prompts.py @@ -2,7 +2,7 @@ """ Classes for handling input/output prompts. -$Id: Prompts.py 2192 2007-04-01 20:51:06Z fperez $""" +$Id: Prompts.py 2349 2007-05-15 16:20:35Z vivainio $""" #***************************************************************************** # Copyright (C) 2001-2006 Fernando Perez @@ -512,13 +512,6 @@ class CachedOutput: if self.do_full_cache: cout_write(outprompt) - if isinstance(arg,Macro): - print 'Executing Macro...' - # in case the macro takes a long time to execute - Term.cout.flush() - self.shell.runlines(arg.value) - return None - # and now call a possibly user-defined print mechanism manipulated_val = self.display(arg) diff --git a/IPython/macro.py b/IPython/macro.py index a54c07a..51887f7 100644 --- a/IPython/macro.py +++ b/IPython/macro.py @@ -7,20 +7,32 @@ # the file COPYING, distributed as part of this software. #***************************************************************************** +import IPython.ipapi + + +from IPython.genutils import Term + + class Macro: """Simple class to store the value of macros as strings. - This allows us to later exec them by checking when something is an - instance of this class.""" + Macro is just a callable that executes a string of IPython + input when called. + """ def __init__(self,data): # store the macro value, as a single string which can be evaluated by # runlines() self.value = ''.join(data).rstrip()+'\n' - + def __str__(self): return self.value def __repr__(self): - return 'IPython.macro.Macro(%s)' % repr(self.value) \ No newline at end of file + return 'IPython.macro.Macro(%s)' % repr(self.value) + + def __call__(self): + Term.cout.flush() + ip = IPython.ipapi.get() + ip.runlines(self.value) \ No newline at end of file diff --git a/doc/ChangeLog b/doc/ChangeLog index 84f9dc7..c65d3e7 100644 --- a/doc/ChangeLog +++ b/doc/ChangeLog @@ -10,9 +10,6 @@ * Magic.py, ipy_rehashdir.py, ipy_profile_sh.py: System command aliases are now lower case on windows (MyCommand.exe => mycommand). - - - 2007-05-10 Fernando Perez