1
0
mirror of https://github.com/arsenetar/dupeguru.git synced 2026-01-22 14:41:39 +00:00

Removed logic duplication across toolkit code in "Add to Ignore List" action.

This commit is contained in:
Virgil Dupras
2010-02-06 12:12:20 +01:00
parent 64c67e19d2
commit 3c75d2f8b7
7 changed files with 38 additions and 35 deletions

View File

@@ -132,6 +132,12 @@ class DupeGuru(RegistrableApplication, Broadcaster):
if other is not dupe:
self.scanner.ignore_list.Ignore(unicode(other.path), unicode(dupe.path))
def add_selected_to_ignore_list(self):
dupes = self.without_ref(self.selected_dupes)
for dupe in dupes:
self.add_to_ignore_list(dupe)
self.remove_duplicates(dupes)
def apply_filter(self, filter):
self.results.apply_filter(None)
if self.options['escape_filter_regexp']:
@@ -220,6 +226,9 @@ class DupeGuru(RegistrableApplication, Broadcaster):
self.results.make_ref(dupe)
changed_groups.add(g)
def remove_duplicates(self, duplicates):
self.results.remove_duplicates(duplicates)
def save(self):
if not op.exists(self.appdata):
os.makedirs(self.appdata)
@@ -248,6 +257,9 @@ class DupeGuru(RegistrableApplication, Broadcaster):
self.results.groups = []
self._start_job(JOB_SCAN, do)
def without_ref(self, dupes):
return [dupe for dupe in dupes if self.results.get_group_of_duplicate(dupe).ref is not dupe]
#--- Properties
@property
def stat_line(self):

View File

@@ -90,10 +90,6 @@ class DupeGuru(app.DupeGuru):
return self.get_folder_path(node_path[1:], curr_path)
#---Public
def AddSelectedToIgnoreList(self):
for dupe in self.selected_dupes:
self.add_to_ignore_list(dupe)
copy_or_move_marked = demo_method(app.DupeGuru.copy_or_move_marked)
delete_marked = demo_method(app.DupeGuru.delete_marked)

View File

@@ -85,7 +85,7 @@ class PyDupeGuruBase(PyApp):
#---Actions
def addSelectedToIgnoreList(self):
self.app.AddSelectedToIgnoreList()
self.app.add_selected_to_ignore_list()
def deleteMarked(self):
self.app.delete_marked()

View File

@@ -307,10 +307,10 @@ class TCDupeGuru(TestCase):
def test_ignore(self):
app = self.app
app.SelectPowerMarkerNodePaths(r2np([2])) #The dupe of the second, 2 sized group
app.AddSelectedToIgnoreList()
app.add_selected_to_ignore_list()
self.assertEqual(1,len(app.scanner.ignore_list))
app.SelectPowerMarkerNodePaths(r2np([0])) #first dupe of the 3 dupes group
app.AddSelectedToIgnoreList()
app.add_selected_to_ignore_list()
#BOTH the ref and the other dupe should have been added
self.assertEqual(3,len(app.scanner.ignore_list))
@@ -337,7 +337,7 @@ class TCDupeGuru(TestCase):
app = self.app
app.scanner.ignore_list.Ignore = FakeIgnore
app.SelectPowerMarkerNodePaths(r2np([2])) #The dupe of the second, 2 sized group
app.AddSelectedToIgnoreList()
app.add_selected_to_ignore_list()
def test_GetOutlineViewChildCounts_out_of_range(self):
# Out of range requests don't crash and return an empty value