mirror of
https://github.com/apprenticeharper/DeDRM_tools
synced 2025-02-11 20:48:16 +01:00
Fix for Python 3
This commit is contained in:
parent
4d8b5cfa33
commit
4bab58e0fa
2 changed files with 16 additions and 4 deletions
|
@ -473,8 +473,12 @@ class DocParser(object):
|
|||
if (link > 0):
|
||||
linktype = self.link_type[link-1]
|
||||
title = self.link_title[link-1]
|
||||
if (title == b"") or (parares.rfind(title.decode('utf-8')) < 0):
|
||||
title=parares[lstart:].encode('utf-8')
|
||||
if isinstance(title, bytes):
|
||||
if (title == b"") or (parares.rfind(title.decode('utf-8')) < 0):
|
||||
title=parares[lstart:].encode('utf-8')
|
||||
else:
|
||||
if (title == "") or (parares.rfind(title) < 0):
|
||||
title=parares[lstart:]
|
||||
if linktype == 'external' :
|
||||
linkhref = self.link_href[link-1]
|
||||
linkhtml = '<a href="%s">' % linkhref
|
||||
|
@ -485,9 +489,15 @@ class DocParser(object):
|
|||
else :
|
||||
# just link to the current page
|
||||
linkhtml = '<a href="#' + self.id + '">'
|
||||
linkhtml += title.decode('utf-8')
|
||||
if isinstance(title, bytes):
|
||||
linkhtml += title.decode('utf-8')
|
||||
else:
|
||||
linkhtml += title
|
||||
linkhtml += '</a>'
|
||||
pos = parares.rfind(title.decode('utf-8'))
|
||||
if isinstance(title, bytes):
|
||||
pos = parares.rfind(title.decode('utf-8'))
|
||||
else:
|
||||
pos = parares.rfind(title)
|
||||
if pos >= 0:
|
||||
parares = parares[0:pos] + linkhtml + parares[pos+len(title):]
|
||||
else :
|
||||
|
|
|
@ -345,6 +345,8 @@ class TopazBook:
|
|||
for pid in pidlst:
|
||||
# use 8 digit pids here
|
||||
pid = pid[0:8]
|
||||
if isinstance(pid, str):
|
||||
pid = pid.encode('utf-8')
|
||||
print("Trying: {0}".format(pid))
|
||||
bookKeys = []
|
||||
data = keydata
|
||||
|
|
Loading…
Add table
Reference in a new issue