cocoa: adjust to latest changes

...that is, scanner on-the-fly instantiation and fileclasses/folderclass config move.

We haven't moved the scan type selector in the UI yet.
This commit is contained in:
Virgil Dupras 2016-06-01 21:56:18 -04:00
parent 8b878b7b13
commit f3c09c7a8d
4 changed files with 29 additions and 26 deletions

View File

@ -128,7 +128,7 @@ class PyDupeGuruBase(PyBaseApp):
#---Properties
def setMixFileKind_(self, mix_file_kind: bool):
self.model.scanner.mix_file_kind = mix_file_kind
self.model.options['mix_file_kind'] = mix_file_kind
def setEscapeFilterRegexp_(self, escape_filter_regexp: bool):
self.model.options['escape_filter_regexp'] = escape_filter_regexp

View File

@ -96,14 +96,14 @@ def get_itunes_songs(plistpath):
return result
class Directories(directories.Directories):
def __init__(self, fileclasses):
directories.Directories.__init__(self, fileclasses)
def __init__(self):
directories.Directories.__init__(self)
try:
self.itunes_libpath = get_itunes_database_path()
except directories.InvalidPathError:
self.itunes_libpath = None
def _get_files(self, from_path, j):
def _get_files(self, from_path, fileclasses, j):
if from_path == ITUNES_PATH:
if self.itunes_libpath is None:
return []
@ -113,7 +113,7 @@ class Directories(directories.Directories):
song.is_ref = is_ref
return songs
else:
return directories.Directories._get_files(self, from_path, j)
return directories.Directories._get_files(self, from_path, fileclasses, j)
@staticmethod
def get_subfolders(path):
@ -145,8 +145,7 @@ class Directories(directories.Directories):
class DupeGuruME(DupeGuruBase):
def __init__(self, view):
DupeGuruBase.__init__(self, view)
# Use fileclasses set in DupeGuruBase.__init__()
self.directories = Directories(fileclasses=self.directories.fileclasses)
self.directories = Directories()
self.dead_tracks = []
def _do_delete(self, j, *args):
@ -259,11 +258,11 @@ class PyDupeGuru(PyDupeGuruBase):
#---Properties
def setMinMatchPercentage_(self, percentage: int):
self.model.scanner.min_match_percentage = percentage
self.model.options['min_match_percentage'] = percentage
def setScanType_(self, scan_type: int):
try:
self.model.scanner.scan_type = [
self.model.options['scan_type'] = [
ScanType.Filename,
ScanType.Fields,
ScanType.FieldsNoOrder,
@ -275,13 +274,15 @@ class PyDupeGuru(PyDupeGuruBase):
pass
def setWordWeighting_(self, words_are_weighted: bool):
self.model.scanner.word_weighting = words_are_weighted
self.model.options['word_weighting'] = words_are_weighted
def setMatchSimilarWords_(self, match_similar_words: bool):
self.model.scanner.match_similar_words = match_similar_words
self.model.options['match_similar_words'] = match_similar_words
def enable_scanForTag_(self, enable: bool, scan_tag: str):
if 'scanned_tags' not in self.model.options:
self.model.options['scanned_tags'] = set()
if enable:
self.model.scanner.scanned_tags.add(scan_tag)
self.model.options['scanned_tags'].add(scan_tag)
else:
self.model.scanner.scanned_tags.discard(scan_tag)
self.model.options['scanned_tags'].discard(scan_tag)

View File

@ -126,7 +126,7 @@ def get_aperture_database_path():
class Directories(directories.Directories):
def __init__(self):
directories.Directories.__init__(self, fileclasses=[Photo])
directories.Directories.__init__(self)
try:
self.iphoto_libpath = get_iphoto_database_path()
self.set_state(self.iphoto_libpath.parent(), directories.DirectoryState.Excluded)
@ -138,7 +138,7 @@ class Directories(directories.Directories):
except directories.InvalidPathError:
self.aperture_libpath = None
def _get_files(self, from_path, j):
def _get_files(self, from_path, fileclasses, j):
if from_path == IPHOTO_PATH:
if self.iphoto_libpath is None:
return []
@ -156,7 +156,7 @@ class Directories(directories.Directories):
photo.is_ref = is_ref
return photos
else:
return directories.Directories._get_files(self, from_path, j)
return directories.Directories._get_files(self, from_path, fileclasses, j)
@staticmethod
def get_subfolders(path):
@ -188,6 +188,7 @@ class Directories(directories.Directories):
class DupeGuruPE(DupeGuruBase):
def __init__(self, view):
DupeGuruBase.__init__(self, view)
self.fileclasses = [Photo]
self.directories = Directories()
def _do_delete(self, j, *args):
@ -316,7 +317,7 @@ class PyDupeGuru(PyDupeGuruBase):
self._init(DupeGuruPE)
def clearPictureCache(self):
self.model.scanner.clear_picture_cache()
self.model.clear_picture_cache()
#---Information
def getSelectedDupePath(self) -> str:
@ -328,7 +329,7 @@ class PyDupeGuru(PyDupeGuruBase):
#---Properties
def setScanType_(self, scan_type: int):
try:
self.model.scanner.scan_type = [
self.model.options['scan_type'] = [
ScanType.FuzzyBlock,
ScanType.ExifTimestamp,
][scan_type]
@ -336,7 +337,7 @@ class PyDupeGuru(PyDupeGuruBase):
pass
def setMatchScaled_(self, match_scaled: bool):
self.model.scanner.match_scaled = match_scaled
self.model.options['match_scaled'] = match_scaled
def setMinMatchPercentage_(self, percentage: int):
self.model.scanner.threshold = percentage
self.model.options['threshold'] = percentage

View File

@ -35,7 +35,7 @@ class Directories(DirectoriesBase):
ROOT_PATH_TO_EXCLUDE = list(map(Path, ['/Library', '/Volumes', '/System', '/bin', '/sbin', '/opt', '/private', '/dev']))
HOME_PATH_TO_EXCLUDE = [Path('Library')]
def __init__(self):
DirectoriesBase.__init__(self, fileclasses=[Bundle, fs.File])
DirectoriesBase.__init__(self)
self.folderclass = fs.Folder
def _default_state_for_path(self, path):
@ -72,6 +72,7 @@ class DupeGuru(DupeGuruBase):
# appdata = op.join(appdata, 'dupeGuru')
# print(repr(appdata))
DupeGuruBase.__init__(self, view)
self.fileclasses = [Bundle, fs.File]
self.directories = Directories()
@ -81,11 +82,11 @@ class PyDupeGuru(PyDupeGuruBase):
#---Properties
def setMinMatchPercentage_(self, percentage: int):
self.model.scanner.min_match_percentage = int(percentage)
self.model.options['min_match_percentage'] = int(percentage)
def setScanType_(self, scan_type: int):
try:
self.model.scanner.scan_type = [
self.model.options['scan_type'] = [
ScanType.Filename,
ScanType.Contents,
ScanType.Folders,
@ -94,11 +95,11 @@ class PyDupeGuru(PyDupeGuruBase):
pass
def setWordWeighting_(self, words_are_weighted: bool):
self.model.scanner.word_weighting = words_are_weighted
self.model.options['word_weighting'] = words_are_weighted
def setMatchSimilarWords_(self, match_similar_words: bool):
self.model.scanner.match_similar_words = match_similar_words
self.model.options['match_similar_words'] = match_similar_words
def setSizeThreshold_(self, size_threshold: int):
self.model.scanner.size_threshold = size_threshold
self.model.options['size_threshold'] = size_threshold