mirror of
https://github.com/Mikaela/Limnoria.git
synced 2024-11-26 12:49:24 +01:00
Let's make sure to zfill those digits before we mircColor.
This commit is contained in:
parent
d7df686b0c
commit
c064aa1155
@ -305,10 +305,13 @@ def mircColor(s, fg=None, bg=None):
|
||||
if fg is None or isinstance(fg, str):
|
||||
fg = mircColors[fg]
|
||||
if bg is None:
|
||||
fg = str(fg).zfill(2)
|
||||
return '\x03%s%s\x03' % (fg, s)
|
||||
else:
|
||||
# We don't need to zfill fg here because the comma delimits it.
|
||||
if isinstance(bg, str):
|
||||
bg = mircColors[bg]
|
||||
bg = str(bg).zfill(2)
|
||||
return '\x03%s,%s%s\x03' % (fg, bg, s)
|
||||
|
||||
def canonicalColor(s, bg=False, shift=0):
|
||||
|
@ -108,13 +108,13 @@ class FunctionsTestCase(SupyTestCase):
|
||||
s = 'foo'
|
||||
self.assertEqual(s, ircutils.mircColor(s))
|
||||
# Test positional args
|
||||
self.assertEqual('\x030foo\x03', ircutils.mircColor(s, 'white'))
|
||||
self.assertEqual('\x031,2foo\x03',ircutils.mircColor(s,'black','blue'))
|
||||
self.assertEqual('\x03,3foo\x03', ircutils.mircColor(s, None, 'green'))
|
||||
self.assertEqual('\x0300foo\x03', ircutils.mircColor(s, 'white'))
|
||||
self.assertEqual('\x031,02foo\x03',ircutils.mircColor(s,'black','blue'))
|
||||
self.assertEqual('\x03,03foo\x03', ircutils.mircColor(s, None, 'green'))
|
||||
# Test keyword args
|
||||
self.assertEqual('\x034foo\x03', ircutils.mircColor(s, fg='red'))
|
||||
self.assertEqual('\x03,5foo\x03', ircutils.mircColor(s, bg='brown'))
|
||||
self.assertEqual('\x036,7foo\x03',
|
||||
self.assertEqual('\x0304foo\x03', ircutils.mircColor(s, fg='red'))
|
||||
self.assertEqual('\x03,05foo\x03', ircutils.mircColor(s, bg='brown'))
|
||||
self.assertEqual('\x036,07foo\x03',
|
||||
ircutils.mircColor(s, bg='orange', fg='purple'))
|
||||
|
||||
def testMircColors(self):
|
||||
|
Loading…
Reference in New Issue
Block a user