From ff73cbf2f9af62cad034f7d76a99fce66033319f Mon Sep 17 00:00:00 2001 From: Timmy Welch Date: Tue, 7 Jun 2022 20:22:33 -0700 Subject: [PATCH] Fix small issues Fix spelling errors Remove Redundant exception types Remove dead code Change the forum link to point to GitHub discussions --- CONTRIBUTING.md | 2 +- README.md | 8 +++++++- comicapi/comicarchive.py | 22 +++++++++++----------- comicapi/utils.py | 2 +- comictagger.py | 5 ----- comictaggerlib/cli.py | 4 ++-- comictaggerlib/comicvinetalker.py | 2 +- comictaggerlib/imagehasher.py | 2 +- comictaggerlib/issueidentifier.py | 2 +- comictaggerlib/main.py | 2 +- comictaggerlib/options.py | 2 +- comictaggerlib/settings.py | 2 +- comictaggerlib/taggerwindow.py | 2 +- comictaggerlib/ui/autotagstartwindow.ui | 2 +- comictaggerlib/ui/settingswindow.ui | 4 ++-- comictaggerlib/ui/taggerwindow.ui | 2 +- comictaggerlib/volumeselectionwindow.py | 4 ++-- desktop-integration/mac/ComicTagger | 2 +- testing/filenames.py | 2 +- 19 files changed, 37 insertions(+), 36 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 9447b1b..3f01cd8 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -77,7 +77,7 @@ pip install -r requirements-GUI.txt -r requirements-CBR.txt pip install . ``` -6. (optionall) run pytest to ensure that their are no failures (xfailed means expected failure) +6. (optionally) run pytest to ensure that their are no failures (xfailed means expected failure) ``` $ pytest ============================= test session starts ============================== diff --git a/README.md b/README.md index 04c4e1b..7972629 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,10 @@ -[![Build](https://github.com/comictagger/comictagger/actions/workflows/build.yaml/badge.svg)](https://github.com/comictagger/comictagger/actions/workflows/build.yaml) +[![CI](https://github.com/comictagger/comictagger/actions/workflows/build.yaml/badge.svg?branch=develop&event=push)](https://github.com/comictagger/comictagger/actions/workflows/build.yaml) +[![GitHub release (latest by date)](https://img.shields.io/github/downloads/comictagger/comictagger/latest/total)](https://github.com/comictagger/comictagger/releases/latest) +[![PyPI](https://img.shields.io/pypi/v/comictagger)](https://pypi.org/project/comictagger/) +[![PyPI - Downloads](https://img.shields.io/pypi/dm/comictagger)](https://pypistats.org/packages/comictagger) +[![PyPI - License](https://img.shields.io/pypi/l/comictagger)](https://opensource.org/licenses/Apache-2.0) + +[![GitHub Discussions](https://img.shields.io/github/discussions/comictagger/comictagger)](https://github.com/comictagger/comictagger/discussions) [![Gitter chat](https://badges.gitter.im/gitterHQ/gitter.png)](https://gitter.im/comictagger/community) [![Google Group](https://img.shields.io/badge/discuss-on%20groups-%23207de5)](https://groups.google.com/forum/#!forum/comictagger) [![Twitter](https://img.shields.io/badge/%40comictagger-twitter-lightgrey)](https://twitter.com/comictagger) diff --git a/comicapi/comicarchive.py b/comicapi/comicarchive.py index 30ff2b8..ae1c288 100644 --- a/comicapi/comicarchive.py +++ b/comicapi/comicarchive.py @@ -318,7 +318,7 @@ class ZipArchiver(UnknownArchiver): file_length = statinfo.st_size try: - with open(filename, mode="r+b") as fo: + with open(filename, mode="r+b") as file: # the starting position, relative to EOF pos = -4 @@ -327,8 +327,8 @@ class ZipArchiver(UnknownArchiver): # walk backwards to find the "End of Central Directory" record while (not found) and (-pos != file_length): # seek, relative to EOF - fo.seek(pos, 2) - value = fo.read(4) + file.seek(pos, 2) + value = file.read(4) # look for the end of central directory signature if bytearray(value) == bytearray([0x50, 0x4B, 0x05, 0x06]): @@ -341,19 +341,19 @@ class ZipArchiver(UnknownArchiver): # now skip forward 20 bytes to the comment length word pos += 20 - fo.seek(pos, 2) + file.seek(pos, 2) # Pack the length of the comment string fmt = "H" # one 2-byte integer comment_length = struct.pack(fmt, len(comment)) # pack integer in a binary string # write out the length - fo.write(comment_length) - fo.seek(pos + 2, 2) + file.write(comment_length) + file.seek(pos + 2, 2) # write out the comment itself - fo.write(comment.encode("utf-8")) - fo.truncate() + file.write(comment.encode("utf-8")) + file.truncate() else: raise Exception("Could not find the End of Central Directory record!") except Exception as e: @@ -636,7 +636,7 @@ class FolderArchiver(UnknownArchiver): def get_filename_list(self) -> list[str]: filenames = [] try: - for root, dirs, files in os.walk(self.path): + for root, _dirs, files in os.walk(self.path): for f in files: filenames.append(os.path.relpath(os.path.join(root, f), self.path).replace(os.path.sep, "/")) return filenames @@ -855,7 +855,7 @@ class ComicArchive: if filename: try: image_data = self.archiver.read_file(filename) or bytes() - except (OSError, Exception): + except Exception: logger.error("Error reading in page %d. Substituting logo page.", index) image_data = ComicArchive.logo_data @@ -1026,7 +1026,7 @@ class ComicArchive: return b"" try: raw_cix = self.archiver.read_file(self.ci_xml_filename) or b"" - except (OSError, Exception) as e: + except Exception as e: logger.error("Error reading in raw CIX! for %s: %s", self.path, e) raw_cix = bytes() return raw_cix diff --git a/comicapi/utils.py b/comicapi/utils.py index 8907949..8b3e20f 100644 --- a/comicapi/utils.py +++ b/comicapi/utils.py @@ -210,7 +210,7 @@ def update_publishers(new_publishers: Mapping[str, Mapping[str, str]]) -> None: class ImprintDict(dict): """ ImprintDict takes a publisher and a dict or mapping of lowercased - imprint names to the proper imprint name. Retreiving a value from an + imprint names to the proper imprint name. Retrieving a value from an ImprintDict returns a tuple of (imprint, publisher, keyExists). if the key does not exist the key is returned as the publisher unchanged """ diff --git a/comictagger.py b/comictagger.py index c12c6b1..947f5a4 100755 --- a/comictagger.py +++ b/comictagger.py @@ -4,11 +4,6 @@ from __future__ import annotations import localefix from comictaggerlib.main import ctmain - -def main(): - pass - - if __name__ == "__main__": localefix.configure_locale() ctmain() diff --git a/comictaggerlib/cli.py b/comictaggerlib/cli.py index c5255cf..3c7725f 100644 --- a/comictaggerlib/cli.py +++ b/comictaggerlib/cli.py @@ -397,7 +397,7 @@ def process_file_cli( if opts.verbose: IssueIdentifier.default_write_output(text) - # use our overlayed MD struct to search + # use our overlaid MD struct to search ii.set_additional_metadata(md) ii.only_use_additional_meta_data = True ii.wait_and_retry_on_rate_limit = opts.wait_on_cv_rate_limit @@ -568,7 +568,7 @@ def process_file_cli( else: msg = msg_hdr + f"Dry-run: Would try to create {os.path.split(new_file)[1]}" if opts.delete_after_zip_export: - msg += " and delete orginal." + msg += " and delete original." print(msg) return diff --git a/comictaggerlib/comicvinetalker.py b/comictaggerlib/comicvinetalker.py index 92b6a66..7995e32 100644 --- a/comictaggerlib/comicvinetalker.py +++ b/comictaggerlib/comicvinetalker.py @@ -86,7 +86,7 @@ class ComicVineTalker: @staticmethod def get_rate_limit_message() -> str: if ComicVineTalker.api_key == "": - return "Comic Vine rate limit exceeded. You should configue your own Comic Vine API key." + return "Comic Vine rate limit exceeded. You should configure your own Comic Vine API key." return "Comic Vine rate limit exceeded. Please wait a bit." diff --git a/comictaggerlib/imagehasher.py b/comictaggerlib/imagehasher.py index 5993462..0d21203 100755 --- a/comictaggerlib/imagehasher.py +++ b/comictaggerlib/imagehasher.py @@ -30,7 +30,7 @@ logger = logging.getLogger(__name__) class ImageHasher: - def __init__(self, path: str | None = None, data: bytes = bytes(), width: int = 8, height: int = 8) -> None: + def __init__(self, path: str | None = None, data: bytes = b"", width: int = 8, height: int = 8) -> None: self.width = width self.height = height diff --git a/comictaggerlib/issueidentifier.py b/comictaggerlib/issueidentifier.py index 0dac00a..9ffa91f 100644 --- a/comictaggerlib/issueidentifier.py +++ b/comictaggerlib/issueidentifier.py @@ -277,7 +277,7 @@ class IssueIdentifier: use_remote_alternates: bool = False, use_log: bool = True, ) -> Score: - # local_cover_hash_list is a list of pre-calculated hashs. + # local_cover_hash_list is a list of pre-calculated hashes. # use_remote_alternates - indicates to use alternate covers from CV try: diff --git a/comictaggerlib/main.py b/comictaggerlib/main.py index 8b02384..52a3c87 100755 --- a/comictaggerlib/main.py +++ b/comictaggerlib/main.py @@ -49,7 +49,7 @@ try: """ if QtWidgets.QApplication.instance() is not None: errorbox = QtWidgets.QMessageBox() - errorbox.setText(f"Oops. An unexpected error occured:\n{log_msg}") + errorbox.setText(f"Oops. An unexpected error occurred:\n{log_msg}") errorbox.exec() QtWidgets.QApplication.exit(1) else: diff --git a/comictaggerlib/options.py b/comictaggerlib/options.py index 3727190..a078030 100644 --- a/comictaggerlib/options.py +++ b/comictaggerlib/options.py @@ -177,7 +177,7 @@ def define_args() -> argparse.ArgumentParser: parser.add_argument( "--overwrite", action="store_true", - help="""Overwite all existing metadata.\nMay be used in conjunction with -o, -f and -m.\n\n""", + help="""Overwrite all existing metadata.\nMay be used in conjunction with -o, -f and -m.\n\n""", ) parser.add_argument( "--raw", action="store_true", help="""With -p, will print out the raw tag block(s)\nfrom the file.\n""" diff --git a/comictaggerlib/settings.py b/comictaggerlib/settings.py index b957f2c..501cc0c 100644 --- a/comictaggerlib/settings.py +++ b/comictaggerlib/settings.py @@ -104,7 +104,7 @@ class ComicTaggerSettings: self.exact_series_matches_first = True self.always_use_publisher_filter = False - # CBL Tranform settings + # CBL Transform settings self.assume_lone_credit_is_primary = False self.copy_characters_to_tags = False diff --git a/comictaggerlib/taggerwindow.py b/comictaggerlib/taggerwindow.py index 4eaddc6..3cefe16 100644 --- a/comictaggerlib/taggerwindow.py +++ b/comictaggerlib/taggerwindow.py @@ -2019,7 +2019,7 @@ Have fun! webbrowser.open("https://github.com/comictagger/comictagger/issues") def show_forum(self) -> None: - webbrowser.open("http://comictagger.forumotion.com/") + webbrowser.open("https://github.com/comictagger/comictagger/discussions") def front_cover_changed(self) -> None: self.metadata.pages = self.page_list_editor.get_page_list() diff --git a/comictaggerlib/ui/autotagstartwindow.ui b/comictaggerlib/ui/autotagstartwindow.ui index f2d252c..09d8450 100644 --- a/comictaggerlib/ui/autotagstartwindow.ui +++ b/comictaggerlib/ui/autotagstartwindow.ui @@ -112,7 +112,7 @@ - Don't use publication year in indentification process + Don't use publication year in identification process diff --git a/comictaggerlib/ui/settingswindow.ui b/comictaggerlib/ui/settingswindow.ui index bc8348c..b489ee3 100644 --- a/comictaggerlib/ui/settingswindow.ui +++ b/comictaggerlib/ui/settingswindow.ui @@ -332,14 +332,14 @@ - Initally sort Series search results by Starting Year instead of No. Issues + Initially sort Series search results by Starting Year instead of No. Issues - Initally show Series Name exact matches first + Initially show Series Name exact matches first diff --git a/comictaggerlib/ui/taggerwindow.ui b/comictaggerlib/ui/taggerwindow.ui index 9a5ec15..80f7074 100644 --- a/comictaggerlib/ui/taggerwindow.ui +++ b/comictaggerlib/ui/taggerwindow.ui @@ -1392,7 +1392,7 @@ - ComicTagger Forum... + ComicTagger Discussions... diff --git a/comictaggerlib/volumeselectionwindow.py b/comictaggerlib/volumeselectionwindow.py index c0d8944..0806245 100644 --- a/comictaggerlib/volumeselectionwindow.py +++ b/comictaggerlib/volumeselectionwindow.py @@ -241,7 +241,7 @@ class VolumeSelectionWindow(QtWidgets.QDialog): QtWidgets.QMessageBox.information( self, "Auto-Select Result", - " Found a match, but cover doesn't seem the same. Verify before commiting!", + " Found a match, but cover doesn't seem the same. Verify before committing!", ) found_match = matches[0] elif result == self.ii.result_found_match_but_not_first_page: @@ -364,7 +364,7 @@ class VolumeSelectionWindow(QtWidgets.QDialog): logger.exception("bad data error filtering publishers") # pre sort the data - so that we can put exact matches first afterwards - # compare as str incase extra chars ie. '1976?' + # compare as str in case extra chars ie. '1976?' # - missing (none) values being converted to 'None' - consistent with prior behaviour in v1.2.3 # sort by start_year if set if self.settings.sort_series_by_year: diff --git a/desktop-integration/mac/ComicTagger b/desktop-integration/mac/ComicTagger index 5233f96..7c79e43 100644 --- a/desktop-integration/mac/ComicTagger +++ b/desktop-integration/mac/ComicTagger @@ -1,4 +1,4 @@ -This file is a placeholder that will automaticlly be replaced with a symlink to +This file is a placeholder that will automatically be replaced with a symlink to the local machine's Python framework python binary. When pip does an uninstall, it will remove the link. diff --git a/testing/filenames.py b/testing/filenames.py index c06bc46..9b3f511 100644 --- a/testing/filenames.py +++ b/testing/filenames.py @@ -236,7 +236,7 @@ fnames = [ ), ( " X-Men-V1-067.cbr", - "hyphen separated with hyphen in series", # only parses corretly because v1 designates the volume + "hyphen separated with hyphen in series", # only parses correctly because v1 designates the volume { "issue": "67", "series": "X-Men",