From 068f0293554bff9bbb8d0cc2b0c12d55fb0e9d4a Mon Sep 17 00:00:00 2001 From: James Vega Date: Tue, 10 Jul 2007 14:10:30 +0000 Subject: [PATCH] wrap() String.len to vastly simplify the function and prevent responding with -1 when we get no arguments. Add a test to make sure we respond with the help when called with no arguments. --- plugins/String/plugin.py | 9 +++------ plugins/String/test.py | 1 + 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/plugins/String/plugin.py b/plugins/String/plugin.py index f2eaa5cc5..937b27cde 100644 --- a/plugins/String/plugin.py +++ b/plugins/String/plugin.py @@ -108,16 +108,13 @@ class String(callbacks.Plugin): irc.reply(utils.str.soundex(text, length)) soundex = wrap(soundex, ['somethingWithoutSpaces', additional('int', 4)]) - def len(self, irc, msg, args): + def len(self, irc, msg, args, text): """ Returns the length of . """ - total = 0 - for arg in args: - total += len(arg) - total += len(args)-1 # spaces between the arguments. - irc.reply(str(total)) + irc.reply(str(len(text))) + len = wrap(len, ['text']) def re(self, irc, msg, args, ff, text): """ diff --git a/plugins/String/test.py b/plugins/String/test.py index 46db0fb45..a50e4552a 100644 --- a/plugins/String/test.py +++ b/plugins/String/test.py @@ -77,6 +77,7 @@ class StringTestCase(PluginTestCase): plugins = ('String', 'Format', 'Status') def testLen(self): self.assertResponse('len foo', '3') + self.assertHelp('len') def testNoErrors(self): self.assertNotError('levenshtein Python Perl')