From b62e2917499999a2c0108e8cd69b1d7ea559d475 Mon Sep 17 00:00:00 2001 From: Timmy Welch Date: Sat, 22 Jan 2022 15:00:22 -0800 Subject: [PATCH] Cleanup settings from #200 Rename blacklist to filter to be more accurate --- comictaggerlib/issueidentifier.py | 14 +++--- comictaggerlib/settings.py | 22 ++++----- comictaggerlib/settingswindow.py | 18 +++---- comictaggerlib/ui/settingswindow.ui | 56 +++++++++++++--------- comictaggerlib/ui/volumeselectionwindow.ui | 2 +- comictaggerlib/volumeselectionwindow.py | 23 +++++---- 6 files changed, 72 insertions(+), 63 deletions(-) diff --git a/comictaggerlib/issueidentifier.py b/comictaggerlib/issueidentifier.py index 7e06cfd..502a8c3 100644 --- a/comictaggerlib/issueidentifier.py +++ b/comictaggerlib/issueidentifier.py @@ -76,8 +76,8 @@ class IssueIdentifier: self.length_delta_thresh = settings.id_length_delta_thresh # used to eliminate unlikely publishers - self.publisher_blacklist = [ - s.strip().lower() for s in settings.id_publisher_blacklist.split(',')] + self.publisher_filter = [ + s.strip().lower() for s in settings.id_publisher_filter.split(',')] self.additional_metadata = GenericMetadata() self.output_function = IssueIdentifier.defaultWriteOutput @@ -100,8 +100,8 @@ class IssueIdentifier: def setNameLengthDeltaThreshold(self, delta): self.length_delta_thresh = delta - def setPublisherBlackList(self, blacklist): - self.publisher_blacklist = blacklist + def setPublisherFilter(self, filter): + self.publisher_filter = filter def setHasherAlgorithm(self, algo): self.image_hasher = algo @@ -394,7 +394,7 @@ class IssueIdentifier: if keys['month'] is not None: self.log_msg("\tMonth: " + str(keys['month'])) - #self.log_msg("Publisher Blacklist: " + str(self.publisher_blacklist)) + #self.log_msg("Publisher Filter: " + str(self.publisher_filter)) comicVine = ComicVineTalker() comicVine.wait_for_rate_limit = self.waitAndRetryOnRateLimit @@ -442,11 +442,11 @@ class IssueIdentifier: len(shortened_key) + self.length_delta_thresh): length_approved = True - # remove any series from publishers on the blacklist + # remove any series from publishers on the filter if item['publisher'] is not None: publisher = item['publisher']['name'] if publisher is not None and publisher.lower( - ) in self.publisher_blacklist: + ) in self.publisher_filter: publisher_approved = False if length_approved and publisher_approved and date_approved: diff --git a/comictaggerlib/settings.py b/comictaggerlib/settings.py index ab09eac..4f74bb7 100644 --- a/comictaggerlib/settings.py +++ b/comictaggerlib/settings.py @@ -78,7 +78,7 @@ class ComicTaggerSettings: # identifier settings self.id_length_delta_thresh = 5 - self.id_publisher_blacklist = "Panini Comics, Abril, Planeta DeAgostini, Editorial Televisa, Dino Comics" + self.id_publisher_filter = "Panini Comics, Abril, Planeta DeAgostini, Editorial Televisa, Dino Comics" # Show/ask dialog flags self.ask_about_cbi_in_rar = True @@ -97,7 +97,7 @@ class ComicTaggerSettings: self.sort_series_by_year = True self.exact_series_matches_first = True - self.always_use_publisher_blacklist = False + self.always_use_publisher_filter = False # CBL Tranform settings @@ -226,9 +226,9 @@ class ComicTaggerSettings: if self.config.has_option('identifier', 'id_length_delta_thresh'): self.id_length_delta_thresh = self.config.getint( 'identifier', 'id_length_delta_thresh') - if self.config.has_option('identifier', 'id_publisher_blacklist'): - self.id_publisher_blacklist = self.config.get( - 'identifier', 'id_publisher_blacklist') + if self.config.has_option('identifier', 'id_publisher_filter'): + self.id_publisher_filter = self.config.get( + 'identifier', 'id_publisher_filter') if self.config.has_option('filenameparser', 'parse_scan_info'): self.parse_scan_info = self.config.getboolean( @@ -265,9 +265,9 @@ class ComicTaggerSettings: if self.config.has_option('comicvine', 'exact_series_matches_first'): self.exact_series_matches_first = self.config.getboolean( 'comicvine', 'exact_series_matches_first') - if self.config.has_option('comicvine', 'always_use_publisher_blacklist'): - self.always_use_publisher_blacklist = self.config.getboolean( - 'comicvine', 'always_use_publisher_blacklist') + if self.config.has_option('comicvine', 'always_use_publisher_filter'): + self.always_use_publisher_filter = self.config.getboolean( + 'comicvine', 'always_use_publisher_filter') if self.config.has_option('comicvine', 'cv_api_key'): self.cv_api_key = self.config.get('comicvine', 'cv_api_key') @@ -390,8 +390,8 @@ class ComicTaggerSettings: self.id_length_delta_thresh) self.config.set( 'identifier', - 'id_publisher_blacklist', - self.id_publisher_blacklist) + 'id_publisher_filter', + self.id_publisher_filter) if not self.config.has_section('dialogflags'): self.config.add_section('dialogflags') @@ -429,7 +429,7 @@ class ComicTaggerSettings: self.config.set( 'comicvine', 'exact_series_matches_first', self.exact_series_matches_first) self.config.set( - 'comicvine', 'always_use_publisher_blacklist', self.always_use_publisher_blacklist) + 'comicvine', 'always_use_publisher_filter', self.always_use_publisher_filter) self.config.set('comicvine', 'cv_api_key', self.cv_api_key) diff --git a/comictaggerlib/settingswindow.py b/comictaggerlib/settingswindow.py index f738d9c..afb473e 100644 --- a/comictaggerlib/settingswindow.py +++ b/comictaggerlib/settingswindow.py @@ -94,12 +94,12 @@ class SettingsWindow(QtWidgets.QDialog): pblTip = ( """ - The Publisher Blacklist is for eliminating automatic matches to certain publishers + The Publisher Filter is for eliminating automatic matches to certain publishers that you know are incorrect. Useful for avoiding international re-prints with same covers or series names. Enter publisher names separated by commas. """ ) - self.tePublisherBlacklist.setToolTip(pblTip) + self.tePublisherFilter.setToolTip(pblTip) validator = QtGui.QIntValidator(1, 4, self) self.leIssueNumPadding.setValidator(validator) @@ -120,8 +120,8 @@ class SettingsWindow(QtWidgets.QDialog): self.leRarExePath.setText(self.settings.rar_exe_path) self.leNameLengthDeltaThresh.setText( str(self.settings.id_length_delta_thresh)) - self.tePublisherBlacklist.setPlainText( - self.settings.id_publisher_blacklist) + self.tePublisherFilter.setPlainText( + self.settings.id_publisher_filter) if self.settings.check_for_new_version: self.cbxCheckForNewVersion.setCheckState(QtCore.Qt.Checked) @@ -136,8 +136,8 @@ class SettingsWindow(QtWidgets.QDialog): if self.settings.remove_html_tables: self.cbxRemoveHtmlTables.setCheckState(QtCore.Qt.Checked) - if self.settings.always_use_publisher_blacklist: - self.cbxUseBlackFilter.setCheckState(QtCore.Qt.Checked) + if self.settings.always_use_publisher_filter: + self.cbxUseFilter.setCheckState(QtCore.Qt.Checked) if self.settings.sort_series_by_year: self.cbxSortByYear.setCheckState(QtCore.Qt.Checked) if self.settings.exact_series_matches_first: @@ -193,8 +193,8 @@ class SettingsWindow(QtWidgets.QDialog): self.settings.id_length_delta_thresh = int( self.leNameLengthDeltaThresh.text()) - self.settings.id_publisher_blacklist = str( - self.tePublisherBlacklist.toPlainText()) + self.settings.id_publisher_filter = str( + self.tePublisherFilter.toPlainText()) self.settings.parse_scan_info = self.cbxParseScanInfo.isChecked() @@ -202,7 +202,7 @@ class SettingsWindow(QtWidgets.QDialog): self.settings.clear_form_before_populating_from_cv = self.cbxClearFormBeforePopulating.isChecked() self.settings.remove_html_tables = self.cbxRemoveHtmlTables.isChecked() - self.settings.always_use_publisher_blacklist = self.cbxUseBlackFilter.isChecked() + self.settings.always_use_publisher_filter = self.cbxUseFilter.isChecked() self.settings.sort_series_by_year = self.cbxSortByYear.isChecked() self.settings.exact_series_matches_first = self.cbxExactMatches.isChecked() diff --git a/comictaggerlib/ui/settingswindow.ui b/comictaggerlib/ui/settingswindow.ui index 5912185..c64e7ce 100644 --- a/comictaggerlib/ui/settingswindow.ui +++ b/comictaggerlib/ui/settingswindow.ui @@ -7,7 +7,7 @@ 0 0 702 - 432 + 478 @@ -28,7 +28,7 @@ - 0 + 1 @@ -133,7 +133,7 @@ - Identifier + Searching @@ -187,15 +187,15 @@ - + - Publisher Blacklist: + Publisher Filter: - - + + 0 @@ -204,6 +204,23 @@ + + + + <html><head/><body><p>Applies the <span style=" font-weight:600;">Publisher Filter</span> on all searches.<br/>The search window has a dynamic toggle to show the unfiltered results.</p></body></html> + + + + + + + + + + Always use Publisher Filter on "manual" searches: + + + @@ -263,23 +280,16 @@ - - - - - 0 - 0 - - - - Qt::Horizontal - - - - - - Always use Publisher Blacklist on 'manual' searches + + + + 0 + 0 + + + + Qt::Horizontal diff --git a/comictaggerlib/ui/volumeselectionwindow.ui b/comictaggerlib/ui/volumeselectionwindow.ui index ff86c6d..3cbfd7b 100644 --- a/comictaggerlib/ui/volumeselectionwindow.ui +++ b/comictaggerlib/ui/volumeselectionwindow.ui @@ -154,7 +154,7 @@ Filter Publishers - Filter the publishers based on the publisher blacklist. + Filter the publishers based on the publisher filter. diff --git a/comictaggerlib/volumeselectionwindow.py b/comictaggerlib/volumeselectionwindow.py index 020afda..9f587b2 100644 --- a/comictaggerlib/volumeselectionwindow.py +++ b/comictaggerlib/volumeselectionwindow.py @@ -126,7 +126,7 @@ class VolumeSelectionWindow(QtWidgets.QDialog): self.cover_index_list = cover_index_list self.cv_search_results = None - self.use_blackList = self.settings.always_use_publisher_blacklist + self.use_filter = self.settings.always_use_publisher_filter self.twList.resizeColumnsToContents() self.twList.currentItemChanged.connect(self.currentItemChanged) @@ -135,7 +135,7 @@ class VolumeSelectionWindow(QtWidgets.QDialog): self.btnIssues.clicked.connect(self.showIssues) self.btnAutoSelect.clicked.connect(self.autoSelect) - self.cbxFilter.setChecked(self.use_blackList) + self.cbxFilter.setChecked(self.use_filter) self.cbxFilter.toggled.connect(self.filterToggled) self.updateButtons() @@ -157,9 +157,9 @@ class VolumeSelectionWindow(QtWidgets.QDialog): def requery(self,): self.performQuery(refresh=True) self.twList.selectRow(0) - + def filterToggled(self): - self.use_blackList = not self.use_blackList + self.use_filter = not self.use_filter self.performQuery(refresh=False) def autoSelect(self): @@ -304,7 +304,6 @@ class VolumeSelectionWindow(QtWidgets.QDialog): self.progdialog.canceled.connect(self.searchCanceled) self.progdialog.setModal(True) self.progdialog.setMinimumDuration(300) - QtCore.QCoreApplication.processEvents() self.search_thread = SearchThread(self.series_name, refresh) self.search_thread.searchComplete.connect(self.searchComplete) self.search_thread.progressUpdate.connect(self.searchProgressUpdate) @@ -345,14 +344,14 @@ class VolumeSelectionWindow(QtWidgets.QDialog): return self.cv_search_results = self.search_thread.cv_search_results - # filter the blacklisted publishers if setting set - if self.use_blackList: + # filter the publishers if enabled set + if self.use_filter: try: - publisher_blacklist = {s.strip().lower() for s in self.settings.id_publisher_blacklist.split(',')} + publisher_filter = {s.strip().lower() for s in self.settings.id_publisher_filter.split(',')} # use '' as publisher name if None - self.cv_search_results = list(filter(lambda d: ('' if d['publisher'] is None else str(d['publisher']['name']).lower()) not in publisher_blacklist, self.cv_search_results)) + self.cv_search_results = list(filter(lambda d: ('' if d['publisher'] is None else str(d['publisher']['name']).lower()) not in publisher_filter, self.cv_search_results)) except: - print('bad data error filtering blacklist publishers') + print('bad data error filtering filter publishers') # pre sort the data - so that we can put exact matches first afterwards # compare as str incase extra chars ie. '1976?' @@ -368,7 +367,7 @@ class VolumeSelectionWindow(QtWidgets.QDialog): self.cv_search_results = sorted(self.cv_search_results, key = lambda i: str(i['count_of_issues']), reverse=True) except: print('bad data error sorting results by count_of_issues') - + # move sanitized matches to the front if self.settings.exact_series_matches_first: try: @@ -449,7 +448,7 @@ class VolumeSelectionWindow(QtWidgets.QDialog): return self.volume_id = self.twList.item(curr.row(), 0).data(QtCore.Qt.UserRole) - + # list selection was changed, update the info on the volume for record in self.cv_search_results: if record['id'] == self.volume_id: