def i_will(): iwill = will() func = lambda: 0 func.will = iwill # return the function itself # so that we can retrieve it after the attribute call func.abc = func return func
def wrapper(self, *args, **kwargs): # Update actions self.did, self.curr = self.curr, self.will self.will = will(2, raise_exc=False) if self.curr in finals and self.will in proxy.holding_left: raise CmdyActionError("Action taken after a final action.") # Initialize data # Make it True to tell future actions that I have been called # Just in case some plugins forget to do this self.data.setdefault(_cmdy_plugin_funcname(func), {}) return func(self, *args, **kwargs)
def func(raise_exc): wil = will(raise_exc=raise_exc) ret = lambda: None ret.a = 1 ret.will = wil return ret
def get_will(): return {'a': will(raise_exc=True)}
def iwill(self): self.will = will() return self
def get_will(): return will(2)
def permit(self): self.will = will(raise_exc=False) if self.will == 'do': # let self handle do return self raise AttributeError('Should do something with AwesomeClass object')