version 0.4.10 with a fix for lit files that don't have a TOC.

This commit is contained in:
Kovid Goyal 2007-10-13 20:30:48 +00:00
parent 436df36413
commit 71c2a5d4fc
3 changed files with 18 additions and 14 deletions

View File

@ -13,7 +13,7 @@
## with this program; if not, write to the Free Software Foundation, Inc., ## with this program; if not, write to the Free Software Foundation, Inc.,
## 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. ## 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
''' E-book management software''' ''' E-book management software'''
__version__ = "0.4.9" __version__ = "0.4.10"
__docformat__ = "epytext" __docformat__ = "epytext"
__author__ = "Kovid Goyal <kovid@kovidgoyal.net>" __author__ = "Kovid Goyal <kovid@kovidgoyal.net>"
__appname__ = 'libprs500' __appname__ = 'libprs500'

View File

@ -1607,6 +1607,7 @@ def process_file(path, options, logger=None):
re.compile(fpba[2], re.IGNORECASE)] re.compile(fpba[2], re.IGNORECASE)]
if not hasattr(options, 'anchor_ids'): if not hasattr(options, 'anchor_ids'):
options.anchor_ids = True options.anchor_ids = True
options.use_spine = options.use_spine and options.toc.toc is not None
files = options.spine if options.use_spine else [path] files = options.spine if options.use_spine else [path]
conv = HTMLConverter(book, fonts, options, logger, files) conv = HTMLConverter(book, fonts, options, logger, files)
if options.use_spine: if options.use_spine:

View File

@ -64,6 +64,7 @@ class Spine(list):
class TOC(list): class TOC(list):
def __init__(self, opfreader, cwd): def __init__(self, opfreader, cwd):
self.toc = toc = None
try: try:
toc = opfreader.soup.find('guide').find('reference', attrs={'type':'toc'})['href'] toc = opfreader.soup.find('guide').find('reference', attrs={'type':'toc'})['href']
except: except:
@ -71,10 +72,12 @@ class TOC(list):
if 'toc' in item.href.lower(): if 'toc' in item.href.lower():
toc = item.href toc = item.href
break break
if toc is not None:
toc = urlparse(unquote(toc))[2] toc = urlparse(unquote(toc))[2]
if not os.path.isabs(toc): if not os.path.isabs(toc):
toc = os.path.join(cwd, toc) toc = os.path.join(cwd, toc)
self.toc = toc self.toc = toc
soup = BeautifulSoup(open(toc, 'rb').read(), convertEntities=BeautifulSoup.HTML_ENTITIES) soup = BeautifulSoup(open(toc, 'rb').read(), convertEntities=BeautifulSoup.HTML_ENTITIES)
for a in soup.findAll('a'): for a in soup.findAll('a'):
if not a.has_key('href'): if not a.has_key('href'):