Fixed a bugz0r.

This commit is contained in:
Jeremy Fincher 2004-10-01 22:33:02 +00:00
parent 9d5a04ba95
commit 567f0b0001

View File

@ -426,6 +426,8 @@ def args(irc,msg,args, types=[], state=None,
if value != '': # value can be None, remember. if value != '': # value can be None, remember.
key += '=' key += '='
getoptL.append(key) getoptL.append(key)
log.debug(str(getoptL))
def callWrapper(spec): def callWrapper(spec):
if isinstance(spec, tuple): if isinstance(spec, tuple):
assert spec, 'tuple specification cannot be empty.' assert spec, 'tuple specification cannot be empty.'
@ -478,12 +480,14 @@ def args(irc,msg,args, types=[], state=None,
for (opt, arg) in optlist: for (opt, arg) in optlist:
opt = opt[2:] # Strip -- opt = opt[2:] # Strip --
assert opt in getopts assert opt in getopts
log.debug('%s: %r', opt, arg)
if arg is not None: if arg is not None:
assert getopts[opt] != '' assert getopts[opt] != ''
state.getopts.append((opt, callWrapper(getopts[opt]))) state.getopts.append((opt, callWrapper(getopts[opt])))
else: else:
assert getopts[opt] == '' assert getopts[opt] == ''
state.getopts.append((opt, True)) state.getopts.append((opt, True))
log.debug('Finished getopts: %s', state.getopts)
# Second, we get out everything but the last argument (or, if combineRest # Second, we get out everything but the last argument (or, if combineRest
# is False, we'll clear out all the types). # is False, we'll clear out all the types).
@ -517,9 +521,10 @@ def wrap(f, *argsArgs, **argsKwargs):
state = State('%s.%s' % (self.name(), f.func_name), self.log) state = State('%s.%s' % (self.name(), f.func_name), self.log)
state.cb = self # This should probably be in State.__init__. state.cb = self # This should probably be in State.__init__.
_args(irc,msg,args, state=state, *argsArgs, **argsKwargs) _args(irc,msg,args, state=state, *argsArgs, **argsKwargs)
if state.getopts: if 'getopts' in argsKwargs:
f(self, irc, msg, args, state.getopts, *state.args, **state.kwargs) f(self, irc, msg, args, state.getopts, *state.args, **state.kwargs)
else: else:
print state.args, state.kwargs
f(self, irc, msg, args, *state.args, **state.kwargs) f(self, irc, msg, args, *state.args, **state.kwargs)
newf = utils.changeFunctionName(newf, f.func_name, f.__doc__) newf = utils.changeFunctionName(newf, f.func_name, f.__doc__)