Added an XXX.

This commit is contained in:
Jeremy Fincher 2004-10-19 16:43:09 +00:00
parent 3f16003371
commit 2179548da9
1 changed files with 30 additions and 6 deletions

View File

@ -35,10 +35,9 @@ __revision__ = "$Id$"
import supybot.fix as fix import supybot.fix as fix
import getopt
import time import time
import types import types
import getopt
import threading import threading
import supybot.log as log import supybot.log as log
@ -280,7 +279,8 @@ def getOtherUser(irc, msg, args, state):
hostmask = state.args.pop() hostmask = state.args.pop()
state.args.append(ircdb.users.getUser(hostmask)) state.args.append(ircdb.users.getUser(hostmask))
except (KeyError, IndexError, callbacks.Error): except (KeyError, IndexError, callbacks.Error):
irc.errorNoUser(Raise=True) # XXX We should eventually give the user here.
irc.errorNoUser()
def _getRe(f): def _getRe(f):
def get(irc, msg, args, state): def get(irc, msg, args, state):
@ -293,9 +293,12 @@ def _getRe(f):
except ValueError: except ValueError:
return False return False
try: try:
while not isRe(s): while len(s) < 512 and not isRe(s):
s += ' ' + args.pop(0) s += ' ' + args.pop(0)
state.args.append(f(s)) if len(s) < 512:
state.args.append(f(s))
else:
irc.errorInvalid('regular expression')
except IndexError: except IndexError:
args[:] = original args[:] = original
raise raise
@ -628,6 +631,26 @@ class many(any):
state.args.pop() state.args.pop()
raise callbacks.ArgumentError raise callbacks.ArgumentError
class first(context):
def __init__(self, *specs, **kw):
if 'default' in kw:
self.default = kw.pop('default')
assert not kw, 'Bad kwargs for first.__init__'
self.specs = map(contextify, specs)
def __call__(self, irc, msg, args, state):
for spec in self.specs:
try:
spec(irc, msg, args, state)
return
except Exception, e:
continue
if hasattr(self, 'default'):
state.args.append(self.default)
else:
raise e
class getopts(context): class getopts(context):
"""The empty string indicates that no argument is taken; None indicates """The empty string indicates that no argument is taken; None indicates
that there is no converter for the argument.""" that there is no converter for the argument."""
@ -751,7 +774,8 @@ def wrap(f, specList=[], decorators=None, **kw):
return newf return newf
__all__ = ['wrap', 'context', 'additional', 'optional', 'any', 'compose','Spec', __all__ = ['wrap', 'context', 'additional', 'optional', 'any', 'compose',
'Spec', 'first',
'many', 'getopts', 'getConverter', 'addConverter', 'callConverter'] 'many', 'getopts', 'getConverter', 'addConverter', 'callConverter']
if world.testing: if world.testing: