mirror of
https://github.com/arsenetar/dupeguru.git
synced 2025-03-10 05:34:36 +00:00
parent
0e542577b0
commit
c34c9562d3
12
core/app.py
12
core/app.py
@ -21,8 +21,7 @@ from hscommon.notify import Broadcaster
|
||||
from hscommon.path import Path
|
||||
from hscommon.conflict import smart_move, smart_copy
|
||||
from hscommon.gui.progress_window import ProgressWindow
|
||||
from hscommon.util import (delete_if_empty, first, escape, nonone, format_time_decimal, allsame,
|
||||
rem_file_ext)
|
||||
from hscommon.util import delete_if_empty, first, escape, nonone, format_time_decimal, allsame
|
||||
from hscommon.trans import tr
|
||||
from hscommon.plat import ISWINDOWS
|
||||
from hscommon import desktop
|
||||
@ -90,9 +89,6 @@ def format_dupe_count(c):
|
||||
return str(c) if c else '---'
|
||||
|
||||
def cmp_value(dupe, attrname):
|
||||
if attrname == 'name':
|
||||
value = rem_file_ext(dupe.name)
|
||||
else:
|
||||
value = getattr(dupe, attrname, '')
|
||||
return value.lower() if isinstance(value, str) else value
|
||||
|
||||
@ -205,13 +201,11 @@ class DupeGuru(RegistrableApplication, Broadcaster):
|
||||
else:
|
||||
result = cmp_value(dupe, key)
|
||||
if delta:
|
||||
refval = getattr(get_group().ref, key)
|
||||
refval = cmp_value(get_group().ref, key)
|
||||
if key in self.result_table.DELTA_COLUMNS:
|
||||
result -= refval
|
||||
else:
|
||||
# We use directly getattr() because cmp_value() does thing that we don't want to do
|
||||
# when we want to determine whether two values are exactly the same.
|
||||
same = getattr(dupe, key) == refval
|
||||
same = cmp_value(dupe, key) == refval
|
||||
result = (same, result)
|
||||
return result
|
||||
|
||||
|
@ -42,7 +42,7 @@ class DupeRow(Row):
|
||||
dupe_info = self.data
|
||||
ref_info = self._group.ref.get_display_info(group=self._group, delta=False)
|
||||
for key, value in dupe_info.items():
|
||||
if ref_info[key] != value:
|
||||
if (key not in self._delta_columns) and (ref_info[key].lower() != value.lower()):
|
||||
self._delta_columns.add(key)
|
||||
return column_name in self._delta_columns
|
||||
|
||||
|
@ -44,3 +44,13 @@ def test_delta_flags_delta_mode_on_non_delta_columns():
|
||||
assert not app.rtable[3].is_cell_delta('name')
|
||||
# "ibabtu" == "ibabtu", flag off
|
||||
assert not app.rtable[4].is_cell_delta('name')
|
||||
|
||||
def test_delta_flags_delta_mode_on_non_delta_columns_case_insensitive():
|
||||
# Comparison that occurs for non-numeric columns to check whether they're delta is case
|
||||
# insensitive
|
||||
app = app_with_results()
|
||||
app.app.results.groups[1].ref.name = "ibAbtu"
|
||||
app.app.results.groups[1].dupes[0].name = "IBaBTU"
|
||||
app.rtable.delta_values = True
|
||||
# "ibAbtu" == "IBaBTU", flag off
|
||||
assert not app.rtable[4].is_cell_delta('name')
|
||||
|
@ -230,6 +230,23 @@ class TestCaseResultsWithSomeGroups:
|
||||
# also remove group ref
|
||||
assert self.results.get_group_of_duplicate(ref) is None
|
||||
|
||||
def test_dupe_list_sort_delta_values_nonnumeric(self):
|
||||
# When sorting dupes in delta mode on a non-numeric column, our first sort criteria is if
|
||||
# the string is the same as its ref.
|
||||
g1r, g1d1, g1d2, g2r, g2d1 = self.objects
|
||||
# "aaa" makes our dupe go first in alphabetical order, but since we have the same value as
|
||||
# ref, we're going last.
|
||||
g2r.name = g2d1.name = "aaa"
|
||||
self.results.sort_dupes('name', delta=True)
|
||||
eq_("aaa", self.results.dupes[2].name)
|
||||
|
||||
def test_dupe_list_sort_delta_values_nonnumeric_case_insensitive(self):
|
||||
# Non-numeric delta sorting comparison is case insensitive
|
||||
g1r, g1d1, g1d2, g2r, g2d1 = self.objects
|
||||
g2r.name = "AaA"
|
||||
g2d1.name = "aAa"
|
||||
self.results.sort_dupes('name', delta=True)
|
||||
eq_("aAa", self.results.dupes[2].name)
|
||||
|
||||
class TestCaseResultsWithSavedResults:
|
||||
def setup_method(self, method):
|
||||
|
Loading…
x
Reference in New Issue
Block a user