comparison cmd2.py @ 212:9c4c4d012a92

parameter onchange hook
author catherine@Elli.myhome.westell.com
date Sat, 14 Mar 2009 20:03:57 -0400
parents 5da7d72e72ee
children 500955dece3f
comparison
equal deleted inserted replaced
211:5da7d72e72ee 212:9c4c4d012a92
697 val = val[1:-1] 697 val = val[1:-1]
698 else: 698 else:
699 val = cast(currentVal, val) 699 val = cast(currentVal, val)
700 setattr(self, paramName, val) 700 setattr(self, paramName, val)
701 self.stdout.write('%s - was: %s\nnow: %s\n' % (paramName, currentVal, val)) 701 self.stdout.write('%s - was: %s\nnow: %s\n' % (paramName, currentVal, val))
702 if currentVal != val:
703 try:
704 onchange_hook = getattr(self, '_onchange_%s' % paramName)
705 onchange_hook(old=currentVal, new=val)
706 except AttributeError:
707 pass
702 else: 708 else:
703 self.do_show(paramName) 709 self.do_show(paramName)
704 except (ValueError, AttributeError, NotSettableError), e: 710 except (ValueError, AttributeError, NotSettableError), e:
705 self.do_show(arg) 711 self.do_show(arg)
706 712