Added a name= keyword argument for commands.wrap, to override the name of the method being wrapped.

This commit is contained in:
Jeremy Fincher 2005-02-28 07:58:46 +00:00
parent 7c2bbeb638
commit fc2a18bdb3

View File

@ -878,7 +878,7 @@ class Spec(object):
raise callbacks.ArgumentError raise callbacks.ArgumentError
return state return state
def wrap(f, specList=[], **kw): def wrap(f, specList=[], name=None, **kw):
spec = Spec(specList, **kw) spec = Spec(specList, **kw)
def newf(self, irc, msg, args, **kwargs): def newf(self, irc, msg, args, **kwargs):
state = spec(irc, msg, args, stateAttrs={'cb': self, 'log': self.log}) state = spec(irc, msg, args, stateAttrs={'cb': self, 'log': self.log})
@ -891,7 +891,7 @@ def wrap(f, specList=[], **kw):
funcArgs = inspect.getargs(f.func_code)[0][len(self.commandArgs):] funcArgs = inspect.getargs(f.func_code)[0][len(self.commandArgs):]
self.log.error('Extra args: %s', funcArgs) self.log.error('Extra args: %s', funcArgs)
raise raise
return utils.changeFunctionName(newf, f.func_name, f.__doc__) return utils.changeFunctionName(newf, name or f.func_name, f.__doc__)
__all__ = [ __all__ = [
# Contexts. # Contexts.