Converted commands.py to use the new utils.web instead of webutils; fixed a bug in the httpUrl converter which rejected https protocols.

This commit is contained in:
Jeremy Fincher 2005-01-28 14:51:25 +00:00
parent 933be49ff2
commit e1fe232e9b
2 changed files with 10 additions and 4 deletions

View File

@ -43,7 +43,6 @@ import supybot.world as world
import supybot.ircdb as ircdb import supybot.ircdb as ircdb
import supybot.ircmsgs as ircmsgs import supybot.ircmsgs as ircmsgs
import supybot.ircutils as ircutils import supybot.ircutils as ircutils
import supybot.webutils as webutils
import supybot.callbacks as callbacks import supybot.callbacks as callbacks
import supybot.structures as structures import supybot.structures as structures
@ -78,7 +77,7 @@ class UrlSnarfThread(world.SupyThread):
def run(self): def run(self):
try: try:
super(UrlSnarfThread, self).run() super(UrlSnarfThread, self).run()
except webutils.WebError, e: except utils.web.Error, e:
log.debug('Exception in urlSnarfer: %s' % utils.exnToString(e)) log.debug('Exception in urlSnarfer: %s' % utils.exnToString(e))
class SnarfQueue(ircutils.FloodQueue): class SnarfQueue(ircutils.FloodQueue):
@ -469,13 +468,13 @@ def getGlob(irc, msg, args, state):
state.args.append(glob) state.args.append(glob)
def getUrl(irc, msg, args, state): def getUrl(irc, msg, args, state):
if webutils.urlRe.match(args[0]): if utils.web.urlRe.match(args[0]):
state.args.append(args.pop(0)) state.args.append(args.pop(0))
else: else:
irc.errorInvalid('url', args[0]) irc.errorInvalid('url', args[0])
def getHttpUrl(irc, msg, args, state): def getHttpUrl(irc, msg, args, state):
if webutils.urlRe.match(args[0]) and args[0].startswith('http://'): if utils.web.httpUrlRe.match(args[0]):
state.args.append(args.pop(0)) state.args.append(args.pop(0))
else: else:
irc.errorInvalid('http url', args[0]) irc.errorInvalid('http url', args[0])

View File

@ -47,6 +47,8 @@ class CommandsTestCase(SupyTestCase):
self.assertEqual(state.args, expected, self.assertEqual(state.args, expected,
'Expected %r, got %r' % (expected, state.args)) 'Expected %r, got %r' % (expected, state.args))
class GeneralContextTestCase(CommandsTestCase):
def testEmptySpec(self): def testEmptySpec(self):
self.assertState([], [], []) self.assertState([], [], [])
@ -133,6 +135,11 @@ class CommandsTestCase(SupyTestCase):
self.assertRaises(callbacks.ArgumentError, self.assertRaises(callbacks.ArgumentError,
self.assertState, spec, ['ba'], ['baz']) self.assertState, spec, ['ba'], ['baz'])
class ConverterTestCase(CommandsTestCase):
def testUrlAllowsHttps(self):
url = 'https://foo.bar/baz'
self.assertState(['url'], [url], [url])
self.assertState(['httpUrl'], [url], [url])
# vim:set shiftwidth=4 tabstop=8 expandtab textwidth=78: # vim:set shiftwidth=4 tabstop=8 expandtab textwidth=78: