Merge pull request #1445 from ableeker/python3
Some more fixes for ePub
This commit is contained in:
commit
bf6170e613
|
@ -66,21 +66,21 @@ class fixZip:
|
||||||
|
|
||||||
def uncompress(self, cmpdata):
|
def uncompress(self, cmpdata):
|
||||||
dc = zlib.decompressobj(-15)
|
dc = zlib.decompressobj(-15)
|
||||||
data = ''
|
data = b''
|
||||||
while len(cmpdata) > 0:
|
while len(cmpdata) > 0:
|
||||||
if len(cmpdata) > _MAX_SIZE :
|
if len(cmpdata) > _MAX_SIZE :
|
||||||
newdata = cmpdata[0:_MAX_SIZE]
|
newdata = cmpdata[0:_MAX_SIZE]
|
||||||
cmpdata = cmpdata[_MAX_SIZE:]
|
cmpdata = cmpdata[_MAX_SIZE:]
|
||||||
else:
|
else:
|
||||||
newdata = cmpdata
|
newdata = cmpdata
|
||||||
cmpdata = ''
|
cmpdata = b''
|
||||||
newdata = dc.decompress(newdata)
|
newdata = dc.decompress(newdata)
|
||||||
unprocessed = dc.unconsumed_tail
|
unprocessed = dc.unconsumed_tail
|
||||||
if len(unprocessed) == 0:
|
if len(unprocessed) == 0:
|
||||||
newdata += dc.flush()
|
newdata += dc.flush()
|
||||||
data += newdata
|
data += newdata
|
||||||
cmpdata += unprocessed
|
cmpdata += unprocessed
|
||||||
unprocessed = ''
|
unprocessed = b''
|
||||||
return data
|
return data
|
||||||
|
|
||||||
def getfiledata(self, zi):
|
def getfiledata(self, zi):
|
||||||
|
@ -123,7 +123,7 @@ class fixZip:
|
||||||
mimeinfo.internal_attr = 1 # text file
|
mimeinfo.internal_attr = 1 # text file
|
||||||
try:
|
try:
|
||||||
# if the mimetype is present, get its info, including time-stamp
|
# if the mimetype is present, get its info, including time-stamp
|
||||||
oldmimeinfo = self.inzip.getinfo('mimetype')
|
oldmimeinfo = self.inzip.getinfo(b'mimetype')
|
||||||
# copy across useful fields
|
# copy across useful fields
|
||||||
mimeinfo.date_time = oldmimeinfo.date_time
|
mimeinfo.date_time = oldmimeinfo.date_time
|
||||||
mimeinfo.comment = oldmimeinfo.comment
|
mimeinfo.comment = oldmimeinfo.comment
|
||||||
|
@ -137,7 +137,7 @@ class fixZip:
|
||||||
|
|
||||||
# write the rest of the files
|
# write the rest of the files
|
||||||
for zinfo in self.inzip.infolist():
|
for zinfo in self.inzip.infolist():
|
||||||
if zinfo.filename != "mimetype" or self.ztype != 'epub':
|
if zinfo.filename != b"mimetype" or self.ztype != 'epub':
|
||||||
data = None
|
data = None
|
||||||
try:
|
try:
|
||||||
data = self.inzip.read(zinfo.filename)
|
data = self.inzip.read(zinfo.filename)
|
||||||
|
|
Loading…
Reference in New Issue