mirror of
https://github.com/Mikaela/Limnoria.git
synced 2024-11-24 03:29:28 +01:00
Fixed bugs in getopt handling with arguments.
This commit is contained in:
parent
e21be94af0
commit
dc55a330fa
@ -320,8 +320,8 @@ def getChannelOrNone(irc, msg, args, state):
|
|||||||
state.args.append(None)
|
state.args.append(None)
|
||||||
|
|
||||||
def checkChannelCapability(irc, msg, args, state, cap):
|
def checkChannelCapability(irc, msg, args, state, cap):
|
||||||
assert state.channel, \
|
assert not state.channel, 'checkChannelCapability acts as a channel.'
|
||||||
'You must use a channel arg before you use checkChannelCapability.'
|
getChannel(irc, msg, args, state)
|
||||||
cap = ircdb.canonicalCapability(cap)
|
cap = ircdb.canonicalCapability(cap)
|
||||||
cap = ircdb.makeChannelCapability(state.channel, cap)
|
cap = ircdb.makeChannelCapability(state.channel, cap)
|
||||||
if not ircdb.checkCapability(msg.prefix, cap):
|
if not ircdb.checkCapability(msg.prefix, cap):
|
||||||
@ -396,6 +396,7 @@ wrappers = ircutils.IrcDict({
|
|||||||
'something': getSomething,
|
'something': getSomething,
|
||||||
'text': anything,
|
'text': anything,
|
||||||
'somethingWithoutSpaces': getSomethingNoSpaces,
|
'somethingWithoutSpaces': getSomethingNoSpaces,
|
||||||
|
'capability': getSomethingNoSpaces,
|
||||||
'channelDb': getChannelDb,
|
'channelDb': getChannelDb,
|
||||||
'hostmask': getHostmask,
|
'hostmask': getHostmask,
|
||||||
'banmask': getBanmask,
|
'banmask': getBanmask,
|
||||||
@ -483,7 +484,7 @@ def args(irc,msg,args, types=[], state=None,
|
|||||||
state.args.append(default)
|
state.args.append(default)
|
||||||
else:
|
else:
|
||||||
state.log.debug('Raising ArgumentError because of '
|
state.log.debug('Raising ArgumentError because of '
|
||||||
'non-optional args.')
|
'non-optional args: %r', spec)
|
||||||
raise callbacks.ArgumentError
|
raise callbacks.ArgumentError
|
||||||
|
|
||||||
# First, we getopt stuff.
|
# First, we getopt stuff.
|
||||||
@ -494,8 +495,16 @@ def args(irc,msg,args, types=[], state=None,
|
|||||||
assert opt in getopts
|
assert opt in getopts
|
||||||
log.debug('%s: %r', opt, arg)
|
log.debug('%s: %r', opt, arg)
|
||||||
if arg is not None:
|
if arg is not None:
|
||||||
|
# This is a MESS. But I can't think of a better way to do it.
|
||||||
assert getopts[opt] != ''
|
assert getopts[opt] != ''
|
||||||
state.getopts.append((opt, callWrapper(getopts[opt])))
|
originalArgs = args
|
||||||
|
args = [arg]
|
||||||
|
originalLen = len(state.args)
|
||||||
|
callWrapper(getopts[opt])
|
||||||
|
args = originalArgs
|
||||||
|
assert originalLen == len(state.args)-1
|
||||||
|
assert not args
|
||||||
|
state.getopts.append((opt, state.args.pop()))
|
||||||
else:
|
else:
|
||||||
assert getopts[opt] == ''
|
assert getopts[opt] == ''
|
||||||
state.getopts.append((opt, True))
|
state.getopts.append((opt, True))
|
||||||
|
Loading…
Reference in New Issue
Block a user