Made separateModes int the argument if it can.

This commit is contained in:
Jeremy Fincher 2004-02-16 00:51:29 +00:00
parent 3bdef0fabf
commit 487fb3cc2f
2 changed files with 8 additions and 3 deletions

View File

@ -216,7 +216,7 @@ def separateModes(args):
[('+s', None), ('-o', 'test')] [('+s', None), ('-o', 'test')]
>>> separateModes(['+sntl', '100']) >>> separateModes(['+sntl', '100'])
[('+s', None), ('+n', None), ('+t', None), ('+l', '100')] [('+s', None), ('+n', None), ('+t', None), ('+l', 100)]
""" """
if not args: if not args:
return [] return []
@ -236,7 +236,12 @@ def separateModes(args):
else: else:
requireArguments = _minusRequireArguments requireArguments = _minusRequireArguments
if modes[index] in requireArguments: if modes[index] in requireArguments:
ret.append((last + modes[index], args.pop(0))) arg = args.pop(0)
try:
arg = int(arg)
except ValueError:
pass
ret.append((last + modes[index], arg))
else: else:
ret.append((last + modes[index], None)) ret.append((last + modes[index], None))
index += 1 index += 1

View File

@ -154,7 +154,7 @@ class FunctionsTestCase(unittest.TestCase):
self.assertEqual(ircutils.separateModes(['+s-o', 'x']), self.assertEqual(ircutils.separateModes(['+s-o', 'x']),
[('+s', None), ('-o', 'x')]) [('+s', None), ('-o', 'x')])
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 testToLower(self): def testToLower(self):
self.assertEqual('jemfinch', ircutils.toLower('jemfinch')) self.assertEqual('jemfinch', ircutils.toLower('jemfinch'))