Update settngs

Fix renamed settings attributes
Add --parse-filename back
Fix conversions in fileranamer
This commit is contained in:
Timmy Welch 2024-06-21 21:01:11 -07:00
parent 6b0dca2f51
commit 42448fa250
6 changed files with 20 additions and 8 deletions

View File

@ -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]

View File

@ -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 = """<html>The <b>Name Match Ratio Threshold: Auto-Identify</b> 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()

View File

@ -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",

View File

@ -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

View File

@ -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(

View File

@ -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