mirror of
https://github.com/Mikaela/Limnoria.git
synced 2024-11-26 04:39:26 +01:00
Fix previous commit.
This commit is contained in:
parent
63a17f7491
commit
030ce5e6d4
@ -36,7 +36,7 @@ class GamesTestCase(ChannelPluginTestCase):
|
||||
self.irc.feedMsg(ircmsgs.op(self.channel, self.irc.nick))
|
||||
sawKick = False
|
||||
for i in range(100):
|
||||
m = self.getMsg('roulette', frm='someoneElse')
|
||||
m = self.getMsg('roulette', frm='someoneElse!foo@bar')
|
||||
if m.command == 'PRIVMSG':
|
||||
self.failUnless(self._nonKickRe.search(m.args[1]),
|
||||
'Got a msg without bang|click|spin: %r' % m)
|
||||
|
@ -926,7 +926,7 @@ class NestedCommandsIrcProxy(ReplyIrcProxy):
|
||||
maximumLength, len(s))
|
||||
s = s[:maximumLength]
|
||||
s_size = len(s.encode()) if minisix.PY3 else len(s)
|
||||
if s_size > allowedLength or \
|
||||
if s_size <= allowedLength or \
|
||||
not conf.get(conf.supybot.reply.mores, target):
|
||||
# In case we're truncating, we add 20 to allowedLength,
|
||||
# because our allowedLength is shortened for the
|
||||
|
@ -598,7 +598,8 @@ class FormatParser(object):
|
||||
|
||||
def wrap(s, length, break_on_hyphens = False, break_long_words = False):
|
||||
processed = []
|
||||
chunks = utils.str.byteTextWrap(s, length)
|
||||
chunks = utils.str.byteTextWrap(s, length,
|
||||
break_long_words=break_long_words)
|
||||
context = None
|
||||
for chunk in chunks:
|
||||
if context is not None:
|
||||
|
@ -306,7 +306,7 @@ def perlVariableSubstitute(vars, text):
|
||||
return '$' + unbraced
|
||||
return _perlVarSubstituteRe.sub(replacer, text)
|
||||
|
||||
def byteTextWrap(text, size):
|
||||
def byteTextWrap(text, size, break_on_hyphens=False, break_long_words=True):
|
||||
"""Similar to textwrap.wrap(), but considers the size of strings (in bytes)
|
||||
instead of their length (in characters)."""
|
||||
words = textwrap.TextWrapper()._split_chunks(text)
|
||||
@ -316,6 +316,9 @@ def byteTextWrap(text, size):
|
||||
lines = [b'']
|
||||
while words:
|
||||
word = words.pop(-1)
|
||||
if len(word) > size:
|
||||
words.append(word[size:])
|
||||
word = word[0:size]
|
||||
if len(lines[-1]) + len(word) <= size:
|
||||
lines[-1] += word
|
||||
else:
|
||||
|
@ -195,6 +195,26 @@ class FunctionsTestCase(SupyTestCase):
|
||||
self.assertTrue(max(map(pred, r)) <= 100)
|
||||
self.assertEqual(''.join(r), s)
|
||||
|
||||
s = ('foobarbazqux ' * 100)[0:-1]
|
||||
|
||||
r = ircutils.wrap(s, 10)
|
||||
self.assertTrue(max(map(pred, r)) <= 10)
|
||||
self.assertEqual(''.join(r), s)
|
||||
|
||||
r = ircutils.wrap(s, 100)
|
||||
self.assertTrue(max(map(pred, r)) <= 100)
|
||||
self.assertEqual(''.join(r), s)
|
||||
|
||||
s = ('foobarbazqux' * 100)[0:-1]
|
||||
|
||||
r = ircutils.wrap(s, 10)
|
||||
self.assertTrue(max(map(pred, r)) <= 10)
|
||||
self.assertEqual(''.join(r), s)
|
||||
|
||||
r = ircutils.wrap(s, 100)
|
||||
self.assertTrue(max(map(pred, r)) <= 100)
|
||||
self.assertEqual(''.join(r), s)
|
||||
|
||||
|
||||
def testSafeArgument(self):
|
||||
s = 'I have been running for 9 seconds'
|
||||
|
Loading…
Reference in New Issue
Block a user