2015-02-21 18:30:32 -08:00
|
|
|
"""A class to represent a single comic, be it file or folder of images"""
|
2023-02-16 17:23:13 -08:00
|
|
|
# Copyright 2012-2014 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
|
2015-02-16 04:27:21 -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
|
|
|
import io
|
|
|
|
import logging
|
2015-02-16 04:27:21 -08:00
|
|
|
import os
|
2022-05-17 13:57:04 -07:00
|
|
|
import pathlib
|
2022-06-01 21:14:51 -07:00
|
|
|
import shutil
|
2022-08-17 15:53:19 -07:00
|
|
|
import sys
|
2023-10-04 19:08:17 -07:00
|
|
|
import traceback
|
2022-06-02 18:32:16 -07:00
|
|
|
from typing import cast
|
2015-02-16 05:09:21 -08:00
|
|
|
|
2023-09-06 01:50:05 -07:00
|
|
|
from comicapi import utils
|
2022-08-17 15:53:19 -07:00
|
|
|
from comicapi.archivers import Archiver, UnknownArchiver, ZipArchiver
|
2023-12-17 21:47:43 -08:00
|
|
|
from comicapi.genericmetadata import GenericMetadata
|
|
|
|
from comicapi.metadata import Metadata
|
|
|
|
from comictaggerlib.ctversion import version
|
2022-06-02 18:32:16 -07: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
|
|
|
logger = logging.getLogger(__name__)
|
2023-01-11 16:19:44 -08:00
|
|
|
|
2022-08-17 15:53:19 -07:00
|
|
|
archivers: list[type[Archiver]] = []
|
2023-12-17 21:47:43 -08:00
|
|
|
metadata_styles: dict[str, Metadata] = {}
|
2022-08-17 15:53:19 -07:00
|
|
|
|
|
|
|
|
|
|
|
def load_archive_plugins() -> None:
|
2023-01-12 15:37:27 -08:00
|
|
|
if not archivers:
|
2023-06-22 20:11:40 -07:00
|
|
|
if sys.version_info < (3, 10):
|
|
|
|
from importlib_metadata import entry_points
|
|
|
|
else:
|
|
|
|
from importlib.metadata import entry_points
|
2023-01-20 19:32:32 -08:00
|
|
|
builtin: list[type[Archiver]] = []
|
2023-01-12 15:37:27 -08:00
|
|
|
for arch in entry_points(group="comicapi.archiver"):
|
|
|
|
try:
|
|
|
|
archiver: type[Archiver] = arch.load()
|
2023-12-17 15:51:43 -08:00
|
|
|
if arch.module.startswith("comicapi"):
|
|
|
|
builtin.append(archiver)
|
|
|
|
else:
|
|
|
|
archivers.append(archiver)
|
2023-01-12 15:37:27 -08:00
|
|
|
except Exception:
|
|
|
|
logger.warning("Failed to load talker: %s", arch.name)
|
2023-01-20 19:32:32 -08:00
|
|
|
archivers.extend(builtin)
|
2022-08-17 15:53:19 -07: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
|
|
|
|
2023-12-17 21:47:43 -08:00
|
|
|
def load_metadata_plugins(version: str = f"ComicAPI/{version}") -> None:
|
|
|
|
if not metadata_styles:
|
|
|
|
if sys.version_info < (3, 10):
|
|
|
|
from importlib_metadata import entry_points
|
|
|
|
else:
|
|
|
|
from importlib.metadata import entry_points
|
|
|
|
builtin: dict[str, Metadata] = {}
|
|
|
|
styles: dict[str, Metadata] = {}
|
|
|
|
for arch in entry_points(group="comicapi.metadata"):
|
|
|
|
try:
|
|
|
|
style: type[Metadata] = arch.load()
|
|
|
|
if style.enabled:
|
|
|
|
if arch.module.startswith("comicapi"):
|
|
|
|
builtin[style.short_name] = style(version)
|
|
|
|
else:
|
|
|
|
styles[style.short_name] = style(version)
|
|
|
|
except Exception:
|
|
|
|
logger.exception("Failed to load metadata plugin: %s", arch.name)
|
|
|
|
metadata_styles.clear()
|
|
|
|
metadata_styles.update(builtin)
|
|
|
|
metadata_styles.update(styles)
|
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
|
|
|
|
2015-02-21 18:30:32 -08:00
|
|
|
|
2015-02-16 04:27:21 -08:00
|
|
|
class ComicArchive:
|
2022-08-10 16:46:00 -07:00
|
|
|
logo_data = b""
|
2023-06-22 20:11:40 -07:00
|
|
|
pil_available = 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
|
|
|
|
2023-12-18 02:37:34 -08:00
|
|
|
def __init__(
|
|
|
|
self, path: pathlib.Path | str | Archiver, default_image_path: pathlib.Path | str | None = None
|
|
|
|
) -> None:
|
2023-12-17 21:47:43 -08:00
|
|
|
self.md: dict[str, GenericMetadata] = {}
|
2022-06-02 18:32:16 -07:00
|
|
|
self.page_count: int | None = None
|
2022-05-17 13:57:04 -07:00
|
|
|
self.page_list: list[str] = []
|
2015-02-16 05:09:21 -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
|
|
|
self.reset_cache()
|
2015-02-16 05:09:21 -08:00
|
|
|
self.default_image_path = default_image_path
|
|
|
|
|
2023-12-18 02:37:34 -08:00
|
|
|
if isinstance(path, Archiver):
|
|
|
|
self.path = path.path
|
|
|
|
self.archiver: Archiver = path
|
|
|
|
else:
|
|
|
|
self.path = pathlib.Path(path).absolute()
|
|
|
|
self.archiver = UnknownArchiver.open(self.path)
|
2015-02-16 05:09:21 -08:00
|
|
|
|
2023-01-12 17:00:11 -08:00
|
|
|
load_archive_plugins()
|
2023-12-17 21:47:43 -08:00
|
|
|
load_metadata_plugins()
|
2022-08-17 15:53:19 -07:00
|
|
|
for archiver in archivers:
|
2023-12-17 15:51:43 -08:00
|
|
|
if archiver.enabled and archiver.is_valid(self.path):
|
2022-08-17 15:53:19 -07:00
|
|
|
self.archiver = archiver.open(self.path)
|
|
|
|
break
|
2022-06-01 21:14:51 -07:00
|
|
|
|
|
|
|
if not ComicArchive.logo_data and self.default_image_path:
|
|
|
|
with open(self.default_image_path, mode="rb") as fd:
|
|
|
|
ComicArchive.logo_data = fd.read()
|
2015-02-16 05:09:21 -08:00
|
|
|
|
2022-05-17 13:57:04 -07:00
|
|
|
def reset_cache(self) -> None:
|
2015-02-21 18:30:32 -08:00
|
|
|
"""Clears the cached data"""
|
|
|
|
|
|
|
|
self.page_count = None
|
2023-12-17 21:47:43 -08:00
|
|
|
self.page_list.clear()
|
|
|
|
self.md.clear()
|
2015-02-16 05:09:21 -08:00
|
|
|
|
2023-12-17 21:47:43 -08:00
|
|
|
def load_cache(self, style_list: list[str]) -> None:
|
2015-02-16 05:09:21 -08:00
|
|
|
for style in style_list:
|
2023-12-17 21:47:43 -08:00
|
|
|
if style in metadata_styles:
|
|
|
|
md = metadata_styles[style].get_metadata(self.archiver)
|
|
|
|
if not md.is_empty:
|
|
|
|
self.md[style] = md
|
|
|
|
|
|
|
|
def get_supported_metadata(self) -> list[str]:
|
|
|
|
return [style[0] for style in metadata_styles.items() if style[1].supports_metadata(self.archiver)]
|
2015-02-16 05:09:21 -08:00
|
|
|
|
2022-06-02 18:32:16 -07:00
|
|
|
def rename(self, path: pathlib.Path | str) -> None:
|
2022-07-09 22:27:45 -07:00
|
|
|
new_path = pathlib.Path(path).absolute()
|
|
|
|
if new_path == self.path:
|
|
|
|
return
|
|
|
|
os.makedirs(new_path.parent, 0o777, True)
|
2022-07-29 22:05:03 -07:00
|
|
|
shutil.move(self.path, new_path)
|
2022-07-09 22:27:45 -07:00
|
|
|
self.path = new_path
|
2022-05-17 13:57:04 -07:00
|
|
|
self.archiver.path = pathlib.Path(path)
|
2015-02-16 05:09:21 -08:00
|
|
|
|
2022-08-17 15:53:19 -07:00
|
|
|
def is_writable(self, check_archive_status: bool = True) -> bool:
|
|
|
|
if isinstance(self.archiver, UnknownArchiver):
|
2015-02-16 05:09:21 -08:00
|
|
|
return False
|
|
|
|
|
2022-08-17 15:53:19 -07:00
|
|
|
if check_archive_status and not self.archiver.is_writable():
|
2015-02-16 05:09:21 -08:00
|
|
|
return False
|
|
|
|
|
2022-08-17 15:53:19 -07:00
|
|
|
if not (os.access(self.path, os.W_OK) or os.access(self.path.parent, os.W_OK)):
|
2015-02-16 05:09:21 -08:00
|
|
|
return False
|
|
|
|
|
|
|
|
return True
|
|
|
|
|
2023-12-17 21:47:43 -08:00
|
|
|
def is_writable_for_style(self, style: str) -> bool:
|
|
|
|
if style in metadata_styles:
|
|
|
|
return self.archiver.is_writable() and metadata_styles[style].supports_metadata(self.archiver)
|
|
|
|
return False
|
2015-02-16 05:09:21 -08:00
|
|
|
|
2022-08-17 15:53:19 -07:00
|
|
|
def is_zip(self) -> bool:
|
|
|
|
return self.archiver.name() == "ZIP"
|
2015-02-16 05:09:21 -08:00
|
|
|
|
2022-05-17 13:57:04 -07:00
|
|
|
def seems_to_be_a_comic_archive(self) -> bool:
|
2022-08-17 15:53:19 -07:00
|
|
|
if not (isinstance(self.archiver, UnknownArchiver)) and self.get_number_of_pages() > 0:
|
2015-02-16 05:09:21 -08:00
|
|
|
return 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
|
|
|
return False
|
2015-02-16 05:09:21 -08:00
|
|
|
|
2022-08-17 15:53:19 -07:00
|
|
|
def extension(self) -> str:
|
|
|
|
return self.archiver.extension()
|
|
|
|
|
2023-12-17 21:47:43 -08:00
|
|
|
def read_metadata(self, style: str) -> GenericMetadata:
|
|
|
|
if style in self.md:
|
|
|
|
return self.md[style]
|
2023-12-18 02:37:34 -08:00
|
|
|
md = metadata_styles[style].get_metadata(self.archiver)
|
|
|
|
md.apply_default_page_list(self.get_page_name_list())
|
|
|
|
return md
|
2015-02-16 05:09:21 -08:00
|
|
|
|
2023-12-17 21:47:43 -08:00
|
|
|
def read_metadata_string(self, style: str) -> str:
|
|
|
|
return metadata_styles[style].get_metadata_string(self.archiver)
|
|
|
|
|
|
|
|
def write_metadata(self, metadata: GenericMetadata, style: str) -> bool:
|
|
|
|
if style in self.md:
|
|
|
|
del self.md[style]
|
|
|
|
return metadata_styles[style].set_metadata(metadata, self.archiver)
|
|
|
|
|
|
|
|
def has_metadata(self, style: str) -> bool:
|
|
|
|
if style in self.md:
|
|
|
|
return True
|
|
|
|
return metadata_styles[style].has_metadata(self.archiver)
|
|
|
|
|
|
|
|
def remove_metadata(self, style: str) -> bool:
|
|
|
|
if style in self.md:
|
|
|
|
del self.md[style]
|
|
|
|
return metadata_styles[style].remove_metadata(self.archiver)
|
2015-02-16 05:09:21 -08:00
|
|
|
|
2022-05-17 13:57:04 -07:00
|
|
|
def get_page(self, index: int) -> bytes:
|
2022-08-10 16:46:00 -07:00
|
|
|
image_data = b""
|
2015-02-16 05:09:21 -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
|
|
|
filename = self.get_page_name(index)
|
2015-02-16 05:09:21 -08:00
|
|
|
|
2022-05-17 13:57:04 -07:00
|
|
|
if filename:
|
2015-02-16 05:09:21 -08:00
|
|
|
try:
|
2022-08-10 16:46:00 -07:00
|
|
|
image_data = self.archiver.read_file(filename) or b""
|
2023-10-04 19:08:17 -07:00
|
|
|
except Exception as e:
|
|
|
|
tb = traceback.extract_tb(e.__traceback__)
|
|
|
|
logger.error(
|
|
|
|
"%s:%s: Error reading in page %d. Substituting logo page.", tb[1].filename, tb[1].lineno, index
|
|
|
|
)
|
2015-02-16 05:09:21 -08:00
|
|
|
image_data = ComicArchive.logo_data
|
|
|
|
|
|
|
|
return image_data
|
|
|
|
|
2022-05-17 13:57:04 -07:00
|
|
|
def get_page_name(self, index: int) -> str:
|
2015-02-16 05:09:21 -08:00
|
|
|
if index is None:
|
2022-07-18 12:17:13 -07:00
|
|
|
return ""
|
2015-02-16 05:09:21 -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
|
|
|
page_list = self.get_page_name_list()
|
2015-02-16 05:09:21 -08:00
|
|
|
|
2015-02-21 18:30:32 -08:00
|
|
|
num_pages = len(page_list)
|
2015-02-16 05:09:21 -08:00
|
|
|
if num_pages == 0 or index >= num_pages:
|
2022-05-17 13:57:04 -07:00
|
|
|
return ""
|
2015-02-16 05:09:21 -08:00
|
|
|
|
2015-02-21 18:30:32 -08:00
|
|
|
return page_list[index]
|
2015-02-16 05:09:21 -08:00
|
|
|
|
2022-06-02 18:32:16 -07:00
|
|
|
def get_scanner_page_index(self) -> int | None:
|
2015-02-16 05:09:21 -08:00
|
|
|
scanner_page_index = None
|
|
|
|
|
2015-02-21 18:30:32 -08:00
|
|
|
# make a guess at the scanner page
|
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
|
|
|
name_list = self.get_page_name_list()
|
|
|
|
count = self.get_number_of_pages()
|
2015-02-16 05:09:21 -08:00
|
|
|
|
2015-02-21 18:30:32 -08:00
|
|
|
# too few pages to really know
|
2015-02-16 05:09:21 -08:00
|
|
|
if count < 5:
|
|
|
|
return None
|
|
|
|
|
2022-04-04 18:59:26 -07:00
|
|
|
# count the length of every filename, and count occurrences
|
2022-05-17 13:57:04 -07:00
|
|
|
length_buckets: dict[int, int] = {}
|
2015-02-16 05:09:21 -08:00
|
|
|
for name in name_list:
|
2015-02-21 18:30:32 -08:00
|
|
|
fname = os.path.split(name)[1]
|
2015-02-16 05:09:21 -08:00
|
|
|
length = len(fname)
|
2015-02-21 18:30:32 -08:00
|
|
|
if length in length_buckets:
|
|
|
|
length_buckets[length] += 1
|
2015-02-16 05:09:21 -08:00
|
|
|
else:
|
2015-02-21 18:30:32 -08:00
|
|
|
length_buckets[length] = 1
|
2015-02-16 05:09:21 -08:00
|
|
|
|
|
|
|
# sort by most common
|
2022-06-01 21:14:51 -07:00
|
|
|
sorted_buckets = sorted(length_buckets.items(), key=lambda tup: (tup[1], tup[0]), reverse=True)
|
2015-02-16 05:09:21 -08:00
|
|
|
|
2022-04-04 18:59:26 -07:00
|
|
|
# statistical mode occurrence is first
|
2015-02-16 05:09:21 -08:00
|
|
|
mode_length = sorted_buckets[0][0]
|
|
|
|
|
|
|
|
# we are only going to consider the final image file:
|
2015-02-21 18:30:32 -08:00
|
|
|
final_name = os.path.split(name_list[count - 1])[1]
|
2015-02-16 05:09:21 -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
|
|
|
common_length_list = []
|
2015-02-16 05:09:21 -08:00
|
|
|
for name in name_list:
|
|
|
|
if len(os.path.split(name)[1]) == mode_length:
|
2015-02-21 18:30:32 -08:00
|
|
|
common_length_list.append(os.path.split(name)[1])
|
2015-02-16 05:09:21 -08:00
|
|
|
|
|
|
|
prefix = os.path.commonprefix(common_length_list)
|
|
|
|
|
|
|
|
if mode_length <= 7 and prefix == "":
|
2015-02-21 18:30:32 -08:00
|
|
|
# probably all numbers
|
2015-02-16 05:09:21 -08:00
|
|
|
if len(final_name) > mode_length:
|
2015-02-21 18:30:32 -08:00
|
|
|
scanner_page_index = count - 1
|
2015-02-16 05:09:21 -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
|
|
|
# see if the last page doesn't start with the same prefix as most others
|
2015-02-16 05:09:21 -08:00
|
|
|
elif not final_name.startswith(prefix):
|
2015-02-21 18:30:32 -08:00
|
|
|
scanner_page_index = count - 1
|
2015-02-16 05:09:21 -08:00
|
|
|
|
|
|
|
return scanner_page_index
|
|
|
|
|
2023-12-18 02:37:34 -08:00
|
|
|
def get_page_name_list(self) -> list[str]:
|
2022-05-17 13:57:04 -07:00
|
|
|
if not self.page_list:
|
2015-02-16 05:09:21 -08:00
|
|
|
# get the list file names in the archive, and sort
|
2022-05-17 13:57:04 -07:00
|
|
|
files: list[str] = self.archiver.get_filename_list()
|
2015-02-16 05:09:21 -08:00
|
|
|
|
2023-12-18 02:37:34 -08:00
|
|
|
files = cast(list[str], utils.os_sorted(files))
|
2015-02-16 05:09:21 -08:00
|
|
|
|
|
|
|
# make a sub-list of image files
|
|
|
|
self.page_list = []
|
|
|
|
for name in files:
|
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 (
|
2022-07-01 16:22:01 -07:00
|
|
|
os.path.splitext(name)[1].casefold() in [".jpg", ".jpeg", ".png", ".gif", ".webp"]
|
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
|
|
|
and os.path.basename(name)[0] != "."
|
|
|
|
):
|
2015-02-16 05:09:21 -08:00
|
|
|
self.page_list.append(name)
|
|
|
|
|
|
|
|
return self.page_list
|
|
|
|
|
2022-05-17 13:57:04 -07:00
|
|
|
def get_number_of_pages(self) -> int:
|
2015-02-16 05:09:21 -08:00
|
|
|
if self.page_count is None:
|
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
|
|
|
self.page_count = len(self.get_page_name_list())
|
2015-02-16 05:09:21 -08:00
|
|
|
return self.page_count
|
|
|
|
|
2022-05-17 13:57:04 -07:00
|
|
|
def apply_archive_info_to_metadata(self, md: GenericMetadata, calc_page_sizes: bool = False) -> None:
|
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
|
|
|
md.page_count = self.get_number_of_pages()
|
2015-02-16 05:09:21 -08:00
|
|
|
|
|
|
|
if calc_page_sizes:
|
2022-06-01 21:14:51 -07:00
|
|
|
for index, p in enumerate(md.pages):
|
2023-12-17 21:47:43 -08:00
|
|
|
idx = int(p["image_index"])
|
2023-12-18 02:37:34 -08:00
|
|
|
p["filename"] = self.get_page_name(idx)
|
2023-06-22 20:11:40 -07:00
|
|
|
if self.pil_available:
|
|
|
|
try:
|
|
|
|
from PIL import Image
|
|
|
|
|
|
|
|
self.pil_available = True
|
|
|
|
except ImportError:
|
|
|
|
self.pil_available = False
|
2023-12-17 21:47:43 -08:00
|
|
|
if "size" not in p or "height" not in p or "width" not in p:
|
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
|
|
|
data = self.get_page(idx)
|
2022-05-17 13:57:04 -07:00
|
|
|
if data:
|
2015-02-16 05:09:21 -08:00
|
|
|
try:
|
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 isinstance(data, bytes):
|
|
|
|
im = Image.open(io.BytesIO(data))
|
|
|
|
else:
|
|
|
|
im = Image.open(io.StringIO(data))
|
2015-02-21 18:30:32 -08:00
|
|
|
w, h = im.size
|
2015-02-16 05:09:21 -08:00
|
|
|
|
2023-12-17 21:47:43 -08:00
|
|
|
p["size"] = str(len(data))
|
|
|
|
p["height"] = str(h)
|
|
|
|
p["width"] = str(w)
|
2022-04-04 18:59:26 -07:00
|
|
|
except Exception as e:
|
2022-06-01 21:14:51 -07:00
|
|
|
logger.warning("Error decoding image [%s] %s :: image %s", e, self.path, index)
|
2023-12-17 21:47:43 -08:00
|
|
|
p["size"] = str(len(data))
|
2015-02-16 05:09:21 -08:00
|
|
|
|
|
|
|
else:
|
2023-12-17 21:47:43 -08:00
|
|
|
if "size" not in p:
|
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
|
|
|
data = self.get_page(idx)
|
2023-12-17 21:47:43 -08:00
|
|
|
p["size"] = str(len(data))
|
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-29 16:37:44 -07:00
|
|
|
def metadata_from_filename(
|
2022-05-17 13:57:04 -07:00
|
|
|
self,
|
|
|
|
complicated_parser: bool = False,
|
|
|
|
remove_c2c: bool = False,
|
|
|
|
remove_fcbd: bool = False,
|
|
|
|
remove_publisher: bool = False,
|
2022-05-19 17:58:45 -07:00
|
|
|
split_words: bool = False,
|
2023-09-06 01:50:05 -07:00
|
|
|
allow_issue_start_with_letter: bool = False,
|
|
|
|
protofolius_issue_number_scheme: bool = False,
|
2022-05-17 13:57:04 -07:00
|
|
|
) -> GenericMetadata:
|
2015-02-16 05:09:21 -08:00
|
|
|
metadata = GenericMetadata()
|
|
|
|
|
2023-09-06 01:50:05 -07:00
|
|
|
filename_info = utils.parse_filename(
|
|
|
|
self.path.name,
|
|
|
|
complicated_parser=complicated_parser,
|
|
|
|
remove_c2c=remove_c2c,
|
|
|
|
remove_fcbd=remove_fcbd,
|
|
|
|
remove_publisher=remove_publisher,
|
|
|
|
split_words=split_words,
|
|
|
|
allow_issue_start_with_letter=allow_issue_start_with_letter,
|
|
|
|
protofolius_issue_number_scheme=protofolius_issue_number_scheme,
|
|
|
|
)
|
|
|
|
metadata.alternate_number = utils.xlate(filename_info.get("alternate", None))
|
|
|
|
metadata.issue = utils.xlate(filename_info.get("issue", None))
|
|
|
|
metadata.issue_count = utils.xlate_int(filename_info.get("issue_count", None))
|
|
|
|
metadata.publisher = utils.xlate(filename_info.get("publisher", None))
|
|
|
|
metadata.series = utils.xlate(filename_info.get("series", None))
|
|
|
|
metadata.title = utils.xlate(filename_info.get("title", None))
|
|
|
|
metadata.volume = utils.xlate_int(filename_info.get("volume", None))
|
|
|
|
metadata.volume_count = utils.xlate_int(filename_info.get("volume_count", None))
|
|
|
|
metadata.year = utils.xlate_int(filename_info.get("year", None))
|
|
|
|
|
|
|
|
metadata.scan_info = utils.xlate(filename_info.get("remainder", None))
|
|
|
|
metadata.format = "FCBD" if filename_info.get("fcbd", None) else None
|
|
|
|
if filename_info.get("annual", None):
|
|
|
|
metadata.format = "Annual"
|
|
|
|
if filename_info.get("format", None):
|
|
|
|
metadata.format = filename_info["format"]
|
2015-02-16 05:09:21 -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
|
|
|
metadata.is_empty = False
|
2015-02-16 05:09:21 -08:00
|
|
|
return metadata
|
|
|
|
|
2022-08-17 15:53:19 -07:00
|
|
|
def export_as_zip(self, zip_filename: pathlib.Path) -> bool:
|
|
|
|
if self.archiver.name() == "ZIP":
|
2015-02-16 05:09:21 -08:00
|
|
|
# nothing to do, we're already a zip
|
|
|
|
return True
|
|
|
|
|
2022-08-17 15:53:19 -07:00
|
|
|
zip_archiver = ZipArchiver.open(zip_filename)
|
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
|
|
|
return zip_archiver.copy_from_archive(self.archiver)
|