From 32b570ee5bc5cb6acc1e093ac50b3cdca6de670e Mon Sep 17 00:00:00 2001 From: Timmy Welch Date: Tue, 21 May 2024 19:57:28 -0700 Subject: [PATCH] Improve help messages Include default values --- comictaggerlib/autotagstartwindow.py | 4 +- comictaggerlib/cli.py | 3 + comictaggerlib/ctsettings/commandline.py | 30 ++++---- comictaggerlib/ctsettings/file.py | 74 ++++++++++--------- .../ctsettings/settngs_namespace.py | 16 ++-- comictaggerlib/ctsettings/types.py | 3 + comictaggerlib/taggerwindow.py | 12 +-- comictaggerlib/ui/settingswindow.ui | 12 +-- 8 files changed, 84 insertions(+), 70 deletions(-) diff --git a/comictaggerlib/autotagstartwindow.py b/comictaggerlib/autotagstartwindow.py index f1a49ae..109ba7d 100644 --- a/comictaggerlib/autotagstartwindow.py +++ b/comictaggerlib/autotagstartwindow.py @@ -46,7 +46,7 @@ class AutoTagStartWindow(QtWidgets.QDialog): self.leSearchString.setEnabled(False) self.cbxSaveOnLowConfidence.setChecked(self.config.Auto_Tag__save_on_low_confidence) - self.cbxDontUseYear.setChecked(self.config.Auto_Tag__dont_use_year_when_auto_tagging) + 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) @@ -95,7 +95,7 @@ class AutoTagStartWindow(QtWidgets.QDialog): # persist some settings self.config.Auto_Tag__save_on_low_confidence = self.auto_save_on_low - self.config.Auto_Tag__dont_use_year_when_auto_tagging = self.dont_use_year + 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 diff --git a/comictaggerlib/cli.py b/comictaggerlib/cli.py index 6f3ff1a..ab5a106 100644 --- a/comictaggerlib/cli.py +++ b/comictaggerlib/cli.py @@ -453,6 +453,9 @@ class CLI: ii.set_output_function(functools.partial(self.output, already_logged=True)) # use our overlaid MD to search + + if not self.config.Auto_Tag__use_year_when_identifying: + md.year = None result, matches = ii.identify(ca, md) found_match = False diff --git a/comictaggerlib/ctsettings/commandline.py b/comictaggerlib/ctsettings/commandline.py index 2d40384..0be17bd 100644 --- a/comictaggerlib/ctsettings/commandline.py +++ b/comictaggerlib/ctsettings/commandline.py @@ -40,7 +40,7 @@ def initial_commandline_parser() -> argparse.ArgumentParser: # Ensure this stays up to date with register_runtime parser.add_argument( "--config", - help="Config directory defaults to ~/.config/ComicTagger on Linux.\n~/Library/Application Support/ComicTagger on Mac.\n%%LOCALAPPDATA%%\\ComicTagger on Windows.\n\n", + help="Config directory for ComicTagger to use.\ndefault: %(default)s\n\n", type=ComicTaggerPaths, default=ComicTaggerPaths(), ) @@ -57,7 +57,7 @@ def initial_commandline_parser() -> argparse.ArgumentParser: def register_runtime(parser: settngs.Manager) -> None: parser.add_setting( "--config", - help="Config directory defaults to ~/.config/ComicTagger on Linux.\n~/Library/Application Support/ComicTagger on Mac.\n%%LOCALAPPDATA%%\\ComicTagger on Windows.\n\n", + help="Config directory for ComicTagger to use.\ndefault: %(default)s\n\n", type=ComicTaggerPaths, default=ComicTaggerPaths(), file=False, @@ -96,7 +96,7 @@ def register_runtime(parser: settngs.Manager) -> None: dest="abort_on_low_confidence", action=argparse.BooleanOptionalAction, default=True, - help="""Abort save operation when online match is of low confidence.""", + help="""Abort save operation when online match is of low confidence.\ndefault: %(default)s""", file=False, ) parser.add_setting( @@ -110,7 +110,7 @@ def register_runtime(parser: settngs.Manager) -> None: "--summary", default=True, action=argparse.BooleanOptionalAction, - help="Show the summary after a save operation.", + help="Show the summary after a save operation.\ndefault: %(default)s", file=False, ) parser.add_setting( @@ -154,31 +154,35 @@ def register_runtime(parser: settngs.Manager) -> None: file=False, ) parser.add_setting( - "--read-style-overlay", - type=merge.Mode, + "--read-style-merge", + metavar=f"{{{','.join(merge.Mode)}}}", default=merge.Mode.OVERLAY, - help="How to overlay new metadata on the current for enabled read styles (CR, CBL, etc.)", + choices=merge.Mode, + type=merge.Mode, + help="How to merge additional metadata for enabled read styles (CR, CBL, etc.) See -t, --type-read default: %(default)s", file=False, ) parser.add_setting( - "--source-overlay", - type=merge.Mode, + "--source-merge", + metavar=f"{{{','.join(merge.Mode)}}}", default=merge.Mode.OVERLAY, - help="How to overlay new metadata from a data source (CV, Metron, GCD, etc.) on to the current", + choices=merge.Mode, + type=merge.Mode, + help="How to merge new metadata from a data source (CV, Metron, GCD, etc.) default: %(default)s", file=False, ) parser.add_setting( - "--overlay-merge-lists", + "--merge-lists", action=argparse.BooleanOptionalAction, default=True, - help="When overlaying, merge or replace lists (genres, characters, etc.)", + help="Merge all items of lists when merging new metadata (genres, characters, etc.) default: %(default)s", file=False, ) parser.add_setting( "--skip-existing-metadata", action=argparse.BooleanOptionalAction, default=True, - help="""Skip archives that already have tags specified with -t,\notherwise merges new metadata with existing metadata (relevant for -s or -c).""", + help="""Skip archives that already have tags specified with -t,\notherwise merges new metadata with existing metadata (relevant for -s or -c).\ndefault: %(default)s""", file=False, ) parser.add_setting("files", nargs="*", default=[], file=False) diff --git a/comictaggerlib/ctsettings/file.py b/comictaggerlib/ctsettings/file.py index e40d784..b82a772 100644 --- a/comictaggerlib/ctsettings/file.py +++ b/comictaggerlib/ctsettings/file.py @@ -19,7 +19,7 @@ def general(parser: settngs.Manager) -> None: "--prompt-on-save", default=True, action=argparse.BooleanOptionalAction, - help="Prompts the user to confirm saving tags when using the GUI.", + help="Prompts the user to confirm saving tags when using the GUI.\ndefault: %(default)s", ) @@ -47,33 +47,33 @@ def identifier(parser: settngs.Manager) -> None: "--series-match-identify-thresh", default=91, type=int, - help="The minimum Series name similarity needed to auto-identify an issue", + help="The minimum Series name similarity needed to auto-identify an issue default: %(default)s", ) parser.add_setting( "--series-match-search-thresh", default=90, type=int, - help="The minimum Series name similarity to return from a search result", + help="The minimum Series name similarity to return from a search result default: %(default)s", ) parser.add_setting( "-b", "--border-crop-percent", default=10, type=int, - help="ComicTagger will automatically add an additional cover that has any black borders cropped.\nIf the difference in height is less than %(default)s%% the cover will not be cropped.\n\n", + help="ComicTagger will automatically add an additional cover that has any black borders cropped.\nIf the difference in height is less than %(default)s%% the cover will not be cropped.\ndefault: %(default)s\n\n", ) parser.add_setting( "--sort-series-by-year", default=True, action=argparse.BooleanOptionalAction, - help="Sorts series by year", + help="Sorts series by year default: %(default)s", ) parser.add_setting( "--exact-series-matches-first", default=True, action=argparse.BooleanOptionalAction, - help="Puts series that are an exact match at the top of the list", + help="Puts series that are an exact match at the top of the list default: %(default)s", ) @@ -89,44 +89,44 @@ def filename(parser: settngs.Manager) -> None: default=utils.Parser.ORIGINAL, metavar=f"{{{','.join(utils.Parser)}}}", type=utils.Parser, - choices=[p.value for p in utils.Parser], - help="Select the filename parser, defaults to original", + choices=utils.Parser, + help="Select the filename parser.\ndefault: %(default)s", ) parser.add_setting( "--remove-c2c", default=False, action=argparse.BooleanOptionalAction, - help="Removes c2c from filenames.\nRequires --complicated-parser\n\n", + help="Removes c2c from filenames.\nRequires --complicated-parser\ndefault: %(default)s\n\n", ) parser.add_setting( "--remove-fcbd", default=False, action=argparse.BooleanOptionalAction, - help="Removes FCBD/free comic book day from filenames.\nRequires --complicated-parser\n\n", + help="Removes FCBD/free comic book day from filenames.\nRequires --complicated-parser\ndefault: %(default)s\n\n", ) parser.add_setting( "--remove-publisher", default=False, action=argparse.BooleanOptionalAction, - help="Attempts to remove publisher names from filenames, currently limited to Marvel and DC.\nRequires --complicated-parser\n\n", + help="Attempts to remove publisher names from filenames, currently limited to Marvel and DC.\nRequires --complicated-parser\ndefault: %(default)s\n\n", ) parser.add_setting( "--split-words", action="store_true", - help="""Splits words before parsing the filename.\ne.g. 'judgedredd' to 'judge dredd'\n\n""", + help="""Splits words before parsing the filename.\ne.g. 'judgedredd' to 'judge dredd'\ndefault: %(default)s\n\n""", file=False, ) parser.add_setting( "--protofolius-issue-number-scheme", default=False, action=argparse.BooleanOptionalAction, - help="Use an issue number scheme devised by protofolius for encoding format information as a letter in front of an issue number.\nImplies --allow-issue-start-with-letter. Requires --complicated-parser\n\n", + help="Use an issue number scheme devised by protofolius for encoding format information as a letter in front of an issue number.\nImplies --allow-issue-start-with-letter. Requires --complicated-parser\ndefault: %(default)s\n\n", ) parser.add_setting( "--allow-issue-start-with-letter", default=False, action=argparse.BooleanOptionalAction, - help="Allows an issue number to start with a single letter (e.g. '#X01').\nRequires --complicated-parser\n\n", + help="Allows an issue number to start with a single letter (e.g. '#X01').\nRequires --complicated-parser\ndefault: %(default)s\n\n", ) @@ -134,14 +134,14 @@ def talker(parser: settngs.Manager) -> None: parser.add_setting( "--source", default="comicvine", - help="Use a specified source by source ID (use --list-plugins to list all sources)", + help="Use a specified source by source ID (use --list-plugins to list all sources).\ndefault: %(default)s", ) parser.add_setting( "--remove-html-tables", default=False, action=argparse.BooleanOptionalAction, display_name="Remove HTML tables", - help="Removes html tables instead of converting them to text", + help="Removes html tables instead of converting them to text.\ndefault: %(default)s", ) @@ -162,48 +162,52 @@ def md_options(parser: settngs.Manager) -> None: "--cr", default=True, action=argparse.BooleanOptionalAction, - help="Enable the ComicRack metadata type. Turn off to only use the CIX metadata type.", + help="Enable the ComicRack metadata type. Turn off to only use the CIX metadata type.\ndefault: %(default)s", ) def rename(parser: settngs.Manager) -> None: - parser.add_setting("--template", default="{series} #{issue} ({year})", help="The teplate to use when renaming") + parser.add_setting( + "--template", + default="{series} #{issue} ({year})", + help="The teplate to use when renaming.\ndefault: %(default)s", + ) parser.add_setting( "--issue-number-padding", default=3, type=int, - help="The minimum number of digits to use for the issue number when renaming", + help="The minimum number of digits to use for the issue number when renaming.\ndefault: %(default)s", ) parser.add_setting( "--use-smart-string-cleanup", default=True, action=argparse.BooleanOptionalAction, - help="Attempts to intelligently cleanup whitespace when renaming", + help="Attempts to intelligently cleanup whitespace when renaming.\ndefault: %(default)s", ) parser.add_setting( "--auto-extension", default=True, action=argparse.BooleanOptionalAction, - help="Automatically sets the extension based on the archive type e.g. cbr for rar, cbz for zip", + help="Automatically sets the extension based on the archive type e.g. cbr for rar, cbz for zip.\ndefault: %(default)s", ) - parser.add_setting("--dir", default="", help="The directory to move renamed files to") + parser.add_setting("--dir", default="", help="The directory to move renamed files to.") parser.add_setting( "--move", default=False, action=argparse.BooleanOptionalAction, - help="Enables moving renamed files to a separate directory", + help="Enables moving renamed files to a separate directory.\ndefault: %(default)s", ) parser.add_setting( "--only-move", default=False, action=argparse.BooleanOptionalAction, - help="Ignores the filename when moving renamed files to a separate directory", + help="Ignores the filename when moving renamed files to a separate directory.\ndefault: %(default)s", ) parser.add_setting( "--strict-filenames", default=False, action=argparse.BooleanOptionalAction, - help="Ensures that filenames are valid for all OSs", + help="Ensures that filenames are valid for all OSs.\ndefault: %(default)s", ) parser.add_setting("replacements", default=DEFAULT_REPLACEMENTS, cmdline=False) @@ -220,26 +224,26 @@ def autotag(parser: settngs.Manager) -> None: "--save-on-low-confidence", default=False, action=argparse.BooleanOptionalAction, - help="Automatically save metadata on low-confidence matches", + help="Automatically save metadata on low-confidence matches.\ndefault: %(default)s", ) parser.add_setting( - "--dont-use-year-when-auto-tagging", - default=False, + "--use-year-when-identifying", + default=True, action=argparse.BooleanOptionalAction, - help="Ignore the year metadata attribute when auto-tagging a comic", + help="Use the year metadata attribute when auto-tagging a comic.\ndefault: %(default)s", ) parser.add_setting( "-1", "--assume-issue-one", action=argparse.BooleanOptionalAction, - help="Assume issue number is 1 if not found (relevant for -s).\n\n", + help="Assume issue number is 1 if not found (relevant for -s).\ndefault: %(default)s\n\n", default=False, ) parser.add_setting( "--ignore-leading-numbers-in-filename", default=False, action=argparse.BooleanOptionalAction, - help="When searching ignore leading numbers in the filename", + help="When searching ignore leading numbers in the filename.\ndefault: %(default)s", ) parser.add_setting("remove_archive_after_successful_match", default=False, cmdline=False) parser.add_setting( @@ -268,27 +272,27 @@ def autotag(parser: settngs.Manager) -> None: "--clear-metadata", default=False, action=argparse.BooleanOptionalAction, - help="Clears all existing metadata during import, default is to merge metadata.\nMay be used in conjunction with -o, -f and -m.\n\n", + help="Clears all existing metadata during import, default is to merge metadata.\nMay be used in conjunction with -o, -f and -m.\ndefault: %(default)s\n\n", ) parser.add_setting( "--publisher-filter", default=["Panini Comics", "Abril", "Planeta DeAgostini", "Editorial Televisa", "Dino Comics"], action="extend", nargs="+", - help="When enabled, filters the listed publishers from all search results.\nEnding a publisher with a '-' removes a publisher from this list\n\n", + help="When enabled, filters the listed publishers from all search results.\nEnding a publisher with a '-' removes a publisher from this list\ndefault: %(default)s\n\n", ) parser.add_setting( "--use-publisher-filter", default=False, action=argparse.BooleanOptionalAction, - help="Enables the publisher filter", + help="Enables the publisher filter.\ndefault: %(default)s", ) parser.add_setting( "-a", "--auto-imprint", default=False, action=argparse.BooleanOptionalAction, - help="Enables the auto imprint functionality.\ne.g. if the publisher is set to 'vertigo' it\nwill be updated to 'DC Comics' and the imprint\nproperty will be set to 'Vertigo'.\n\n", + help="Enables the auto imprint functionality.\ne.g. if the publisher is set to 'vertigo' it\nwill be updated to 'DC Comics' and the imprint\nproperty will be set to 'Vertigo'.\ndefault: %(default)s\n\n", ) diff --git a/comictaggerlib/ctsettings/settngs_namespace.py b/comictaggerlib/ctsettings/settngs_namespace.py index c8eb061..a106485 100644 --- a/comictaggerlib/ctsettings/settngs_namespace.py +++ b/comictaggerlib/ctsettings/settngs_namespace.py @@ -34,9 +34,9 @@ class SettngsNS(settngs.TypedNS): Runtime_Options__delete_original: bool Runtime_Options__type_read: list[str] Runtime_Options__type_modify: list[str] - Runtime_Options__read_style_overlay: comicapi.merge.Mode - Runtime_Options__source_overlay: comicapi.merge.Mode - Runtime_Options__overlay_merge_lists: bool + Runtime_Options__read_style_merge: comicapi.merge.Mode + Runtime_Options__source_merge: comicapi.merge.Mode + Runtime_Options__merge_lists: bool Runtime_Options__skip_existing_metadata: bool Runtime_Options__files: list[str] @@ -97,7 +97,7 @@ class SettngsNS(settngs.TypedNS): Auto_Tag__online: bool Auto_Tag__save_on_low_confidence: bool - Auto_Tag__dont_use_year_when_auto_tagging: bool + Auto_Tag__use_year_when_identifying: bool Auto_Tag__assume_issue_one: bool Auto_Tag__ignore_leading_numbers_in_filename: bool Auto_Tag__remove_archive_after_successful_match: bool @@ -147,9 +147,9 @@ class Runtime_Options(typing.TypedDict): delete_original: bool type_read: list[str] type_modify: list[str] - read_style_overlay: comicapi.merge.Mode - source_overlay: comicapi.merge.Mode - overlay_merge_lists: bool + read_style_merge: comicapi.merge.Mode + source_merge: comicapi.merge.Mode + merge_lists: bool skip_existing_metadata: bool files: list[str] @@ -224,7 +224,7 @@ class File_Rename(typing.TypedDict): class Auto_Tag(typing.TypedDict): online: bool save_on_low_confidence: bool - dont_use_year_when_auto_tagging: bool + use_year_when_identifying: bool assume_issue_one: bool ignore_leading_numbers_in_filename: bool remove_archive_after_successful_match: bool diff --git a/comictaggerlib/ctsettings/types.py b/comictaggerlib/ctsettings/types.py index f693a0d..a195ec6 100644 --- a/comictaggerlib/ctsettings/types.py +++ b/comictaggerlib/ctsettings/types.py @@ -147,6 +147,9 @@ class ComicTaggerPaths(AppDirs): def site_config_dir(self) -> pathlib.Path: return pathlib.Path(super().site_config_dir) + def __str__(self) -> str: + return f"logs: {self.user_log_dir}, config: {self.user_config_dir}, cache: {self.user_cache_dir}" + def metadata_type_single(types: str) -> str: result = metadata_type(types) diff --git a/comictaggerlib/taggerwindow.py b/comictaggerlib/taggerwindow.py index 78d014a..c3bf113 100644 --- a/comictaggerlib/taggerwindow.py +++ b/comictaggerlib/taggerwindow.py @@ -219,12 +219,12 @@ class TaggerWindow(QtWidgets.QMainWindow): config[0].internal__load_data_style = config[0].Runtime_Options__type_read # Respect command line overlay settings - if config[0].Runtime_Options__read_style_overlay: - config[0].internal__load_data_overlay = config[0].Runtime_Options__read_style_overlay - if config[0].Runtime_Options__source_overlay: - config[0].internal__source_data_overlay = config[0].Runtime_Options__source_overlay - if isinstance(config[0].Runtime_Options__overlay_merge_lists, bool): - config[0].internal__overlay_merge_lists = config[0].Runtime_Options__overlay_merge_lists + if config[0].Runtime_Options__read_style_merge: + config[0].internal__load_data_overlay = config[0].Runtime_Options__read_style_merge + if config[0].Runtime_Options__source_merge: + config[0].internal__source_data_overlay = config[0].Runtime_Options__source_merge + if isinstance(config[0].Runtime_Options__merge_lists, bool): + config[0].internal__overlay_merge_lists = config[0].Runtime_Options__merge_lists for style in config[0].internal__save_data_style: if style not in metadata_styles: diff --git a/comictaggerlib/ui/settingswindow.ui b/comictaggerlib/ui/settingswindow.ui index 001a4ec..f7fed10 100644 --- a/comictaggerlib/ui/settingswindow.ui +++ b/comictaggerlib/ui/settingswindow.ui @@ -703,6 +703,12 @@ One Publisher per line 0 + + + 0 + 150 + + 16777215 @@ -715,12 +721,6 @@ One Publisher per line 0 - - true - - - false -