Cleanup setCheckState

Fix word splitting when auto-tagging
Remove commented code
This commit is contained in:
lordwelch 2022-05-22 20:02:49 -07:00
parent 710d9bf6a5
commit c5772c75e5
12 changed files with 35 additions and 101 deletions

View File

@ -138,13 +138,6 @@ class Lexer:
self.backup()
# NextItem returns the next item from the input.
# Called by the parser, not in the lexing goroutine.
# def next_item(self) -> Item:
# item: Item = self.items.get()
# self.lastPos = item.pos
# return item
def scan_number(self) -> bool:
digits = "0123456789"
@ -253,7 +246,6 @@ def lex_filename(lex: Lexer) -> Optional[Callable[[Lexer], Optional[Callable]]]:
if lex.sbrace_depth < 0:
return errorf(lex, "unexpected right brace " + r)
elif is_symbol(r):
# L.backup()
lex.emit(ItemType.Symbol)
else:
return errorf(lex, "unrecognized character in action: " + r)

View File

@ -404,7 +404,6 @@ def parse(p: Parser) -> Optional[Callable[[Parser], Optional[Callable]]]:
if item.typ == filenamelexer.ItemType.Number:
likely_year = False
if p.firstItem and p.first_is_alt:
# raise Exception("fuck you")
p.alt = True
return parse_issue_number

View File

@ -34,25 +34,6 @@ class UtilsVars:
already_fixed_encoding = False
def get_actual_preferred_encoding() -> str:
preferred_encoding = locale.getpreferredencoding()
if platform.system() == "Darwin":
preferred_encoding = "utf-8"
return preferred_encoding
# def fix_output_encoding() -> None:
# if not UtilsVars.already_fixed_encoding:
# # this reads the environment and inits the right locale
# locale.setlocale(locale.LC_ALL, "")
# # try to make stdout/stderr encodings happy for unicode printing
# preferred_encoding = get_actual_preferred_encoding()
# sys.stdout = codecs.getwriter(preferred_encoding)(sys.stdout)
# sys.stderr = codecs.getwriter(preferred_encoding)(sys.stderr)
# UtilsVars.already_fixed_encoding = True
def get_recursive_filelist(pathlist: List[str]) -> List[str]:
"""Get a recursive list of of all files under all path items in the list"""

View File

@ -37,31 +37,18 @@ class AutoTagStartWindow(QtWidgets.QDialog):
self.settings = settings
self.cbxSaveOnLowConfidence.setCheckState(QtCore.Qt.CheckState.Unchecked)
self.cbxDontUseYear.setCheckState(QtCore.Qt.CheckState.Unchecked)
self.cbxAssumeIssueOne.setCheckState(QtCore.Qt.CheckState.Unchecked)
self.cbxIgnoreLeadingDigitsInFilename.setCheckState(QtCore.Qt.CheckState.Unchecked)
self.cbxRemoveAfterSuccess.setCheckState(QtCore.Qt.CheckState.Unchecked)
self.cbxSpecifySearchString.setCheckState(QtCore.Qt.CheckState.Unchecked)
self.cbxAutoImprint.setCheckState(QtCore.Qt.CheckState.Unchecked)
self.cbxSplitWords.setCheckState(QtCore.Qt.Unchecked)
self.cbxSpecifySearchString.setChecked(False)
self.cbxSplitWords.setChecked(False)
self.leNameLengthMatchTolerance.setText(str(self.settings.id_length_delta_thresh))
self.leSearchString.setEnabled(False)
if self.settings.save_on_low_confidence:
self.cbxSaveOnLowConfidence.setCheckState(QtCore.Qt.CheckState.Checked)
if self.settings.dont_use_year_when_identifying:
self.cbxDontUseYear.setCheckState(QtCore.Qt.CheckState.Checked)
if self.settings.assume_1_if_no_issue_num:
self.cbxAssumeIssueOne.setCheckState(QtCore.Qt.CheckState.Checked)
if self.settings.ignore_leading_numbers_in_filename:
self.cbxIgnoreLeadingDigitsInFilename.setCheckState(QtCore.Qt.CheckState.Checked)
if self.settings.remove_archive_after_successful_match:
self.cbxRemoveAfterSuccess.setCheckState(QtCore.Qt.CheckState.Checked)
if self.settings.wait_and_retry_on_rate_limit:
self.cbxWaitForRateLimit.setCheckState(QtCore.Qt.CheckState.Checked)
if self.settings.auto_imprint:
self.cbxAutoImprint.setCheckState(QtCore.Qt.CheckState.Checked)
self.cbxSaveOnLowConfidence.setChecked(self.settings.save_on_low_confidence)
self.cbxDontUseYear.setChecked(self.settings.dont_use_year_when_identifying)
self.cbxAssumeIssueOne.setChecked(self.settings.assume_1_if_no_issue_num)
self.cbxIgnoreLeadingDigitsInFilename.setChecked(self.settings.ignore_leading_numbers_in_filename)
self.cbxRemoveAfterSuccess.setChecked(self.settings.remove_archive_after_successful_match)
self.cbxWaitForRateLimit.setChecked(self.settings.wait_and_retry_on_rate_limit)
self.cbxAutoImprint.setChecked(self.settings.auto_imprint)
nlmt_tip = """ <html>The <b>Name Length Match Tolerance</b> is for eliminating automatic
search matches that are too long compared to your series name search. The higher
@ -108,7 +95,7 @@ class AutoTagStartWindow(QtWidgets.QDialog):
self.remove_after_success = self.cbxRemoveAfterSuccess.isChecked()
self.name_length_match_tolerance = int(self.leNameLengthMatchTolerance.text())
self.wait_and_retry_on_rate_limit = self.cbxWaitForRateLimit.isChecked()
self.splitWords = self.cbxSplitWords.isChecked()
self.split_words = self.cbxSplitWords.isChecked()
# persist some settings
self.settings.save_on_low_confidence = self.auto_save_on_low

View File

@ -34,7 +34,6 @@ from comictaggerlib.options import Options
from comictaggerlib.resulttypes import IssueResult, MultipleMatch, OnlineMatchResults
from comictaggerlib.settings import ComicTaggerSettings
filename_encoding = sys.getfilesystemencoding()
logger = logging.getLogger(__name__)

View File

@ -311,7 +311,6 @@ class ComicVineCacher:
"name": row[1],
"count_of_issues": row[3],
"start_year": row[4],
# "issues": [],
"publisher": {"name": row[2]},
}
)

View File

@ -18,7 +18,7 @@
import logging
from typing import Any
from PyQt5 import QtCore, QtWidgets, uic
from PyQt5 import QtWidgets, uic
from comictaggerlib.settings import ComicTaggerSettings
@ -64,8 +64,7 @@ class CreditEditorWindow(QtWidgets.QDialog):
else:
self.cbRole.setCurrentIndex(i)
if primary:
self.cbPrimary.setCheckState(QtCore.Qt.CheckState.Checked)
self.cbPrimary.setChecked(primary)
self.cbRole.currentIndexChanged.connect(self.role_changed)
self.cbRole.editTextChanged.connect(self.role_changed)

View File

@ -43,8 +43,8 @@ class ExportWindow(QtWidgets.QDialog):
self.settings = settings
self.cbxDeleteOriginal.setCheckState(QtCore.Qt.CheckState.Unchecked)
self.cbxAddToList.setCheckState(QtCore.Qt.CheckState.Checked)
self.cbxDeleteOriginal.setChecked(False)
self.cbxAddToList.setChecked(True)
self.radioDontCreate.setChecked(True)
self.deleteOriginal = False

View File

@ -244,7 +244,6 @@ class FileSelectionList(QtWidgets.QWidget):
def add_path_item(self, path: str) -> int:
path = str(path)
path = os.path.abspath(path)
# print "processing", path
if self.is_list_dupe(path):
return self.get_current_list_row(path)

View File

@ -88,7 +88,7 @@ try:
from comictaggerlib.taggerwindow import TaggerWindow
except ImportError as e:
def show_exception_box(log_msg: str):
def show_exception_box(log_msg: str) -> None:
pass
logger.error(str(e))

View File

@ -214,8 +214,7 @@ class SettingsWindow(QtWidgets.QDialog):
self.leNameLengthDeltaThresh.setText(str(self.settings.id_length_delta_thresh))
self.tePublisherFilter.setPlainText(self.settings.id_publisher_filter)
if self.settings.check_for_new_version:
self.cbxCheckForNewVersion.setCheckState(QtCore.Qt.CheckState.Checked)
self.cbxCheckForNewVersion.setChecked(self.settings.check_for_new_version)
self.cbxComplicatedParser.setChecked(self.settings.complicated_parser)
self.cbxRemoveC2C.setChecked(self.settings.remove_c2c)
@ -223,52 +222,33 @@ class SettingsWindow(QtWidgets.QDialog):
self.cbxRemovePublisher.setChecked(self.settings.remove_publisher)
self.switch_parser()
if self.settings.use_series_start_as_volume:
self.cbxUseSeriesStartAsVolume.setCheckState(QtCore.Qt.CheckState.Checked)
if self.settings.clear_form_before_populating_from_cv:
self.cbxClearFormBeforePopulating.setCheckState(QtCore.Qt.CheckState.Checked)
if self.settings.remove_html_tables:
self.cbxRemoveHtmlTables.setCheckState(QtCore.Qt.CheckState.Checked)
self.cbxUseSeriesStartAsVolume.setChecked(self.settings.use_series_start_as_volume)
self.cbxClearFormBeforePopulating.setChecked(self.settings.clear_form_before_populating_from_cv)
self.cbxRemoveHtmlTables.setChecked(self.settings.remove_html_tables)
if self.settings.always_use_publisher_filter:
self.cbxUseFilter.setCheckState(QtCore.Qt.CheckState.Checked)
if self.settings.sort_series_by_year:
self.cbxSortByYear.setCheckState(QtCore.Qt.CheckState.Checked)
if self.settings.exact_series_matches_first:
self.cbxExactMatches.setCheckState(QtCore.Qt.CheckState.Checked)
self.cbxUseFilter.setChecked(self.settings.always_use_publisher_filter)
self.cbxSortByYear.setChecked(self.settings.sort_series_by_year)
self.cbxExactMatches.setChecked(self.settings.exact_series_matches_first)
self.leKey.setText(str(self.settings.cv_api_key))
if self.settings.assume_lone_credit_is_primary:
self.cbxAssumeLoneCreditIsPrimary.setCheckState(QtCore.Qt.CheckState.Checked)
if self.settings.copy_characters_to_tags:
self.cbxCopyCharactersToTags.setCheckState(QtCore.Qt.CheckState.Checked)
if self.settings.copy_teams_to_tags:
self.cbxCopyTeamsToTags.setCheckState(QtCore.Qt.CheckState.Checked)
if self.settings.copy_locations_to_tags:
self.cbxCopyLocationsToTags.setCheckState(QtCore.Qt.CheckState.Checked)
if self.settings.copy_storyarcs_to_tags:
self.cbxCopyStoryArcsToTags.setCheckState(QtCore.Qt.CheckState.Checked)
if self.settings.copy_notes_to_comments:
self.cbxCopyNotesToComments.setCheckState(QtCore.Qt.CheckState.Checked)
if self.settings.copy_weblink_to_comments:
self.cbxCopyWebLinkToComments.setCheckState(QtCore.Qt.CheckState.Checked)
if self.settings.apply_cbl_transform_on_cv_import:
self.cbxApplyCBLTransformOnCVIMport.setCheckState(QtCore.Qt.CheckState.Checked)
if self.settings.apply_cbl_transform_on_bulk_operation:
self.cbxApplyCBLTransformOnBatchOperation.setCheckState(QtCore.Qt.CheckState.Checked)
self.cbxAssumeLoneCreditIsPrimary.setChecked(self.settings.assume_lone_credit_is_primary)
self.cbxCopyCharactersToTags.setChecked(self.settings.copy_characters_to_tags)
self.cbxCopyTeamsToTags.setChecked(self.settings.copy_teams_to_tags)
self.cbxCopyLocationsToTags.setChecked(self.settings.copy_locations_to_tags)
self.cbxCopyStoryArcsToTags.setChecked(self.settings.copy_storyarcs_to_tags)
self.cbxCopyNotesToComments.setChecked(self.settings.copy_notes_to_comments)
self.cbxCopyWebLinkToComments.setChecked(self.settings.copy_weblink_to_comments)
self.cbxApplyCBLTransformOnCVIMport.setChecked(self.settings.apply_cbl_transform_on_cv_import)
self.cbxApplyCBLTransformOnBatchOperation.setChecked(self.settings.apply_cbl_transform_on_bulk_operation)
self.leRenameTemplate.setText(self.settings.rename_template)
self.leIssueNumPadding.setText(str(self.settings.rename_issue_number_padding))
if self.settings.rename_use_smart_string_cleanup:
self.cbxSmartCleanup.setCheckState(QtCore.Qt.CheckState.Checked)
if self.settings.rename_extension_based_on_archive:
self.cbxChangeExtension.setCheckState(QtCore.Qt.CheckState.Checked)
if self.settings.rename_move_dir:
self.cbxMoveFiles.setCheckState(QtCore.Qt.CheckState.Checked)
self.cbxSmartCleanup.setChecked(self.settings.rename_use_smart_string_cleanup)
self.cbxChangeExtension.setChecked(self.settings.rename_extension_based_on_archive)
self.cbxMoveFiles.setChecked(self.settings.rename_move_dir)
self.leDirectory.setText(self.settings.rename_dir)
if self.settings.rename_strict:
self.cbxRenameStrict.setCheckState(QtCore.Qt.CheckState.Checked)
self.cbxRenameStrict.setChecked(self.settings.rename_strict)
def accept(self) -> None:
self.rename_test()

View File

@ -255,7 +255,6 @@ Have fun!
self.settings.show_disclaimer = not checked
if self.settings.check_for_new_version:
# self.checkLatestVersionOnline()
pass
def sigint_handler(self, *args: Any) -> None: