mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-07 10:14:46 -04:00
pep8
This commit is contained in:
parent
8179235f2d
commit
23f0256db7
@ -26,4 +26,3 @@
|
|||||||
__all__ = ["chm", "chmlib", "_chmlib", "extra"]
|
__all__ = ["chm", "chmlib", "_chmlib", "extra"]
|
||||||
__version__ = "0.8.4"
|
__version__ = "0.8.4"
|
||||||
__revision__ = "$Id: __init__.py,v 1.8 2006/06/18 10:50:43 rubensr Exp $"
|
__revision__ = "$Id: __init__.py,v 1.8 2006/06/18 10:50:43 rubensr Exp $"
|
||||||
|
|
||||||
|
@ -210,11 +210,11 @@ class CHMFile:
|
|||||||
such as the index file name and the topics file. It returns 1 on
|
such as the index file name and the topics file. It returns 1 on
|
||||||
success, and 0 if it fails.
|
success, and 0 if it fails.
|
||||||
'''
|
'''
|
||||||
if (self.filename is not None):
|
if self.filename is not None:
|
||||||
self.CloseCHM()
|
self.CloseCHM()
|
||||||
|
|
||||||
self.file = chmlib.chm_open(archiveName)
|
self.file = chmlib.chm_open(archiveName)
|
||||||
if (self.file is None):
|
if self.file is None:
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
self.filename = archiveName
|
self.filename = archiveName
|
||||||
@ -227,7 +227,7 @@ class CHMFile:
|
|||||||
This function will close the CHM file, if it is open. All variables
|
This function will close the CHM file, if it is open. All variables
|
||||||
are also reset.
|
are also reset.
|
||||||
'''
|
'''
|
||||||
if (self.filename is not None):
|
if self.filename is not None:
|
||||||
chmlib.chm_close(self.file)
|
chmlib.chm_close(self.file)
|
||||||
self.file = None
|
self.file = None
|
||||||
self.filename = ''
|
self.filename = ''
|
||||||
@ -265,32 +265,32 @@ class CHMFile:
|
|||||||
while (index < size):
|
while (index < size):
|
||||||
cursor = buff[index] + (buff[index+1] * 256)
|
cursor = buff[index] + (buff[index+1] * 256)
|
||||||
|
|
||||||
if (cursor == 0):
|
if cursor == 0:
|
||||||
index += 2
|
index += 2
|
||||||
cursor = buff[index] + (buff[index+1] * 256)
|
cursor = buff[index] + (buff[index+1] * 256)
|
||||||
index += 2
|
index += 2
|
||||||
self.topics = '/' + text[index:index+cursor-1]
|
self.topics = '/' + text[index:index+cursor-1]
|
||||||
elif (cursor == 1):
|
elif cursor == 1:
|
||||||
index += 2
|
index += 2
|
||||||
cursor = buff[index] + (buff[index+1] * 256)
|
cursor = buff[index] + (buff[index+1] * 256)
|
||||||
index += 2
|
index += 2
|
||||||
self.index = '/' + text[index:index+cursor-1]
|
self.index = '/' + text[index:index+cursor-1]
|
||||||
elif (cursor == 2):
|
elif cursor == 2:
|
||||||
index += 2
|
index += 2
|
||||||
cursor = buff[index] + (buff[index+1] * 256)
|
cursor = buff[index] + (buff[index+1] * 256)
|
||||||
index += 2
|
index += 2
|
||||||
self.home = '/' + text[index:index+cursor-1]
|
self.home = '/' + text[index:index+cursor-1]
|
||||||
elif (cursor == 3):
|
elif cursor == 3:
|
||||||
index += 2
|
index += 2
|
||||||
cursor = buff[index] + (buff[index+1] * 256)
|
cursor = buff[index] + (buff[index+1] * 256)
|
||||||
index += 2
|
index += 2
|
||||||
self.title = text[index:index+cursor-1]
|
self.title = text[index:index+cursor-1]
|
||||||
elif (cursor == 4):
|
elif cursor == 4:
|
||||||
index += 2
|
index += 2
|
||||||
cursor = buff[index] + (buff[index+1] * 256)
|
cursor = buff[index] + (buff[index+1] * 256)
|
||||||
index += 2
|
index += 2
|
||||||
self.lcid = buff[index] + (buff[index+1] * 256)
|
self.lcid = buff[index] + (buff[index+1] * 256)
|
||||||
elif (cursor == 6):
|
elif cursor == 6:
|
||||||
index += 2
|
index += 2
|
||||||
cursor = buff[index] + (buff[index+1] * 256)
|
cursor = buff[index] + (buff[index+1] * 256)
|
||||||
index += 2
|
index += 2
|
||||||
@ -300,13 +300,13 @@ class CHMFile:
|
|||||||
tmp2 = '/' + tmp + '.hhk'
|
tmp2 = '/' + tmp + '.hhk'
|
||||||
res1, ui1 = chmlib.chm_resolve_object(self.file, tmp1)
|
res1, ui1 = chmlib.chm_resolve_object(self.file, tmp1)
|
||||||
res2, ui2 = chmlib.chm_resolve_object(self.file, tmp2)
|
res2, ui2 = chmlib.chm_resolve_object(self.file, tmp2)
|
||||||
if (not self.topics) and \
|
if not self.topics and \
|
||||||
(res1 == chmlib.CHM_RESOLVE_SUCCESS):
|
res1 == chmlib.CHM_RESOLVE_SUCCESS:
|
||||||
self.topics = '/' + tmp + '.hhc'
|
self.topics = '/' + tmp + '.hhc'
|
||||||
if (not self.index) and \
|
if not self.index and \
|
||||||
(res2 == chmlib.CHM_RESOLVE_SUCCESS):
|
res2 == chmlib.CHM_RESOLVE_SUCCESS:
|
||||||
self.index = '/' + tmp + '.hhk'
|
self.index = '/' + tmp + '.hhk'
|
||||||
elif (cursor == 16):
|
elif cursor == 16:
|
||||||
index += 2
|
index += 2
|
||||||
cursor = buff[index] + (buff[index+1] * 256)
|
cursor = buff[index] + (buff[index+1] * 256)
|
||||||
index += 2
|
index += 2
|
||||||
@ -329,7 +329,7 @@ class CHMFile:
|
|||||||
This auxiliary function reads and returns the topics tree file
|
This auxiliary function reads and returns the topics tree file
|
||||||
contents for the CHM archive.
|
contents for the CHM archive.
|
||||||
'''
|
'''
|
||||||
if (self.topics is None):
|
if self.topics is None:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
if self.topics:
|
if self.topics:
|
||||||
@ -338,7 +338,7 @@ class CHMFile:
|
|||||||
return None
|
return None
|
||||||
|
|
||||||
size, text = chmlib.chm_retrieve_object(self.file, ui, 0, ui.length)
|
size, text = chmlib.chm_retrieve_object(self.file, ui, 0, ui.length)
|
||||||
if (size == 0):
|
if size == 0:
|
||||||
sys.stderr.write('GetTopicsTree: file size = 0\n')
|
sys.stderr.write('GetTopicsTree: file size = 0\n')
|
||||||
return None
|
return None
|
||||||
return text
|
return text
|
||||||
|
Loading…
x
Reference in New Issue
Block a user