2015-02-21 18:30:32 -08:00
|
|
|
|
"""Some generic utilities"""
|
|
|
|
|
# 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
|
2015-02-16 04:27:21 -08:00
|
|
|
|
|
2022-07-01 16:22:01 -07:00
|
|
|
|
import glob
|
2022-05-19 13:28:18 -07:00
|
|
|
|
import json
|
2022-04-04 18:59:26 -07:00
|
|
|
|
import logging
|
2015-02-16 04:27:21 -08:00
|
|
|
|
import os
|
2022-05-19 13:28:18 -07:00
|
|
|
|
import pathlib
|
2021-09-26 17:06:30 -07:00
|
|
|
|
import unicodedata
|
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 collections import defaultdict
|
2022-08-10 16:46:00 -07:00
|
|
|
|
from collections.abc import Mapping
|
2022-06-06 16:58:27 -07:00
|
|
|
|
from shutil import which # noqa: F401
|
2022-08-10 16:46:00 -07:00
|
|
|
|
from typing import Any
|
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 pycountry
|
2022-07-08 12:33:00 -07:00
|
|
|
|
import thefuzz.fuzz
|
2015-02-16 04:27:21 -08:00
|
|
|
|
|
2022-04-04 18:59:26 -07:00
|
|
|
|
logger = logging.getLogger(__name__)
|
|
|
|
|
|
2015-02-16 04:27:21 -08:00
|
|
|
|
|
|
|
|
|
class UtilsVars:
|
2015-02-21 18:30:32 -08:00
|
|
|
|
already_fixed_encoding = False
|
|
|
|
|
|
2015-02-16 04:27:21 -08:00
|
|
|
|
|
2022-07-25 11:22:44 -07:00
|
|
|
|
def parse_date_str(date_str: str) -> tuple[int | None, int | None, int | None]:
|
|
|
|
|
day = None
|
|
|
|
|
month = None
|
|
|
|
|
year = None
|
|
|
|
|
if date_str:
|
|
|
|
|
parts = date_str.split("-")
|
|
|
|
|
year = xlate(parts[0], True)
|
|
|
|
|
if len(parts) > 1:
|
|
|
|
|
month = xlate(parts[1], True)
|
|
|
|
|
if len(parts) > 2:
|
|
|
|
|
day = xlate(parts[2], True)
|
|
|
|
|
return day, month, year
|
|
|
|
|
|
|
|
|
|
|
2022-06-02 18:32:16 -07:00
|
|
|
|
def get_recursive_filelist(pathlist: list[str]) -> list[str]:
|
2015-02-21 18:30:32 -08:00
|
|
|
|
"""Get a recursive list of of all files under all path items in the list"""
|
|
|
|
|
|
2022-07-01 16:22:01 -07:00
|
|
|
|
filelist: list[str] = []
|
2015-02-21 18:30:32 -08:00
|
|
|
|
for p in pathlist:
|
|
|
|
|
|
|
|
|
|
if os.path.isdir(p):
|
2022-07-01 16:22:01 -07:00
|
|
|
|
filelist.extend(x for x in glob.glob(f"{p}{os.sep}/**", recursive=True) if not os.path.isdir(x))
|
2022-08-08 18:03:29 -07:00
|
|
|
|
elif str(p) not in filelist:
|
|
|
|
|
filelist.append(str(p))
|
2015-02-21 18:30:32 -08:00
|
|
|
|
|
|
|
|
|
return filelist
|
|
|
|
|
|
|
|
|
|
|
2022-05-17 13:57:04 -07:00
|
|
|
|
def add_to_path(dirname: str) -> None:
|
2022-08-08 18:03:29 -07:00
|
|
|
|
if dirname:
|
|
|
|
|
dirname = os.path.abspath(dirname)
|
|
|
|
|
paths = [os.path.normpath(x) for x in os.environ["PATH"].split(os.pathsep)]
|
2015-02-21 18:30:32 -08:00
|
|
|
|
|
2022-08-08 18:03:29 -07:00
|
|
|
|
if dirname not in paths:
|
|
|
|
|
paths.insert(0, dirname)
|
|
|
|
|
os.environ["PATH"] = os.pathsep.join(paths)
|
2015-02-16 04:27:21 -08:00
|
|
|
|
|
|
|
|
|
|
2022-06-23 13:08:09 -07:00
|
|
|
|
def xlate(data: Any, is_int: bool = False, is_float: bool = False) -> Any:
|
2021-08-07 21:54:29 -07:00
|
|
|
|
if data is None or data == "":
|
|
|
|
|
return None
|
2022-06-23 13:08:09 -07:00
|
|
|
|
if is_int or is_float:
|
|
|
|
|
i: str | int | float
|
|
|
|
|
if isinstance(data, (int, float)):
|
|
|
|
|
i = data
|
|
|
|
|
else:
|
|
|
|
|
i = str(data).translate(defaultdict(lambda: None, zip((ord(c) for c in "1234567890."), "1234567890.")))
|
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 i == "":
|
2021-08-07 21:54:29 -07:00
|
|
|
|
return None
|
2022-07-01 16:22:01 -07:00
|
|
|
|
try:
|
|
|
|
|
if is_float:
|
|
|
|
|
return float(i)
|
|
|
|
|
return int(float(i))
|
|
|
|
|
except ValueError:
|
|
|
|
|
return 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
|
|
|
|
|
|
|
|
|
return str(data)
|
2021-08-07 21:54:29 -07:00
|
|
|
|
|
|
|
|
|
|
2022-05-17 13:57:04 -07:00
|
|
|
|
def remove_articles(text: str) -> str:
|
2022-07-01 16:22:01 -07:00
|
|
|
|
text = text.casefold()
|
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
|
|
|
|
articles = [
|
|
|
|
|
"&",
|
|
|
|
|
"a",
|
|
|
|
|
"am",
|
|
|
|
|
"an",
|
|
|
|
|
"and",
|
|
|
|
|
"as",
|
|
|
|
|
"at",
|
|
|
|
|
"be",
|
|
|
|
|
"but",
|
|
|
|
|
"by",
|
|
|
|
|
"for",
|
|
|
|
|
"if",
|
|
|
|
|
"is",
|
|
|
|
|
"issue",
|
|
|
|
|
"it",
|
|
|
|
|
"it's",
|
|
|
|
|
"its",
|
|
|
|
|
"itself",
|
|
|
|
|
"of",
|
|
|
|
|
"or",
|
|
|
|
|
"so",
|
|
|
|
|
"the",
|
|
|
|
|
"the",
|
|
|
|
|
"with",
|
|
|
|
|
]
|
|
|
|
|
new_text = ""
|
2022-08-12 07:10:36 -07:00
|
|
|
|
for word in text.split():
|
2015-02-21 18:30:32 -08:00
|
|
|
|
if word not in articles:
|
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
|
|
|
|
new_text += word + " "
|
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
|
|
|
|
new_text = new_text[:-1]
|
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
|
|
|
|
return new_text
|
2015-02-16 04:27:21 -08:00
|
|
|
|
|
|
|
|
|
|
2022-06-07 11:49:56 -07:00
|
|
|
|
def sanitize_title(text: str, basic: bool = False) -> str:
|
2021-09-26 17:06:30 -07:00
|
|
|
|
# normalize unicode and convert to ascii. Does not work for everything eg ½ to 1⁄2 not 1/2
|
2022-07-09 23:26:30 -07:00
|
|
|
|
text = unicodedata.normalize("NFKD", text).casefold()
|
2022-08-12 07:10:36 -07:00
|
|
|
|
# comicvine keeps apostrophes a part of the word
|
|
|
|
|
text = text.replace("'", "")
|
|
|
|
|
text = text.replace('"', "")
|
|
|
|
|
if not basic:
|
2022-07-09 23:26:30 -07:00
|
|
|
|
# comicvine ignores punctuation and accents
|
|
|
|
|
# remove all characters that are not a letter, separator (space) or number
|
|
|
|
|
# replace any "dash punctuation" with a space
|
|
|
|
|
# makes sure that batman-superman and self-proclaimed stay separate words
|
|
|
|
|
text = "".join(
|
2022-08-12 07:10:36 -07:00
|
|
|
|
c if unicodedata.category(c)[0] not in "P" else " " for c in text if unicodedata.category(c)[0] in "LZNP"
|
2022-07-09 23:26:30 -07:00
|
|
|
|
)
|
2022-06-07 11:49:56 -07:00
|
|
|
|
# remove extra space and articles and all lower case
|
2022-07-09 23:26:30 -07:00
|
|
|
|
text = remove_articles(text).strip()
|
2021-09-26 17:06:30 -07:00
|
|
|
|
|
|
|
|
|
return text
|
|
|
|
|
|
|
|
|
|
|
2022-08-08 18:03:29 -07:00
|
|
|
|
def titles_match(search_title: str, record_title: str, threshold: int = 90) -> bool:
|
2022-07-09 23:26:30 -07:00
|
|
|
|
sanitized_search = sanitize_title(search_title)
|
|
|
|
|
sanitized_record = sanitize_title(record_title)
|
2022-08-08 18:03:29 -07:00
|
|
|
|
ratio: int = thefuzz.fuzz.ratio(sanitized_search, sanitized_record)
|
2022-07-08 12:33:00 -07:00
|
|
|
|
logger.debug(
|
|
|
|
|
"search title: %s ; record title: %s ; ratio: %d ; match threshold: %d",
|
|
|
|
|
search_title,
|
|
|
|
|
record_title,
|
|
|
|
|
ratio,
|
|
|
|
|
threshold,
|
|
|
|
|
)
|
|
|
|
|
return ratio >= threshold
|
2022-07-09 23:26:30 -07:00
|
|
|
|
|
|
|
|
|
|
2022-07-09 22:27:45 -07:00
|
|
|
|
def unique_file(file_name: pathlib.Path) -> pathlib.Path:
|
2022-08-19 20:20:37 -07:00
|
|
|
|
name = file_name.stem
|
2015-02-21 18:30:32 -08:00
|
|
|
|
counter = 1
|
|
|
|
|
while True:
|
2022-07-09 22:27:45 -07:00
|
|
|
|
if not file_name.exists():
|
2015-02-21 18:30:32 -08:00
|
|
|
|
return file_name
|
2022-08-19 20:20:37 -07:00
|
|
|
|
file_name = file_name.with_stem(name + " (" + str(counter) + ")")
|
2015-02-21 18:30:32 -08:00
|
|
|
|
counter += 1
|
2015-02-16 04:27:21 -08:00
|
|
|
|
|
|
|
|
|
|
2022-06-02 18:32:16 -07:00
|
|
|
|
languages: dict[str | None, str | None] = defaultdict(lambda: 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
|
|
|
|
|
2022-06-02 18:32:16 -07:00
|
|
|
|
countries: dict[str | None, str | None] = defaultdict(lambda: 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
|
|
|
|
|
|
|
|
|
for c in pycountry.countries:
|
|
|
|
|
if "alpha_2" in c._fields:
|
|
|
|
|
countries[c.alpha_2] = c.name
|
|
|
|
|
|
|
|
|
|
for lng in pycountry.languages:
|
|
|
|
|
if "alpha_2" in lng._fields:
|
|
|
|
|
languages[lng.alpha_2] = lng.name
|
|
|
|
|
|
|
|
|
|
|
2022-06-02 18:32:16 -07:00
|
|
|
|
def get_language_from_iso(iso: str | None) -> str | 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
|
|
|
|
return languages[iso]
|
|
|
|
|
|
|
|
|
|
|
2022-06-02 18:32:16 -07:00
|
|
|
|
def get_language(string: str | None) -> str | 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
|
|
|
|
if string is None:
|
2015-02-21 18:30:32 -08:00
|
|
|
|
return None
|
2022-08-08 18:03:29 -07:00
|
|
|
|
string = string.casefold()
|
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
|
|
|
|
|
|
|
|
|
lang = get_language_from_iso(string)
|
|
|
|
|
|
|
|
|
|
if lang is None:
|
|
|
|
|
try:
|
2022-05-17 13:57:04 -07:00
|
|
|
|
return str(pycountry.languages.lookup(string).name)
|
2022-06-02 18:32:16 -07:00
|
|
|
|
except LookupError:
|
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 None
|
|
|
|
|
return lang
|
2022-05-19 13:28:18 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def get_publisher(publisher: str) -> tuple[str, str]:
|
2021-08-07 21:50:45 -07:00
|
|
|
|
imprint = ""
|
|
|
|
|
|
2022-05-19 13:28:18 -07:00
|
|
|
|
for pub in publishers.values():
|
2021-08-07 21:50:45 -07:00
|
|
|
|
imprint, publisher, ok = pub[publisher]
|
|
|
|
|
if ok:
|
|
|
|
|
break
|
|
|
|
|
|
|
|
|
|
return (imprint, publisher)
|
|
|
|
|
|
|
|
|
|
|
2022-06-02 18:32:16 -07:00
|
|
|
|
def update_publishers(new_publishers: Mapping[str, Mapping[str, str]]) -> None:
|
2022-05-19 13:28:18 -07:00
|
|
|
|
for publisher in new_publishers:
|
|
|
|
|
if publisher in publishers:
|
|
|
|
|
publishers[publisher].update(new_publishers[publisher])
|
|
|
|
|
else:
|
|
|
|
|
publishers[publisher] = ImprintDict(publisher, new_publishers[publisher])
|
|
|
|
|
|
|
|
|
|
|
2021-08-07 21:50:45 -07:00
|
|
|
|
class ImprintDict(dict):
|
2022-05-19 13:28:18 -07:00
|
|
|
|
"""
|
2021-08-07 21:50:45 -07:00
|
|
|
|
ImprintDict takes a publisher and a dict or mapping of lowercased
|
2022-06-07 20:22:33 -07:00
|
|
|
|
imprint names to the proper imprint name. Retrieving a value from an
|
2021-08-07 21:50:45 -07:00
|
|
|
|
ImprintDict returns a tuple of (imprint, publisher, keyExists).
|
|
|
|
|
if the key does not exist the key is returned as the publisher unchanged
|
2022-05-19 13:28:18 -07:00
|
|
|
|
"""
|
|
|
|
|
|
2022-07-18 12:17:13 -07:00
|
|
|
|
def __init__(self, publisher: str, mapping: tuple | Mapping = (), **kwargs: dict) -> None:
|
2021-08-07 21:50:45 -07:00
|
|
|
|
super().__init__(mapping, **kwargs)
|
|
|
|
|
self.publisher = publisher
|
|
|
|
|
|
2022-05-19 13:28:18 -07:00
|
|
|
|
def __missing__(self, key: str) -> None:
|
2021-08-07 21:50:45 -07:00
|
|
|
|
return None
|
|
|
|
|
|
2022-05-19 13:28:18 -07:00
|
|
|
|
def __getitem__(self, k: str) -> tuple[str, str, bool]:
|
|
|
|
|
item = super().__getitem__(k.casefold())
|
|
|
|
|
if k.casefold() == self.publisher.casefold():
|
|
|
|
|
return ("", self.publisher, True)
|
2021-08-07 21:50:45 -07:00
|
|
|
|
if item is None:
|
|
|
|
|
return ("", k, False)
|
|
|
|
|
else:
|
|
|
|
|
return (item, self.publisher, True)
|
|
|
|
|
|
2022-06-02 18:32:16 -07:00
|
|
|
|
def copy(self) -> ImprintDict:
|
2022-05-21 00:16:45 -07:00
|
|
|
|
return ImprintDict(self.publisher, super().copy())
|
|
|
|
|
|
2022-05-19 13:28:18 -07:00
|
|
|
|
|
|
|
|
|
publishers: dict[str, ImprintDict] = {}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def load_publishers() -> None:
|
2022-05-19 20:13:59 -07:00
|
|
|
|
try:
|
|
|
|
|
update_publishers(json.loads((pathlib.Path(__file__).parent / "data" / "publishers.json").read_text("utf-8")))
|
|
|
|
|
except Exception:
|
|
|
|
|
logger.exception("Failed to load publishers.json; The are no publishers or imprints loaded")
|