mirror of
				https://github.com/arsenetar/dupeguru.git
				synced 2025-09-11 17:58:17 +00:00 
			
		
		
		
	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:
		
							parent
							
								
									8b878b7b13
								
							
						
					
					
						commit
						f3c09c7a8d
					
				| @ -128,7 +128,7 @@ class PyDupeGuruBase(PyBaseApp): | |||||||
|      |      | ||||||
|     #---Properties |     #---Properties | ||||||
|     def setMixFileKind_(self, mix_file_kind: bool): |     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): |     def setEscapeFilterRegexp_(self, escape_filter_regexp: bool): | ||||||
|         self.model.options['escape_filter_regexp'] = escape_filter_regexp |         self.model.options['escape_filter_regexp'] = escape_filter_regexp | ||||||
|  | |||||||
| @ -96,14 +96,14 @@ def get_itunes_songs(plistpath): | |||||||
|     return result |     return result | ||||||
| 
 | 
 | ||||||
| class Directories(directories.Directories): | class Directories(directories.Directories): | ||||||
|     def __init__(self, fileclasses): |     def __init__(self): | ||||||
|         directories.Directories.__init__(self, fileclasses) |         directories.Directories.__init__(self) | ||||||
|         try: |         try: | ||||||
|             self.itunes_libpath = get_itunes_database_path() |             self.itunes_libpath = get_itunes_database_path() | ||||||
|         except directories.InvalidPathError: |         except directories.InvalidPathError: | ||||||
|             self.itunes_libpath = None |             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 from_path == ITUNES_PATH: | ||||||
|             if self.itunes_libpath is None: |             if self.itunes_libpath is None: | ||||||
|                 return [] |                 return [] | ||||||
| @ -113,7 +113,7 @@ class Directories(directories.Directories): | |||||||
|                 song.is_ref = is_ref |                 song.is_ref = is_ref | ||||||
|             return songs |             return songs | ||||||
|         else: |         else: | ||||||
|             return directories.Directories._get_files(self, from_path, j) |             return directories.Directories._get_files(self, from_path, fileclasses, j) | ||||||
|      |      | ||||||
|     @staticmethod |     @staticmethod | ||||||
|     def get_subfolders(path): |     def get_subfolders(path): | ||||||
| @ -145,8 +145,7 @@ class Directories(directories.Directories): | |||||||
| class DupeGuruME(DupeGuruBase): | class DupeGuruME(DupeGuruBase): | ||||||
|     def __init__(self, view): |     def __init__(self, view): | ||||||
|         DupeGuruBase.__init__(self, view) |         DupeGuruBase.__init__(self, view) | ||||||
|         # Use fileclasses set in DupeGuruBase.__init__() |         self.directories = Directories() | ||||||
|         self.directories = Directories(fileclasses=self.directories.fileclasses) |  | ||||||
|         self.dead_tracks = [] |         self.dead_tracks = [] | ||||||
|      |      | ||||||
|     def _do_delete(self, j, *args): |     def _do_delete(self, j, *args): | ||||||
| @ -259,11 +258,11 @@ class PyDupeGuru(PyDupeGuruBase): | |||||||
|      |      | ||||||
|     #---Properties |     #---Properties | ||||||
|     def setMinMatchPercentage_(self, percentage: int): |     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): |     def setScanType_(self, scan_type: int): | ||||||
|         try: |         try: | ||||||
|             self.model.scanner.scan_type = [ |             self.model.options['scan_type'] = [ | ||||||
|                 ScanType.Filename, |                 ScanType.Filename, | ||||||
|                 ScanType.Fields, |                 ScanType.Fields, | ||||||
|                 ScanType.FieldsNoOrder, |                 ScanType.FieldsNoOrder, | ||||||
| @ -275,13 +274,15 @@ class PyDupeGuru(PyDupeGuruBase): | |||||||
|             pass |             pass | ||||||
|      |      | ||||||
|     def setWordWeighting_(self, words_are_weighted: bool): |     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): |     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): |     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: |         if enable: | ||||||
|             self.model.scanner.scanned_tags.add(scan_tag) |             self.model.options['scanned_tags'].add(scan_tag) | ||||||
|         else: |         else: | ||||||
|             self.model.scanner.scanned_tags.discard(scan_tag) |             self.model.options['scanned_tags'].discard(scan_tag) | ||||||
|  | |||||||
| @ -126,7 +126,7 @@ def get_aperture_database_path(): | |||||||
| 
 | 
 | ||||||
| class Directories(directories.Directories): | class Directories(directories.Directories): | ||||||
|     def __init__(self): |     def __init__(self): | ||||||
|         directories.Directories.__init__(self, fileclasses=[Photo]) |         directories.Directories.__init__(self) | ||||||
|         try: |         try: | ||||||
|             self.iphoto_libpath = get_iphoto_database_path() |             self.iphoto_libpath = get_iphoto_database_path() | ||||||
|             self.set_state(self.iphoto_libpath.parent(), directories.DirectoryState.Excluded) |             self.set_state(self.iphoto_libpath.parent(), directories.DirectoryState.Excluded) | ||||||
| @ -138,7 +138,7 @@ class Directories(directories.Directories): | |||||||
|         except directories.InvalidPathError: |         except directories.InvalidPathError: | ||||||
|             self.aperture_libpath = None |             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 from_path == IPHOTO_PATH: | ||||||
|             if self.iphoto_libpath is None: |             if self.iphoto_libpath is None: | ||||||
|                 return [] |                 return [] | ||||||
| @ -156,7 +156,7 @@ class Directories(directories.Directories): | |||||||
|                 photo.is_ref = is_ref |                 photo.is_ref = is_ref | ||||||
|             return photos |             return photos | ||||||
|         else: |         else: | ||||||
|             return directories.Directories._get_files(self, from_path, j) |             return directories.Directories._get_files(self, from_path, fileclasses, j) | ||||||
|      |      | ||||||
|     @staticmethod |     @staticmethod | ||||||
|     def get_subfolders(path): |     def get_subfolders(path): | ||||||
| @ -188,6 +188,7 @@ class Directories(directories.Directories): | |||||||
| class DupeGuruPE(DupeGuruBase): | class DupeGuruPE(DupeGuruBase): | ||||||
|     def __init__(self, view): |     def __init__(self, view): | ||||||
|         DupeGuruBase.__init__(self, view) |         DupeGuruBase.__init__(self, view) | ||||||
|  |         self.fileclasses = [Photo] | ||||||
|         self.directories = Directories() |         self.directories = Directories() | ||||||
|      |      | ||||||
|     def _do_delete(self, j, *args): |     def _do_delete(self, j, *args): | ||||||
| @ -316,7 +317,7 @@ class PyDupeGuru(PyDupeGuruBase): | |||||||
|         self._init(DupeGuruPE) |         self._init(DupeGuruPE) | ||||||
|      |      | ||||||
|     def clearPictureCache(self): |     def clearPictureCache(self): | ||||||
|         self.model.scanner.clear_picture_cache() |         self.model.clear_picture_cache() | ||||||
|      |      | ||||||
|     #---Information     |     #---Information     | ||||||
|     def getSelectedDupePath(self) -> str: |     def getSelectedDupePath(self) -> str: | ||||||
| @ -328,7 +329,7 @@ class PyDupeGuru(PyDupeGuruBase): | |||||||
|     #---Properties |     #---Properties | ||||||
|     def setScanType_(self, scan_type: int): |     def setScanType_(self, scan_type: int): | ||||||
|         try: |         try: | ||||||
|             self.model.scanner.scan_type = [ |             self.model.options['scan_type'] = [ | ||||||
|                 ScanType.FuzzyBlock, |                 ScanType.FuzzyBlock, | ||||||
|                 ScanType.ExifTimestamp, |                 ScanType.ExifTimestamp, | ||||||
|             ][scan_type] |             ][scan_type] | ||||||
| @ -336,7 +337,7 @@ class PyDupeGuru(PyDupeGuruBase): | |||||||
|             pass |             pass | ||||||
|      |      | ||||||
|     def setMatchScaled_(self, match_scaled: bool): |     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): |     def setMinMatchPercentage_(self, percentage: int): | ||||||
|         self.model.scanner.threshold = percentage |         self.model.options['threshold'] = percentage | ||||||
|  | |||||||
| @ -35,7 +35,7 @@ class Directories(DirectoriesBase): | |||||||
|     ROOT_PATH_TO_EXCLUDE = list(map(Path, ['/Library', '/Volumes', '/System', '/bin', '/sbin', '/opt', '/private', '/dev'])) |     ROOT_PATH_TO_EXCLUDE = list(map(Path, ['/Library', '/Volumes', '/System', '/bin', '/sbin', '/opt', '/private', '/dev'])) | ||||||
|     HOME_PATH_TO_EXCLUDE = [Path('Library')] |     HOME_PATH_TO_EXCLUDE = [Path('Library')] | ||||||
|     def __init__(self): |     def __init__(self): | ||||||
|         DirectoriesBase.__init__(self, fileclasses=[Bundle, fs.File]) |         DirectoriesBase.__init__(self) | ||||||
|         self.folderclass = fs.Folder |         self.folderclass = fs.Folder | ||||||
|      |      | ||||||
|     def _default_state_for_path(self, path): |     def _default_state_for_path(self, path): | ||||||
| @ -72,6 +72,7 @@ class DupeGuru(DupeGuruBase): | |||||||
|         # appdata = op.join(appdata, 'dupeGuru') |         # appdata = op.join(appdata, 'dupeGuru') | ||||||
|         # print(repr(appdata)) |         # print(repr(appdata)) | ||||||
|         DupeGuruBase.__init__(self, view) |         DupeGuruBase.__init__(self, view) | ||||||
|  |         self.fileclasses = [Bundle, fs.File] | ||||||
|         self.directories = Directories() |         self.directories = Directories() | ||||||
|      |      | ||||||
| 
 | 
 | ||||||
| @ -81,11 +82,11 @@ class PyDupeGuru(PyDupeGuruBase): | |||||||
|      |      | ||||||
|     #---Properties |     #---Properties | ||||||
|     def setMinMatchPercentage_(self, percentage: int): |     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): |     def setScanType_(self, scan_type: int): | ||||||
|         try: |         try: | ||||||
|             self.model.scanner.scan_type = [ |             self.model.options['scan_type'] = [ | ||||||
|                 ScanType.Filename, |                 ScanType.Filename, | ||||||
|                 ScanType.Contents, |                 ScanType.Contents, | ||||||
|                 ScanType.Folders, |                 ScanType.Folders, | ||||||
| @ -94,11 +95,11 @@ class PyDupeGuru(PyDupeGuruBase): | |||||||
|             pass |             pass | ||||||
|      |      | ||||||
|     def setWordWeighting_(self, words_are_weighted: bool): |     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): |     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): |     def setSizeThreshold_(self, size_threshold: int): | ||||||
|         self.model.scanner.size_threshold = size_threshold |         self.model.options['size_threshold'] = size_threshold | ||||||
|      |      | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user