From 9307b60bca91defde5d571066fcde80edd1775ca Mon Sep 17 00:00:00 2001 From: Keegi Date: Wed, 8 Jun 2011 22:11:59 +0300 Subject: [PATCH] bugfix reading multi-line macros from .pronsolerc --- pronsole.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/pronsole.py b/pronsole.py index 6012021..62b8c93 100644 --- a/pronsole.py +++ b/pronsole.py @@ -81,6 +81,7 @@ class pronsole(cmd.Cmd): return [] def hook_macro(self,l): + l = l.rstrip() ls = l.lstrip() ws = l[:len(l)-len(ls)] # just leading whitespace if len(ws)==0: @@ -100,14 +101,13 @@ class pronsole(cmd.Cmd): print "Macro '"+self.cur_macro_name+"' defined" #print self.cur_macro+"------------" # debug self.prompt="PC>" - if self.cur_macro_def=="": + if self.cur_macro_def!="": + self.macros[self.cur_macro_name] = self.cur_macro_def + exec self.cur_macro + setattr(self.__class__,"do_"+self.cur_macro_name,lambda self,largs,macro=macro:macro(self,*largs.split())) + setattr(self.__class__,"help_"+self.cur_macro_name,lambda self,macro_name=self.cur_macro_name: self.subhelp_macro(macro_name)) + else: print "Empty macro - cancelled" - del self.cur_macro,self.cur_macro_name,self.cur_macro_def - return - self.macros[self.cur_macro_name] = self.cur_macro_def - exec self.cur_macro - setattr(self.__class__,"do_"+self.cur_macro_name,lambda self,largs,macro=macro:macro(self,*largs.split())) - setattr(self.__class__,"help_"+self.cur_macro_name,lambda self,macro_name=self.cur_macro_name: self.subhelp_macro(macro_name)) del self.cur_macro,self.cur_macro_name,self.cur_macro_def def do_macro(self,args):