2015-02-21 18:30:32 -08:00
|
|
|
"""A python app to (automatically) tag comic archives"""
|
2022-06-02 18:32:16 -07:00
|
|
|
#
|
2015-02-21 18:30:32 -08:00
|
|
|
# Copyright 2012-2014 Anthony Beville
|
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
|
2013-02-06 17:20:05 -08:00
|
|
|
|
2022-05-19 13:28:18 -07:00
|
|
|
import json
|
2022-04-04 18:59:26 -07:00
|
|
|
import logging.handlers
|
2018-01-14 07:41:27 -08:00
|
|
|
import os
|
2022-04-04 18:59:26 -07:00
|
|
|
import pathlib
|
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 platform
|
2013-02-06 17:20:05 -08:00
|
|
|
import signal
|
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
|
2013-02-06 17:20:05 -08:00
|
|
|
import traceback
|
2022-05-17 13:57:04 -07:00
|
|
|
import types
|
2018-01-14 07:41:27 -08:00
|
|
|
|
2022-10-27 15:36:57 -07:00
|
|
|
import comictalker.comictalkerapi as ct_api
|
2022-05-19 13:28:18 -07:00
|
|
|
from comicapi import utils
|
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 import cli
|
2022-04-04 18:59:26 -07:00
|
|
|
from comictaggerlib.ctversion import version
|
2022-10-25 21:48:01 -07:00
|
|
|
from comictaggerlib.graphics import graphics_path
|
2022-06-02 18:28:54 -07:00
|
|
|
from comictaggerlib.options import parse_cmd_line
|
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.settings import ComicTaggerSettings
|
2013-02-06 17:20:05 -08:00
|
|
|
|
2022-06-23 13:05:27 -07:00
|
|
|
if sys.version_info < (3, 10):
|
|
|
|
import importlib_metadata
|
|
|
|
else:
|
|
|
|
import importlib.metadata as importlib_metadata
|
|
|
|
|
2022-04-04 18:59:26 -07:00
|
|
|
logger = logging.getLogger("comictagger")
|
|
|
|
logging.getLogger("comicapi").setLevel(logging.DEBUG)
|
2022-06-06 19:33:02 -07:00
|
|
|
logging.getLogger("comictaggerlib").setLevel(logging.DEBUG)
|
2022-06-28 07:21:35 -07:00
|
|
|
logging.getLogger("sourcesapi").setLevel(logging.DEBUG)
|
2022-04-04 18:59:26 -07:00
|
|
|
logger.setLevel(logging.DEBUG)
|
|
|
|
|
2013-02-06 17:20:05 -08:00
|
|
|
try:
|
2015-02-12 14:57:46 -08:00
|
|
|
qt_available = True
|
2022-04-11 14:52:41 -07:00
|
|
|
from PyQt5 import QtCore, QtGui, QtWidgets
|
|
|
|
|
2022-05-17 13:57:04 -07:00
|
|
|
def show_exception_box(log_msg: str) -> None:
|
2022-04-11 14:52:41 -07:00
|
|
|
"""Checks if a QApplication instance is available and shows a messagebox with the exception message.
|
|
|
|
If unavailable (non-console application), log an additional notice.
|
|
|
|
"""
|
|
|
|
if QtWidgets.QApplication.instance() is not None:
|
|
|
|
errorbox = QtWidgets.QMessageBox()
|
2022-06-07 20:22:33 -07:00
|
|
|
errorbox.setText(f"Oops. An unexpected error occurred:\n{log_msg}")
|
2022-04-20 13:13:03 -07:00
|
|
|
errorbox.exec()
|
2022-04-11 14:52:41 -07:00
|
|
|
QtWidgets.QApplication.exit(1)
|
|
|
|
else:
|
|
|
|
logger.debug("No QApplication instance available.")
|
|
|
|
|
|
|
|
class UncaughtHook(QtCore.QObject):
|
|
|
|
_exception_caught = QtCore.pyqtSignal(object)
|
|
|
|
|
2022-05-17 13:57:04 -07:00
|
|
|
def __init__(self) -> None:
|
|
|
|
super().__init__()
|
2022-04-11 14:52:41 -07:00
|
|
|
|
|
|
|
# this registers the exception_hook() function as hook with the Python interpreter
|
|
|
|
sys.excepthook = self.exception_hook
|
|
|
|
|
|
|
|
# connect signal to execute the message box function always on main thread
|
|
|
|
self._exception_caught.connect(show_exception_box)
|
|
|
|
|
2022-05-17 13:57:04 -07:00
|
|
|
def exception_hook(
|
2022-06-02 18:32:16 -07:00
|
|
|
self, exc_type: type[BaseException], exc_value: BaseException, exc_traceback: types.TracebackType | None
|
2022-05-17 13:57:04 -07:00
|
|
|
) -> None:
|
2022-04-11 14:52:41 -07:00
|
|
|
"""Function handling uncaught exceptions.
|
|
|
|
It is triggered each time an uncaught exception occurs.
|
|
|
|
"""
|
|
|
|
if issubclass(exc_type, KeyboardInterrupt):
|
|
|
|
# ignore keyboard interrupt to support console applications
|
|
|
|
sys.__excepthook__(exc_type, exc_value, exc_traceback)
|
|
|
|
else:
|
|
|
|
exc_info = (exc_type, exc_value, exc_traceback)
|
2022-04-20 13:13:03 -07:00
|
|
|
log_msg = "\n".join(["".join(traceback.format_tb(exc_traceback)), f"{exc_type.__name__}: {exc_value}"])
|
|
|
|
logger.critical("Uncaught exception: %s: %s", exc_type.__name__, exc_value, exc_info=exc_info)
|
2022-04-11 14:52:41 -07:00
|
|
|
|
|
|
|
# trigger message box show
|
|
|
|
self._exception_caught.emit(log_msg)
|
|
|
|
|
|
|
|
qt_exception_hook = UncaughtHook()
|
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.taggerwindow import TaggerWindow
|
2022-10-25 21:48:01 -07:00
|
|
|
|
|
|
|
class Application(QtWidgets.QApplication):
|
|
|
|
openFileRequest = QtCore.pyqtSignal(QtCore.QUrl, name="openfileRequest")
|
|
|
|
|
|
|
|
def event(self, event):
|
|
|
|
if event.type() == QtCore.QEvent.FileOpen:
|
|
|
|
logger.info(event.url().toLocalFile())
|
|
|
|
self.openFileRequest.emit(event.url())
|
|
|
|
return True
|
|
|
|
return super().event(event)
|
|
|
|
|
2013-02-06 17:20:05 -08:00
|
|
|
except ImportError as e:
|
2022-05-19 20:13:59 -07:00
|
|
|
|
2022-05-22 20:02:49 -07:00
|
|
|
def show_exception_box(log_msg: str) -> None:
|
2022-07-18 12:17:13 -07:00
|
|
|
...
|
2022-05-19 20:13:59 -07:00
|
|
|
|
2022-04-18 18:32:45 -07:00
|
|
|
logger.error(str(e))
|
2015-02-12 14:57:46 -08:00
|
|
|
qt_available = False
|
2015-02-13 15:08:07 -08:00
|
|
|
|
|
|
|
|
2022-05-17 13:57:04 -07:00
|
|
|
def rotate(handler: logging.handlers.RotatingFileHandler, filename: pathlib.Path) -> None:
|
2022-04-04 18:59:26 -07:00
|
|
|
if filename.is_file() and filename.stat().st_size > 0:
|
|
|
|
handler.doRollover()
|
|
|
|
|
|
|
|
|
2022-05-19 13:28:18 -07:00
|
|
|
def update_publishers() -> None:
|
|
|
|
json_file = ComicTaggerSettings.get_settings_folder() / "publishers.json"
|
|
|
|
if json_file.exists():
|
|
|
|
try:
|
|
|
|
utils.update_publishers(json.loads(json_file.read_text("utf-8")))
|
2022-05-19 20:13:59 -07:00
|
|
|
except Exception as e:
|
2022-05-19 13:28:18 -07:00
|
|
|
logger.exception("Failed to load publishers from %s", json_file)
|
2022-05-19 20:13:59 -07:00
|
|
|
show_exception_box(str(e))
|
2022-05-19 13:28:18 -07:00
|
|
|
|
|
|
|
|
2022-05-17 13:57:04 -07:00
|
|
|
def ctmain() -> None:
|
2022-06-02 18:28:54 -07:00
|
|
|
opts = parse_cmd_line()
|
2022-07-18 12:17:13 -07:00
|
|
|
settings = ComicTaggerSettings(opts.config_path)
|
2022-04-18 18:31:06 -07:00
|
|
|
|
2022-04-05 00:58:19 -07:00
|
|
|
os.makedirs(ComicTaggerSettings.get_settings_folder() / "logs", exist_ok=True)
|
2022-04-04 18:59:26 -07:00
|
|
|
stream_handler = logging.StreamHandler()
|
|
|
|
stream_handler.setLevel(logging.WARNING)
|
|
|
|
file_handler = logging.handlers.RotatingFileHandler(
|
|
|
|
ComicTaggerSettings.get_settings_folder() / "logs" / "ComicTagger.log", encoding="utf-8", backupCount=10
|
|
|
|
)
|
|
|
|
rotate(file_handler, ComicTaggerSettings.get_settings_folder() / "logs" / "ComicTagger.log")
|
|
|
|
logging.basicConfig(
|
|
|
|
handlers=[
|
|
|
|
stream_handler,
|
|
|
|
file_handler,
|
|
|
|
],
|
|
|
|
level=logging.WARNING,
|
|
|
|
format="%(asctime)s | %(name)s | %(levelname)s | %(message)s",
|
|
|
|
datefmt="%Y-%m-%dT%H:%M:%S",
|
|
|
|
)
|
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
|
|
|
# Need to load setting before anything else
|
2015-02-12 14:57:46 -08:00
|
|
|
|
|
|
|
signal.signal(signal.SIGINT, signal.SIG_DFL)
|
|
|
|
|
2022-04-04 18:59:26 -07:00
|
|
|
logger.info(
|
|
|
|
"ComicTagger Version: %s running on: %s PyInstaller: %s",
|
|
|
|
version,
|
|
|
|
platform.system(),
|
|
|
|
"Yes" if getattr(sys, "frozen", None) else "No",
|
|
|
|
)
|
|
|
|
|
|
|
|
logger.debug("Installed Packages")
|
2022-06-23 13:05:27 -07:00
|
|
|
for pkg in sorted(importlib_metadata.distributions(), key=lambda x: x.name):
|
2022-09-19 22:54:48 -07:00
|
|
|
logger.debug("%s\t%s", pkg.metadata["Name"], pkg.metadata["Version"])
|
2022-04-04 18:59:26 -07:00
|
|
|
|
2022-10-27 15:36:57 -07:00
|
|
|
talker_api = ct_api.get_comic_talker(settings.comic_info_source)()
|
2022-06-28 07:21:35 -07:00
|
|
|
|
2022-05-19 13:28:18 -07:00
|
|
|
utils.load_publishers()
|
|
|
|
update_publishers()
|
|
|
|
|
2015-02-12 14:57:46 -08:00
|
|
|
if not qt_available and not opts.no_gui:
|
|
|
|
opts.no_gui = True
|
2022-07-18 12:17:13 -07:00
|
|
|
logger.warning("PyQt5 is not available. ComicTagger is limited to command-line mode.")
|
2015-02-12 14:57:46 -08:00
|
|
|
|
|
|
|
if opts.no_gui:
|
2022-04-04 18:59:26 -07:00
|
|
|
try:
|
2022-10-04 15:50:55 -07:00
|
|
|
cli.cli_mode(opts, settings, talker_api)
|
2022-06-02 18:32:16 -07:00
|
|
|
except Exception:
|
2022-04-11 14:52:41 -07:00
|
|
|
logger.exception("CLI mode failed")
|
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
|
|
|
os.environ["QtWidgets.QT_AUTO_SCREEN_SCALE_FACTOR"] = "1"
|
|
|
|
args = []
|
|
|
|
if opts.darkmode:
|
|
|
|
args.extend(["-platform", "windows:darkmode=2"])
|
|
|
|
args.extend(sys.argv)
|
2022-10-25 21:48:01 -07:00
|
|
|
app = Application(args)
|
|
|
|
|
|
|
|
# needed to catch initial open file events (macOS)
|
|
|
|
app.openFileRequest.connect(lambda x: opts.files.append(x.toLocalFile()))
|
|
|
|
|
2018-09-19 13:05:39 -07:00
|
|
|
if platform.system() == "Darwin":
|
|
|
|
# Set the MacOS dock icon
|
2022-10-25 21:48:01 -07:00
|
|
|
app.setWindowIcon(QtGui.QIcon(str(graphics_path / "app.png")))
|
2018-09-19 13:05:39 -07:00
|
|
|
|
|
|
|
if platform.system() == "Windows":
|
|
|
|
# For pure python, tell windows that we're not python,
|
|
|
|
# so we can have our own taskbar icon
|
|
|
|
import ctypes
|
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
|
|
|
|
|
|
|
myappid = "comictagger" # arbitrary string
|
2022-06-02 18:32:16 -07:00
|
|
|
ctypes.windll.shell32.SetCurrentProcessExplicitAppUserModelID(myappid) # type: ignore[attr-defined]
|
2019-10-06 05:15:18 -07:00
|
|
|
# force close of console window
|
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
|
|
|
swp_hidewindow = 0x0080
|
2022-06-02 18:32:16 -07:00
|
|
|
console_wnd = ctypes.windll.kernel32.GetConsoleWindow() # type: ignore[attr-defined]
|
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 console_wnd != 0:
|
2022-06-02 18:32:16 -07:00
|
|
|
ctypes.windll.user32.SetWindowPos(console_wnd, None, 0, 0, 0, 0, swp_hidewindow) # type: ignore[attr-defined]
|
2015-02-12 14:57:46 -08:00
|
|
|
|
|
|
|
if platform.system() != "Linux":
|
2022-10-25 21:48:01 -07:00
|
|
|
img = QtGui.QPixmap(str(graphics_path / "tags.png"))
|
2015-02-12 14:57:46 -08:00
|
|
|
|
2018-09-19 13:05:39 -07:00
|
|
|
splash = QtWidgets.QSplashScreen(img)
|
2015-02-12 14:57:46 -08:00
|
|
|
splash.show()
|
|
|
|
splash.raise_()
|
2022-05-17 13:57:04 -07:00
|
|
|
QtWidgets.QApplication.processEvents()
|
2015-02-12 14:57:46 -08:00
|
|
|
|
|
|
|
try:
|
2022-10-04 15:50:55 -07:00
|
|
|
tagger_window = TaggerWindow(opts.files, settings, talker_api, opts=opts)
|
2022-10-25 21:48:01 -07:00
|
|
|
tagger_window.setWindowIcon(QtGui.QIcon(str(graphics_path / "app.png")))
|
2015-02-12 14:57:46 -08:00
|
|
|
tagger_window.show()
|
|
|
|
|
2022-10-25 21:48:01 -07:00
|
|
|
# Catch open file events (macOS)
|
|
|
|
app.openFileRequest.connect(tagger_window.open_file_event)
|
|
|
|
|
2015-02-12 14:57:46 -08:00
|
|
|
if platform.system() != "Linux":
|
2015-02-13 15:08:07 -08:00
|
|
|
splash.finish(tagger_window)
|
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
|
|
|
sys.exit(app.exec())
|
|
|
|
except Exception:
|
2022-04-11 14:52:41 -07:00
|
|
|
logger.exception("GUI mode failed")
|
2018-09-19 13:05:39 -07:00
|
|
|
QtWidgets.QMessageBox.critical(
|
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
|
|
|
QtWidgets.QMainWindow(), "Error", "Unhandled exception in app:\n" + traceback.format_exc()
|
|
|
|
)
|