mirror of
https://github.com/arsenetar/dupeguru.git
synced 2026-01-22 06:37:17 +00:00
refactoring: take ignore_list out of Scanner class
It's now `DupeGuru` that holds it and passes it to `get_dupe_groups()`, the only place where it's actually used in `Scanner`. This will make the SE/ME/PE merge easier by allowing us to instantiate the Scanner on-the-fly since it doesn't hold state anymore.
This commit is contained in:
@@ -1,6 +1,4 @@
|
||||
# Created By: Virgil Dupras
|
||||
# Created On: 2007-06-23
|
||||
# Copyright 2015 Hardcoded Software (http://www.hardcoded.net)
|
||||
# Copyright 2016 Hardcoded Software (http://www.hardcoded.net)
|
||||
#
|
||||
# This software is licensed under the "GPLv3" License as described in the "LICENSE" file,
|
||||
# which should be included with this package. The terms are also available at
|
||||
@@ -14,10 +12,10 @@ from pytest import mark
|
||||
from hscommon.path import Path
|
||||
import hscommon.conflict
|
||||
import hscommon.util
|
||||
from hscommon.testutil import CallLogger, eq_, log_calls
|
||||
from hscommon.testutil import eq_, log_calls
|
||||
from hscommon.jobprogress.job import Job
|
||||
|
||||
from .base import DupeGuru, TestApp
|
||||
from .base import TestApp
|
||||
from .results_test import GetTestGroups
|
||||
from .. import app, fs, engine
|
||||
from ..scanner import ScanType
|
||||
@@ -347,11 +345,11 @@ class TestCaseDupeGuruWithResults:
|
||||
app = self.app
|
||||
self.rtable.select([4]) #The dupe of the second, 2 sized group
|
||||
app.add_selected_to_ignore_list()
|
||||
eq_(len(app.scanner.ignore_list), 1)
|
||||
eq_(len(app.ignore_list), 1)
|
||||
self.rtable.select([1]) #first dupe of the 3 dupes group
|
||||
app.add_selected_to_ignore_list()
|
||||
#BOTH the ref and the other dupe should have been added
|
||||
eq_(len(app.scanner.ignore_list), 3)
|
||||
eq_(len(app.ignore_list), 3)
|
||||
|
||||
def test_purgeIgnoreList(self, do_setup, tmpdir):
|
||||
app = self.app
|
||||
@@ -360,13 +358,13 @@ class TestCaseDupeGuruWithResults:
|
||||
open(p1, 'w').close()
|
||||
open(p2, 'w').close()
|
||||
dne = '/does_not_exist'
|
||||
app.scanner.ignore_list.Ignore(dne,p1)
|
||||
app.scanner.ignore_list.Ignore(p2,dne)
|
||||
app.scanner.ignore_list.Ignore(p1,p2)
|
||||
app.ignore_list.Ignore(dne,p1)
|
||||
app.ignore_list.Ignore(p2,dne)
|
||||
app.ignore_list.Ignore(p1,p2)
|
||||
app.purge_ignore_list()
|
||||
eq_(1,len(app.scanner.ignore_list))
|
||||
assert app.scanner.ignore_list.AreIgnored(p1,p2)
|
||||
assert not app.scanner.ignore_list.AreIgnored(dne,p1)
|
||||
eq_(1,len(app.ignore_list))
|
||||
assert app.ignore_list.AreIgnored(p1,p2)
|
||||
assert not app.ignore_list.AreIgnored(dne,p1)
|
||||
|
||||
def test_only_unicode_is_added_to_ignore_list(self, do_setup):
|
||||
def FakeIgnore(first,second):
|
||||
@@ -376,7 +374,7 @@ class TestCaseDupeGuruWithResults:
|
||||
self.fail()
|
||||
|
||||
app = self.app
|
||||
app.scanner.ignore_list.Ignore = FakeIgnore
|
||||
app.ignore_list.Ignore = FakeIgnore
|
||||
self.rtable.select([4])
|
||||
app.add_selected_to_ignore_list()
|
||||
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
# Created By: Virgil Dupras
|
||||
# Created On: 2006/03/03
|
||||
# Copyright 2015 Hardcoded Software (http://www.hardcoded.net)
|
||||
# Copyright 2016 Hardcoded Software (http://www.hardcoded.net)
|
||||
#
|
||||
# This software is licensed under the "GPLv3" License as described in the "LICENSE" file,
|
||||
# which should be included with this package. The terms are also available at
|
||||
@@ -13,7 +11,7 @@ from hscommon.testutil import eq_
|
||||
from .. import fs
|
||||
from ..engine import getwords, Match
|
||||
from ..ignore import IgnoreList
|
||||
from ..scanner import *
|
||||
from ..scanner import Scanner, ScanType
|
||||
|
||||
class NamedObject:
|
||||
def __init__(self, name="foobar", size=1, path=None):
|
||||
@@ -50,7 +48,6 @@ def test_default_settings(fake_fileexists):
|
||||
eq_(s.mix_file_kind, True)
|
||||
eq_(s.word_weighting, False)
|
||||
eq_(s.match_similar_words, False)
|
||||
assert isinstance(s.ignore_list, IgnoreList)
|
||||
|
||||
def test_simple_with_default_settings(fake_fileexists):
|
||||
s = Scanner()
|
||||
@@ -142,7 +139,7 @@ def test_content_scan_doesnt_put_md5_in_words_at_the_end(fake_fileexists):
|
||||
f[0].md5 = f[0].md5partial = '\x00\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f'
|
||||
f[1].md5 = f[1].md5partial = '\x00\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f'
|
||||
r = s.get_dupe_groups(f)
|
||||
g = r[0]
|
||||
r[0]
|
||||
|
||||
def test_extension_is_not_counted_in_filename_scan(fake_fileexists):
|
||||
s = Scanner()
|
||||
@@ -160,7 +157,7 @@ def test_job(fake_fileexists):
|
||||
s = Scanner()
|
||||
log = []
|
||||
f = [no('foo bar'), no('foo bar'), no('foo bleh')]
|
||||
r = s.get_dupe_groups(f, job.Job(1, do_progress))
|
||||
s.get_dupe_groups(f, j=job.Job(1, do_progress))
|
||||
eq_(log[0], 0)
|
||||
eq_(log[-1], 100)
|
||||
|
||||
@@ -346,9 +343,10 @@ def test_ignore_list(fake_fileexists):
|
||||
f1.path = Path('dir1/foobar')
|
||||
f2.path = Path('dir2/foobar')
|
||||
f3.path = Path('dir3/foobar')
|
||||
s.ignore_list.Ignore(str(f1.path),str(f2.path))
|
||||
s.ignore_list.Ignore(str(f1.path),str(f3.path))
|
||||
r = s.get_dupe_groups([f1,f2,f3])
|
||||
ignore_list = IgnoreList()
|
||||
ignore_list.Ignore(str(f1.path),str(f2.path))
|
||||
ignore_list.Ignore(str(f1.path),str(f3.path))
|
||||
r = s.get_dupe_groups([f1,f2,f3], ignore_list=ignore_list)
|
||||
eq_(len(r), 1)
|
||||
g = r[0]
|
||||
eq_(len(g.dupes), 1)
|
||||
@@ -368,9 +366,10 @@ def test_ignore_list_checks_for_unicode(fake_fileexists):
|
||||
f1.path = Path('foo1\u00e9')
|
||||
f2.path = Path('foo2\u00e9')
|
||||
f3.path = Path('foo3\u00e9')
|
||||
s.ignore_list.Ignore(str(f1.path),str(f2.path))
|
||||
s.ignore_list.Ignore(str(f1.path),str(f3.path))
|
||||
r = s.get_dupe_groups([f1,f2,f3])
|
||||
ignore_list = IgnoreList()
|
||||
ignore_list.Ignore(str(f1.path),str(f2.path))
|
||||
ignore_list.Ignore(str(f1.path),str(f3.path))
|
||||
r = s.get_dupe_groups([f1,f2,f3], ignore_list=ignore_list)
|
||||
eq_(len(r), 1)
|
||||
g = r[0]
|
||||
eq_(len(g.dupes), 1)
|
||||
|
||||
Reference in New Issue
Block a user