From 8592fdee74d7b4e7fd10a4f6e98f51a8a68ab808 Mon Sep 17 00:00:00 2001 From: Timmy Welch Date: Tue, 1 Nov 2022 13:49:52 -0700 Subject: [PATCH 1/5] Revert "Install PyInstaller from git until >5.6.1 is available" This reverts commit 79137a12f81a5f89587d717d9d399706e2fad8fb. --- .github/workflows/build.yaml | 1 - .github/workflows/package.yaml | 1 - 2 files changed, 2 deletions(-) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 6c484c0..337661e 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -74,7 +74,6 @@ jobs: - name: Install build dependencies run: | - pip install --force-reinstall git+https://github.com/pyinstaller/pyinstaller python -m pip install --upgrade --upgrade-strategy eager -r requirements_dev.txt - name: Install Windows build dependencies diff --git a/.github/workflows/package.yaml b/.github/workflows/package.yaml index b82cddf..eb37ecd 100644 --- a/.github/workflows/package.yaml +++ b/.github/workflows/package.yaml @@ -35,7 +35,6 @@ jobs: - name: Install build dependencies run: | - pip install --force-reinstall git+https://github.com/pyinstaller/pyinstaller python -m pip install --upgrade --upgrade-strategy eager -r requirements_dev.txt - name: Install Windows build dependencies From 70293a08198acddc2dfa0a83da8dc2e48af6a3b3 Mon Sep 17 00:00:00 2001 From: Timmy Welch Date: Tue, 1 Nov 2022 13:51:10 -0700 Subject: [PATCH 2/5] Require PyInstaller >= 5.6.2 --- requirements_dev.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements_dev.txt b/requirements_dev.txt index 9655e03..ace72dd 100644 --- a/requirements_dev.txt +++ b/requirements_dev.txt @@ -5,7 +5,7 @@ flake8-black flake8-encodings flake8-isort isort>=5.10 -pyinstaller>=4.10, != 5.6 +pyinstaller>=5.6.2 pytest==7.* setuptools>=42 setuptools_scm[toml]>=3.4 From d55d75cd7949727dedccf8aed6ca6c895ff8e34a Mon Sep 17 00:00:00 2001 From: Timmy Welch Date: Fri, 4 Nov 2022 15:39:40 -0700 Subject: [PATCH 3/5] Append notes instead of overwriting them Add issue_id to GenericMetadata --- comicapi/comicinfoxml.py | 6 ------ comicapi/genericmetadata.py | 1 + comicapi/utils.py | 8 ++++++++ comictaggerlib/cli.py | 14 ++++++++++++-- comictaggerlib/comicvinetalker.py | 7 ++----- comictaggerlib/taggerwindow.py | 17 +++++++++++++++-- tests/utils_test.py | 17 +++++++++++++++++ 7 files changed, 55 insertions(+), 15 deletions(-) diff --git a/comicapi/comicinfoxml.py b/comicapi/comicinfoxml.py index 10a599a..38c74d6 100644 --- a/comicapi/comicinfoxml.py +++ b/comicapi/comicinfoxml.py @@ -137,17 +137,11 @@ class ComicInfoXml: # second, convert each list to string, and add to XML struct assign("Writer", ", ".join(credit_writer_list)) - assign("Penciller", ", ".join(credit_penciller_list)) - assign("Inker", ", ".join(credit_inker_list)) - assign("Colorist", ", ".join(credit_colorist_list)) - assign("Letterer", ", ".join(credit_letterer_list)) - assign("CoverArtist", ", ".join(credit_cover_list)) - assign("Editor", ", ".join(credit_editor_list)) assign("Publisher", md.publisher) diff --git a/comicapi/genericmetadata.py b/comicapi/genericmetadata.py index 77700d7..4b7e4da 100644 --- a/comicapi/genericmetadata.py +++ b/comicapi/genericmetadata.py @@ -78,6 +78,7 @@ class GenericMetadata: is_empty: bool = True tag_origin: str | None = None + issue_id: int | None = None series: str | None = None issue: str | None = None diff --git a/comicapi/utils.py b/comicapi/utils.py index c162b87..8243f3d 100644 --- a/comicapi/utils.py +++ b/comicapi/utils.py @@ -37,6 +37,14 @@ class UtilsVars: already_fixed_encoding = False +def combine_notes(existing_notes: str | None, new_notes: str | None, split: str) -> str: + split_notes, _, untouched_notes = (existing_notes or "").rpartition(split) + if split_notes: + return (split_notes + (new_notes or "")).strip() + else: + return (untouched_notes + "\n" + (new_notes or "")).strip() + + def parse_date_str(date_str: str) -> tuple[int | None, int | None, int | None]: day = None month = None diff --git a/comictaggerlib/cli.py b/comictaggerlib/cli.py index b48bed2..b73b75d 100644 --- a/comictaggerlib/cli.py +++ b/comictaggerlib/cli.py @@ -22,11 +22,13 @@ import logging import os import pathlib import sys +from datetime import datetime from pprint import pprint from comicapi import utils from comicapi.comicarchive import ComicArchive, MetaDataStyle from comicapi.genericmetadata import GenericMetadata +from comictaggerlib import ctversion from comictaggerlib.cbltransformer import CBLTransformer from comictaggerlib.comicvinetalker import ComicVineTalker, ComicVineTalkerException from comictaggerlib.filerenamer import FileRenamer, get_rename_dir @@ -112,7 +114,11 @@ def display_match_set_for_choice( if opts.overwrite: md = cv_md else: - md.overlay(cv_md) + notes = ( + f"Tagged with ComicTagger {ctversion.version} using info from Comic Vine on" + f" {datetime.now():%Y-%m-%d %H:%M:%S}. [Issue ID {cv_md.issue_id}]" + ) + md.overlay(cv_md.replace(notes=utils.combine_notes(md.notes, notes, "Tagged with ComicTagger"))) if opts.auto_imprint: md.fix_publisher() @@ -461,7 +467,11 @@ def process_file_cli( if opts.overwrite: md = cv_md else: - md.overlay(cv_md) + notes = ( + f"Tagged with ComicTagger {ctversion.version} using info from Comic Vine on" + f" {datetime.now():%Y-%m-%d %H:%M:%S}. [Issue ID {cv_md.issue_id}]" + ) + md.overlay(cv_md.replace(notes=utils.combine_notes(md.notes, notes, "Tagged with ComicTagger"))) if opts.auto_imprint: md.fix_publisher() diff --git a/comictaggerlib/comicvinetalker.py b/comictaggerlib/comicvinetalker.py index 5b56b14..13fedaf 100644 --- a/comictaggerlib/comicvinetalker.py +++ b/comictaggerlib/comicvinetalker.py @@ -19,7 +19,6 @@ import json import logging import re import time -from datetime import datetime from typing import Any, Callable, cast from urllib.parse import urlencode, urljoin, urlsplit @@ -466,6 +465,8 @@ class ComicVineTalker: # Now, map the Comic Vine data to generic metadata metadata = GenericMetadata() metadata.is_empty = False + metadata.tag_origin = "Comic Vine" + metadata.issue_id = issue_results["id"] metadata.series = utils.xlate(issue_results["volume"]["name"]) metadata.issue = IssueString(issue_results["issue_number"]).as_string() @@ -479,10 +480,6 @@ class ComicVineTalker: if settings.use_series_start_as_volume: metadata.volume = int(volume_results["start_year"]) - metadata.notes = ( - f"Tagged with ComicTagger {ctversion.version} using info from Comic Vine on" - f" {datetime.now():%Y-%m-%d %H:%M:%S}. [Issue ID {issue_results['id']}]" - ) metadata.web_link = issue_results["site_detail_url"] person_credits = issue_results["person_credits"] diff --git a/comictaggerlib/taggerwindow.py b/comictaggerlib/taggerwindow.py index f0698a2..f7c783a 100644 --- a/comictaggerlib/taggerwindow.py +++ b/comictaggerlib/taggerwindow.py @@ -27,6 +27,7 @@ import re import sys import webbrowser from collections.abc import Iterable +from datetime import datetime from typing import Any, Callable, cast from urllib.parse import urlparse @@ -1090,7 +1091,15 @@ Have fun! if self.settings.clear_form_before_populating_from_cv: self.clear_form() - self.metadata.overlay(new_metadata) + notes = ( + f"Tagged with ComicTagger {ctversion.version} using info from Comic Vine on" + f" {datetime.now():%Y-%m-%d %H:%M:%S}. [Issue ID {new_metadata.issue_id}]" + ) + self.metadata.overlay( + new_metadata.replace( + notes=utils.combine_notes(self.metadata.notes, notes, "Tagged with ComicTagger") + ) + ) # Now push the new combined data into the edit controls self.metadata_to_form() else: @@ -1794,7 +1803,11 @@ Have fun! if dlg.cbxRemoveMetadata.isChecked(): md = cv_md else: - md.overlay(cv_md) + notes = ( + f"Tagged with ComicTagger {ctversion.version} using info from Comic Vine on" + f" {datetime.now():%Y-%m-%d %H:%M:%S}. [Issue ID {cv_md.issue_id}]" + ) + md.overlay(cv_md.replace(notes=utils.combine_notes(md.notes, notes, "Tagged with ComicTagger"))) if self.settings.auto_imprint: md.fix_publisher() diff --git a/tests/utils_test.py b/tests/utils_test.py index 960c018..6d66b28 100644 --- a/tests/utils_test.py +++ b/tests/utils_test.py @@ -77,6 +77,23 @@ def test_get_language_iso(value, result): assert result == comicapi.utils.get_language_iso(value) +combine_values = [ + ("hello", "english", "en", "hello\nenglish"), + ("hello en", "english", "en", "hello english"), + ("hello en goodbye", "english", "en", "hello english"), + ("hello en en goodbye", "english", "en", "hello en english"), + ("", "english", "en", "english"), + (None, "english", "en", "english"), + ("hello", "", "en", "hello"), + ("hello", None, "en", "hello"), +] + + +@pytest.mark.parametrize("existing_notes, new_notes, split, result", combine_values) +def test_combine_notes(existing_notes, new_notes, split, result): + assert result == comicapi.utils.combine_notes(existing_notes, new_notes, split) + + def test_unique_file(tmp_path): file = tmp_path / "test.cbz" assert file == comicapi.utils.unique_file(file) From 62bf1d3808b59d79a02186e08e16bc8d7075a5db Mon Sep 17 00:00:00 2001 From: Timmy Welch Date: Fri, 4 Nov 2022 16:16:19 -0700 Subject: [PATCH 4/5] Update macOS packaging --- comictagger.spec | 30 +++--------------------------- 1 file changed, 3 insertions(+), 27 deletions(-) diff --git a/comictagger.spec b/comictagger.spec index 33b93d7..413c6e4 100644 --- a/comictagger.spec +++ b/comictagger.spec @@ -93,15 +93,6 @@ if platform.system() not in ["Windows"]: "CFBundleShortVersionString": ctversion.version, "CFBundleVersion": ctversion.version, "CFBundleDocumentTypes": [ - { - "CFBundleTypeRole": "Viewer", - "LSItemContentTypes": [ - "com.rarlab.rar-archive", - ], - "CFBundleTypeName": "RAR Archive", - "CFBundleTypeRole": "Editor", - "LSHandlerRank": "Default", - }, { "CFBundleTypeRole": "Editor", "LSHandlerRank": "Default", @@ -118,7 +109,6 @@ if platform.system() not in ["Windows"]: "NSPersistentStoreTypeKey": "Binary", "CFBundleTypeIconSystemGenerated": True, "CFBundleTypeName": "ZIP Comic Archive", - # 'CFBundleTypeIconFile': 'cbz', "LSItemContentTypes": [ "public.zip-comic-archive", "com.simplecomic.cbz-archive", @@ -129,6 +119,7 @@ if platform.system() not in ["Windows"]: "com.milke.cbz-archive", "com.bitcartel.comicbooklover.cbz", "public.archive.cbz", + "public.zip-archive", ], "CFBundleTypeRole": "Editor", "LSHandlerRank": "Default", @@ -141,8 +132,8 @@ if platform.system() not in ["Windows"]: "NSPersistentStoreTypeKey": "Binary", "CFBundleTypeIconSystemGenerated": True, "CFBundleTypeName": "7-Zip Comic Archive", - # 'CFBundleTypeIconFile': 'cb7', "LSItemContentTypes": [ + "org.7-zip.7-zip-archive", "com.simplecomic.cb7-archive", "public.cb7-archive", "com.macitbetter.cb7-archive", @@ -160,8 +151,8 @@ if platform.system() not in ["Windows"]: "NSPersistentStoreTypeKey": "Binary", "CFBundleTypeIconSystemGenerated": True, "CFBundleTypeName": "RAR Comic Archive", - # 'CFBundleTypeIconFile': 'cbr', "LSItemContentTypes": [ + "com.rarlab.rar-archive", "com.rarlab.rar-comic-archive", "com.simplecomic.cbr-archive", "com.macitbetter.cbr-archive", @@ -195,16 +186,11 @@ if platform.system() not in ["Windows"]: }, }, { - # 'UTTypeIcons': { - # 'UTTypeIconText': 'cbr', - # 'UTTypeIconBackgroundName': comic-fill - # } "UTTypeConformsTo": [ "public.data", "public.archive", "com.rarlab.rar-archive", ], - # 'UTTypeIconFile': 'cbr', "UTTypeIdentifier": "com.rarlab.rar-comic-archive", "UTTypeDescription": "RAR Comic Archive", "UTTypeTagSpecification": { @@ -218,16 +204,11 @@ if platform.system() not in ["Windows"]: }, }, { - # 'UTTypeIcons': { - # 'UTTypeIconText': 'cbz', - # 'UTTypeIconBackgroundName': 'comic-fill', - # } "UTTypeConformsTo": [ "public.data", "public.archive", "public.zip-archive", ], - # 'UTTypeIconFile': cbz, "UTTypeIdentifier": "public.zip-comic-archive", "UTTypeDescription": "ZIP Comic Archive", "UTTypeTagSpecification": { @@ -237,16 +218,11 @@ if platform.system() not in ["Windows"]: }, }, { - # 'UTTypeIcons': { - # 'UTTypeIconText': 'cb7', - # 'UTTypeIconBackgroundName': comic-fill - # } "UTTypeConformsTo": [ "public.data", "public.archive", "org.7-zip.7-zip-archive", ], - # 'UTTypeIconFile': cb7 "UTTypeIdentifier": "org.7-zip.7-zip-comic-archive", "UTTypeDescription": "7-Zip Comic Archive", "UTTypeTagSpecification": { From 685ce014b64a8a9cb8306b139d46777ce1ebb135 Mon Sep 17 00:00:00 2001 From: Timmy Welch Date: Fri, 4 Nov 2022 16:27:30 -0700 Subject: [PATCH 5/5] Fix tests for comicvinetalker --- testing/comicvine.py | 5 +++-- tests/comicvinetalker_test.py | 6 +++--- tests/conftest.py | 13 ------------- 3 files changed, 6 insertions(+), 18 deletions(-) diff --git a/testing/comicvine.py b/testing/comicvine.py index c2ca298..82dfca2 100644 --- a/testing/comicvine.py +++ b/testing/comicvine.py @@ -160,7 +160,8 @@ date = comictaggerlib.comicvinetalker.ComicVineTalker().parse_date_str(cv_issue_ cv_md = comicapi.genericmetadata.GenericMetadata( is_empty=False, - tag_origin=None, + tag_origin="Comic Vine", + issue_id=cv_issue_result["results"]["id"], series=cv_issue_result["results"]["volume"]["name"], issue=cv_issue_result["results"]["issue_number"], title=cv_issue_result["results"]["name"], @@ -182,7 +183,7 @@ cv_md = comicapi.genericmetadata.GenericMetadata( alternate_number=None, alternate_count=None, imprint=None, - notes="Tagged with ComicTagger 1.4.4a9.dev20 using info from Comic Vine on 2022-07-11 17:42:41. [Issue ID 140529]", + notes=None, web_link=cv_issue_result["results"]["site_detail_url"], format=None, manga=None, diff --git a/tests/comicvinetalker_test.py b/tests/comicvinetalker_test.py index 89cabba..1d4a43c 100644 --- a/tests/comicvinetalker_test.py +++ b/tests/comicvinetalker_test.py @@ -39,7 +39,7 @@ def test_fetch_issues_by_volume(comicvine_api, comic_cache): assert results == cache_issues -def test_fetch_issue_data_by_issue_id(comicvine_api, settings, mock_now, mock_version): +def test_fetch_issue_data_by_issue_id(comicvine_api, settings, mock_version): ct = comictaggerlib.comicvinetalker.ComicVineTalker() result = ct.fetch_issue_data_by_issue_id(140529, settings) assert result == testing.comicvine.cv_md @@ -65,13 +65,13 @@ cv_issue = [ @pytest.mark.parametrize("volume_id, issue_number, expected", cv_issue) -def test_fetch_issue_data(comicvine_api, settings, mock_now, mock_version, volume_id, issue_number, expected): +def test_fetch_issue_data(comicvine_api, settings, mock_version, volume_id, issue_number, expected): ct = comictaggerlib.comicvinetalker.ComicVineTalker() results = ct.fetch_issue_data(volume_id, issue_number, settings) assert results == expected -def test_fetch_issue_select_details(comicvine_api, mock_now, mock_version): +def test_fetch_issue_select_details(comicvine_api, mock_version): ct = comictaggerlib.comicvinetalker.ComicVineTalker() result = ct.fetch_issue_select_details(140529) expected = { diff --git a/tests/conftest.py b/tests/conftest.py index 2fcdc8d..1fac14f 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -1,7 +1,6 @@ from __future__ import annotations import copy -import datetime import io import shutil import unittest.mock @@ -115,18 +114,6 @@ def comicvine_api(monkeypatch, cbz, comic_cache) -> unittest.mock.Mock: return m_get -@pytest.fixture -def mock_now(monkeypatch): - class mydatetime: - time = datetime.datetime(2022, 7, 11, 17, 42, 41) - - @classmethod - def now(cls): - return cls.time - - monkeypatch.setattr(comictaggerlib.comicvinetalker, "datetime", mydatetime) - - @pytest.fixture def mock_version(monkeypatch): version = "1.4.4a9.dev20"