From 147f9b2ea398f6b63fae7568636d404b3b8c716f Mon Sep 17 00:00:00 2001 From: MichaelFitzurka Date: Sun, 3 Apr 2022 15:39:03 -0400 Subject: [PATCH 1/3] method renamed to match new changes. --- comicapi/comicarchive.py | 26 +++++++++++++------------- comicapi/comicinfoxml.py | 2 +- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/comicapi/comicarchive.py b/comicapi/comicarchive.py index 02d84ab..7aeec0c 100644 --- a/comicapi/comicarchive.py +++ b/comicapi/comicarchive.py @@ -65,13 +65,13 @@ class SevenZipArchiver: self.path = path # @todo: Implement Comment? - def getArchiveComment(self): + def get_comment(self): return "" - def setArchiveComment(self, comment): + def set_comment(self, comment): return False - def readArchiveFile(self, archive_file): + def read_file(self, archive_file): data = "" try: with py7zr.SevenZipFile(self.path, "r") as zf: @@ -85,22 +85,22 @@ class SevenZipArchiver: return data - def removeArchiveFile(self, archive_file): + def remove_file(self, archive_file): try: - self.rebuildSevenZipFile([archive_file]) + self.rebuild_zip_file([archive_file]) except: return False else: return True - def writeArchiveFile(self, archive_file, data): + def write_file(self, archive_file, data): # At the moment, no other option but to rebuild the whole # zip archive w/o the indicated file. Very sucky, but maybe # another solution can be found try: - files = self.getArchiveFilenameList() + files = self.get_filename_list() if archive_file in files: - self.rebuildSevenZipFile([archive_file]) + self.rebuild_zip_file([archive_file]) # now just add the archive file as a new one with py7zr.SevenZipFile(self.path, "a") as zf: @@ -109,7 +109,7 @@ class SevenZipArchiver: except: return False - def getArchiveFilenameList(self): + def get_filename_list(self): try: with py7zr.SevenZipFile(self.path, "r") as zf: namelist = zf.getnames() @@ -119,7 +119,7 @@ class SevenZipArchiver: logger.warning("Unable to get 7zip file list [%s]: %s", e, self.path) return [] - def rebuildSevenZipFile(self, exclude_list): + def rebuild_zip_file(self, exclude_list): """Zip helper func This recompresses the zip archive, without the files in the exclude_list @@ -142,12 +142,12 @@ class SevenZipArchiver: os.remove(self.path) os.rename(tmp_name, self.path) - def copyFromArchive(self, otherArchive): + def copy_from_archive(self, otherArchive): """Replace the current zip with one copied from another archive""" try: with py7zr.SevenZipFile(self.path, "w") as zout: - for fname in otherArchive.getArchiveFilenameList(): - data = otherArchive.readArchiveFile(fname) + for fname in otherArchive.get_filename_list(): + data = otherArchive.read_file(fname) if data is not None: zout.writestr(data, fname) except Exception as e: diff --git a/comicapi/comicinfoxml.py b/comicapi/comicinfoxml.py index 10675fc..1533e41 100644 --- a/comicapi/comicinfoxml.py +++ b/comicapi/comicinfoxml.py @@ -152,7 +152,7 @@ class ComicInfoXml: assign("LanguageISO", md.language) assign("Format", md.format) assign("AgeRating", md.maturity_rating) - assign("BlackAndWhite", "Yes" if md.blackAndWhite else None) + assign("BlackAndWhite", "Yes" if md.black_and_white else None) assign("Manga", md.manga) assign("Characters", md.characters) assign("Teams", md.teams) From d16f6af137e40ca20d72563ceadf114e464390b2 Mon Sep 17 00:00:00 2001 From: MichaelFitzurka Date: Sun, 3 Apr 2022 15:44:20 -0400 Subject: [PATCH 2/3] Bookmark functionality. Fixes #212. --- comicapi/comicinfoxml.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/comicapi/comicinfoxml.py b/comicapi/comicinfoxml.py index 1533e41..0858d66 100644 --- a/comicapi/comicinfoxml.py +++ b/comicapi/comicinfoxml.py @@ -168,7 +168,7 @@ class ComicInfoXml: for page_dict in md.pages: page_node = ET.SubElement(pages_node, "Page") - page_node.attrib = page_dict + page_node.attrib = dict(sorted(page_dict.items())) utils.indent(root) From c2768c160bbb853beaee08db6fbfe6cebd58e997 Mon Sep 17 00:00:00 2001 From: MichaelFitzurka Date: Sun, 3 Apr 2022 16:50:27 -0400 Subject: [PATCH 3/3] Empty metadata should not assign an empty tag. --- comicapi/comicinfoxml.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/comicapi/comicinfoxml.py b/comicapi/comicinfoxml.py index 0858d66..0079f2b 100644 --- a/comicapi/comicinfoxml.py +++ b/comicapi/comicinfoxml.py @@ -67,7 +67,7 @@ class ComicInfoXml: # helper func def assign(cix_entry, md_entry): - if md_entry is not None: + if md_entry is not None and md_entry: et_entry = root.find(cix_entry) if et_entry is not None: et_entry.text = str(md_entry)