Code cleanup
This commit is contained in:
parent
35669dd1e3
commit
c4b4dbcfeb
@ -135,8 +135,8 @@ class SevenZipArchiver:
|
|||||||
os.close(tmp_fd)
|
os.close(tmp_fd)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
with py7zr.SevenZipFile(self.path, "r") as zip:
|
with py7zr.SevenZipFile(self.path, "r") as zin:
|
||||||
targets = [f for f in zip.getnames() if f not in exclude_list]
|
targets = [f for f in zin.getnames() if f not in exclude_list]
|
||||||
with py7zr.SevenZipFile(self.path, "r") as zin:
|
with py7zr.SevenZipFile(self.path, "r") as zin:
|
||||||
with py7zr.SevenZipFile(tmp_name, "w") as zout:
|
with py7zr.SevenZipFile(tmp_name, "w") as zout:
|
||||||
for fname, bio in zin.read(targets).items():
|
for fname, bio in zin.read(targets).items():
|
||||||
|
@ -89,7 +89,7 @@ class FileNameParser:
|
|||||||
# is the series name followed by issue
|
# is the series name followed by issue
|
||||||
filename = re.sub(r"--.*", self.repl, filename)
|
filename = re.sub(r"--.*", self.repl, filename)
|
||||||
|
|
||||||
elif "__" in filename and not re.search(r"\[__\d+__\]", filename):
|
elif "__" in filename and not re.search(r"\[__\d+__]", filename):
|
||||||
# the pattern seems to be that anything to left of the first "__"
|
# the pattern seems to be that anything to left of the first "__"
|
||||||
# is the series name followed by issue
|
# is the series name followed by issue
|
||||||
filename = re.sub(r"__.*", self.repl, filename)
|
filename = re.sub(r"__.*", self.repl, filename)
|
||||||
|
@ -21,6 +21,7 @@ possible, however lossy it might be
|
|||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
|
|
||||||
import logging
|
import logging
|
||||||
|
from enum import Enum
|
||||||
from typing import List, TypedDict
|
from typing import List, TypedDict
|
||||||
|
|
||||||
from comicapi import utils
|
from comicapi import utils
|
||||||
@ -28,7 +29,7 @@ from comicapi import utils
|
|||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
class PageType:
|
class PageType(Enum):
|
||||||
|
|
||||||
"""
|
"""
|
||||||
These page info classes are exactly the same as the CIX scheme, since
|
These page info classes are exactly the same as the CIX scheme, since
|
||||||
@ -48,7 +49,7 @@ class PageType:
|
|||||||
Deleted = "Deleted"
|
Deleted = "Deleted"
|
||||||
|
|
||||||
|
|
||||||
class ImageMetadata(TypedDict):
|
class ImageMetadata(TypedDict, total=False):
|
||||||
Type: PageType
|
Type: PageType
|
||||||
Bookmark: str
|
Bookmark: str
|
||||||
DoublePage: bool
|
DoublePage: bool
|
||||||
@ -213,8 +214,7 @@ class GenericMetadata:
|
|||||||
def set_default_page_list(self, count):
|
def set_default_page_list(self, count):
|
||||||
# generate a default page list, with the first page marked as the cover
|
# generate a default page list, with the first page marked as the cover
|
||||||
for i in range(count):
|
for i in range(count):
|
||||||
page_dict = {}
|
page_dict = ImageMetadata(Image=i)
|
||||||
page_dict["Image"] = str(i)
|
|
||||||
if i == 0:
|
if i == 0:
|
||||||
page_dict["Type"] = PageType.FrontCover
|
page_dict["Type"] = PageType.FrontCover
|
||||||
self.pages.append(page_dict)
|
self.pages.append(page_dict)
|
||||||
@ -241,11 +241,7 @@ class GenericMetadata:
|
|||||||
|
|
||||||
def add_credit(self, person, role, primary=False):
|
def add_credit(self, person, role, primary=False):
|
||||||
|
|
||||||
credit = {}
|
credit: CreditMetadata = {"person": person, "role": role, "primary": primary}
|
||||||
credit["person"] = person
|
|
||||||
credit["role"] = role
|
|
||||||
if primary:
|
|
||||||
credit["primary"] = primary
|
|
||||||
|
|
||||||
# look to see if it's not already there...
|
# look to see if it's not already there...
|
||||||
found = False
|
found = False
|
||||||
|
Loading…
x
Reference in New Issue
Block a user