2012-11-02 13:54:17 -07:00
|
|
|
#!/usr/bin/python
|
2015-02-21 18:30:32 -08:00
|
|
|
"""ComicTagger CLI functions"""
|
2022-06-02 18:32:16 -07:00
|
|
|
#
|
2023-02-16 17:23:13 -08:00
|
|
|
# Copyright 2013 ComicTagger Authors
|
2022-06-02 18:32:16 -07:00
|
|
|
#
|
2015-02-21 18:30:32 -08:00
|
|
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
# you may not use this file except in compliance with the License.
|
|
|
|
# You may obtain a copy of the License at
|
2022-06-02 18:32:16 -07:00
|
|
|
#
|
2015-02-21 18:30:32 -08:00
|
|
|
# http://www.apache.org/licenses/LICENSE-2.0
|
2022-06-02 18:32:16 -07:00
|
|
|
#
|
2015-02-21 18:30:32 -08:00
|
|
|
# Unless required by applicable law or agreed to in writing, software
|
|
|
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
# See the License for the specific language governing permissions and
|
|
|
|
# limitations under the License.
|
2022-06-02 18:32:16 -07:00
|
|
|
from __future__ import annotations
|
2012-11-02 13:54:17 -07:00
|
|
|
|
2022-04-04 18:59:26 -07:00
|
|
|
import logging
|
2012-11-06 12:29:18 -08:00
|
|
|
import os
|
Code cleanup
Remove no longer used google scripts
Remove convenience files from comicataggerlib and import comicapi directly
Add type-hints to facilitate auto-complete tools
Make PyQt5 code more compatible with PyQt6
Implement automatic tooling
isort and black for code formatting
Line length has been set to 120
flake8 for code standards with exceptions:
E203 - Whitespace before ':' - format compatiblity with black
E501 - Line too long - flake8 line limit cannot be set
E722 - Do not use bare except - fixing bare except statements is a
lot of overhead and there are already
many in the codebase
These changes, along with some manual fixes creates much more readable code.
See examples below:
diff --git a/comicapi/comet.py b/comicapi/comet.py
index d1741c5..52dc195 100644
--- a/comicapi/comet.py
+++ b/comicapi/comet.py
@@ -166,7 +166,2 @@ class CoMet:
- if credit['role'].lower() in set(self.editor_synonyms):
- ET.SubElement(
- root,
- 'editor').text = "{0}".format(
- credit['person'])
@@ -174,2 +169,4 @@ class CoMet:
self.indent(root)
+ if credit["role"].lower() in set(self.editor_synonyms):
+ ET.SubElement(root, "editor").text = str(credit["person"])
diff --git a/comictaggerlib/autotagmatchwindow.py b/comictaggerlib/autotagmatchwindow.py
index 4338176..9219f01 100644
--- a/comictaggerlib/autotagmatchwindow.py
+++ b/comictaggerlib/autotagmatchwindow.py
@@ -63,4 +63,3 @@ class AutoTagMatchWindow(QtWidgets.QDialog):
self.skipButton, QtWidgets.QDialogButtonBox.ActionRole)
- self.buttonBox.button(QtWidgets.QDialogButtonBox.Ok).setText(
- "Accept and Write Tags")
+ self.buttonBox.button(QtWidgets.QDialogButtonBox.StandardButton.Ok).setText("Accept and Write Tags")
diff --git a/comictaggerlib/cli.py b/comictaggerlib/cli.py
index 688907d..dbd0c2e 100644
--- a/comictaggerlib/cli.py
+++ b/comictaggerlib/cli.py
@@ -293,7 +293,3 @@ def process_file_cli(filename, opts, settings, match_results):
if opts.raw:
- print((
- "{0}".format(
- str(
- ca.readRawCIX(),
- errors='ignore'))))
+ print(ca.read_raw_cix())
else:
2022-04-01 16:50:46 -07:00
|
|
|
import sys
|
2022-11-04 15:39:40 -07:00
|
|
|
from datetime import datetime
|
2012-11-12 16:12:43 -08:00
|
|
|
|
Code cleanup
Remove no longer used google scripts
Remove convenience files from comicataggerlib and import comicapi directly
Add type-hints to facilitate auto-complete tools
Make PyQt5 code more compatible with PyQt6
Implement automatic tooling
isort and black for code formatting
Line length has been set to 120
flake8 for code standards with exceptions:
E203 - Whitespace before ':' - format compatiblity with black
E501 - Line too long - flake8 line limit cannot be set
E722 - Do not use bare except - fixing bare except statements is a
lot of overhead and there are already
many in the codebase
These changes, along with some manual fixes creates much more readable code.
See examples below:
diff --git a/comicapi/comet.py b/comicapi/comet.py
index d1741c5..52dc195 100644
--- a/comicapi/comet.py
+++ b/comicapi/comet.py
@@ -166,7 +166,2 @@ class CoMet:
- if credit['role'].lower() in set(self.editor_synonyms):
- ET.SubElement(
- root,
- 'editor').text = "{0}".format(
- credit['person'])
@@ -174,2 +169,4 @@ class CoMet:
self.indent(root)
+ if credit["role"].lower() in set(self.editor_synonyms):
+ ET.SubElement(root, "editor").text = str(credit["person"])
diff --git a/comictaggerlib/autotagmatchwindow.py b/comictaggerlib/autotagmatchwindow.py
index 4338176..9219f01 100644
--- a/comictaggerlib/autotagmatchwindow.py
+++ b/comictaggerlib/autotagmatchwindow.py
@@ -63,4 +63,3 @@ class AutoTagMatchWindow(QtWidgets.QDialog):
self.skipButton, QtWidgets.QDialogButtonBox.ActionRole)
- self.buttonBox.button(QtWidgets.QDialogButtonBox.Ok).setText(
- "Accept and Write Tags")
+ self.buttonBox.button(QtWidgets.QDialogButtonBox.StandardButton.Ok).setText("Accept and Write Tags")
diff --git a/comictaggerlib/cli.py b/comictaggerlib/cli.py
index 688907d..dbd0c2e 100644
--- a/comictaggerlib/cli.py
+++ b/comictaggerlib/cli.py
@@ -293,7 +293,3 @@ def process_file_cli(filename, opts, settings, match_results):
if opts.raw:
- print((
- "{0}".format(
- str(
- ca.readRawCIX(),
- errors='ignore'))))
+ print(ca.read_raw_cix())
else:
2022-04-01 16:50:46 -07:00
|
|
|
from comicapi import utils
|
|
|
|
from comicapi.comicarchive import ComicArchive, MetaDataStyle
|
|
|
|
from comicapi.genericmetadata import GenericMetadata
|
2022-12-14 23:13:53 -08:00
|
|
|
from comictaggerlib import ctversion
|
Code cleanup
Remove no longer used google scripts
Remove convenience files from comicataggerlib and import comicapi directly
Add type-hints to facilitate auto-complete tools
Make PyQt5 code more compatible with PyQt6
Implement automatic tooling
isort and black for code formatting
Line length has been set to 120
flake8 for code standards with exceptions:
E203 - Whitespace before ':' - format compatiblity with black
E501 - Line too long - flake8 line limit cannot be set
E722 - Do not use bare except - fixing bare except statements is a
lot of overhead and there are already
many in the codebase
These changes, along with some manual fixes creates much more readable code.
See examples below:
diff --git a/comicapi/comet.py b/comicapi/comet.py
index d1741c5..52dc195 100644
--- a/comicapi/comet.py
+++ b/comicapi/comet.py
@@ -166,7 +166,2 @@ class CoMet:
- if credit['role'].lower() in set(self.editor_synonyms):
- ET.SubElement(
- root,
- 'editor').text = "{0}".format(
- credit['person'])
@@ -174,2 +169,4 @@ class CoMet:
self.indent(root)
+ if credit["role"].lower() in set(self.editor_synonyms):
+ ET.SubElement(root, "editor").text = str(credit["person"])
diff --git a/comictaggerlib/autotagmatchwindow.py b/comictaggerlib/autotagmatchwindow.py
index 4338176..9219f01 100644
--- a/comictaggerlib/autotagmatchwindow.py
+++ b/comictaggerlib/autotagmatchwindow.py
@@ -63,4 +63,3 @@ class AutoTagMatchWindow(QtWidgets.QDialog):
self.skipButton, QtWidgets.QDialogButtonBox.ActionRole)
- self.buttonBox.button(QtWidgets.QDialogButtonBox.Ok).setText(
- "Accept and Write Tags")
+ self.buttonBox.button(QtWidgets.QDialogButtonBox.StandardButton.Ok).setText("Accept and Write Tags")
diff --git a/comictaggerlib/cli.py b/comictaggerlib/cli.py
index 688907d..dbd0c2e 100644
--- a/comictaggerlib/cli.py
+++ b/comictaggerlib/cli.py
@@ -293,7 +293,3 @@ def process_file_cli(filename, opts, settings, match_results):
if opts.raw:
- print((
- "{0}".format(
- str(
- ca.readRawCIX(),
- errors='ignore'))))
+ print(ca.read_raw_cix())
else:
2022-04-01 16:50:46 -07:00
|
|
|
from comictaggerlib.cbltransformer import CBLTransformer
|
2023-06-09 16:20:00 -07:00
|
|
|
from comictaggerlib.ctsettings import ct_ns
|
2022-07-09 22:27:45 -07:00
|
|
|
from comictaggerlib.filerenamer import FileRenamer, get_rename_dir
|
2022-10-25 21:48:01 -07:00
|
|
|
from comictaggerlib.graphics import graphics_path
|
Code cleanup
Remove no longer used google scripts
Remove convenience files from comicataggerlib and import comicapi directly
Add type-hints to facilitate auto-complete tools
Make PyQt5 code more compatible with PyQt6
Implement automatic tooling
isort and black for code formatting
Line length has been set to 120
flake8 for code standards with exceptions:
E203 - Whitespace before ':' - format compatiblity with black
E501 - Line too long - flake8 line limit cannot be set
E722 - Do not use bare except - fixing bare except statements is a
lot of overhead and there are already
many in the codebase
These changes, along with some manual fixes creates much more readable code.
See examples below:
diff --git a/comicapi/comet.py b/comicapi/comet.py
index d1741c5..52dc195 100644
--- a/comicapi/comet.py
+++ b/comicapi/comet.py
@@ -166,7 +166,2 @@ class CoMet:
- if credit['role'].lower() in set(self.editor_synonyms):
- ET.SubElement(
- root,
- 'editor').text = "{0}".format(
- credit['person'])
@@ -174,2 +169,4 @@ class CoMet:
self.indent(root)
+ if credit["role"].lower() in set(self.editor_synonyms):
+ ET.SubElement(root, "editor").text = str(credit["person"])
diff --git a/comictaggerlib/autotagmatchwindow.py b/comictaggerlib/autotagmatchwindow.py
index 4338176..9219f01 100644
--- a/comictaggerlib/autotagmatchwindow.py
+++ b/comictaggerlib/autotagmatchwindow.py
@@ -63,4 +63,3 @@ class AutoTagMatchWindow(QtWidgets.QDialog):
self.skipButton, QtWidgets.QDialogButtonBox.ActionRole)
- self.buttonBox.button(QtWidgets.QDialogButtonBox.Ok).setText(
- "Accept and Write Tags")
+ self.buttonBox.button(QtWidgets.QDialogButtonBox.StandardButton.Ok).setText("Accept and Write Tags")
diff --git a/comictaggerlib/cli.py b/comictaggerlib/cli.py
index 688907d..dbd0c2e 100644
--- a/comictaggerlib/cli.py
+++ b/comictaggerlib/cli.py
@@ -293,7 +293,3 @@ def process_file_cli(filename, opts, settings, match_results):
if opts.raw:
- print((
- "{0}".format(
- str(
- ca.readRawCIX(),
- errors='ignore'))))
+ print(ca.read_raw_cix())
else:
2022-04-01 16:50:46 -07:00
|
|
|
from comictaggerlib.issueidentifier import IssueIdentifier
|
2022-11-04 09:16:07 -07:00
|
|
|
from comictaggerlib.resulttypes import MultipleMatch, OnlineMatchResults
|
2023-02-09 19:33:10 -08:00
|
|
|
from comictalker.comictalker import ComicTalker, TalkerError
|
Convert ComicIssue into GenericMetadata
I could not find a good reason for ComicIssue to exist other than that
it had more attributes than GenericMetadata, so it has been replaced.
New attributes for GenericMetadata:
series_id: a string uniquely identifying the series to tag_origin
series_aliases: alternate series names that are not the canonical name
title_aliases: alternate issue titles that are not the canonical name
alternate_images: a list of urls to alternate cover images
Updated attributes for GenericMetadata:
genre -> genres: str -> list[str]
comments -> description: str -> str
story_arc -> story_arcs: str -> list[str]
series_group -> series_groups: str -> list[str]
character -> characters: str -> list[str]
team -> teams: str -> list[str]
location -> locations: str -> list[str]
tag_origin -> tag_origin: str -> TagOrigin (tuple[str, str])
ComicSeries has been relocated to the ComicAPI package, currently has no
usage within ComicAPI.
CreditMetadata has been renamed to Credit and has replaced Credit from
ComicTalker.
fetch_series has been added to ComicTalker, this is currently only used
in the GUI when a series is selected and does not already contain the
needed fields, this function should always be cached.
A new split function has been added to ComicAPI, all uses of split on
single characters have been updated to use this
cleanup_html and the corresponding setting are now only used in
ComicTagger proper, for display we want any html directly from the
upstream. When applying the metadata we then strip the description of
any html.
A new conversion has been added to the MetadataFormatter:
j: joins any lists into a string with ', '. Note this is a valid
operation on strings as well, it will add ', ' in between every
character.
parse_settings now assigns the given ComicTaggerPaths object to the
result ensuring that the correct path is always used.
2023-08-02 09:00:04 -07:00
|
|
|
from comictalker.talker_utils import cleanup_html
|
2015-02-15 02:44:00 -08:00
|
|
|
|
2022-04-04 18:59:26 -07:00
|
|
|
logger = logging.getLogger(__name__)
|
2012-12-05 20:46:01 -08:00
|
|
|
|
2015-02-15 02:44:00 -08:00
|
|
|
|
2022-11-26 16:47:18 -08:00
|
|
|
class CLI:
|
2023-06-09 16:20:00 -07:00
|
|
|
def __init__(self, config: ct_ns, talkers: dict[str, ComicTalker]) -> None:
|
2023-01-31 20:21:39 -08:00
|
|
|
self.config = config
|
2023-02-09 19:33:10 -08:00
|
|
|
self.talkers = talkers
|
2022-11-26 16:47:18 -08:00
|
|
|
self.batch_mode = False
|
2015-02-12 14:57:46 -08:00
|
|
|
|
2023-02-09 19:33:10 -08:00
|
|
|
def current_talker(self) -> ComicTalker:
|
2023-09-05 00:55:12 -07:00
|
|
|
if self.config.Sources_source in self.talkers:
|
|
|
|
return self.talkers[self.config.Sources_source]
|
|
|
|
logger.error("Could not find the '%s' talker", self.config.Sources_source)
|
2023-02-09 19:33:10 -08:00
|
|
|
raise SystemExit(2)
|
|
|
|
|
2022-12-23 00:09:19 -08:00
|
|
|
def actual_issue_data_fetch(self, issue_id: str) -> GenericMetadata:
|
2022-11-26 16:47:18 -08:00
|
|
|
# now get the particular issue data
|
|
|
|
try:
|
2023-02-09 19:33:10 -08:00
|
|
|
ct_md = self.current_talker().fetch_comic_data(issue_id)
|
2022-11-26 16:47:18 -08:00
|
|
|
except TalkerError as e:
|
|
|
|
logger.exception(f"Error retrieving issue details. Save aborted.\n{e}")
|
|
|
|
return GenericMetadata()
|
|
|
|
|
2023-09-05 00:55:12 -07:00
|
|
|
if self.config.Comic_Book_Lover_apply_transform_on_import:
|
2023-01-31 20:21:39 -08:00
|
|
|
ct_md = CBLTransformer(ct_md, self.config).apply()
|
2022-11-26 16:47:18 -08:00
|
|
|
|
|
|
|
return ct_md
|
|
|
|
|
|
|
|
def actual_metadata_save(self, ca: ComicArchive, md: GenericMetadata) -> bool:
|
2023-09-05 00:55:12 -07:00
|
|
|
if not self.config.Runtime_Options_dryrun:
|
|
|
|
for metadata_style in self.config.Runtime_Options_type:
|
2022-11-26 16:47:18 -08:00
|
|
|
# write out the new data
|
|
|
|
if not ca.write_metadata(md, metadata_style):
|
|
|
|
logger.error("The tag save seemed to fail for style: %s!", MetaDataStyle.name[metadata_style])
|
|
|
|
return False
|
|
|
|
|
|
|
|
print("Save complete.")
|
|
|
|
logger.info("Save complete.")
|
2015-02-12 14:57:46 -08:00
|
|
|
else:
|
2023-09-05 00:55:12 -07:00
|
|
|
if self.config.Runtime_Options_quiet:
|
2022-11-26 16:47:18 -08:00
|
|
|
logger.info("dry-run option was set, so nothing was written")
|
|
|
|
print("dry-run option was set, so nothing was written")
|
2022-05-17 18:28:37 -07:00
|
|
|
else:
|
2022-11-26 16:47:18 -08:00
|
|
|
logger.info("dry-run option was set, so nothing was written, but here is the final set of tags:")
|
|
|
|
print("dry-run option was set, so nothing was written, but here is the final set of tags:")
|
|
|
|
print(f"{md}")
|
|
|
|
return True
|
|
|
|
|
|
|
|
def display_match_set_for_choice(self, label: str, match_set: MultipleMatch) -> None:
|
|
|
|
print(f"{match_set.ca.path} -- {label}:")
|
|
|
|
|
|
|
|
# sort match list by year
|
|
|
|
match_set.matches.sort(key=lambda k: k["year"] or 0)
|
|
|
|
|
Convert ComicIssue into GenericMetadata
I could not find a good reason for ComicIssue to exist other than that
it had more attributes than GenericMetadata, so it has been replaced.
New attributes for GenericMetadata:
series_id: a string uniquely identifying the series to tag_origin
series_aliases: alternate series names that are not the canonical name
title_aliases: alternate issue titles that are not the canonical name
alternate_images: a list of urls to alternate cover images
Updated attributes for GenericMetadata:
genre -> genres: str -> list[str]
comments -> description: str -> str
story_arc -> story_arcs: str -> list[str]
series_group -> series_groups: str -> list[str]
character -> characters: str -> list[str]
team -> teams: str -> list[str]
location -> locations: str -> list[str]
tag_origin -> tag_origin: str -> TagOrigin (tuple[str, str])
ComicSeries has been relocated to the ComicAPI package, currently has no
usage within ComicAPI.
CreditMetadata has been renamed to Credit and has replaced Credit from
ComicTalker.
fetch_series has been added to ComicTalker, this is currently only used
in the GUI when a series is selected and does not already contain the
needed fields, this function should always be cached.
A new split function has been added to ComicAPI, all uses of split on
single characters have been updated to use this
cleanup_html and the corresponding setting are now only used in
ComicTagger proper, for display we want any html directly from the
upstream. When applying the metadata we then strip the description of
any html.
A new conversion has been added to the MetadataFormatter:
j: joins any lists into a string with ', '. Note this is a valid
operation on strings as well, it will add ', ' in between every
character.
parse_settings now assigns the given ComicTaggerPaths object to the
result ensuring that the correct path is always used.
2023-08-02 09:00:04 -07:00
|
|
|
for counter, m in enumerate(match_set.matches, 1):
|
2022-11-26 16:47:18 -08:00
|
|
|
print(
|
|
|
|
" {}. {} #{} [{}] ({}/{}) - {}".format(
|
|
|
|
counter,
|
|
|
|
m["series"],
|
|
|
|
m["issue_number"],
|
|
|
|
m["publisher"],
|
|
|
|
m["month"],
|
|
|
|
m["year"],
|
|
|
|
m["issue_title"],
|
2022-11-04 15:39:40 -07:00
|
|
|
)
|
2022-11-26 16:47:18 -08:00
|
|
|
)
|
2023-09-05 00:55:12 -07:00
|
|
|
if self.config.Runtime_Options_interactive:
|
2022-11-26 16:47:18 -08:00
|
|
|
while True:
|
|
|
|
i = input("Choose a match #, or 's' to skip: ")
|
|
|
|
if (i.isdigit() and int(i) in range(1, len(match_set.matches) + 1)) or i == "s":
|
|
|
|
break
|
|
|
|
if i != "s":
|
|
|
|
# save the data!
|
|
|
|
# we know at this point, that the file is all good to go
|
|
|
|
ca = match_set.ca
|
|
|
|
md = self.create_local_metadata(ca)
|
|
|
|
ct_md = self.actual_issue_data_fetch(match_set.matches[int(i) - 1]["issue_id"])
|
2023-09-05 00:55:12 -07:00
|
|
|
if self.config.Issue_Identifier_clear_metadata_on_import:
|
2022-11-26 16:47:18 -08:00
|
|
|
md = ct_md
|
|
|
|
else:
|
|
|
|
notes = (
|
2023-06-01 14:05:14 -07:00
|
|
|
f"Tagged with ComicTagger {ctversion.version} using info from {self.current_talker().name} on"
|
2022-11-26 16:47:18 -08:00
|
|
|
f" {datetime.now():%Y-%m-%d %H:%M:%S}. [Issue ID {ct_md.issue_id}]"
|
|
|
|
)
|
|
|
|
md.overlay(ct_md.replace(notes=utils.combine_notes(md.notes, notes, "Tagged with ComicTagger")))
|
|
|
|
|
2023-09-05 00:55:12 -07:00
|
|
|
if self.config.Issue_Identifier_auto_imprint:
|
2022-11-26 16:47:18 -08:00
|
|
|
md.fix_publisher()
|
|
|
|
|
|
|
|
self.actual_metadata_save(ca, md)
|
|
|
|
|
|
|
|
def post_process_matches(self, match_results: OnlineMatchResults) -> None:
|
|
|
|
# now go through the match results
|
2023-09-05 00:55:12 -07:00
|
|
|
if self.config.Runtime_Options_summary:
|
2022-11-26 16:47:18 -08:00
|
|
|
if len(match_results.good_matches) > 0:
|
|
|
|
print("\nSuccessful matches:\n------------------")
|
|
|
|
for f in match_results.good_matches:
|
|
|
|
print(f)
|
|
|
|
|
|
|
|
if len(match_results.no_matches) > 0:
|
|
|
|
print("\nNo matches:\n------------------")
|
|
|
|
for f in match_results.no_matches:
|
|
|
|
print(f)
|
|
|
|
|
|
|
|
if len(match_results.write_failures) > 0:
|
|
|
|
print("\nFile Write Failures:\n------------------")
|
|
|
|
for f in match_results.write_failures:
|
|
|
|
print(f)
|
|
|
|
|
|
|
|
if len(match_results.fetch_data_failures) > 0:
|
|
|
|
print("\nNetwork Data Fetch Failures:\n------------------")
|
|
|
|
for f in match_results.fetch_data_failures:
|
|
|
|
print(f)
|
|
|
|
|
2023-09-05 00:55:12 -07:00
|
|
|
if not self.config.Runtime_Options_summary and not self.config.Runtime_Options_interactive:
|
2022-11-26 16:47:18 -08:00
|
|
|
# just quit if we're not interactive or showing the summary
|
|
|
|
return
|
2015-02-12 14:57:46 -08:00
|
|
|
|
2022-11-26 16:47:18 -08:00
|
|
|
if len(match_results.multiple_matches) > 0:
|
|
|
|
print("\nArchives with multiple high-confidence matches:\n------------------")
|
|
|
|
for match_set in match_results.multiple_matches:
|
|
|
|
self.display_match_set_for_choice("Multiple high-confidence matches", match_set)
|
2022-06-02 18:28:54 -07:00
|
|
|
|
2022-11-26 16:47:18 -08:00
|
|
|
if len(match_results.low_confidence_matches) > 0:
|
|
|
|
print("\nArchives with low-confidence matches:\n------------------")
|
|
|
|
for match_set in match_results.low_confidence_matches:
|
|
|
|
if len(match_set.matches) == 1:
|
|
|
|
label = "Single low-confidence match"
|
|
|
|
else:
|
|
|
|
label = "Multiple low-confidence matches"
|
Code cleanup
Remove no longer used google scripts
Remove convenience files from comicataggerlib and import comicapi directly
Add type-hints to facilitate auto-complete tools
Make PyQt5 code more compatible with PyQt6
Implement automatic tooling
isort and black for code formatting
Line length has been set to 120
flake8 for code standards with exceptions:
E203 - Whitespace before ':' - format compatiblity with black
E501 - Line too long - flake8 line limit cannot be set
E722 - Do not use bare except - fixing bare except statements is a
lot of overhead and there are already
many in the codebase
These changes, along with some manual fixes creates much more readable code.
See examples below:
diff --git a/comicapi/comet.py b/comicapi/comet.py
index d1741c5..52dc195 100644
--- a/comicapi/comet.py
+++ b/comicapi/comet.py
@@ -166,7 +166,2 @@ class CoMet:
- if credit['role'].lower() in set(self.editor_synonyms):
- ET.SubElement(
- root,
- 'editor').text = "{0}".format(
- credit['person'])
@@ -174,2 +169,4 @@ class CoMet:
self.indent(root)
+ if credit["role"].lower() in set(self.editor_synonyms):
+ ET.SubElement(root, "editor").text = str(credit["person"])
diff --git a/comictaggerlib/autotagmatchwindow.py b/comictaggerlib/autotagmatchwindow.py
index 4338176..9219f01 100644
--- a/comictaggerlib/autotagmatchwindow.py
+++ b/comictaggerlib/autotagmatchwindow.py
@@ -63,4 +63,3 @@ class AutoTagMatchWindow(QtWidgets.QDialog):
self.skipButton, QtWidgets.QDialogButtonBox.ActionRole)
- self.buttonBox.button(QtWidgets.QDialogButtonBox.Ok).setText(
- "Accept and Write Tags")
+ self.buttonBox.button(QtWidgets.QDialogButtonBox.StandardButton.Ok).setText("Accept and Write Tags")
diff --git a/comictaggerlib/cli.py b/comictaggerlib/cli.py
index 688907d..dbd0c2e 100644
--- a/comictaggerlib/cli.py
+++ b/comictaggerlib/cli.py
@@ -293,7 +293,3 @@ def process_file_cli(filename, opts, settings, match_results):
if opts.raw:
- print((
- "{0}".format(
- str(
- ca.readRawCIX(),
- errors='ignore'))))
+ print(ca.read_raw_cix())
else:
2022-04-01 16:50:46 -07:00
|
|
|
|
2022-11-26 16:47:18 -08:00
|
|
|
self.display_match_set_for_choice(label, match_set)
|
2015-02-12 14:57:46 -08:00
|
|
|
|
2022-11-26 16:47:18 -08:00
|
|
|
def run(self) -> None:
|
2023-09-05 00:55:12 -07:00
|
|
|
if len(self.config.Runtime_Options_files) < 1:
|
2022-11-26 16:47:18 -08:00
|
|
|
logger.error("You must specify at least one filename. Use the -h option for more info")
|
|
|
|
return
|
2015-02-12 14:57:46 -08:00
|
|
|
|
2022-11-26 16:47:18 -08:00
|
|
|
match_results = OnlineMatchResults()
|
2023-09-05 00:55:12 -07:00
|
|
|
self.batch_mode = len(self.config.Runtime_Options_files) > 1
|
2012-12-03 17:16:58 -08:00
|
|
|
|
2023-09-05 00:55:12 -07:00
|
|
|
for f in self.config.Runtime_Options_files:
|
2022-11-26 16:47:18 -08:00
|
|
|
self.process_file_cli(f, match_results)
|
|
|
|
sys.stdout.flush()
|
2015-02-15 02:44:00 -08:00
|
|
|
|
2022-11-26 16:47:18 -08:00
|
|
|
self.post_process_matches(match_results)
|
2015-02-12 14:57:46 -08:00
|
|
|
|
2023-09-05 01:05:20 -07:00
|
|
|
if self.config.Runtime_Options_online:
|
|
|
|
print(
|
|
|
|
f"\nFiles tagged with metadata provided by {self.current_talker().name} {self.current_talker().website}"
|
|
|
|
)
|
2023-05-15 08:46:31 -07:00
|
|
|
|
2022-11-26 16:47:18 -08:00
|
|
|
def create_local_metadata(self, ca: ComicArchive) -> GenericMetadata:
|
|
|
|
md = GenericMetadata()
|
|
|
|
md.set_default_page_list(ca.get_number_of_pages())
|
2015-02-12 14:57:46 -08:00
|
|
|
|
2022-11-26 16:47:18 -08:00
|
|
|
# now, overlay the parsed filename info
|
2023-09-05 00:55:12 -07:00
|
|
|
if self.config.Runtime_Options_parse_filename:
|
2022-11-26 16:47:18 -08:00
|
|
|
f_md = ca.metadata_from_filename(
|
2023-09-05 00:55:12 -07:00
|
|
|
self.config.Filename_Parsing_complicated_parser,
|
|
|
|
self.config.Filename_Parsing_remove_c2c,
|
|
|
|
self.config.Filename_Parsing_remove_fcbd,
|
|
|
|
self.config.Filename_Parsing_remove_publisher,
|
|
|
|
self.config.Runtime_Options_split_words,
|
2022-11-26 16:47:18 -08:00
|
|
|
)
|
2015-02-12 14:57:46 -08:00
|
|
|
|
2022-11-26 16:47:18 -08:00
|
|
|
md.overlay(f_md)
|
2015-02-12 14:57:46 -08:00
|
|
|
|
2023-09-05 00:55:12 -07:00
|
|
|
for metadata_style in self.config.Runtime_Options_type:
|
2022-11-26 16:47:18 -08:00
|
|
|
if ca.has_metadata(metadata_style):
|
|
|
|
try:
|
|
|
|
t_md = ca.read_metadata(metadata_style)
|
|
|
|
md.overlay(t_md)
|
|
|
|
break
|
|
|
|
except Exception as e:
|
|
|
|
logger.error("Failed to load metadata for %s: %s", ca.path, e)
|
2015-02-12 14:57:46 -08:00
|
|
|
|
2022-11-26 16:47:18 -08:00
|
|
|
# finally, use explicit stuff
|
2023-09-05 00:55:12 -07:00
|
|
|
md.overlay(self.config.Runtime_Options_metadata)
|
2015-02-12 14:57:46 -08:00
|
|
|
|
2022-11-26 16:47:18 -08:00
|
|
|
return md
|
2015-02-12 14:57:46 -08:00
|
|
|
|
2022-11-26 16:47:18 -08:00
|
|
|
def print(self, ca: ComicArchive) -> None:
|
2023-09-05 00:55:12 -07:00
|
|
|
if not self.config.Runtime_Options_type:
|
Code cleanup
Remove no longer used google scripts
Remove convenience files from comicataggerlib and import comicapi directly
Add type-hints to facilitate auto-complete tools
Make PyQt5 code more compatible with PyQt6
Implement automatic tooling
isort and black for code formatting
Line length has been set to 120
flake8 for code standards with exceptions:
E203 - Whitespace before ':' - format compatiblity with black
E501 - Line too long - flake8 line limit cannot be set
E722 - Do not use bare except - fixing bare except statements is a
lot of overhead and there are already
many in the codebase
These changes, along with some manual fixes creates much more readable code.
See examples below:
diff --git a/comicapi/comet.py b/comicapi/comet.py
index d1741c5..52dc195 100644
--- a/comicapi/comet.py
+++ b/comicapi/comet.py
@@ -166,7 +166,2 @@ class CoMet:
- if credit['role'].lower() in set(self.editor_synonyms):
- ET.SubElement(
- root,
- 'editor').text = "{0}".format(
- credit['person'])
@@ -174,2 +169,4 @@ class CoMet:
self.indent(root)
+ if credit["role"].lower() in set(self.editor_synonyms):
+ ET.SubElement(root, "editor").text = str(credit["person"])
diff --git a/comictaggerlib/autotagmatchwindow.py b/comictaggerlib/autotagmatchwindow.py
index 4338176..9219f01 100644
--- a/comictaggerlib/autotagmatchwindow.py
+++ b/comictaggerlib/autotagmatchwindow.py
@@ -63,4 +63,3 @@ class AutoTagMatchWindow(QtWidgets.QDialog):
self.skipButton, QtWidgets.QDialogButtonBox.ActionRole)
- self.buttonBox.button(QtWidgets.QDialogButtonBox.Ok).setText(
- "Accept and Write Tags")
+ self.buttonBox.button(QtWidgets.QDialogButtonBox.StandardButton.Ok).setText("Accept and Write Tags")
diff --git a/comictaggerlib/cli.py b/comictaggerlib/cli.py
index 688907d..dbd0c2e 100644
--- a/comictaggerlib/cli.py
+++ b/comictaggerlib/cli.py
@@ -293,7 +293,3 @@ def process_file_cli(filename, opts, settings, match_results):
if opts.raw:
- print((
- "{0}".format(
- str(
- ca.readRawCIX(),
- errors='ignore'))))
+ print(ca.read_raw_cix())
else:
2022-04-01 16:50:46 -07:00
|
|
|
page_count = ca.get_number_of_pages()
|
2015-02-12 14:57:46 -08:00
|
|
|
|
|
|
|
brief = ""
|
|
|
|
|
2022-11-26 16:47:18 -08:00
|
|
|
if self.batch_mode:
|
Code cleanup
Remove no longer used google scripts
Remove convenience files from comicataggerlib and import comicapi directly
Add type-hints to facilitate auto-complete tools
Make PyQt5 code more compatible with PyQt6
Implement automatic tooling
isort and black for code formatting
Line length has been set to 120
flake8 for code standards with exceptions:
E203 - Whitespace before ':' - format compatiblity with black
E501 - Line too long - flake8 line limit cannot be set
E722 - Do not use bare except - fixing bare except statements is a
lot of overhead and there are already
many in the codebase
These changes, along with some manual fixes creates much more readable code.
See examples below:
diff --git a/comicapi/comet.py b/comicapi/comet.py
index d1741c5..52dc195 100644
--- a/comicapi/comet.py
+++ b/comicapi/comet.py
@@ -166,7 +166,2 @@ class CoMet:
- if credit['role'].lower() in set(self.editor_synonyms):
- ET.SubElement(
- root,
- 'editor').text = "{0}".format(
- credit['person'])
@@ -174,2 +169,4 @@ class CoMet:
self.indent(root)
+ if credit["role"].lower() in set(self.editor_synonyms):
+ ET.SubElement(root, "editor").text = str(credit["person"])
diff --git a/comictaggerlib/autotagmatchwindow.py b/comictaggerlib/autotagmatchwindow.py
index 4338176..9219f01 100644
--- a/comictaggerlib/autotagmatchwindow.py
+++ b/comictaggerlib/autotagmatchwindow.py
@@ -63,4 +63,3 @@ class AutoTagMatchWindow(QtWidgets.QDialog):
self.skipButton, QtWidgets.QDialogButtonBox.ActionRole)
- self.buttonBox.button(QtWidgets.QDialogButtonBox.Ok).setText(
- "Accept and Write Tags")
+ self.buttonBox.button(QtWidgets.QDialogButtonBox.StandardButton.Ok).setText("Accept and Write Tags")
diff --git a/comictaggerlib/cli.py b/comictaggerlib/cli.py
index 688907d..dbd0c2e 100644
--- a/comictaggerlib/cli.py
+++ b/comictaggerlib/cli.py
@@ -293,7 +293,3 @@ def process_file_cli(filename, opts, settings, match_results):
if opts.raw:
- print((
- "{0}".format(
- str(
- ca.readRawCIX(),
- errors='ignore'))))
+ print(ca.read_raw_cix())
else:
2022-04-01 16:50:46 -07:00
|
|
|
brief = f"{ca.path}: "
|
2015-02-12 14:57:46 -08:00
|
|
|
|
2022-08-17 15:53:19 -07:00
|
|
|
brief += ca.archiver.name() + " archive "
|
2015-02-12 14:57:46 -08:00
|
|
|
|
Code cleanup
Remove no longer used google scripts
Remove convenience files from comicataggerlib and import comicapi directly
Add type-hints to facilitate auto-complete tools
Make PyQt5 code more compatible with PyQt6
Implement automatic tooling
isort and black for code formatting
Line length has been set to 120
flake8 for code standards with exceptions:
E203 - Whitespace before ':' - format compatiblity with black
E501 - Line too long - flake8 line limit cannot be set
E722 - Do not use bare except - fixing bare except statements is a
lot of overhead and there are already
many in the codebase
These changes, along with some manual fixes creates much more readable code.
See examples below:
diff --git a/comicapi/comet.py b/comicapi/comet.py
index d1741c5..52dc195 100644
--- a/comicapi/comet.py
+++ b/comicapi/comet.py
@@ -166,7 +166,2 @@ class CoMet:
- if credit['role'].lower() in set(self.editor_synonyms):
- ET.SubElement(
- root,
- 'editor').text = "{0}".format(
- credit['person'])
@@ -174,2 +169,4 @@ class CoMet:
self.indent(root)
+ if credit["role"].lower() in set(self.editor_synonyms):
+ ET.SubElement(root, "editor").text = str(credit["person"])
diff --git a/comictaggerlib/autotagmatchwindow.py b/comictaggerlib/autotagmatchwindow.py
index 4338176..9219f01 100644
--- a/comictaggerlib/autotagmatchwindow.py
+++ b/comictaggerlib/autotagmatchwindow.py
@@ -63,4 +63,3 @@ class AutoTagMatchWindow(QtWidgets.QDialog):
self.skipButton, QtWidgets.QDialogButtonBox.ActionRole)
- self.buttonBox.button(QtWidgets.QDialogButtonBox.Ok).setText(
- "Accept and Write Tags")
+ self.buttonBox.button(QtWidgets.QDialogButtonBox.StandardButton.Ok).setText("Accept and Write Tags")
diff --git a/comictaggerlib/cli.py b/comictaggerlib/cli.py
index 688907d..dbd0c2e 100644
--- a/comictaggerlib/cli.py
+++ b/comictaggerlib/cli.py
@@ -293,7 +293,3 @@ def process_file_cli(filename, opts, settings, match_results):
if opts.raw:
- print((
- "{0}".format(
- str(
- ca.readRawCIX(),
- errors='ignore'))))
+ print(ca.read_raw_cix())
else:
2022-04-01 16:50:46 -07:00
|
|
|
brief += f"({page_count: >3} pages)"
|
2015-02-12 14:57:46 -08:00
|
|
|
brief += " tags:[ "
|
|
|
|
|
2022-11-26 16:47:18 -08:00
|
|
|
if not (
|
|
|
|
ca.has_metadata(MetaDataStyle.CBI)
|
|
|
|
or ca.has_metadata(MetaDataStyle.CIX)
|
|
|
|
or ca.has_metadata(MetaDataStyle.COMET)
|
|
|
|
):
|
2015-02-12 14:57:46 -08:00
|
|
|
brief += "none "
|
|
|
|
else:
|
2022-11-26 16:47:18 -08:00
|
|
|
if ca.has_metadata(MetaDataStyle.CBI):
|
2015-02-15 02:44:00 -08:00
|
|
|
brief += "CBL "
|
2022-11-26 16:47:18 -08:00
|
|
|
if ca.has_metadata(MetaDataStyle.CIX):
|
2015-02-15 02:44:00 -08:00
|
|
|
brief += "CR "
|
2022-11-26 16:47:18 -08:00
|
|
|
if ca.has_metadata(MetaDataStyle.COMET):
|
2015-02-15 02:44:00 -08:00
|
|
|
brief += "CoMet "
|
2015-02-12 14:57:46 -08:00
|
|
|
brief += "]"
|
|
|
|
|
2018-09-19 13:05:39 -07:00
|
|
|
print(brief)
|
2015-02-12 14:57:46 -08:00
|
|
|
|
2023-09-05 00:55:12 -07:00
|
|
|
if self.config.Runtime_Options_quiet:
|
2015-02-12 14:57:46 -08:00
|
|
|
return
|
|
|
|
|
2018-09-19 13:05:39 -07:00
|
|
|
print()
|
2015-02-12 14:57:46 -08:00
|
|
|
|
2023-09-05 01:05:20 -07:00
|
|
|
raw: str | bytes = ""
|
2023-09-05 00:55:12 -07:00
|
|
|
if not self.config.Runtime_Options_type or MetaDataStyle.CIX in self.config.Runtime_Options_type:
|
2022-11-26 16:47:18 -08:00
|
|
|
if ca.has_metadata(MetaDataStyle.CIX):
|
2015-02-13 15:08:07 -08:00
|
|
|
print("--------- ComicRack tags ---------")
|
2022-06-06 19:33:02 -07:00
|
|
|
try:
|
2023-09-05 00:55:12 -07:00
|
|
|
if self.config.Runtime_Options_raw:
|
2023-09-05 01:05:20 -07:00
|
|
|
raw = ca.read_raw_cix()
|
|
|
|
if isinstance(raw, bytes):
|
|
|
|
raw = raw.decode("utf-8")
|
|
|
|
print(raw)
|
2022-06-06 19:33:02 -07:00
|
|
|
else:
|
|
|
|
print(ca.read_cix())
|
|
|
|
except Exception as e:
|
|
|
|
logger.error("Failed to load metadata for %s: %s", ca.path, e)
|
2015-02-12 14:57:46 -08:00
|
|
|
|
2023-09-05 00:55:12 -07:00
|
|
|
if not self.config.Runtime_Options_type or MetaDataStyle.CBI in self.config.Runtime_Options_type:
|
2022-11-26 16:47:18 -08:00
|
|
|
if ca.has_metadata(MetaDataStyle.CBI):
|
2015-02-13 15:08:07 -08:00
|
|
|
print("------- ComicBookLover tags -------")
|
2022-06-06 19:33:02 -07:00
|
|
|
try:
|
2023-09-05 00:55:12 -07:00
|
|
|
if self.config.Runtime_Options_raw:
|
2023-09-05 01:05:20 -07:00
|
|
|
raw = ca.read_raw_cbi()
|
|
|
|
if isinstance(raw, bytes):
|
|
|
|
raw = raw.decode("utf-8")
|
|
|
|
print(raw)
|
2022-06-06 19:33:02 -07:00
|
|
|
else:
|
|
|
|
print(ca.read_cbi())
|
|
|
|
except Exception as e:
|
|
|
|
logger.error("Failed to load metadata for %s: %s", ca.path, e)
|
2015-02-12 14:57:46 -08:00
|
|
|
|
2023-09-05 00:55:12 -07:00
|
|
|
if not self.config.Runtime_Options_type or MetaDataStyle.COMET in self.config.Runtime_Options_type:
|
2022-11-26 16:47:18 -08:00
|
|
|
if ca.has_metadata(MetaDataStyle.COMET):
|
2015-02-13 15:08:07 -08:00
|
|
|
print("----------- CoMet tags -----------")
|
2022-06-06 19:33:02 -07:00
|
|
|
try:
|
2023-09-05 00:55:12 -07:00
|
|
|
if self.config.Runtime_Options_raw:
|
2023-09-05 01:05:20 -07:00
|
|
|
raw = ca.read_raw_comet()
|
|
|
|
if isinstance(raw, bytes):
|
|
|
|
raw = raw.decode("utf-8")
|
|
|
|
print(raw)
|
2022-06-06 19:33:02 -07:00
|
|
|
else:
|
|
|
|
print(ca.read_comet())
|
|
|
|
except Exception as e:
|
|
|
|
logger.error("Failed to load metadata for %s: %s", ca.path, e)
|
2015-02-12 14:57:46 -08:00
|
|
|
|
2022-11-26 16:47:18 -08:00
|
|
|
def delete(self, ca: ComicArchive) -> None:
|
2023-09-05 00:55:12 -07:00
|
|
|
for metadata_style in self.config.Runtime_Options_type:
|
2022-06-10 16:20:58 -07:00
|
|
|
style_name = MetaDataStyle.name[metadata_style]
|
2022-11-26 16:47:18 -08:00
|
|
|
if ca.has_metadata(metadata_style):
|
2023-09-05 00:55:12 -07:00
|
|
|
if not self.config.Runtime_Options_dryrun:
|
2022-06-10 16:20:58 -07:00
|
|
|
if not ca.remove_metadata(metadata_style):
|
2022-11-26 16:47:18 -08:00
|
|
|
print(f"{ca.path}: Tag removal seemed to fail!")
|
2022-06-10 16:20:58 -07:00
|
|
|
else:
|
2022-11-26 16:47:18 -08:00
|
|
|
print(f"{ca.path}: Removed {style_name} tags.")
|
2015-02-12 14:57:46 -08:00
|
|
|
else:
|
2022-11-26 16:47:18 -08:00
|
|
|
print(f"{ca.path}: dry-run. {style_name} tags not removed")
|
2015-02-12 14:57:46 -08:00
|
|
|
else:
|
2022-11-26 16:47:18 -08:00
|
|
|
print(f"{ca.path}: This archive doesn't have {style_name} tags to remove.")
|
2022-06-10 16:20:58 -07:00
|
|
|
|
2022-11-26 16:47:18 -08:00
|
|
|
def copy(self, ca: ComicArchive) -> None:
|
2023-09-05 00:55:12 -07:00
|
|
|
for metadata_style in self.config.Runtime_Options_type:
|
2022-06-10 16:20:58 -07:00
|
|
|
dst_style_name = MetaDataStyle.name[metadata_style]
|
2023-09-05 00:55:12 -07:00
|
|
|
if not self.config.Runtime_Options_overwrite and ca.has_metadata(metadata_style):
|
2022-11-26 16:47:18 -08:00
|
|
|
print(f"{ca.path}: Already has {dst_style_name} tags. Not overwriting.")
|
2022-06-10 16:20:58 -07:00
|
|
|
return
|
2023-09-05 00:55:12 -07:00
|
|
|
if self.config.Commands_copy == metadata_style:
|
2022-11-26 16:47:18 -08:00
|
|
|
print(f"{ca.path}: Destination and source are same: {dst_style_name}. Nothing to do.")
|
2022-06-10 16:20:58 -07:00
|
|
|
return
|
|
|
|
|
2023-09-05 00:55:12 -07:00
|
|
|
src_style_name = MetaDataStyle.name[self.config.Commands_copy]
|
|
|
|
if ca.has_metadata(self.config.Commands_copy):
|
|
|
|
if not self.config.Runtime_Options_dryrun:
|
2022-06-10 16:20:58 -07:00
|
|
|
try:
|
2023-09-05 00:55:12 -07:00
|
|
|
md = ca.read_metadata(self.config.Commands_copy)
|
2022-06-10 16:20:58 -07:00
|
|
|
except Exception as e:
|
|
|
|
md = GenericMetadata()
|
|
|
|
logger.error("Failed to load metadata for %s: %s", ca.path, e)
|
|
|
|
|
2023-09-05 00:55:12 -07:00
|
|
|
if self.config.Comic_Book_Lover_apply_transform_on_bulk_operation == MetaDataStyle.CBI:
|
2023-01-31 20:21:39 -08:00
|
|
|
md = CBLTransformer(md, self.config).apply()
|
2022-06-10 16:20:58 -07:00
|
|
|
|
|
|
|
if not ca.write_metadata(md, metadata_style):
|
2022-11-26 16:47:18 -08:00
|
|
|
print(f"{ca.path}: Tag copy seemed to fail!")
|
2022-06-10 16:20:58 -07:00
|
|
|
else:
|
2022-11-26 16:47:18 -08:00
|
|
|
print(f"{ca.path}: Copied {src_style_name} tags to {dst_style_name}.")
|
2015-02-12 14:57:46 -08:00
|
|
|
else:
|
2022-11-26 16:47:18 -08:00
|
|
|
print(f"{ca.path}: dry-run. {src_style_name} tags not copied")
|
2015-02-12 14:57:46 -08:00
|
|
|
else:
|
2022-11-26 16:47:18 -08:00
|
|
|
print(f"{ca.path}: This archive doesn't have {src_style_name} tags to copy.")
|
2015-02-12 14:57:46 -08:00
|
|
|
|
2022-11-26 16:47:18 -08:00
|
|
|
def save(self, ca: ComicArchive, match_results: OnlineMatchResults) -> None:
|
2023-09-05 00:55:12 -07:00
|
|
|
if not self.config.Runtime_Options_overwrite:
|
|
|
|
for metadata_style in self.config.Runtime_Options_type:
|
2022-11-26 16:47:18 -08:00
|
|
|
if ca.has_metadata(metadata_style):
|
|
|
|
print(f"{ca.path}: Already has {MetaDataStyle.name[metadata_style]} tags. Not overwriting.")
|
2022-06-10 16:20:58 -07:00
|
|
|
return
|
2015-02-12 14:57:46 -08:00
|
|
|
|
2022-11-26 16:47:18 -08:00
|
|
|
if self.batch_mode:
|
Code cleanup
Remove no longer used google scripts
Remove convenience files from comicataggerlib and import comicapi directly
Add type-hints to facilitate auto-complete tools
Make PyQt5 code more compatible with PyQt6
Implement automatic tooling
isort and black for code formatting
Line length has been set to 120
flake8 for code standards with exceptions:
E203 - Whitespace before ':' - format compatiblity with black
E501 - Line too long - flake8 line limit cannot be set
E722 - Do not use bare except - fixing bare except statements is a
lot of overhead and there are already
many in the codebase
These changes, along with some manual fixes creates much more readable code.
See examples below:
diff --git a/comicapi/comet.py b/comicapi/comet.py
index d1741c5..52dc195 100644
--- a/comicapi/comet.py
+++ b/comicapi/comet.py
@@ -166,7 +166,2 @@ class CoMet:
- if credit['role'].lower() in set(self.editor_synonyms):
- ET.SubElement(
- root,
- 'editor').text = "{0}".format(
- credit['person'])
@@ -174,2 +169,4 @@ class CoMet:
self.indent(root)
+ if credit["role"].lower() in set(self.editor_synonyms):
+ ET.SubElement(root, "editor").text = str(credit["person"])
diff --git a/comictaggerlib/autotagmatchwindow.py b/comictaggerlib/autotagmatchwindow.py
index 4338176..9219f01 100644
--- a/comictaggerlib/autotagmatchwindow.py
+++ b/comictaggerlib/autotagmatchwindow.py
@@ -63,4 +63,3 @@ class AutoTagMatchWindow(QtWidgets.QDialog):
self.skipButton, QtWidgets.QDialogButtonBox.ActionRole)
- self.buttonBox.button(QtWidgets.QDialogButtonBox.Ok).setText(
- "Accept and Write Tags")
+ self.buttonBox.button(QtWidgets.QDialogButtonBox.StandardButton.Ok).setText("Accept and Write Tags")
diff --git a/comictaggerlib/cli.py b/comictaggerlib/cli.py
index 688907d..dbd0c2e 100644
--- a/comictaggerlib/cli.py
+++ b/comictaggerlib/cli.py
@@ -293,7 +293,3 @@ def process_file_cli(filename, opts, settings, match_results):
if opts.raw:
- print((
- "{0}".format(
- str(
- ca.readRawCIX(),
- errors='ignore'))))
+ print(ca.read_raw_cix())
else:
2022-04-01 16:50:46 -07:00
|
|
|
print(f"Processing {ca.path}...")
|
2015-02-12 14:57:46 -08:00
|
|
|
|
2022-11-26 16:47:18 -08:00
|
|
|
md = self.create_local_metadata(ca)
|
2015-02-12 14:57:46 -08:00
|
|
|
if md.issue is None or md.issue == "":
|
2023-09-05 00:55:12 -07:00
|
|
|
if self.config.Auto_Tag_assume_1_if_no_issue_num:
|
2015-02-12 14:57:46 -08:00
|
|
|
md.issue = "1"
|
|
|
|
|
|
|
|
# now, search online
|
2023-09-05 00:55:12 -07:00
|
|
|
if self.config.Runtime_Options_online:
|
|
|
|
if self.config.Runtime_Options_issue_id is not None:
|
2022-10-04 17:58:46 -07:00
|
|
|
# we were given the actual issue ID to search with
|
2015-02-12 14:57:46 -08:00
|
|
|
try:
|
2023-09-05 00:55:12 -07:00
|
|
|
ct_md = self.current_talker().fetch_comic_data(self.config.Runtime_Options_issue_id)
|
2022-06-28 07:21:35 -07:00
|
|
|
except TalkerError as e:
|
|
|
|
logger.exception(f"Error retrieving issue details. Save aborted.\n{e}")
|
2022-05-17 13:57:04 -07:00
|
|
|
match_results.fetch_data_failures.append(str(ca.path.absolute()))
|
2015-02-12 14:57:46 -08:00
|
|
|
return
|
|
|
|
|
2022-06-28 07:21:35 -07:00
|
|
|
if ct_md is None:
|
2023-09-05 00:55:12 -07:00
|
|
|
logger.error("No match for ID %s was found.", self.config.Runtime_Options_issue_id)
|
2022-05-17 13:57:04 -07:00
|
|
|
match_results.no_matches.append(str(ca.path.absolute()))
|
2015-02-12 14:57:46 -08:00
|
|
|
return
|
|
|
|
|
2023-09-05 00:55:12 -07:00
|
|
|
if self.config.Comic_Book_Lover_apply_transform_on_import:
|
2023-01-31 20:21:39 -08:00
|
|
|
ct_md = CBLTransformer(ct_md, self.config).apply()
|
2015-02-12 14:57:46 -08:00
|
|
|
else:
|
Code cleanup
Remove no longer used google scripts
Remove convenience files from comicataggerlib and import comicapi directly
Add type-hints to facilitate auto-complete tools
Make PyQt5 code more compatible with PyQt6
Implement automatic tooling
isort and black for code formatting
Line length has been set to 120
flake8 for code standards with exceptions:
E203 - Whitespace before ':' - format compatiblity with black
E501 - Line too long - flake8 line limit cannot be set
E722 - Do not use bare except - fixing bare except statements is a
lot of overhead and there are already
many in the codebase
These changes, along with some manual fixes creates much more readable code.
See examples below:
diff --git a/comicapi/comet.py b/comicapi/comet.py
index d1741c5..52dc195 100644
--- a/comicapi/comet.py
+++ b/comicapi/comet.py
@@ -166,7 +166,2 @@ class CoMet:
- if credit['role'].lower() in set(self.editor_synonyms):
- ET.SubElement(
- root,
- 'editor').text = "{0}".format(
- credit['person'])
@@ -174,2 +169,4 @@ class CoMet:
self.indent(root)
+ if credit["role"].lower() in set(self.editor_synonyms):
+ ET.SubElement(root, "editor").text = str(credit["person"])
diff --git a/comictaggerlib/autotagmatchwindow.py b/comictaggerlib/autotagmatchwindow.py
index 4338176..9219f01 100644
--- a/comictaggerlib/autotagmatchwindow.py
+++ b/comictaggerlib/autotagmatchwindow.py
@@ -63,4 +63,3 @@ class AutoTagMatchWindow(QtWidgets.QDialog):
self.skipButton, QtWidgets.QDialogButtonBox.ActionRole)
- self.buttonBox.button(QtWidgets.QDialogButtonBox.Ok).setText(
- "Accept and Write Tags")
+ self.buttonBox.button(QtWidgets.QDialogButtonBox.StandardButton.Ok).setText("Accept and Write Tags")
diff --git a/comictaggerlib/cli.py b/comictaggerlib/cli.py
index 688907d..dbd0c2e 100644
--- a/comictaggerlib/cli.py
+++ b/comictaggerlib/cli.py
@@ -293,7 +293,3 @@ def process_file_cli(filename, opts, settings, match_results):
if opts.raw:
- print((
- "{0}".format(
- str(
- ca.readRawCIX(),
- errors='ignore'))))
+ print(ca.read_raw_cix())
else:
2022-04-01 16:50:46 -07:00
|
|
|
if md is None or md.is_empty:
|
2022-04-04 18:59:26 -07:00
|
|
|
logger.error("No metadata given to search online with!")
|
2022-05-17 13:57:04 -07:00
|
|
|
match_results.no_matches.append(str(ca.path.absolute()))
|
2015-02-12 14:57:46 -08:00
|
|
|
return
|
|
|
|
|
2023-02-09 19:33:10 -08:00
|
|
|
ii = IssueIdentifier(ca, self.config, self.current_talker())
|
2022-06-28 07:21:35 -07:00
|
|
|
|
2022-05-17 13:57:04 -07:00
|
|
|
def myoutput(text: str) -> None:
|
2023-09-05 00:55:12 -07:00
|
|
|
if self.config.Runtime_Options_verbose:
|
Code cleanup
Remove no longer used google scripts
Remove convenience files from comicataggerlib and import comicapi directly
Add type-hints to facilitate auto-complete tools
Make PyQt5 code more compatible with PyQt6
Implement automatic tooling
isort and black for code formatting
Line length has been set to 120
flake8 for code standards with exceptions:
E203 - Whitespace before ':' - format compatiblity with black
E501 - Line too long - flake8 line limit cannot be set
E722 - Do not use bare except - fixing bare except statements is a
lot of overhead and there are already
many in the codebase
These changes, along with some manual fixes creates much more readable code.
See examples below:
diff --git a/comicapi/comet.py b/comicapi/comet.py
index d1741c5..52dc195 100644
--- a/comicapi/comet.py
+++ b/comicapi/comet.py
@@ -166,7 +166,2 @@ class CoMet:
- if credit['role'].lower() in set(self.editor_synonyms):
- ET.SubElement(
- root,
- 'editor').text = "{0}".format(
- credit['person'])
@@ -174,2 +169,4 @@ class CoMet:
self.indent(root)
+ if credit["role"].lower() in set(self.editor_synonyms):
+ ET.SubElement(root, "editor").text = str(credit["person"])
diff --git a/comictaggerlib/autotagmatchwindow.py b/comictaggerlib/autotagmatchwindow.py
index 4338176..9219f01 100644
--- a/comictaggerlib/autotagmatchwindow.py
+++ b/comictaggerlib/autotagmatchwindow.py
@@ -63,4 +63,3 @@ class AutoTagMatchWindow(QtWidgets.QDialog):
self.skipButton, QtWidgets.QDialogButtonBox.ActionRole)
- self.buttonBox.button(QtWidgets.QDialogButtonBox.Ok).setText(
- "Accept and Write Tags")
+ self.buttonBox.button(QtWidgets.QDialogButtonBox.StandardButton.Ok).setText("Accept and Write Tags")
diff --git a/comictaggerlib/cli.py b/comictaggerlib/cli.py
index 688907d..dbd0c2e 100644
--- a/comictaggerlib/cli.py
+++ b/comictaggerlib/cli.py
@@ -293,7 +293,3 @@ def process_file_cli(filename, opts, settings, match_results):
if opts.raw:
- print((
- "{0}".format(
- str(
- ca.readRawCIX(),
- errors='ignore'))))
+ print(ca.read_raw_cix())
else:
2022-04-01 16:50:46 -07:00
|
|
|
IssueIdentifier.default_write_output(text)
|
2015-02-12 14:57:46 -08:00
|
|
|
|
2022-06-07 20:22:33 -07:00
|
|
|
# use our overlaid MD struct to search
|
Code cleanup
Remove no longer used google scripts
Remove convenience files from comicataggerlib and import comicapi directly
Add type-hints to facilitate auto-complete tools
Make PyQt5 code more compatible with PyQt6
Implement automatic tooling
isort and black for code formatting
Line length has been set to 120
flake8 for code standards with exceptions:
E203 - Whitespace before ':' - format compatiblity with black
E501 - Line too long - flake8 line limit cannot be set
E722 - Do not use bare except - fixing bare except statements is a
lot of overhead and there are already
many in the codebase
These changes, along with some manual fixes creates much more readable code.
See examples below:
diff --git a/comicapi/comet.py b/comicapi/comet.py
index d1741c5..52dc195 100644
--- a/comicapi/comet.py
+++ b/comicapi/comet.py
@@ -166,7 +166,2 @@ class CoMet:
- if credit['role'].lower() in set(self.editor_synonyms):
- ET.SubElement(
- root,
- 'editor').text = "{0}".format(
- credit['person'])
@@ -174,2 +169,4 @@ class CoMet:
self.indent(root)
+ if credit["role"].lower() in set(self.editor_synonyms):
+ ET.SubElement(root, "editor").text = str(credit["person"])
diff --git a/comictaggerlib/autotagmatchwindow.py b/comictaggerlib/autotagmatchwindow.py
index 4338176..9219f01 100644
--- a/comictaggerlib/autotagmatchwindow.py
+++ b/comictaggerlib/autotagmatchwindow.py
@@ -63,4 +63,3 @@ class AutoTagMatchWindow(QtWidgets.QDialog):
self.skipButton, QtWidgets.QDialogButtonBox.ActionRole)
- self.buttonBox.button(QtWidgets.QDialogButtonBox.Ok).setText(
- "Accept and Write Tags")
+ self.buttonBox.button(QtWidgets.QDialogButtonBox.StandardButton.Ok).setText("Accept and Write Tags")
diff --git a/comictaggerlib/cli.py b/comictaggerlib/cli.py
index 688907d..dbd0c2e 100644
--- a/comictaggerlib/cli.py
+++ b/comictaggerlib/cli.py
@@ -293,7 +293,3 @@ def process_file_cli(filename, opts, settings, match_results):
if opts.raw:
- print((
- "{0}".format(
- str(
- ca.readRawCIX(),
- errors='ignore'))))
+ print(ca.read_raw_cix())
else:
2022-04-01 16:50:46 -07:00
|
|
|
ii.set_additional_metadata(md)
|
|
|
|
ii.only_use_additional_meta_data = True
|
|
|
|
ii.set_output_function(myoutput)
|
|
|
|
ii.cover_page_index = md.get_cover_page_index_list()[0]
|
2015-02-12 14:57:46 -08:00
|
|
|
matches = ii.search()
|
|
|
|
|
|
|
|
result = ii.search_result
|
|
|
|
|
|
|
|
found_match = False
|
|
|
|
choices = False
|
|
|
|
low_confidence = False
|
|
|
|
|
Code cleanup
Remove no longer used google scripts
Remove convenience files from comicataggerlib and import comicapi directly
Add type-hints to facilitate auto-complete tools
Make PyQt5 code more compatible with PyQt6
Implement automatic tooling
isort and black for code formatting
Line length has been set to 120
flake8 for code standards with exceptions:
E203 - Whitespace before ':' - format compatiblity with black
E501 - Line too long - flake8 line limit cannot be set
E722 - Do not use bare except - fixing bare except statements is a
lot of overhead and there are already
many in the codebase
These changes, along with some manual fixes creates much more readable code.
See examples below:
diff --git a/comicapi/comet.py b/comicapi/comet.py
index d1741c5..52dc195 100644
--- a/comicapi/comet.py
+++ b/comicapi/comet.py
@@ -166,7 +166,2 @@ class CoMet:
- if credit['role'].lower() in set(self.editor_synonyms):
- ET.SubElement(
- root,
- 'editor').text = "{0}".format(
- credit['person'])
@@ -174,2 +169,4 @@ class CoMet:
self.indent(root)
+ if credit["role"].lower() in set(self.editor_synonyms):
+ ET.SubElement(root, "editor").text = str(credit["person"])
diff --git a/comictaggerlib/autotagmatchwindow.py b/comictaggerlib/autotagmatchwindow.py
index 4338176..9219f01 100644
--- a/comictaggerlib/autotagmatchwindow.py
+++ b/comictaggerlib/autotagmatchwindow.py
@@ -63,4 +63,3 @@ class AutoTagMatchWindow(QtWidgets.QDialog):
self.skipButton, QtWidgets.QDialogButtonBox.ActionRole)
- self.buttonBox.button(QtWidgets.QDialogButtonBox.Ok).setText(
- "Accept and Write Tags")
+ self.buttonBox.button(QtWidgets.QDialogButtonBox.StandardButton.Ok).setText("Accept and Write Tags")
diff --git a/comictaggerlib/cli.py b/comictaggerlib/cli.py
index 688907d..dbd0c2e 100644
--- a/comictaggerlib/cli.py
+++ b/comictaggerlib/cli.py
@@ -293,7 +293,3 @@ def process_file_cli(filename, opts, settings, match_results):
if opts.raw:
- print((
- "{0}".format(
- str(
- ca.readRawCIX(),
- errors='ignore'))))
+ print(ca.read_raw_cix())
else:
2022-04-01 16:50:46 -07:00
|
|
|
if result == ii.result_no_matches:
|
2015-02-12 14:57:46 -08:00
|
|
|
pass
|
Code cleanup
Remove no longer used google scripts
Remove convenience files from comicataggerlib and import comicapi directly
Add type-hints to facilitate auto-complete tools
Make PyQt5 code more compatible with PyQt6
Implement automatic tooling
isort and black for code formatting
Line length has been set to 120
flake8 for code standards with exceptions:
E203 - Whitespace before ':' - format compatiblity with black
E501 - Line too long - flake8 line limit cannot be set
E722 - Do not use bare except - fixing bare except statements is a
lot of overhead and there are already
many in the codebase
These changes, along with some manual fixes creates much more readable code.
See examples below:
diff --git a/comicapi/comet.py b/comicapi/comet.py
index d1741c5..52dc195 100644
--- a/comicapi/comet.py
+++ b/comicapi/comet.py
@@ -166,7 +166,2 @@ class CoMet:
- if credit['role'].lower() in set(self.editor_synonyms):
- ET.SubElement(
- root,
- 'editor').text = "{0}".format(
- credit['person'])
@@ -174,2 +169,4 @@ class CoMet:
self.indent(root)
+ if credit["role"].lower() in set(self.editor_synonyms):
+ ET.SubElement(root, "editor").text = str(credit["person"])
diff --git a/comictaggerlib/autotagmatchwindow.py b/comictaggerlib/autotagmatchwindow.py
index 4338176..9219f01 100644
--- a/comictaggerlib/autotagmatchwindow.py
+++ b/comictaggerlib/autotagmatchwindow.py
@@ -63,4 +63,3 @@ class AutoTagMatchWindow(QtWidgets.QDialog):
self.skipButton, QtWidgets.QDialogButtonBox.ActionRole)
- self.buttonBox.button(QtWidgets.QDialogButtonBox.Ok).setText(
- "Accept and Write Tags")
+ self.buttonBox.button(QtWidgets.QDialogButtonBox.StandardButton.Ok).setText("Accept and Write Tags")
diff --git a/comictaggerlib/cli.py b/comictaggerlib/cli.py
index 688907d..dbd0c2e 100644
--- a/comictaggerlib/cli.py
+++ b/comictaggerlib/cli.py
@@ -293,7 +293,3 @@ def process_file_cli(filename, opts, settings, match_results):
if opts.raw:
- print((
- "{0}".format(
- str(
- ca.readRawCIX(),
- errors='ignore'))))
+ print(ca.read_raw_cix())
else:
2022-04-01 16:50:46 -07:00
|
|
|
elif result == ii.result_found_match_but_bad_cover_score:
|
2015-02-12 14:57:46 -08:00
|
|
|
low_confidence = True
|
|
|
|
found_match = True
|
Code cleanup
Remove no longer used google scripts
Remove convenience files from comicataggerlib and import comicapi directly
Add type-hints to facilitate auto-complete tools
Make PyQt5 code more compatible with PyQt6
Implement automatic tooling
isort and black for code formatting
Line length has been set to 120
flake8 for code standards with exceptions:
E203 - Whitespace before ':' - format compatiblity with black
E501 - Line too long - flake8 line limit cannot be set
E722 - Do not use bare except - fixing bare except statements is a
lot of overhead and there are already
many in the codebase
These changes, along with some manual fixes creates much more readable code.
See examples below:
diff --git a/comicapi/comet.py b/comicapi/comet.py
index d1741c5..52dc195 100644
--- a/comicapi/comet.py
+++ b/comicapi/comet.py
@@ -166,7 +166,2 @@ class CoMet:
- if credit['role'].lower() in set(self.editor_synonyms):
- ET.SubElement(
- root,
- 'editor').text = "{0}".format(
- credit['person'])
@@ -174,2 +169,4 @@ class CoMet:
self.indent(root)
+ if credit["role"].lower() in set(self.editor_synonyms):
+ ET.SubElement(root, "editor").text = str(credit["person"])
diff --git a/comictaggerlib/autotagmatchwindow.py b/comictaggerlib/autotagmatchwindow.py
index 4338176..9219f01 100644
--- a/comictaggerlib/autotagmatchwindow.py
+++ b/comictaggerlib/autotagmatchwindow.py
@@ -63,4 +63,3 @@ class AutoTagMatchWindow(QtWidgets.QDialog):
self.skipButton, QtWidgets.QDialogButtonBox.ActionRole)
- self.buttonBox.button(QtWidgets.QDialogButtonBox.Ok).setText(
- "Accept and Write Tags")
+ self.buttonBox.button(QtWidgets.QDialogButtonBox.StandardButton.Ok).setText("Accept and Write Tags")
diff --git a/comictaggerlib/cli.py b/comictaggerlib/cli.py
index 688907d..dbd0c2e 100644
--- a/comictaggerlib/cli.py
+++ b/comictaggerlib/cli.py
@@ -293,7 +293,3 @@ def process_file_cli(filename, opts, settings, match_results):
if opts.raw:
- print((
- "{0}".format(
- str(
- ca.readRawCIX(),
- errors='ignore'))))
+ print(ca.read_raw_cix())
else:
2022-04-01 16:50:46 -07:00
|
|
|
elif result == ii.result_found_match_but_not_first_page:
|
2015-02-12 14:57:46 -08:00
|
|
|
found_match = True
|
Code cleanup
Remove no longer used google scripts
Remove convenience files from comicataggerlib and import comicapi directly
Add type-hints to facilitate auto-complete tools
Make PyQt5 code more compatible with PyQt6
Implement automatic tooling
isort and black for code formatting
Line length has been set to 120
flake8 for code standards with exceptions:
E203 - Whitespace before ':' - format compatiblity with black
E501 - Line too long - flake8 line limit cannot be set
E722 - Do not use bare except - fixing bare except statements is a
lot of overhead and there are already
many in the codebase
These changes, along with some manual fixes creates much more readable code.
See examples below:
diff --git a/comicapi/comet.py b/comicapi/comet.py
index d1741c5..52dc195 100644
--- a/comicapi/comet.py
+++ b/comicapi/comet.py
@@ -166,7 +166,2 @@ class CoMet:
- if credit['role'].lower() in set(self.editor_synonyms):
- ET.SubElement(
- root,
- 'editor').text = "{0}".format(
- credit['person'])
@@ -174,2 +169,4 @@ class CoMet:
self.indent(root)
+ if credit["role"].lower() in set(self.editor_synonyms):
+ ET.SubElement(root, "editor").text = str(credit["person"])
diff --git a/comictaggerlib/autotagmatchwindow.py b/comictaggerlib/autotagmatchwindow.py
index 4338176..9219f01 100644
--- a/comictaggerlib/autotagmatchwindow.py
+++ b/comictaggerlib/autotagmatchwindow.py
@@ -63,4 +63,3 @@ class AutoTagMatchWindow(QtWidgets.QDialog):
self.skipButton, QtWidgets.QDialogButtonBox.ActionRole)
- self.buttonBox.button(QtWidgets.QDialogButtonBox.Ok).setText(
- "Accept and Write Tags")
+ self.buttonBox.button(QtWidgets.QDialogButtonBox.StandardButton.Ok).setText("Accept and Write Tags")
diff --git a/comictaggerlib/cli.py b/comictaggerlib/cli.py
index 688907d..dbd0c2e 100644
--- a/comictaggerlib/cli.py
+++ b/comictaggerlib/cli.py
@@ -293,7 +293,3 @@ def process_file_cli(filename, opts, settings, match_results):
if opts.raw:
- print((
- "{0}".format(
- str(
- ca.readRawCIX(),
- errors='ignore'))))
+ print(ca.read_raw_cix())
else:
2022-04-01 16:50:46 -07:00
|
|
|
elif result == ii.result_multiple_matches_with_bad_image_scores:
|
2015-02-12 14:57:46 -08:00
|
|
|
low_confidence = True
|
|
|
|
choices = True
|
Code cleanup
Remove no longer used google scripts
Remove convenience files from comicataggerlib and import comicapi directly
Add type-hints to facilitate auto-complete tools
Make PyQt5 code more compatible with PyQt6
Implement automatic tooling
isort and black for code formatting
Line length has been set to 120
flake8 for code standards with exceptions:
E203 - Whitespace before ':' - format compatiblity with black
E501 - Line too long - flake8 line limit cannot be set
E722 - Do not use bare except - fixing bare except statements is a
lot of overhead and there are already
many in the codebase
These changes, along with some manual fixes creates much more readable code.
See examples below:
diff --git a/comicapi/comet.py b/comicapi/comet.py
index d1741c5..52dc195 100644
--- a/comicapi/comet.py
+++ b/comicapi/comet.py
@@ -166,7 +166,2 @@ class CoMet:
- if credit['role'].lower() in set(self.editor_synonyms):
- ET.SubElement(
- root,
- 'editor').text = "{0}".format(
- credit['person'])
@@ -174,2 +169,4 @@ class CoMet:
self.indent(root)
+ if credit["role"].lower() in set(self.editor_synonyms):
+ ET.SubElement(root, "editor").text = str(credit["person"])
diff --git a/comictaggerlib/autotagmatchwindow.py b/comictaggerlib/autotagmatchwindow.py
index 4338176..9219f01 100644
--- a/comictaggerlib/autotagmatchwindow.py
+++ b/comictaggerlib/autotagmatchwindow.py
@@ -63,4 +63,3 @@ class AutoTagMatchWindow(QtWidgets.QDialog):
self.skipButton, QtWidgets.QDialogButtonBox.ActionRole)
- self.buttonBox.button(QtWidgets.QDialogButtonBox.Ok).setText(
- "Accept and Write Tags")
+ self.buttonBox.button(QtWidgets.QDialogButtonBox.StandardButton.Ok).setText("Accept and Write Tags")
diff --git a/comictaggerlib/cli.py b/comictaggerlib/cli.py
index 688907d..dbd0c2e 100644
--- a/comictaggerlib/cli.py
+++ b/comictaggerlib/cli.py
@@ -293,7 +293,3 @@ def process_file_cli(filename, opts, settings, match_results):
if opts.raw:
- print((
- "{0}".format(
- str(
- ca.readRawCIX(),
- errors='ignore'))))
+ print(ca.read_raw_cix())
else:
2022-04-01 16:50:46 -07:00
|
|
|
elif result == ii.result_one_good_match:
|
2015-02-12 14:57:46 -08:00
|
|
|
found_match = True
|
Code cleanup
Remove no longer used google scripts
Remove convenience files from comicataggerlib and import comicapi directly
Add type-hints to facilitate auto-complete tools
Make PyQt5 code more compatible with PyQt6
Implement automatic tooling
isort and black for code formatting
Line length has been set to 120
flake8 for code standards with exceptions:
E203 - Whitespace before ':' - format compatiblity with black
E501 - Line too long - flake8 line limit cannot be set
E722 - Do not use bare except - fixing bare except statements is a
lot of overhead and there are already
many in the codebase
These changes, along with some manual fixes creates much more readable code.
See examples below:
diff --git a/comicapi/comet.py b/comicapi/comet.py
index d1741c5..52dc195 100644
--- a/comicapi/comet.py
+++ b/comicapi/comet.py
@@ -166,7 +166,2 @@ class CoMet:
- if credit['role'].lower() in set(self.editor_synonyms):
- ET.SubElement(
- root,
- 'editor').text = "{0}".format(
- credit['person'])
@@ -174,2 +169,4 @@ class CoMet:
self.indent(root)
+ if credit["role"].lower() in set(self.editor_synonyms):
+ ET.SubElement(root, "editor").text = str(credit["person"])
diff --git a/comictaggerlib/autotagmatchwindow.py b/comictaggerlib/autotagmatchwindow.py
index 4338176..9219f01 100644
--- a/comictaggerlib/autotagmatchwindow.py
+++ b/comictaggerlib/autotagmatchwindow.py
@@ -63,4 +63,3 @@ class AutoTagMatchWindow(QtWidgets.QDialog):
self.skipButton, QtWidgets.QDialogButtonBox.ActionRole)
- self.buttonBox.button(QtWidgets.QDialogButtonBox.Ok).setText(
- "Accept and Write Tags")
+ self.buttonBox.button(QtWidgets.QDialogButtonBox.StandardButton.Ok).setText("Accept and Write Tags")
diff --git a/comictaggerlib/cli.py b/comictaggerlib/cli.py
index 688907d..dbd0c2e 100644
--- a/comictaggerlib/cli.py
+++ b/comictaggerlib/cli.py
@@ -293,7 +293,3 @@ def process_file_cli(filename, opts, settings, match_results):
if opts.raw:
- print((
- "{0}".format(
- str(
- ca.readRawCIX(),
- errors='ignore'))))
+ print(ca.read_raw_cix())
else:
2022-04-01 16:50:46 -07:00
|
|
|
elif result == ii.result_multiple_good_matches:
|
2015-02-12 14:57:46 -08:00
|
|
|
choices = True
|
|
|
|
|
|
|
|
if choices:
|
|
|
|
if low_confidence:
|
2022-04-04 18:59:26 -07:00
|
|
|
logger.error("Online search: Multiple low confidence matches. Save aborted")
|
Code cleanup
Remove no longer used google scripts
Remove convenience files from comicataggerlib and import comicapi directly
Add type-hints to facilitate auto-complete tools
Make PyQt5 code more compatible with PyQt6
Implement automatic tooling
isort and black for code formatting
Line length has been set to 120
flake8 for code standards with exceptions:
E203 - Whitespace before ':' - format compatiblity with black
E501 - Line too long - flake8 line limit cannot be set
E722 - Do not use bare except - fixing bare except statements is a
lot of overhead and there are already
many in the codebase
These changes, along with some manual fixes creates much more readable code.
See examples below:
diff --git a/comicapi/comet.py b/comicapi/comet.py
index d1741c5..52dc195 100644
--- a/comicapi/comet.py
+++ b/comicapi/comet.py
@@ -166,7 +166,2 @@ class CoMet:
- if credit['role'].lower() in set(self.editor_synonyms):
- ET.SubElement(
- root,
- 'editor').text = "{0}".format(
- credit['person'])
@@ -174,2 +169,4 @@ class CoMet:
self.indent(root)
+ if credit["role"].lower() in set(self.editor_synonyms):
+ ET.SubElement(root, "editor").text = str(credit["person"])
diff --git a/comictaggerlib/autotagmatchwindow.py b/comictaggerlib/autotagmatchwindow.py
index 4338176..9219f01 100644
--- a/comictaggerlib/autotagmatchwindow.py
+++ b/comictaggerlib/autotagmatchwindow.py
@@ -63,4 +63,3 @@ class AutoTagMatchWindow(QtWidgets.QDialog):
self.skipButton, QtWidgets.QDialogButtonBox.ActionRole)
- self.buttonBox.button(QtWidgets.QDialogButtonBox.Ok).setText(
- "Accept and Write Tags")
+ self.buttonBox.button(QtWidgets.QDialogButtonBox.StandardButton.Ok).setText("Accept and Write Tags")
diff --git a/comictaggerlib/cli.py b/comictaggerlib/cli.py
index 688907d..dbd0c2e 100644
--- a/comictaggerlib/cli.py
+++ b/comictaggerlib/cli.py
@@ -293,7 +293,3 @@ def process_file_cli(filename, opts, settings, match_results):
if opts.raw:
- print((
- "{0}".format(
- str(
- ca.readRawCIX(),
- errors='ignore'))))
+ print(ca.read_raw_cix())
else:
2022-04-01 16:50:46 -07:00
|
|
|
match_results.low_confidence_matches.append(MultipleMatch(ca, matches))
|
2015-02-12 14:57:46 -08:00
|
|
|
return
|
Code cleanup
Remove no longer used google scripts
Remove convenience files from comicataggerlib and import comicapi directly
Add type-hints to facilitate auto-complete tools
Make PyQt5 code more compatible with PyQt6
Implement automatic tooling
isort and black for code formatting
Line length has been set to 120
flake8 for code standards with exceptions:
E203 - Whitespace before ':' - format compatiblity with black
E501 - Line too long - flake8 line limit cannot be set
E722 - Do not use bare except - fixing bare except statements is a
lot of overhead and there are already
many in the codebase
These changes, along with some manual fixes creates much more readable code.
See examples below:
diff --git a/comicapi/comet.py b/comicapi/comet.py
index d1741c5..52dc195 100644
--- a/comicapi/comet.py
+++ b/comicapi/comet.py
@@ -166,7 +166,2 @@ class CoMet:
- if credit['role'].lower() in set(self.editor_synonyms):
- ET.SubElement(
- root,
- 'editor').text = "{0}".format(
- credit['person'])
@@ -174,2 +169,4 @@ class CoMet:
self.indent(root)
+ if credit["role"].lower() in set(self.editor_synonyms):
+ ET.SubElement(root, "editor").text = str(credit["person"])
diff --git a/comictaggerlib/autotagmatchwindow.py b/comictaggerlib/autotagmatchwindow.py
index 4338176..9219f01 100644
--- a/comictaggerlib/autotagmatchwindow.py
+++ b/comictaggerlib/autotagmatchwindow.py
@@ -63,4 +63,3 @@ class AutoTagMatchWindow(QtWidgets.QDialog):
self.skipButton, QtWidgets.QDialogButtonBox.ActionRole)
- self.buttonBox.button(QtWidgets.QDialogButtonBox.Ok).setText(
- "Accept and Write Tags")
+ self.buttonBox.button(QtWidgets.QDialogButtonBox.StandardButton.Ok).setText("Accept and Write Tags")
diff --git a/comictaggerlib/cli.py b/comictaggerlib/cli.py
index 688907d..dbd0c2e 100644
--- a/comictaggerlib/cli.py
+++ b/comictaggerlib/cli.py
@@ -293,7 +293,3 @@ def process_file_cli(filename, opts, settings, match_results):
if opts.raw:
- print((
- "{0}".format(
- str(
- ca.readRawCIX(),
- errors='ignore'))))
+ print(ca.read_raw_cix())
else:
2022-04-01 16:50:46 -07:00
|
|
|
|
2022-04-04 18:59:26 -07:00
|
|
|
logger.error("Online search: Multiple good matches. Save aborted")
|
Code cleanup
Remove no longer used google scripts
Remove convenience files from comicataggerlib and import comicapi directly
Add type-hints to facilitate auto-complete tools
Make PyQt5 code more compatible with PyQt6
Implement automatic tooling
isort and black for code formatting
Line length has been set to 120
flake8 for code standards with exceptions:
E203 - Whitespace before ':' - format compatiblity with black
E501 - Line too long - flake8 line limit cannot be set
E722 - Do not use bare except - fixing bare except statements is a
lot of overhead and there are already
many in the codebase
These changes, along with some manual fixes creates much more readable code.
See examples below:
diff --git a/comicapi/comet.py b/comicapi/comet.py
index d1741c5..52dc195 100644
--- a/comicapi/comet.py
+++ b/comicapi/comet.py
@@ -166,7 +166,2 @@ class CoMet:
- if credit['role'].lower() in set(self.editor_synonyms):
- ET.SubElement(
- root,
- 'editor').text = "{0}".format(
- credit['person'])
@@ -174,2 +169,4 @@ class CoMet:
self.indent(root)
+ if credit["role"].lower() in set(self.editor_synonyms):
+ ET.SubElement(root, "editor").text = str(credit["person"])
diff --git a/comictaggerlib/autotagmatchwindow.py b/comictaggerlib/autotagmatchwindow.py
index 4338176..9219f01 100644
--- a/comictaggerlib/autotagmatchwindow.py
+++ b/comictaggerlib/autotagmatchwindow.py
@@ -63,4 +63,3 @@ class AutoTagMatchWindow(QtWidgets.QDialog):
self.skipButton, QtWidgets.QDialogButtonBox.ActionRole)
- self.buttonBox.button(QtWidgets.QDialogButtonBox.Ok).setText(
- "Accept and Write Tags")
+ self.buttonBox.button(QtWidgets.QDialogButtonBox.StandardButton.Ok).setText("Accept and Write Tags")
diff --git a/comictaggerlib/cli.py b/comictaggerlib/cli.py
index 688907d..dbd0c2e 100644
--- a/comictaggerlib/cli.py
+++ b/comictaggerlib/cli.py
@@ -293,7 +293,3 @@ def process_file_cli(filename, opts, settings, match_results):
if opts.raw:
- print((
- "{0}".format(
- str(
- ca.readRawCIX(),
- errors='ignore'))))
+ print(ca.read_raw_cix())
else:
2022-04-01 16:50:46 -07:00
|
|
|
match_results.multiple_matches.append(MultipleMatch(ca, matches))
|
|
|
|
return
|
2023-09-05 00:55:12 -07:00
|
|
|
if low_confidence and self.config.Runtime_Options_abort_on_low_confidence:
|
2022-04-04 18:59:26 -07:00
|
|
|
logger.error("Online search: Low confidence match. Save aborted")
|
Code cleanup
Remove no longer used google scripts
Remove convenience files from comicataggerlib and import comicapi directly
Add type-hints to facilitate auto-complete tools
Make PyQt5 code more compatible with PyQt6
Implement automatic tooling
isort and black for code formatting
Line length has been set to 120
flake8 for code standards with exceptions:
E203 - Whitespace before ':' - format compatiblity with black
E501 - Line too long - flake8 line limit cannot be set
E722 - Do not use bare except - fixing bare except statements is a
lot of overhead and there are already
many in the codebase
These changes, along with some manual fixes creates much more readable code.
See examples below:
diff --git a/comicapi/comet.py b/comicapi/comet.py
index d1741c5..52dc195 100644
--- a/comicapi/comet.py
+++ b/comicapi/comet.py
@@ -166,7 +166,2 @@ class CoMet:
- if credit['role'].lower() in set(self.editor_synonyms):
- ET.SubElement(
- root,
- 'editor').text = "{0}".format(
- credit['person'])
@@ -174,2 +169,4 @@ class CoMet:
self.indent(root)
+ if credit["role"].lower() in set(self.editor_synonyms):
+ ET.SubElement(root, "editor").text = str(credit["person"])
diff --git a/comictaggerlib/autotagmatchwindow.py b/comictaggerlib/autotagmatchwindow.py
index 4338176..9219f01 100644
--- a/comictaggerlib/autotagmatchwindow.py
+++ b/comictaggerlib/autotagmatchwindow.py
@@ -63,4 +63,3 @@ class AutoTagMatchWindow(QtWidgets.QDialog):
self.skipButton, QtWidgets.QDialogButtonBox.ActionRole)
- self.buttonBox.button(QtWidgets.QDialogButtonBox.Ok).setText(
- "Accept and Write Tags")
+ self.buttonBox.button(QtWidgets.QDialogButtonBox.StandardButton.Ok).setText("Accept and Write Tags")
diff --git a/comictaggerlib/cli.py b/comictaggerlib/cli.py
index 688907d..dbd0c2e 100644
--- a/comictaggerlib/cli.py
+++ b/comictaggerlib/cli.py
@@ -293,7 +293,3 @@ def process_file_cli(filename, opts, settings, match_results):
if opts.raw:
- print((
- "{0}".format(
- str(
- ca.readRawCIX(),
- errors='ignore'))))
+ print(ca.read_raw_cix())
else:
2022-04-01 16:50:46 -07:00
|
|
|
match_results.low_confidence_matches.append(MultipleMatch(ca, matches))
|
2015-02-12 14:57:46 -08:00
|
|
|
return
|
|
|
|
if not found_match:
|
2022-04-04 18:59:26 -07:00
|
|
|
logger.error("Online search: No match found. Save aborted")
|
2022-05-17 13:57:04 -07:00
|
|
|
match_results.no_matches.append(str(ca.path.absolute()))
|
2015-02-12 14:57:46 -08:00
|
|
|
return
|
|
|
|
|
|
|
|
# we got here, so we have a single match
|
|
|
|
|
|
|
|
# now get the particular issue data
|
2022-11-26 16:47:18 -08:00
|
|
|
ct_md = self.actual_issue_data_fetch(matches[0]["issue_id"])
|
2022-06-28 07:21:35 -07:00
|
|
|
if ct_md.is_empty:
|
2022-05-17 13:57:04 -07:00
|
|
|
match_results.fetch_data_failures.append(str(ca.path.absolute()))
|
2015-02-12 14:57:46 -08:00
|
|
|
return
|
|
|
|
|
2023-09-05 00:55:12 -07:00
|
|
|
if self.config.Issue_Identifier_clear_metadata_on_import:
|
2023-05-30 21:33:59 -07:00
|
|
|
md = GenericMetadata()
|
|
|
|
|
|
|
|
notes = (
|
2023-06-01 14:05:14 -07:00
|
|
|
f"Tagged with ComicTagger {ctversion.version} using info from {self.current_talker().name} on"
|
2023-05-30 21:33:59 -07:00
|
|
|
f" {datetime.now():%Y-%m-%d %H:%M:%S}. [Issue ID {ct_md.issue_id}]"
|
|
|
|
)
|
Convert ComicIssue into GenericMetadata
I could not find a good reason for ComicIssue to exist other than that
it had more attributes than GenericMetadata, so it has been replaced.
New attributes for GenericMetadata:
series_id: a string uniquely identifying the series to tag_origin
series_aliases: alternate series names that are not the canonical name
title_aliases: alternate issue titles that are not the canonical name
alternate_images: a list of urls to alternate cover images
Updated attributes for GenericMetadata:
genre -> genres: str -> list[str]
comments -> description: str -> str
story_arc -> story_arcs: str -> list[str]
series_group -> series_groups: str -> list[str]
character -> characters: str -> list[str]
team -> teams: str -> list[str]
location -> locations: str -> list[str]
tag_origin -> tag_origin: str -> TagOrigin (tuple[str, str])
ComicSeries has been relocated to the ComicAPI package, currently has no
usage within ComicAPI.
CreditMetadata has been renamed to Credit and has replaced Credit from
ComicTalker.
fetch_series has been added to ComicTalker, this is currently only used
in the GUI when a series is selected and does not already contain the
needed fields, this function should always be cached.
A new split function has been added to ComicAPI, all uses of split on
single characters have been updated to use this
cleanup_html and the corresponding setting are now only used in
ComicTagger proper, for display we want any html directly from the
upstream. When applying the metadata we then strip the description of
any html.
A new conversion has been added to the MetadataFormatter:
j: joins any lists into a string with ', '. Note this is a valid
operation on strings as well, it will add ', ' in between every
character.
parse_settings now assigns the given ComicTaggerPaths object to the
result ensuring that the correct path is always used.
2023-08-02 09:00:04 -07:00
|
|
|
md.overlay(
|
|
|
|
ct_md.replace(
|
|
|
|
notes=utils.combine_notes(md.notes, notes, "Tagged with ComicTagger"),
|
2023-09-05 00:55:12 -07:00
|
|
|
description=cleanup_html(ct_md.description, self.config.Sources_remove_html_tables),
|
Convert ComicIssue into GenericMetadata
I could not find a good reason for ComicIssue to exist other than that
it had more attributes than GenericMetadata, so it has been replaced.
New attributes for GenericMetadata:
series_id: a string uniquely identifying the series to tag_origin
series_aliases: alternate series names that are not the canonical name
title_aliases: alternate issue titles that are not the canonical name
alternate_images: a list of urls to alternate cover images
Updated attributes for GenericMetadata:
genre -> genres: str -> list[str]
comments -> description: str -> str
story_arc -> story_arcs: str -> list[str]
series_group -> series_groups: str -> list[str]
character -> characters: str -> list[str]
team -> teams: str -> list[str]
location -> locations: str -> list[str]
tag_origin -> tag_origin: str -> TagOrigin (tuple[str, str])
ComicSeries has been relocated to the ComicAPI package, currently has no
usage within ComicAPI.
CreditMetadata has been renamed to Credit and has replaced Credit from
ComicTalker.
fetch_series has been added to ComicTalker, this is currently only used
in the GUI when a series is selected and does not already contain the
needed fields, this function should always be cached.
A new split function has been added to ComicAPI, all uses of split on
single characters have been updated to use this
cleanup_html and the corresponding setting are now only used in
ComicTagger proper, for display we want any html directly from the
upstream. When applying the metadata we then strip the description of
any html.
A new conversion has been added to the MetadataFormatter:
j: joins any lists into a string with ', '. Note this is a valid
operation on strings as well, it will add ', ' in between every
character.
parse_settings now assigns the given ComicTaggerPaths object to the
result ensuring that the correct path is always used.
2023-08-02 09:00:04 -07:00
|
|
|
)
|
|
|
|
)
|
2015-02-12 14:57:46 -08:00
|
|
|
|
2023-09-05 00:55:12 -07:00
|
|
|
if self.config.Issue_Identifier_auto_imprint:
|
2022-05-19 13:28:18 -07:00
|
|
|
md.fix_publisher()
|
2021-08-07 21:50:45 -07:00
|
|
|
|
2015-02-12 14:57:46 -08:00
|
|
|
# ok, done building our metadata. time to save
|
2022-11-26 16:47:18 -08:00
|
|
|
if not self.actual_metadata_save(ca, md):
|
2022-05-17 13:57:04 -07:00
|
|
|
match_results.write_failures.append(str(ca.path.absolute()))
|
2015-02-12 14:57:46 -08:00
|
|
|
else:
|
2022-05-17 13:57:04 -07:00
|
|
|
match_results.good_matches.append(str(ca.path.absolute()))
|
2015-02-12 14:57:46 -08:00
|
|
|
|
2022-11-26 16:47:18 -08:00
|
|
|
def rename(self, ca: ComicArchive) -> None:
|
2022-08-19 20:20:37 -07:00
|
|
|
original_path = ca.path
|
2015-02-12 14:57:46 -08:00
|
|
|
msg_hdr = ""
|
2022-11-26 16:47:18 -08:00
|
|
|
if self.batch_mode:
|
Code cleanup
Remove no longer used google scripts
Remove convenience files from comicataggerlib and import comicapi directly
Add type-hints to facilitate auto-complete tools
Make PyQt5 code more compatible with PyQt6
Implement automatic tooling
isort and black for code formatting
Line length has been set to 120
flake8 for code standards with exceptions:
E203 - Whitespace before ':' - format compatiblity with black
E501 - Line too long - flake8 line limit cannot be set
E722 - Do not use bare except - fixing bare except statements is a
lot of overhead and there are already
many in the codebase
These changes, along with some manual fixes creates much more readable code.
See examples below:
diff --git a/comicapi/comet.py b/comicapi/comet.py
index d1741c5..52dc195 100644
--- a/comicapi/comet.py
+++ b/comicapi/comet.py
@@ -166,7 +166,2 @@ class CoMet:
- if credit['role'].lower() in set(self.editor_synonyms):
- ET.SubElement(
- root,
- 'editor').text = "{0}".format(
- credit['person'])
@@ -174,2 +169,4 @@ class CoMet:
self.indent(root)
+ if credit["role"].lower() in set(self.editor_synonyms):
+ ET.SubElement(root, "editor").text = str(credit["person"])
diff --git a/comictaggerlib/autotagmatchwindow.py b/comictaggerlib/autotagmatchwindow.py
index 4338176..9219f01 100644
--- a/comictaggerlib/autotagmatchwindow.py
+++ b/comictaggerlib/autotagmatchwindow.py
@@ -63,4 +63,3 @@ class AutoTagMatchWindow(QtWidgets.QDialog):
self.skipButton, QtWidgets.QDialogButtonBox.ActionRole)
- self.buttonBox.button(QtWidgets.QDialogButtonBox.Ok).setText(
- "Accept and Write Tags")
+ self.buttonBox.button(QtWidgets.QDialogButtonBox.StandardButton.Ok).setText("Accept and Write Tags")
diff --git a/comictaggerlib/cli.py b/comictaggerlib/cli.py
index 688907d..dbd0c2e 100644
--- a/comictaggerlib/cli.py
+++ b/comictaggerlib/cli.py
@@ -293,7 +293,3 @@ def process_file_cli(filename, opts, settings, match_results):
if opts.raw:
- print((
- "{0}".format(
- str(
- ca.readRawCIX(),
- errors='ignore'))))
+ print(ca.read_raw_cix())
else:
2022-04-01 16:50:46 -07:00
|
|
|
msg_hdr = f"{ca.path}: "
|
2015-02-12 14:57:46 -08:00
|
|
|
|
2022-11-26 16:47:18 -08:00
|
|
|
md = self.create_local_metadata(ca)
|
2015-02-12 14:57:46 -08:00
|
|
|
|
|
|
|
if md.series is None:
|
2022-04-04 18:59:26 -07:00
|
|
|
logger.error(msg_hdr + "Can't rename without series name")
|
2015-02-12 14:57:46 -08:00
|
|
|
return
|
|
|
|
|
2022-05-17 13:57:04 -07:00
|
|
|
new_ext = "" # default
|
2023-09-05 00:55:12 -07:00
|
|
|
if self.config.File_Rename_set_extension_based_on_archive:
|
2022-08-17 15:53:19 -07:00
|
|
|
new_ext = ca.extension()
|
2015-02-12 14:57:46 -08:00
|
|
|
|
2022-11-23 22:16:46 -08:00
|
|
|
renamer = FileRenamer(
|
|
|
|
md,
|
2023-09-05 00:55:12 -07:00
|
|
|
platform="universal" if self.config.File_Rename_strict else "auto",
|
|
|
|
replacements=self.config.File_Rename_replacements,
|
2022-11-23 22:16:46 -08:00
|
|
|
)
|
2023-09-05 00:55:12 -07:00
|
|
|
renamer.set_template(self.config.File_Rename_template)
|
|
|
|
renamer.set_issue_zero_padding(self.config.File_Rename_issue_number_padding)
|
|
|
|
renamer.set_smart_cleanup(self.config.File_Rename_use_smart_string_cleanup)
|
|
|
|
renamer.move = self.config.File_Rename_move_to_dir
|
2022-04-18 18:44:20 -07:00
|
|
|
|
|
|
|
try:
|
2022-04-18 18:59:17 -07:00
|
|
|
new_name = renamer.determine_name(ext=new_ext)
|
2022-07-27 23:24:34 -07:00
|
|
|
except ValueError:
|
2022-04-20 13:13:03 -07:00
|
|
|
logger.exception(
|
|
|
|
msg_hdr + "Invalid format string!\n"
|
|
|
|
"Your rename template is invalid!\n\n"
|
2022-07-27 23:24:34 -07:00
|
|
|
"%s\n\n"
|
2022-04-20 13:13:03 -07:00
|
|
|
"Please consult the template help in the settings "
|
2022-04-18 18:44:20 -07:00
|
|
|
"and the documentation on the format at "
|
2022-07-27 23:24:34 -07:00
|
|
|
"https://docs.python.org/3/library/string.html#format-string-syntax",
|
2023-09-05 00:55:12 -07:00
|
|
|
self.config.File_Rename_template,
|
2022-04-18 18:44:20 -07:00
|
|
|
)
|
2015-02-12 14:57:46 -08:00
|
|
|
return
|
2022-07-27 23:24:34 -07:00
|
|
|
except Exception:
|
2023-09-05 00:55:12 -07:00
|
|
|
logger.exception("Formatter failure: %s metadata: %s", self.config.File_Rename_template, renamer.metadata)
|
2023-06-09 16:20:00 -07:00
|
|
|
return
|
2015-02-12 14:57:46 -08:00
|
|
|
|
2023-09-05 00:55:12 -07:00
|
|
|
folder = get_rename_dir(ca, self.config.File_Rename_dir if self.config.File_Rename_move_to_dir else None)
|
2022-04-18 18:44:20 -07:00
|
|
|
|
2022-07-09 22:27:45 -07:00
|
|
|
full_path = folder / new_name
|
2015-02-12 14:57:46 -08:00
|
|
|
|
2022-07-09 22:27:45 -07:00
|
|
|
if full_path == ca.path:
|
2022-04-18 18:44:20 -07:00
|
|
|
print(msg_hdr + "Filename is already good!", file=sys.stderr)
|
|
|
|
return
|
|
|
|
|
2015-02-12 14:57:46 -08:00
|
|
|
suffix = ""
|
2023-09-05 00:55:12 -07:00
|
|
|
if not self.config.Runtime_Options_dryrun:
|
2015-02-12 14:57:46 -08:00
|
|
|
# rename the file
|
2022-09-17 01:28:26 -07:00
|
|
|
try:
|
|
|
|
ca.rename(utils.unique_file(full_path))
|
|
|
|
except OSError:
|
|
|
|
logger.exception("Failed to rename comic archive: %s", ca.path)
|
2015-02-12 14:57:46 -08:00
|
|
|
else:
|
|
|
|
suffix = " (dry-run, no change)"
|
|
|
|
|
2022-08-19 20:20:37 -07:00
|
|
|
print(f"renamed '{original_path.name}' -> '{new_name}' {suffix}")
|
2015-02-12 14:57:46 -08:00
|
|
|
|
2022-11-26 16:47:18 -08:00
|
|
|
def export(self, ca: ComicArchive) -> None:
|
2015-02-12 14:57:46 -08:00
|
|
|
msg_hdr = ""
|
2022-11-26 16:47:18 -08:00
|
|
|
if self.batch_mode:
|
Code cleanup
Remove no longer used google scripts
Remove convenience files from comicataggerlib and import comicapi directly
Add type-hints to facilitate auto-complete tools
Make PyQt5 code more compatible with PyQt6
Implement automatic tooling
isort and black for code formatting
Line length has been set to 120
flake8 for code standards with exceptions:
E203 - Whitespace before ':' - format compatiblity with black
E501 - Line too long - flake8 line limit cannot be set
E722 - Do not use bare except - fixing bare except statements is a
lot of overhead and there are already
many in the codebase
These changes, along with some manual fixes creates much more readable code.
See examples below:
diff --git a/comicapi/comet.py b/comicapi/comet.py
index d1741c5..52dc195 100644
--- a/comicapi/comet.py
+++ b/comicapi/comet.py
@@ -166,7 +166,2 @@ class CoMet:
- if credit['role'].lower() in set(self.editor_synonyms):
- ET.SubElement(
- root,
- 'editor').text = "{0}".format(
- credit['person'])
@@ -174,2 +169,4 @@ class CoMet:
self.indent(root)
+ if credit["role"].lower() in set(self.editor_synonyms):
+ ET.SubElement(root, "editor").text = str(credit["person"])
diff --git a/comictaggerlib/autotagmatchwindow.py b/comictaggerlib/autotagmatchwindow.py
index 4338176..9219f01 100644
--- a/comictaggerlib/autotagmatchwindow.py
+++ b/comictaggerlib/autotagmatchwindow.py
@@ -63,4 +63,3 @@ class AutoTagMatchWindow(QtWidgets.QDialog):
self.skipButton, QtWidgets.QDialogButtonBox.ActionRole)
- self.buttonBox.button(QtWidgets.QDialogButtonBox.Ok).setText(
- "Accept and Write Tags")
+ self.buttonBox.button(QtWidgets.QDialogButtonBox.StandardButton.Ok).setText("Accept and Write Tags")
diff --git a/comictaggerlib/cli.py b/comictaggerlib/cli.py
index 688907d..dbd0c2e 100644
--- a/comictaggerlib/cli.py
+++ b/comictaggerlib/cli.py
@@ -293,7 +293,3 @@ def process_file_cli(filename, opts, settings, match_results):
if opts.raw:
- print((
- "{0}".format(
- str(
- ca.readRawCIX(),
- errors='ignore'))))
+ print(ca.read_raw_cix())
else:
2022-04-01 16:50:46 -07:00
|
|
|
msg_hdr = f"{ca.path}: "
|
2015-02-12 14:57:46 -08:00
|
|
|
|
2022-07-09 22:27:45 -07:00
|
|
|
if ca.is_zip():
|
|
|
|
logger.error(msg_hdr + "Archive is already a zip file.")
|
2015-02-12 14:57:46 -08:00
|
|
|
return
|
|
|
|
|
2022-11-26 16:47:18 -08:00
|
|
|
filename_path = ca.path
|
2022-07-09 22:27:45 -07:00
|
|
|
new_file = filename_path.with_suffix(".cbz")
|
2015-02-12 14:57:46 -08:00
|
|
|
|
2023-09-05 00:55:12 -07:00
|
|
|
if self.config.Runtime_Options_abort_on_conflict and new_file.exists():
|
2022-07-09 22:27:45 -07:00
|
|
|
print(msg_hdr + f"{new_file.name} already exists in the that folder.")
|
2015-02-12 14:57:46 -08:00
|
|
|
return
|
|
|
|
|
2022-07-09 22:27:45 -07:00
|
|
|
new_file = utils.unique_file(new_file)
|
2015-02-12 14:57:46 -08:00
|
|
|
|
|
|
|
delete_success = False
|
|
|
|
export_success = False
|
2023-09-05 00:55:12 -07:00
|
|
|
if not self.config.Runtime_Options_dryrun:
|
Code cleanup
Remove no longer used google scripts
Remove convenience files from comicataggerlib and import comicapi directly
Add type-hints to facilitate auto-complete tools
Make PyQt5 code more compatible with PyQt6
Implement automatic tooling
isort and black for code formatting
Line length has been set to 120
flake8 for code standards with exceptions:
E203 - Whitespace before ':' - format compatiblity with black
E501 - Line too long - flake8 line limit cannot be set
E722 - Do not use bare except - fixing bare except statements is a
lot of overhead and there are already
many in the codebase
These changes, along with some manual fixes creates much more readable code.
See examples below:
diff --git a/comicapi/comet.py b/comicapi/comet.py
index d1741c5..52dc195 100644
--- a/comicapi/comet.py
+++ b/comicapi/comet.py
@@ -166,7 +166,2 @@ class CoMet:
- if credit['role'].lower() in set(self.editor_synonyms):
- ET.SubElement(
- root,
- 'editor').text = "{0}".format(
- credit['person'])
@@ -174,2 +169,4 @@ class CoMet:
self.indent(root)
+ if credit["role"].lower() in set(self.editor_synonyms):
+ ET.SubElement(root, "editor").text = str(credit["person"])
diff --git a/comictaggerlib/autotagmatchwindow.py b/comictaggerlib/autotagmatchwindow.py
index 4338176..9219f01 100644
--- a/comictaggerlib/autotagmatchwindow.py
+++ b/comictaggerlib/autotagmatchwindow.py
@@ -63,4 +63,3 @@ class AutoTagMatchWindow(QtWidgets.QDialog):
self.skipButton, QtWidgets.QDialogButtonBox.ActionRole)
- self.buttonBox.button(QtWidgets.QDialogButtonBox.Ok).setText(
- "Accept and Write Tags")
+ self.buttonBox.button(QtWidgets.QDialogButtonBox.StandardButton.Ok).setText("Accept and Write Tags")
diff --git a/comictaggerlib/cli.py b/comictaggerlib/cli.py
index 688907d..dbd0c2e 100644
--- a/comictaggerlib/cli.py
+++ b/comictaggerlib/cli.py
@@ -293,7 +293,3 @@ def process_file_cli(filename, opts, settings, match_results):
if opts.raw:
- print((
- "{0}".format(
- str(
- ca.readRawCIX(),
- errors='ignore'))))
+ print(ca.read_raw_cix())
else:
2022-04-01 16:50:46 -07:00
|
|
|
if ca.export_as_zip(new_file):
|
2015-02-12 14:57:46 -08:00
|
|
|
export_success = True
|
2023-09-05 00:55:12 -07:00
|
|
|
if self.config.Runtime_Options_delete_after_zip_export:
|
2015-02-12 14:57:46 -08:00
|
|
|
try:
|
2022-07-09 22:27:45 -07:00
|
|
|
filename_path.unlink(missing_ok=True)
|
|
|
|
delete_success = True
|
2022-06-02 18:32:16 -07:00
|
|
|
except OSError:
|
2022-07-09 22:27:45 -07:00
|
|
|
logger.exception(msg_hdr + "Error deleting original archive after export")
|
2015-02-12 14:57:46 -08:00
|
|
|
delete_success = False
|
|
|
|
else:
|
|
|
|
# last export failed, so remove the zip, if it exists
|
2022-07-09 22:27:45 -07:00
|
|
|
new_file.unlink(missing_ok=True)
|
2015-02-12 14:57:46 -08:00
|
|
|
else:
|
Code cleanup
Remove no longer used google scripts
Remove convenience files from comicataggerlib and import comicapi directly
Add type-hints to facilitate auto-complete tools
Make PyQt5 code more compatible with PyQt6
Implement automatic tooling
isort and black for code formatting
Line length has been set to 120
flake8 for code standards with exceptions:
E203 - Whitespace before ':' - format compatiblity with black
E501 - Line too long - flake8 line limit cannot be set
E722 - Do not use bare except - fixing bare except statements is a
lot of overhead and there are already
many in the codebase
These changes, along with some manual fixes creates much more readable code.
See examples below:
diff --git a/comicapi/comet.py b/comicapi/comet.py
index d1741c5..52dc195 100644
--- a/comicapi/comet.py
+++ b/comicapi/comet.py
@@ -166,7 +166,2 @@ class CoMet:
- if credit['role'].lower() in set(self.editor_synonyms):
- ET.SubElement(
- root,
- 'editor').text = "{0}".format(
- credit['person'])
@@ -174,2 +169,4 @@ class CoMet:
self.indent(root)
+ if credit["role"].lower() in set(self.editor_synonyms):
+ ET.SubElement(root, "editor").text = str(credit["person"])
diff --git a/comictaggerlib/autotagmatchwindow.py b/comictaggerlib/autotagmatchwindow.py
index 4338176..9219f01 100644
--- a/comictaggerlib/autotagmatchwindow.py
+++ b/comictaggerlib/autotagmatchwindow.py
@@ -63,4 +63,3 @@ class AutoTagMatchWindow(QtWidgets.QDialog):
self.skipButton, QtWidgets.QDialogButtonBox.ActionRole)
- self.buttonBox.button(QtWidgets.QDialogButtonBox.Ok).setText(
- "Accept and Write Tags")
+ self.buttonBox.button(QtWidgets.QDialogButtonBox.StandardButton.Ok).setText("Accept and Write Tags")
diff --git a/comictaggerlib/cli.py b/comictaggerlib/cli.py
index 688907d..dbd0c2e 100644
--- a/comictaggerlib/cli.py
+++ b/comictaggerlib/cli.py
@@ -293,7 +293,3 @@ def process_file_cli(filename, opts, settings, match_results):
if opts.raw:
- print((
- "{0}".format(
- str(
- ca.readRawCIX(),
- errors='ignore'))))
+ print(ca.read_raw_cix())
else:
2022-04-01 16:50:46 -07:00
|
|
|
msg = msg_hdr + f"Dry-run: Would try to create {os.path.split(new_file)[1]}"
|
2023-09-05 00:55:12 -07:00
|
|
|
if self.config.Runtime_Options_delete_after_zip_export:
|
2022-06-07 20:22:33 -07:00
|
|
|
msg += " and delete original."
|
2015-02-13 15:08:07 -08:00
|
|
|
print(msg)
|
2015-02-12 14:57:46 -08:00
|
|
|
return
|
|
|
|
|
|
|
|
msg = msg_hdr
|
|
|
|
if export_success:
|
Code cleanup
Remove no longer used google scripts
Remove convenience files from comicataggerlib and import comicapi directly
Add type-hints to facilitate auto-complete tools
Make PyQt5 code more compatible with PyQt6
Implement automatic tooling
isort and black for code formatting
Line length has been set to 120
flake8 for code standards with exceptions:
E203 - Whitespace before ':' - format compatiblity with black
E501 - Line too long - flake8 line limit cannot be set
E722 - Do not use bare except - fixing bare except statements is a
lot of overhead and there are already
many in the codebase
These changes, along with some manual fixes creates much more readable code.
See examples below:
diff --git a/comicapi/comet.py b/comicapi/comet.py
index d1741c5..52dc195 100644
--- a/comicapi/comet.py
+++ b/comicapi/comet.py
@@ -166,7 +166,2 @@ class CoMet:
- if credit['role'].lower() in set(self.editor_synonyms):
- ET.SubElement(
- root,
- 'editor').text = "{0}".format(
- credit['person'])
@@ -174,2 +169,4 @@ class CoMet:
self.indent(root)
+ if credit["role"].lower() in set(self.editor_synonyms):
+ ET.SubElement(root, "editor").text = str(credit["person"])
diff --git a/comictaggerlib/autotagmatchwindow.py b/comictaggerlib/autotagmatchwindow.py
index 4338176..9219f01 100644
--- a/comictaggerlib/autotagmatchwindow.py
+++ b/comictaggerlib/autotagmatchwindow.py
@@ -63,4 +63,3 @@ class AutoTagMatchWindow(QtWidgets.QDialog):
self.skipButton, QtWidgets.QDialogButtonBox.ActionRole)
- self.buttonBox.button(QtWidgets.QDialogButtonBox.Ok).setText(
- "Accept and Write Tags")
+ self.buttonBox.button(QtWidgets.QDialogButtonBox.StandardButton.Ok).setText("Accept and Write Tags")
diff --git a/comictaggerlib/cli.py b/comictaggerlib/cli.py
index 688907d..dbd0c2e 100644
--- a/comictaggerlib/cli.py
+++ b/comictaggerlib/cli.py
@@ -293,7 +293,3 @@ def process_file_cli(filename, opts, settings, match_results):
if opts.raw:
- print((
- "{0}".format(
- str(
- ca.readRawCIX(),
- errors='ignore'))))
+ print(ca.read_raw_cix())
else:
2022-04-01 16:50:46 -07:00
|
|
|
msg += f"Archive exported successfully to: {os.path.split(new_file)[1]}"
|
2023-09-05 00:55:12 -07:00
|
|
|
if self.config.Runtime_Options_delete_after_zip_export and delete_success:
|
2018-09-19 13:05:39 -07:00
|
|
|
msg += " (Original deleted) "
|
2015-02-12 14:57:46 -08:00
|
|
|
else:
|
2018-09-19 13:05:39 -07:00
|
|
|
msg += "Archive failed to export!"
|
2015-02-12 14:57:46 -08:00
|
|
|
|
2015-02-13 15:08:07 -08:00
|
|
|
print(msg)
|
2022-11-26 16:47:18 -08:00
|
|
|
|
|
|
|
def process_file_cli(self, filename: str, match_results: OnlineMatchResults) -> None:
|
|
|
|
if not os.path.lexists(filename):
|
|
|
|
logger.error("Cannot find %s", filename)
|
|
|
|
return
|
|
|
|
|
2023-01-31 00:01:50 -08:00
|
|
|
ca = ComicArchive(filename, str(graphics_path / "nocover.png"))
|
2022-11-26 16:47:18 -08:00
|
|
|
|
|
|
|
if not ca.seems_to_be_a_comic_archive():
|
|
|
|
logger.error("Sorry, but %s is not a comic archive!", filename)
|
|
|
|
return
|
|
|
|
|
|
|
|
if not ca.is_writable() and (
|
2023-09-05 00:55:12 -07:00
|
|
|
self.config.Commands_delete
|
|
|
|
or self.config.Commands_copy
|
|
|
|
or self.config.Commands_save
|
|
|
|
or self.config.Commands_rename
|
2022-11-26 16:47:18 -08:00
|
|
|
):
|
|
|
|
logger.error("This archive is not writable")
|
|
|
|
return
|
|
|
|
|
2023-09-05 00:55:12 -07:00
|
|
|
if self.config.Commands_print:
|
2022-11-26 16:47:18 -08:00
|
|
|
self.print(ca)
|
|
|
|
|
2023-09-05 00:55:12 -07:00
|
|
|
elif self.config.Commands_delete:
|
2022-11-26 16:47:18 -08:00
|
|
|
self.delete(ca)
|
|
|
|
|
2023-09-05 00:55:12 -07:00
|
|
|
elif self.config.Commands_copy is not None:
|
2022-11-26 16:47:18 -08:00
|
|
|
self.copy(ca)
|
|
|
|
|
2023-09-05 00:55:12 -07:00
|
|
|
elif self.config.Commands_save:
|
2022-11-26 16:47:18 -08:00
|
|
|
self.save(ca, match_results)
|
|
|
|
|
2023-09-05 00:55:12 -07:00
|
|
|
elif self.config.Commands_rename:
|
2022-11-26 16:47:18 -08:00
|
|
|
self.rename(ca)
|
|
|
|
|
2023-09-05 00:55:12 -07:00
|
|
|
elif self.config.Commands_export_to_zip:
|
2022-11-26 16:47:18 -08:00
|
|
|
self.export(ca)
|