mirror of
https://github.com/Mikaela/Limnoria.git
synced 2025-01-11 12:42:34 +01:00
Added a name= keyword argument for commands.wrap, to override the name of the method being wrapped.
This commit is contained in:
parent
7c2bbeb638
commit
fc2a18bdb3
@ -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.
|
||||||
|
Loading…
Reference in New Issue
Block a user