From 68bb0ca5ee17acfc23960c6a60aa832c7004d8c5 Mon Sep 17 00:00:00 2001 From: Bruno Tournay Date: Tue, 28 Jan 2014 14:21:45 +0100 Subject: [PATCH] Removed duplicated code: modified showdiff() so it uses also different() --- beets/ui/commands.py | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/beets/ui/commands.py b/beets/ui/commands.py index 498935324..a69b008d8 100644 --- a/beets/ui/commands.py +++ b/beets/ui/commands.py @@ -75,6 +75,9 @@ def _do_query(lib, query, album, also_items=True): FLOAT_EPSILON = 0.01 def _different(val1, val2): + """Says if the two values are considered different.""" + # Considering floats incomparable for perfect equality, introduce + # an epsilon tolerance. if (val1 == val2) or \ ( isinstance(val1, float) and isinstance(val2, float) and \ abs(val1 - val2) < FLOAT_EPSILON ): @@ -85,13 +88,7 @@ def _different(val1, val2): def _showdiff(field, oldval, newval): """Prints out a human-readable field difference line.""" - # Considering floats incomparable for perfect equality, introduce - # an epsilon tolerance. - if isinstance(oldval, float) and isinstance(newval, float) and \ - abs(oldval - newval) < FLOAT_EPSILON: - return - - if newval != oldval: + if _different(newval, oldval): oldval, newval = ui.colordiff(oldval, newval) print_(u' %s: %s -> %s' % (field, oldval, newval))