mirror of
https://github.com/Mikaela/Limnoria.git
synced 2024-11-23 02:49:27 +01:00
Fixed G-LiTe's bug with -l.
This commit is contained in:
parent
b96dab0a03
commit
5d3a3437db
@ -198,7 +198,9 @@ def banmask(hostmask):
|
||||
else:
|
||||
return '*!*@' + host
|
||||
|
||||
def separateModes(args, requireArguments='ovhblkqe'):
|
||||
_plusRequireArguments = 'ovhblkqe'
|
||||
_minusRequireArguments = 'ocvbkqe'
|
||||
def separateModes(args):
|
||||
"""Separates modelines into single mode change tuples. Basically, you
|
||||
should give it the .args of a MODE IrcMsg.
|
||||
|
||||
@ -216,9 +218,8 @@ def separateModes(args, requireArguments='ovhblkqe'):
|
||||
>>> separateModes(['+sntl', '100'])
|
||||
[('+s', None), ('+n', None), ('+t', None), ('+l', '100')]
|
||||
"""
|
||||
if not requireArguments:
|
||||
if not isinstance(args, list):
|
||||
args = [args]
|
||||
if not args:
|
||||
return []
|
||||
modes = args[0]
|
||||
assert modes[0] in '+-', 'Invalid args: %r' % args
|
||||
args = list(args[1:])
|
||||
@ -230,14 +231,15 @@ def separateModes(args, requireArguments='ovhblkqe'):
|
||||
last = modes[index]
|
||||
index += 1
|
||||
else:
|
||||
if last == '+':
|
||||
requireArguments = _plusRequireArguments
|
||||
else:
|
||||
requireArguments = _minusRequireArguments
|
||||
if modes[index] in requireArguments:
|
||||
ret.append((last + modes[index], args.pop(0)))
|
||||
else:
|
||||
ret.append((last + modes[index], None))
|
||||
index += 1
|
||||
if not requireArguments: # Special case
|
||||
return [x for (x, y) in ret]
|
||||
else:
|
||||
return ret
|
||||
|
||||
def joinModes(modes):
|
||||
|
@ -156,12 +156,6 @@ class FunctionsTestCase(unittest.TestCase):
|
||||
self.assertEqual(ircutils.separateModes(['+sntl', '100']),
|
||||
[('+s', None),('+n', None),('+t', None),('+l', '100')])
|
||||
|
||||
def testSeparateModesWithoutRequireArguments(self):
|
||||
self.assertEqual(ircutils.separateModes(['+oo-b'], ''),
|
||||
['+o', '+o', '-b'])
|
||||
self.assertEqual(ircutils.separateModes('+oo-b', ''),
|
||||
['+o', '+o', '-b'])
|
||||
|
||||
def testToLower(self):
|
||||
self.assertEqual('jemfinch', ircutils.toLower('jemfinch'))
|
||||
self.assertEqual('{}|^', ircutils.toLower('[]\\~'))
|
||||
|
Loading…
Reference in New Issue
Block a user