Swapped the argument order for nItems *again*.

This commit is contained in:
Jeremy Fincher 2005-01-28 15:17:26 +00:00
parent e248012369
commit 34f1fe6562
4 changed files with 12 additions and 10 deletions

View File

@ -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):

View File

@ -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'

View File

@ -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:

View File

@ -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