swap the order of cardinalize()'s arguments after intuiting the wrong order a couple times. gotta be consistent, this isn't PHP.

This commit is contained in:
Mahmoud Hashemi 2013-05-31 23:43:37 -07:00
parent cc1a422b79
commit 77b536d516
2 changed files with 5 additions and 5 deletions

View File

@ -88,7 +88,7 @@ def unit_len(sized_iterable, unit_noun='item'): # TODO: len_units()/unitize()?
No worries
"""
count = len(sized_iterable)
units = cardinalize(count, unit_noun)
units = cardinalize(unit_noun, count)
if count:
return u'%s %s' % (count, units)
return u'No %s' % (units,)
@ -121,15 +121,15 @@ def ordinalize(number, ext_only=False):
return numstr + ext
def cardinalize(count, unit_noun):
def cardinalize(unit_noun, count):
"""\
Conditionally pluralizes a singular word ``unit_noun`` if
``count`` is not one, preserving case when possible.
>>> vowels = 'aeiou'
>>> print len(vowels), cardinalize(len(vowels), 'vowel')
>>> print len(vowels), cardinalize('vowel', len(vowels))
5 vowels
>>> print 3, cardinalize(3, 'Wish')
>>> print 3, cardinalize('Wish', 3)
3 Wishes
"""
if count == 1:

View File

@ -51,7 +51,7 @@ def decimal_relative_time(d, other=None, ndigits=0):
bbound, bunit, bname = _BOUNDS[b_idx]
float_diff = diff_seconds / total_seconds(bunit)
rounded_diff = round(float_diff, ndigits)
return rounded_diff, cardinalize(rounded_diff, bname)
return rounded_diff, cardinalize(bname, rounded_diff)
def relative_time(d, other=None):