mirror of
https://github.com/Mikaela/Limnoria.git
synced 2024-12-22 18:52:45 +01:00
Swapped the argument order for nItems *again*.
This commit is contained in:
parent
e248012369
commit
34f1fe6562
@ -866,7 +866,7 @@ class IrcObjectProxy(RichReplyMethods):
|
||||
response = msgs.pop()
|
||||
if msgs:
|
||||
n = ircutils.bold('(%s)')
|
||||
n %= utils.str.nItems('message', len(msgs), 'more')
|
||||
n %= utils.str.nItems(len(msgs), 'message', 'more')
|
||||
response = '%s %s' % (response, n)
|
||||
prefix = msg.prefix
|
||||
if self.to and ircutils.isNick(self.to):
|
||||
|
@ -81,7 +81,7 @@ def timeElapsed(elapsed, short=False, leadingZeroes=False, years=True,
|
||||
if short:
|
||||
ret.append('%s%s' % (i, s[0]))
|
||||
else:
|
||||
ret.append(nItems(s, i))
|
||||
ret.append(nItems(i, s))
|
||||
elapsed = int(elapsed)
|
||||
assert years or weeks or days or \
|
||||
hours or minutes or seconds, 'One flag must be True'
|
||||
|
@ -285,18 +285,20 @@ def depluralize(s):
|
||||
else:
|
||||
return s # Don't know what to do.
|
||||
|
||||
def nItems(item, n, between=None):
|
||||
def nItems(n, item, between=None):
|
||||
"""Works like this:
|
||||
|
||||
>>> nItems('clock', 1)
|
||||
>>> nItems(1, 'clock')
|
||||
'1 clock'
|
||||
|
||||
>>> nItems('clock', 10)
|
||||
>>> nItems(10, 'clock')
|
||||
'10 clocks'
|
||||
|
||||
>>> nItems('clock', 10, between='grandfather')
|
||||
>>> nItems(10, 'clock', between='grandfather')
|
||||
'10 grandfather clocks'
|
||||
"""
|
||||
assert isinstance(n, int), \
|
||||
'The order of the arguments to nItems changed again, sorry.'
|
||||
if between is None:
|
||||
return '%s %s' % (n, pluralize(item, n))
|
||||
else:
|
||||
|
@ -335,10 +335,10 @@ class StrTest(SupyTestCase):
|
||||
|
||||
def testNItems(self):
|
||||
nItems = utils.str.nItems
|
||||
self.assertEqual(nItems('tool', 1, 'crazy'), '1 crazy tool')
|
||||
self.assertEqual(nItems('tool', 1), '1 tool')
|
||||
self.assertEqual(nItems('tool', 2, 'crazy'), '2 crazy tools')
|
||||
self.assertEqual(nItems('tool', 2), '2 tools')
|
||||
self.assertEqual(nItems(1, 'tool', 'crazy'), '1 crazy tool')
|
||||
self.assertEqual(nItems(1, 'tool'), '1 tool')
|
||||
self.assertEqual(nItems(2, 'tool', 'crazy'), '2 crazy tools')
|
||||
self.assertEqual(nItems(2, 'tool'), '2 tools')
|
||||
|
||||
def testEllipsisify(self):
|
||||
f = utils.str.ellipsisify
|
||||
|
Loading…
Reference in New Issue
Block a user