mirror of
https://github.com/Mikaela/Limnoria.git
synced 2024-12-23 03:02:52 +01:00
core: Fix normalizeWhitespace handling of new lines.
This commit is contained in:
parent
29e13a9061
commit
fe39d35b2f
@ -55,13 +55,14 @@ def rsplit(s, sep=None, maxsplit=-1):
|
||||
else:
|
||||
return s.rsplit(sep, maxsplit)
|
||||
|
||||
def normalizeWhitespace(s, removeNewline=False):
|
||||
def normalizeWhitespace(s, removeNewline=True):
|
||||
"""Normalizes the whitespace in a string; \s+ becomes one space."""
|
||||
if not s:
|
||||
return str(s) # not the same reference
|
||||
starts_with_space = (s[0] in ' \n\t')
|
||||
ends_with_space = (s[-1] in ' \n\t')
|
||||
s = ('' if removeNewline else ' ').join(filter(bool, s.split('\n')))
|
||||
if removeNewline:
|
||||
s = ' '.join(filter(bool, s.split('\n')))
|
||||
s = ' '.join(filter(bool, s.split('\t')))
|
||||
s = ' '.join(filter(bool, s.split(' ')))
|
||||
if starts_with_space:
|
||||
|
@ -39,7 +39,7 @@ _ = PluginInternationalization()
|
||||
|
||||
@internationalizeDocstring
|
||||
def foo():
|
||||
'The operation succeeded.'
|
||||
"""The operation succeeded."""
|
||||
pass
|
||||
|
||||
class I18nTestCase(SupyTestCase):
|
||||
@ -49,6 +49,8 @@ class I18nTestCase(SupyTestCase):
|
||||
self.assertEqual(_(msg_en), msg_fr)
|
||||
conf.supybot.language.setValue('en')
|
||||
self.assertEqual(_(msg_en), msg_en)
|
||||
multiline = '%s\n\n%s' % (msg_en, msg_en)
|
||||
self.assertEqual(_(multiline), multiline)
|
||||
|
||||
def testDocstring(self):
|
||||
self.assertEqual(foo.__doc__, msg_en)
|
||||
|
Loading…
Reference in New Issue
Block a user