diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 84823e5..ac2a554 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -41,6 +41,6 @@ repos: rev: v1.10.0 hooks: - id: mypy - additional_dependencies: [types-setuptools, types-requests, settngs>=0.10.3] + additional_dependencies: [types-setuptools, types-requests, settngs>=0.10.4] ci: skip: [mypy] diff --git a/comictaggerlib/autotagstartwindow.py b/comictaggerlib/autotagstartwindow.py index 109ba7d..373edbd 100644 --- a/comictaggerlib/autotagstartwindow.py +++ b/comictaggerlib/autotagstartwindow.py @@ -49,7 +49,7 @@ class AutoTagStartWindow(QtWidgets.QDialog): self.cbxDontUseYear.setChecked(not self.config.Auto_Tag__use_year_when_identifying) self.cbxAssumeIssueOne.setChecked(self.config.Auto_Tag__assume_issue_one) self.cbxIgnoreLeadingDigitsInFilename.setChecked(self.config.Auto_Tag__ignore_leading_numbers_in_filename) - self.cbxRemoveAfterSuccess.setChecked(self.config.Auto_Tag__remove_archive_after_successful_match) + self.cbxRemoveAfterSuccess.setChecked(self.config.internal__remove_archive_after_successful_match) self.cbxAutoImprint.setChecked(self.config.Auto_Tag__auto_imprint) nlmt_tip = """The Name Match Ratio Threshold: Auto-Identify is for eliminating automatic @@ -98,7 +98,7 @@ class AutoTagStartWindow(QtWidgets.QDialog): self.config.Auto_Tag__use_year_when_identifying = not self.dont_use_year self.config.Auto_Tag__assume_issue_one = self.assume_issue_one self.config.Auto_Tag__ignore_leading_numbers_in_filename = self.ignore_leading_digits_in_filename - self.config.Auto_Tag__remove_archive_after_successful_match = self.remove_after_success + self.config.internal__remove_archive_after_successful_match = self.remove_after_success if self.cbxSpecifySearchString.isChecked(): self.search_string = self.leSearchString.text() diff --git a/comictaggerlib/ctsettings/file.py b/comictaggerlib/ctsettings/file.py index 031a1b0..1a9b1be 100644 --- a/comictaggerlib/ctsettings/file.py +++ b/comictaggerlib/ctsettings/file.py @@ -273,6 +273,13 @@ def autotag(parser: settngs.Manager) -> None: action=argparse.BooleanOptionalAction, help="When searching ignore leading numbers in the filename.\ndefault: %(default)s", ) + parser.add_setting( + "-f", + "--parse-filename", + action="store_true", + help="""Parse the filename to get some info,\nspecifically series name, issue number,\nvolume, and publication year.\n\n""", + file=False, + ) parser.add_setting( "--prefer-filename", action="store_true", diff --git a/comictaggerlib/ctsettings/settngs_namespace.py b/comictaggerlib/ctsettings/settngs_namespace.py index 6e519dc..10a60cc 100644 --- a/comictaggerlib/ctsettings/settngs_namespace.py +++ b/comictaggerlib/ctsettings/settngs_namespace.py @@ -99,6 +99,7 @@ class SettngsNS(settngs.TypedNS): Auto_Tag__use_year_when_identifying: bool Auto_Tag__assume_issue_one: bool Auto_Tag__ignore_leading_numbers_in_filename: bool + Auto_Tag__parse_filename: bool Auto_Tag__prefer_filename: bool Auto_Tag__issue_id: str | None Auto_Tag__metadata: comicapi.genericmetadata.GenericMetadata @@ -225,6 +226,7 @@ class Auto_Tag(typing.TypedDict): use_year_when_identifying: bool assume_issue_one: bool ignore_leading_numbers_in_filename: bool + parse_filename: bool prefer_filename: bool issue_id: str | None metadata: comicapi.genericmetadata.GenericMetadata diff --git a/comictaggerlib/filerenamer.py b/comictaggerlib/filerenamer.py index 04c5ea0..3ef5bbf 100644 --- a/comictaggerlib/filerenamer.py +++ b/comictaggerlib/filerenamer.py @@ -73,7 +73,7 @@ class MetadataFormatter(string.Formatter): return cast(str, super().format_field(value, format_spec)) def convert_field(self, value: Any, conversion: str | None) -> str: - if isinstance(value, Iterable) and not isinstance(value, str) and not _isnamedtupleinstance(value): + if isinstance(value, Iterable) and not isinstance(value, (str, tuple)): if conversion == "C": if isinstance(value, Sized): return str(len(value)) @@ -91,11 +91,13 @@ class MetadataFormatter(string.Formatter): ... return list(value)[i] return "" + if conversion == "j": + conversion = "s" try: - return ", ".join(list(self.convert_field(v, conversion) for v in sorted(value))) + return ", ".join(list(self.convert_field(v, conversion) for v in sorted(value) if v is not None)) except Exception: ... - return ", ".join(list(self.convert_field(v, conversion) for v in value)) + return ", ".join(list(self.convert_field(v, conversion) for v in value if v is not None)) if not conversion: return cast(str, super().convert_field(value, conversion)) if conversion == "u": @@ -186,7 +188,8 @@ class MetadataFormatter(string.Formatter): obj = self.none_replacement(obj, replacement, r) # do any conversion on the resulting object obj = self.convert_field(obj, conversion) - obj = self.none_replacement(obj, replacement, r) + if r == "-": + obj = self.none_replacement(obj, replacement, r) # expand the format spec, if needed format_spec, _ = self._vformat( diff --git a/setup.cfg b/setup.cfg index 0899619..5c169f1 100644 --- a/setup.cfg +++ b/setup.cfg @@ -48,7 +48,7 @@ install_requires = pyyaml rapidfuzz>=2.12.0 requests==2.* - settngs==0.10.3 + settngs==0.10.4 text2digits typing-extensions>=4.3.0 wordninja