Make it easy to test the index generating code with an env var

This commit is contained in:
Kovid Goyal 2014-03-30 22:06:20 +05:30
parent c2d94d518f
commit 914b45edc3

View File

@ -28,11 +28,11 @@ from calibre.ebooks.docx.theme import Theme
from calibre.ebooks.docx.toc import create_toc from calibre.ebooks.docx.toc import create_toc
from calibre.ebooks.docx.fields import Fields from calibre.ebooks.docx.fields import Fields
from calibre.ebooks.docx.settings import Settings from calibre.ebooks.docx.settings import Settings
# from calibre.ebooks.docx.index import Index
from calibre.ebooks.metadata.opf2 import OPFCreator from calibre.ebooks.metadata.opf2 import OPFCreator
from calibre.utils.localization import canonicalize_lang, lang_as_iso639_1 from calibre.utils.localization import canonicalize_lang, lang_as_iso639_1
NBSP = '\xa0' NBSP = '\xa0'
TEST_INDEX = 'CALIBRE_TEST_INDEX' in os.environ
class Text: class Text:
@ -99,10 +99,9 @@ class Convert(object):
self.log.debug('Converting Word markup to HTML') self.log.debug('Converting Word markup to HTML')
# If we are doing an index, do the body part of the processing here. if TEST_INDEX:
# We need to insert bookmarks at the indexed locations before the from calibre.ebooks.docx.index import Index
# main conversion work. self.index = Index(self.fields)
# index = Index(self)
self.read_page_properties(doc) self.read_page_properties(doc)
self.current_rels = relationships_by_id self.current_rels = relationships_by_id
@ -169,8 +168,8 @@ class Convert(object):
self.resolve_links() self.resolve_links()
# For an index, we now want to append the index object if TEST_INDEX:
# index.generate() self.index.generate()
self.styles.cascade(self.layers) self.styles.cascade(self.layers)