From 77b536d5168ac3a54dfcdd9d9866e2e572d3d448 Mon Sep 17 00:00:00 2001 From: Mahmoud Hashemi Date: Fri, 31 May 2013 23:43:37 -0700 Subject: [PATCH] swap the order of cardinalize()'s arguments after intuiting the wrong order a couple times. gotta be consistent, this isn't PHP. --- boltons/strutils.py | 8 ++++---- boltons/timeutils.py | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/boltons/strutils.py b/boltons/strutils.py index feb29ea..7b794dd 100644 --- a/boltons/strutils.py +++ b/boltons/strutils.py @@ -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: diff --git a/boltons/timeutils.py b/boltons/timeutils.py index 56d1f43..c58b77d 100644 --- a/boltons/timeutils.py +++ b/boltons/timeutils.py @@ -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):