method renamed to match new changes.
This commit is contained in:
parent
bedfb233da
commit
147f9b2ea3
@ -65,13 +65,13 @@ class SevenZipArchiver:
|
|||||||
self.path = path
|
self.path = path
|
||||||
|
|
||||||
# @todo: Implement Comment?
|
# @todo: Implement Comment?
|
||||||
def getArchiveComment(self):
|
def get_comment(self):
|
||||||
return ""
|
return ""
|
||||||
|
|
||||||
def setArchiveComment(self, comment):
|
def set_comment(self, comment):
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def readArchiveFile(self, archive_file):
|
def read_file(self, archive_file):
|
||||||
data = ""
|
data = ""
|
||||||
try:
|
try:
|
||||||
with py7zr.SevenZipFile(self.path, "r") as zf:
|
with py7zr.SevenZipFile(self.path, "r") as zf:
|
||||||
@ -85,22 +85,22 @@ class SevenZipArchiver:
|
|||||||
|
|
||||||
return data
|
return data
|
||||||
|
|
||||||
def removeArchiveFile(self, archive_file):
|
def remove_file(self, archive_file):
|
||||||
try:
|
try:
|
||||||
self.rebuildSevenZipFile([archive_file])
|
self.rebuild_zip_file([archive_file])
|
||||||
except:
|
except:
|
||||||
return False
|
return False
|
||||||
else:
|
else:
|
||||||
return True
|
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
|
# At the moment, no other option but to rebuild the whole
|
||||||
# zip archive w/o the indicated file. Very sucky, but maybe
|
# zip archive w/o the indicated file. Very sucky, but maybe
|
||||||
# another solution can be found
|
# another solution can be found
|
||||||
try:
|
try:
|
||||||
files = self.getArchiveFilenameList()
|
files = self.get_filename_list()
|
||||||
if archive_file in files:
|
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
|
# now just add the archive file as a new one
|
||||||
with py7zr.SevenZipFile(self.path, "a") as zf:
|
with py7zr.SevenZipFile(self.path, "a") as zf:
|
||||||
@ -109,7 +109,7 @@ class SevenZipArchiver:
|
|||||||
except:
|
except:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def getArchiveFilenameList(self):
|
def get_filename_list(self):
|
||||||
try:
|
try:
|
||||||
with py7zr.SevenZipFile(self.path, "r") as zf:
|
with py7zr.SevenZipFile(self.path, "r") as zf:
|
||||||
namelist = zf.getnames()
|
namelist = zf.getnames()
|
||||||
@ -119,7 +119,7 @@ class SevenZipArchiver:
|
|||||||
logger.warning("Unable to get 7zip file list [%s]: %s", e, self.path)
|
logger.warning("Unable to get 7zip file list [%s]: %s", e, self.path)
|
||||||
return []
|
return []
|
||||||
|
|
||||||
def rebuildSevenZipFile(self, exclude_list):
|
def rebuild_zip_file(self, exclude_list):
|
||||||
"""Zip helper func
|
"""Zip helper func
|
||||||
|
|
||||||
This recompresses the zip archive, without the files in the exclude_list
|
This recompresses the zip archive, without the files in the exclude_list
|
||||||
@ -142,12 +142,12 @@ class SevenZipArchiver:
|
|||||||
os.remove(self.path)
|
os.remove(self.path)
|
||||||
os.rename(tmp_name, 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"""
|
"""Replace the current zip with one copied from another archive"""
|
||||||
try:
|
try:
|
||||||
with py7zr.SevenZipFile(self.path, "w") as zout:
|
with py7zr.SevenZipFile(self.path, "w") as zout:
|
||||||
for fname in otherArchive.getArchiveFilenameList():
|
for fname in otherArchive.get_filename_list():
|
||||||
data = otherArchive.readArchiveFile(fname)
|
data = otherArchive.read_file(fname)
|
||||||
if data is not None:
|
if data is not None:
|
||||||
zout.writestr(data, fname)
|
zout.writestr(data, fname)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
@ -152,7 +152,7 @@ class ComicInfoXml:
|
|||||||
assign("LanguageISO", md.language)
|
assign("LanguageISO", md.language)
|
||||||
assign("Format", md.format)
|
assign("Format", md.format)
|
||||||
assign("AgeRating", md.maturity_rating)
|
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("Manga", md.manga)
|
||||||
assign("Characters", md.characters)
|
assign("Characters", md.characters)
|
||||||
assign("Teams", md.teams)
|
assign("Teams", md.teams)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user