mirror of
https://github.com/Mikaela/Limnoria.git
synced 2024-11-27 05:09:23 +01:00
add replace function to format that takes varying-length strings to replace.
add test for it add error test for format.translate for different length translate args.
This commit is contained in:
parent
2d718d31bb
commit
dae8dfd2e7
@ -99,6 +99,15 @@ class Format(callbacks.Plugin):
|
|||||||
translate = wrap(translate, ['something', 'something', 'text'])
|
translate = wrap(translate, ['something', 'something', 'text'])
|
||||||
|
|
||||||
@internationalizeDocstring
|
@internationalizeDocstring
|
||||||
|
def replace(self, irc, msg, args, bad, good, text):
|
||||||
|
"""<substring to translate> <substring to replace it with> <text>
|
||||||
|
|
||||||
|
Replaces all non-overlapping occurrences of <substring to translate>
|
||||||
|
with <substring to replace it with> in <text>.
|
||||||
|
"""
|
||||||
|
irc.reply(text.replace(bad, good))
|
||||||
|
replace = wrap(replace, ['something', 'something', 'text'])
|
||||||
|
|
||||||
def upper(self, irc, msg, args, text):
|
def upper(self, irc, msg, args, text):
|
||||||
"""<text>
|
"""<text>
|
||||||
|
|
||||||
|
@ -54,6 +54,10 @@ class FormatTestCase(PluginTestCase):
|
|||||||
|
|
||||||
def testTranslate(self):
|
def testTranslate(self):
|
||||||
self.assertResponse('translate 123 456 1234567890', '4564567890')
|
self.assertResponse('translate 123 456 1234567890', '4564567890')
|
||||||
|
self.assertError('translate 123 1234 123125151')
|
||||||
|
|
||||||
|
def testReplace(self):
|
||||||
|
self.assertResponse('replace # %23 bla#foo', 'bla%23foo')
|
||||||
|
|
||||||
def testUpper(self):
|
def testUpper(self):
|
||||||
self.assertResponse('upper foo', 'FOO')
|
self.assertResponse('upper foo', 'FOO')
|
||||||
|
Loading…
Reference in New Issue
Block a user