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:
|
else:
|
||||||
return '*!*@' + host
|
return '*!*@' + host
|
||||||
|
|
||||||
def separateModes(args, requireArguments='ovhblkqe'):
|
_plusRequireArguments = 'ovhblkqe'
|
||||||
|
_minusRequireArguments = 'ocvbkqe'
|
||||||
|
def separateModes(args):
|
||||||
"""Separates modelines into single mode change tuples. Basically, you
|
"""Separates modelines into single mode change tuples. Basically, you
|
||||||
should give it the .args of a MODE IrcMsg.
|
should give it the .args of a MODE IrcMsg.
|
||||||
|
|
||||||
@ -216,9 +218,8 @@ def separateModes(args, requireArguments='ovhblkqe'):
|
|||||||
>>> separateModes(['+sntl', '100'])
|
>>> separateModes(['+sntl', '100'])
|
||||||
[('+s', None), ('+n', None), ('+t', None), ('+l', '100')]
|
[('+s', None), ('+n', None), ('+t', None), ('+l', '100')]
|
||||||
"""
|
"""
|
||||||
if not requireArguments:
|
if not args:
|
||||||
if not isinstance(args, list):
|
return []
|
||||||
args = [args]
|
|
||||||
modes = args[0]
|
modes = args[0]
|
||||||
assert modes[0] in '+-', 'Invalid args: %r' % args
|
assert modes[0] in '+-', 'Invalid args: %r' % args
|
||||||
args = list(args[1:])
|
args = list(args[1:])
|
||||||
@ -230,14 +231,15 @@ def separateModes(args, requireArguments='ovhblkqe'):
|
|||||||
last = modes[index]
|
last = modes[index]
|
||||||
index += 1
|
index += 1
|
||||||
else:
|
else:
|
||||||
|
if last == '+':
|
||||||
|
requireArguments = _plusRequireArguments
|
||||||
|
else:
|
||||||
|
requireArguments = _minusRequireArguments
|
||||||
if modes[index] in requireArguments:
|
if modes[index] in requireArguments:
|
||||||
ret.append((last + modes[index], args.pop(0)))
|
ret.append((last + modes[index], args.pop(0)))
|
||||||
else:
|
else:
|
||||||
ret.append((last + modes[index], None))
|
ret.append((last + modes[index], None))
|
||||||
index += 1
|
index += 1
|
||||||
if not requireArguments: # Special case
|
|
||||||
return [x for (x, y) in ret]
|
|
||||||
else:
|
|
||||||
return ret
|
return ret
|
||||||
|
|
||||||
def joinModes(modes):
|
def joinModes(modes):
|
||||||
|
@ -156,12 +156,6 @@ class FunctionsTestCase(unittest.TestCase):
|
|||||||
self.assertEqual(ircutils.separateModes(['+sntl', '100']),
|
self.assertEqual(ircutils.separateModes(['+sntl', '100']),
|
||||||
[('+s', None),('+n', None),('+t', None),('+l', '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):
|
def testToLower(self):
|
||||||
self.assertEqual('jemfinch', ircutils.toLower('jemfinch'))
|
self.assertEqual('jemfinch', ircutils.toLower('jemfinch'))
|
||||||
self.assertEqual('{}|^', ircutils.toLower('[]\\~'))
|
self.assertEqual('{}|^', ircutils.toLower('[]\\~'))
|
||||||
|
Loading…
Reference in New Issue
Block a user