def get_content(module_name="ESV", verse_per_line=False): biblemgr.temporary_state(biblemgr.plainstate) old_expand_crossref = filterutils.filter_settings["footnote_ellipsis_level"] try: book = biblemgr.get_module_book_wrapper(module_name) biblemgr.set_option("Footnotes", True) biblemgr.set_option("Cross-references", True) filterutils.filter_settings["footnote_ellipsis_level"] = 0 content = [] #vk = VK() for bible_book in [bible_book for bible_book in UserVK.books #if len(bible_book.chapters) < N if not RESTRICTED or ( bible_book.bookname in ("Psalms", "Matthew") ) ]:#VK.books: print "Processing", bible_book content.append(get_book(book, bible_book, verse_per_line=verse_per_line)) # if bible_book.bookname == "Genesis": break # if bible_book.bookname == "Joshua": break finally: filterutils.filter_settings["footnote_ellipsis_level"] = old_expand_crossref biblemgr.restore_state() return content
def get_content(module_name="ESV", verse_per_line=False): biblemgr.temporary_state(biblemgr.plainstate) old_expand_crossref = filterutils.filter_settings[ "footnote_ellipsis_level"] try: book = biblemgr.get_module_book_wrapper(module_name) biblemgr.set_option("Footnotes", True) biblemgr.set_option("Cross-references", True) filterutils.filter_settings["footnote_ellipsis_level"] = 0 content = [] #vk = VK() for bible_book in [ bible_book for bible_book in UserVK.books #if len(bible_book.chapters) < N if not RESTRICTED or (bible_book.bookname in ("Psalms", "Matthew")) ]: #VK.books: print "Processing", bible_book content.append( get_book(book, bible_book, verse_per_line=verse_per_line)) # if bible_book.bookname == "Genesis": break # if bible_book.bookname == "Joshua": break finally: filterutils.filter_settings[ "footnote_ellipsis_level"] = old_expand_crossref biblemgr.restore_state() return content
def display_option_changed(option_name, reload_options, options_section): from backend.bibleinterface import biblemgr if option_name in sword_options_map: biblemgr.set_option(sword_options_map[option_name], options_section[option_name]) display_option_changed_observers(option_name, options_section) if reload_options == RELOAD_BIBLE_FRAMES: guiconfig.mainfrm.UpdateBibleUI(settings_changed=True, source=events.SETTINGS_CHANGED) elif reload_options == RELOAD_ALL_FRAMES: guiconfig.mainfrm.refresh_all_pages()
def get_chapter_headings(chapter): """Get chapter headings from the current Bible for a given chapter chapter must be a whole chapter reference, not a verse in the chapter Returns list of (VK, heading text) """ if biblemgr.bible.mod is None: return [] version_headings = headings_cache.setdefault(biblemgr.bible.version, {}) if chapter in version_headings: return version_headings[chapter] # put ourselves into a plain state biblemgr.temporary_state(biblemgr.plainstate) # and turn on headings biblemgr.set_option("Headings", True) vk = EncodedVK(("%s:0" % chapter, chapter), headings=True) mod = biblemgr.bible.mod headings = [] for item in vk: mod.setKey(item) content = to_unicode(mod.RenderText(), mod) # if it was in verse 0, link to verse 1 for now if item.Verse() == 0: item.Verse(1) hs = biblemgr.bible.get_headings(item.getText()) # see comment in book.py for why we are checking if it starts with < # (short version - pre-verse div's) # try to handle pre-verse headings in div's content = '\n'.join(to_unicode(mod.RenderText(heading), mod) for heading, canonical in hs if heading.startswith("<")) + content # and non-div pre-verse headings headings += ((item, to_unicode(mod.RenderText(heading), mod)) for heading, canonical in hs if not heading.startswith("<")) headings += ((item, text) for heading, text in re.findall( '(<h2 class="heading(?: canonical)?">(.*?)</h2>)', content, re.U) if text) biblemgr.restore_state() version_headings[chapter] = headings return headings
def GetText(self, ref): print "Getting text for", ref template = VerseTemplate(header=self.template_panel.header.GetText(), body=self.template_panel.body.GetText(), footer=self.template_panel.footer.GetText()) #no footnotes biblemgr.temporary_state(biblemgr.plainstate) if display_options.options["colour_speakers"] == "woc_in_red": biblemgr.set_option("Words of Christ in Red", "On") #apply template biblemgr.bible.templatelist.append(template) biblemgr.parser_mode = COPY_VERSES_PARSER_MODE data = biblemgr.bible.GetReference(ref) if data is None: data = config.MODULE_MISSING_STRING() if self.formatted: # TODO: make it scan CSS and amalgamate rules? data = data.replace("<span class='WoC'>", "<span style='color: red'>") data = data.replace("<span class='divineName'>", "<span style='font-variant:small-caps'>") # Use the font that has been selected for the module. # XXX: We could still use language specific fonts for particular # sections of the text, but I'm not sure it's worth doing. # It would probably only apply to Hebrew and Greek (which we # treat specially) anyway. default, (font, size, in_gui) = fonts.get_module_font_params( biblemgr.bible.mod) data = u"<span style=\"font-family: %s; font-size: %spt;\">%s</span>" % ( font, size, data) else: data = string_util.br2nl(data) data = string_util.KillTags(data) data = string_util.amps_to_unicode(data) #restore biblemgr.restore_state() biblemgr.bible.templatelist.pop() biblemgr.parser_mode = NORMAL_PARSER_MODE return data
def GetText(self, ref): print "Getting text for", ref template = VerseTemplate(header=self.template_panel.header.GetText(), body=self.template_panel.body.GetText(), footer=self.template_panel.footer.GetText()) #no footnotes biblemgr.temporary_state(biblemgr.plainstate) if display_options.options["colour_speakers"] == "woc_in_red": biblemgr.set_option("Words of Christ in Red", "On") #apply template biblemgr.bible.templatelist.append(template) biblemgr.parser_mode = COPY_VERSES_PARSER_MODE data = biblemgr.bible.GetReference(ref) if data is None: data = config.MODULE_MISSING_STRING() if self.formatted: # TODO: make it scan CSS and amalgamate rules? data = data.replace("<span class='WoC'>", "<span style='color: red'>") data = data.replace("<span class='divineName'>", "<span style='font-variant:small-caps'>") # Use the font that has been selected for the module. # XXX: We could still use language specific fonts for particular # sections of the text, but I'm not sure it's worth doing. # It would probably only apply to Hebrew and Greek (which we # treat specially) anyway. default, (font, size, in_gui) = fonts.get_module_font_params(biblemgr.bible.mod) data = u"<span style=\"font-family: %s; font-size: %spt;\">%s</span>" % (font, size, data) else: data = string_util.br2nl(data) data = string_util.KillTags(data) data = string_util.amps_to_unicode(data) #restore biblemgr.restore_state() biblemgr.bible.templatelist.pop() biblemgr.parser_mode = NORMAL_PARSER_MODE return data