diff --git a/plugins/Utilities/locale/fr.po b/plugins/Utilities/locale/fr.po index 932921d94..e488e35ca 100644 --- a/plugins/Utilities/locale/fr.po +++ b/plugins/Utilities/locale/fr.po @@ -1,7 +1,7 @@ msgid "" msgstr "" "Project-Id-Version: Supybot-fr\n" -"POT-Creation-Date: 2010-10-20 09:39+CEST\n" +"POT-Creation-Date: 2011-02-20 11:27+CET\n" "PO-Revision-Date: \n" "Last-Translator: Valentin Lorentz \n" "Language-Team: Supybot-fr \n" @@ -71,7 +71,7 @@ msgstr "" msgid "" " [ ...]\n" "\n" -" Shuffles the arguments given it.\n" +" Shuffles the arguments given.\n" " " msgstr "" " [ ...]\n" @@ -80,6 +80,17 @@ msgstr "" #: plugin.py:109 msgid "" +" [ ...]\n" +"\n" +" Randomly chooses items out of the arguments given.\n" +" " +msgstr "" +" [ ...]\n" +"\n" +"Choisi de façon aléatoire un certain d's." + +#: plugin.py:122 +msgid "" " \n" "\n" " Tokenizes and calls with the resulting arguments.\n" diff --git a/plugins/Utilities/messages.pot b/plugins/Utilities/messages.pot index c7187afce..58272ab07 100644 --- a/plugins/Utilities/messages.pot +++ b/plugins/Utilities/messages.pot @@ -5,7 +5,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" -"POT-Creation-Date: 2010-10-20 09:39+CEST\n" +"POT-Creation-Date: 2011-02-20 11:27+CET\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -66,13 +66,22 @@ msgstr "" msgid "" " [ ...]\n" "\n" -" Shuffles the arguments given it.\n" +" Shuffles the arguments given.\n" " " msgstr "" #: plugin.py:109 #, docstring msgid "" +" [ ...]\n" +"\n" +" Randomly chooses items out of the arguments given.\n" +" " +msgstr "" + +#: plugin.py:122 +#, docstring +msgid "" " \n" "\n" " Tokenizes and calls with the resulting arguments.\n" diff --git a/plugins/Utilities/plugin.py b/plugins/Utilities/plugin.py index 5f7fa72eb..767b51a88 100644 --- a/plugins/Utilities/plugin.py +++ b/plugins/Utilities/plugin.py @@ -98,12 +98,25 @@ class Utilities(callbacks.Plugin): def shuffle(self, irc, msg, args, things): """ [ ...] - Shuffles the arguments given it. + Shuffles the arguments given. """ random.shuffle(things) irc.reply(' '.join(things)) shuffle = wrap(shuffle, [many('anything')]) + @internationalizeDocstring + def sample(self, irc, msg, args, num, things): + """ [ ...] + + Randomly chooses items out of the arguments given. + """ + try: + samp = random.sample(things, num) + irc.reply(' '.join(samp)) + except ValueError, e: + irc.error('%s' % (e,)) + sample = wrap(sample, ['positiveInt', many('anything')]) + @internationalizeDocstring def apply(self, irc, msg, args, command, rest): """ diff --git a/plugins/Utilities/test.py b/plugins/Utilities/test.py index 7241b2d61..851a6cae0 100644 --- a/plugins/Utilities/test.py +++ b/plugins/Utilities/test.py @@ -59,4 +59,10 @@ class UtilitiesTestCase(PluginTestCase): def testShuffle(self): self.assertResponse('shuffle a', 'a') + def testSample(self): + self.assertResponse('sample 1 a', 'a') + self.assertError('sample moo') + self.assertError('sample 5 moo') + self.assertRegexp('sample 2 a b c', '^[a-c] [a-c]$') + # vim:set shiftwidth=4 softtabstop=4 expandtab textwidth=79: