From 487fb3cc2fe21fc0b2c3317591788d07889a26b4 Mon Sep 17 00:00:00 2001 From: Jeremy Fincher Date: Mon, 16 Feb 2004 00:51:29 +0000 Subject: [PATCH] Made separateModes int the argument if it can. --- src/ircutils.py | 9 +++++++-- test/test_ircutils.py | 2 +- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/ircutils.py b/src/ircutils.py index c93ac6508..f1bbd386b 100644 --- a/src/ircutils.py +++ b/src/ircutils.py @@ -216,7 +216,7 @@ def separateModes(args): [('+s', None), ('-o', 'test')] >>> separateModes(['+sntl', '100']) - [('+s', None), ('+n', None), ('+t', None), ('+l', '100')] + [('+s', None), ('+n', None), ('+t', None), ('+l', 100)] """ if not args: return [] @@ -236,7 +236,12 @@ def separateModes(args): else: requireArguments = _minusRequireArguments 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: ret.append((last + modes[index], None)) index += 1 diff --git a/test/test_ircutils.py b/test/test_ircutils.py index af4a3a97c..00863d10a 100644 --- a/test/test_ircutils.py +++ b/test/test_ircutils.py @@ -154,7 +154,7 @@ class FunctionsTestCase(unittest.TestCase): self.assertEqual(ircutils.separateModes(['+s-o', 'x']), [('+s', None), ('-o', 'x')]) 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): self.assertEqual('jemfinch', ircutils.toLower('jemfinch'))