def get(self, passage): if not passage: self.redirect("/") refsearch = scriptures.extract(passage) data = [] par = [] if refsearch: ref = refsearch[0] book_name = ( ref[0] .replace("III ", "3 ") .replace("II ", "2 ") .replace("I ", "1 ") .replace("Revelation of Jesus Christ", "Revelation") ) self.cur.execute("select id, section from books where value = %s", (book_name,)) d = self.cur.fetchone() book_id = d["id"] testament = d["section"] if testament == "NT": version_id = 3 else: version_id = 4 startchap = ref[1] endchap = ref[3] startverse = ref[2] endverse = ref[4] startfullref = scriptures.reference_to_string(book_name, startchap, startverse) endfullref = scriptures.reference_to_string(book_name, endchap, endverse) startfullref = startfullref.replace("Revelation of Jesus Christ", "Revelation") endfullref = endfullref.replace("Revelation of Jesus Christ", "Revelation") startfullref = startfullref.replace("III ", "3 ").replace("II ", "2 ").replace("I ", "1 ") endfullref = endfullref.replace("III ", "3 ").replace("II ", "2 ").replace("I ", "1 ") if ":" in startfullref and ":" in endfullref: if len(startfullref) - (startfullref.index(":") + 1) == 1: startfullref = startfullref.replace(":", ":0") if len(endfullref) - (endfullref.index(":") + 1) == 1: endfullref = endfullref.replace(":", ":0") sql = "select * from verse where version_id = 1 and searchreftext between %s and %s order by searchref asc;" self.cur.execute(sql, (startfullref, endfullref)) data = self.cur.fetchall() sql = "select max(searchref) stopref, min(searchref) startref from verse where searchreftext between %s and %s" self.cur.execute(sql, (startfullref, endfullref)) d = self.cur.fetchall() startref = d[0]["startref"] stopref = d[0]["stopref"] sql = "select distinct link, title from se_link where searchref between %s and %s" self.cur.execute(sql, (startref, stopref)) par = self.cur.fetchall() self.render("stack.html", passage=passage, data=data, par=par, version_id=version_id)
def get(self, passage, version_id): if not passage: self.redirect("/") ref = scriptures.extract(passage)[0] book_name = ref[0].replace("I ", "1 ").replace("II ", "2 ").replace("III ", "3") startchap = ref[1] endchap = ref[3] startverse = ref[2] endverse = ref[4] version_id = self.get_argument("version_id", None) startfullref = scriptures.reference_to_string(book_name, startchap, startverse) endfullref = scriptures.reference_to_string(book_name, endchap, endverse) startfullref = startfullref.replace("Revelation of Jesus Christ", "Revelation") endfullref = endfullref.replace("Revelation of Jesus Christ", "Revelation") if len(startfullref) - (startfullref.index(":") + 1) == 1: startfullref = startfullref.replace(":", ":0") if len(endfullref) - (endfullref.index(":") + 1) == 1: endfullref = endfullref.replace(":", ":0") print startfullref, endfullref if version_id: sql = "select reference, chapter_num, verse_num, version_id, analysis_text from verse where version_id = %s and searchreftext between %s and %s order by searchref asc, version_id desc;" self.cur.execute(sql, (version_id, startfullref, endfullref)) else: sql = "select reference, chapter_num, verse_num, version_id, analysis_text from verse where searchreftext between %s and %s order by searchref asc, version_id desc;" self.cur.execute(sql, (startfullref, endfullref)) # self.cur.execute(sql, (version_id, startfullref,endfullref)) data = self.cur.fetchall() versedata = [] for p in data: versedata.append( { "reference": p["reference"], "chapter": p["chapter_num"], "verse": p["verse_num"], "version_id": p["version_id"], #'text': p['display_text'], "words": p["analysis_text"].split(" "), } ) # print len(words) """versedata = [] sql = "select * from worddetailsbyword(%s)" for verse in data: words = verse['analysis_text'].split(' ') for word in words: self.cur.execute(sql, (word,)) versedata.append(self.cur.fetchone()) """ self.render("analyze.html", passage=passage, versedata=versedata)
def f(txt): """ accept a string containing a scripture reference, normalize it, and then return the reformatted string """ return reference_to_string( *normalize_reference(*scripture_re.match(txt).groups()))
def _set_headings(self): self.headings = False return try: headings = self.soup.find_all( "div", class_="result-text-style-normal")[0].find_all("h3") first_element = self.soup.find_all( "div", class_="result-text-style-normal")[0].find_all()[0] if first_element.name != "h3": new_heading = self._get_previous_heading() if new_heading: headings = [new_heading] + headings formatted_headings = [] for heading in headings: span = heading.find_next("span") classes = span.get_attribute_list("class") try: classes.remove("text") except ValueError: pass passage = classes[0].split("-") passage = "{} {}:{}".format(passage[0], passage[1], passage[2]) passage = scriptures.extract(passage)[0] passage = scriptures.reference_to_string(*passage) formatted_headings.append((passage, heading.string)) return formatted_headings except Exception as e: print(e) return None
def format_reading(self, book, passage): if book == "Canticle": canticle_class = self.get_canticle_class(passage) return canticle_class.citation passage = "{} {}".format(book, passage) if book == "Ps": return passage.replace("Ps", "Psalms") references = scriptures.extract(passage) if not references: return passage result = [] for i, reference in enumerate(references): print(reference) string = scriptures.reference_to_string(*reference) print(string) if i == 0: result.append(string) elif reference[1] == references[ i - 1][1] and reference[1] == reference[3]: result.append("{}-{}".format(reference[2], reference[4])) elif reference[1] != references[ i - 1][1] and reference[1] == reference[3]: result.append("{}:{}-{}".format(reference[1], reference[2], reference[4])) elif reference[1] != reference[3]: result.append("{}:{}-{}:{}".format(reference[1], reference[2], reference[3], reference[4])) return ", ".join(result)
def get_passage(self, book, passage, reading_type): if book == "Canticle": canticle = self.get_canticle_class(passage) return "<h3>{}</h3><h4>{}</h4>{}<h5>{}</h5>".format( canticle.latin_name, canticle.english_name, canticle().content, canticle.citation) if reading_type == "psalm": passage = passage.replace("Psalms ", "") psalm = parse_single_psalm(passage) return get_psalms(psalm) passage = "{} {}".format(book, passage) if book == "Ps": return passage.replace("Ps", "Psalms") references = scriptures.extract(passage) passages = [] for reference in references: passage = scriptures.reference_to_string(*reference) try: passages.append(Passage(passage, source="esv").html) except PassageNotFoundException: try: passages.append(Passage(passage, source="rsv").html) except PassageNotFoundException: pass return "<br>".join(passages)
def parse_passage(self, passage): try: passage = scriptures.extract(passage)[0] return scriptures.reference_to_string(*passage) except: return None
def f(txt): """ accept a string containing a scripture reference, normalize it, and then return the reformatted string """ return reference_to_string(*normalize_reference( *scripture_re.match(txt).groups()))
def BibleBot(): while True: readbuffer = readBuffer + s.recv(1024) temp = string.split(readbuffer, "\n") readbuffer = temp.pop() for line in temp: print(line) if "PING" in line: #looks for twitch's ping and sends response back s.send(line.replace("PING", "PONG")) break user = getUser(line) message = getMessage(line) print(user) + " typed: " + message try: if "!verse" in message: #looks for !verse command in twitch chat scriptFind = message.split() book, chapter, verse = scriptFind[1], scriptFind[2], scriptFind[3] passage = scriptures.reference_to_string(bookname=book, chapter=chapter, verse=verse) scripture = str(biblegateway.biblegateway_api.get_passage(passage, ui.VERSION)) sendMessage(s, passage + " (" + ui.VERSION + "): "+ scripture) time.sleep(CMDDELAY) elif "!votd" in message: #looks for votd command in twitch chat votd = biblegateway.biblegateway_api.jsonText votdRef = biblegateway.biblegateway_api.jsonRef sendMessage(s, "Verse of the Day: " + votdRef + " (" + ui.VERSION + "): "+ votd) time.sleep(CMDDELAY) elif "!biblebot" in message: sendMessage(s, HELP) else: pass except Exception: logging.exception('Error: ') pass
def getBiblePassages(self, sermon): text = self.extractor.text() lines = text.splitlines() i = 0 for line in lines: passages = scriptures.extract(line) if passages: if i < 4: i = i + 1 book = passages[0][0] segments = [] texts = [] for passage in passages: texts.append(Passage(scriptures.reference_to_string(*passage)).text) segments.append("{}:{}-{}:{}".format(passage[1], passage[2], passage[3], passage[4])) texts = list(filter(lambda x: x is not None, texts)) text = " ".join(texts) segments = " ".join(segments) quote = "{} {}".format(book, segments) book = book.lower() if book in ["psalms"]: book_type = SermonBiblePassage.PSALM elif book in ["matthew", "mark", "luke", "john"]: book_type = SermonBiblePassage.GOSPEL elif book in [ "acts", "romans", "1 corinthians", "2 corinthians", "galatians", "ephesians", "philippians", "colossians", "1 thessalonians", "2 thessalonians", "1 timothy", "2 timothy", "titus", "philemon", "hebrews", "james", "1 peter", "2 peter", "1 john", "2 john", "3 john", "jude", "revelation", ]: book_type = SermonBiblePassage.EPISTLE else: book_type = SermonBiblePassage.PROPHECY SermonBiblePassage.objects.create( type=book_type, text=text, html=text, passage=quote, version="nrsv", sermon=sermon )
def get(self,passage): ''' TO DO !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! verify that the top and bottom constraints are REAL passages ''' if not passage: self.redirect("/") refsearch = scriptures.extract(passage) if refsearch: ref = refsearch[0] book_name = ref[0] cursor = yield gen.Task(self.db.execute, "select id, section from books where value = %s", (book_name,)) book_id,testament = cursor.fetchone() if testament == 'NT': version_id = 3 else: version_id = 4 startchap = ref[1] endchap = ref[3] startverse = ref[2] endverse = ref[4] startfullref = scriptures.reference_to_string(book_name,startchap,startverse) endfullref = scriptures.reference_to_string(book_name,endchap,endverse) '''if ':' in startfullref and ':' in endfullref: if len(startfullref) - (startfullref.index(':') + 1) == 1: startfullref = startfullref.replace(':',':0') if len(endfullref) - (endfullref.index(':') + 1) == 1: endfullref = endfullref.replace(':',':0') sql = "select id,verse_num,display_text from verse where version_id = 1 and searchreftext between %s and %s order by searchref asc;" cursor = yield gen.Task(self.db.execute,sql, (startfullref, endfullref)) data = cursor.fetchall() sql = "select id,verse_num,display_text from verse where version_id = %s and searchreftext between %s and %s order by searchref asc;" cursor = yield gen.Task(self.db.execute, sql, (startfullref, endfullref)) par = cursor.fetchall() ''' cursors = yield gen.Task(self.db.batch, { 'LEB': ["select * from getdisplayverses(1,%s,%s);", (startfullref, endfullref)], 'PAR': ["select * from getanalysisverses(%s,%s,%s);", (version_id,startfullref, endfullref)] }) results = {} for key, cursor in cursors.items(): results[key] = cursor.fetchall() self.render('read.html', passage=passage, verses=results, version_id=version_id)
def f(txt): """ accept a string containing a scripture reference, normalize it, and then return the reformatted string """ #print("parsing {}".format(txt)) res = reference_to_string( *normalize_reference(*scripture_re.match(txt).groups())) #print("...yielded {}".format(res)) return res
def bible(components): spec = components['arguments'].split('!bible ')[1] refs = scriptures.extract(spec) if len(refs) == 0: return '' response = '' verse_length = 0 for r in refs: start_string = scriptures.reference_to_string(r[0], r[1], r[2], r[1], r[2]) end_string = scriptures.reference_to_string(r[0], r[3], r[4], r[3], r[4]) verse_length = verse_length + len(Passage(start_string, end_string)) if verse_length > 5: return 'Could not fetch verses: length of passage too long'.encode('utf8') vs = GetPassage(r) response = '%(old_resp)s%(spec)s (ESV)\r\n%(verses)s\r\n' % { 'old_resp': response, 'spec': scriptures.reference_to_string(r[0], r[1], r[2], r[3], r[4]), 'verses': vs } return response.encode('utf8')
def name(self): tags = '' if len(self.topics) > 0: tags = ' ({})'.format(', '.join(self.topics)) prefix = '' if self.kids: prefix = '*' n = prefix + scriptures.reference_to_string( self.book, self.chap1, self.verse1, self.chapN, self.verseN) + tags n = n.replace(' of Jesus Christ', '') return n
def get(self,passage): if not passage: self.redirect("/") refsearch = scriptures.extract(passage) if refsearch: ref = refsearch[0] book_name = ref[0] cursor = yield gen.Task(self.db.execute, "select id, section from books where value = %s", (book_name,)) book_id,testament = cursor.fetchone() if testament == 'NT': version_id = 3 else: version_id = 4 startchap = ref[1] endchap = ref[3] startverse = ref[2] endverse = ref[4] startfullref = scriptures.reference_to_string(book_name,startchap,startverse) endfullref = scriptures.reference_to_string(book_name,endchap,endverse) if ':' in startfullref and ':' in endfullref: if len(startfullref) - (startfullref.index(':') + 1) == 1: startfullref = startfullref.replace(':',':0') if len(endfullref) - (endfullref.index(':') + 1) == 1: endfullref = endfullref.replace(':',':0') cursor = yield gen.Task(self.db.execute,"select max(searchref) stopref, min(searchref) startref from verse where searchreftext between %s and %s", (startfullref, endfullref)) stopref, startref = cursor.fetchone() cursors = yield gen.Task(self.db.batch, { 'LEB': ["select id,verse_num,display_text from verse where version_id = 1 and searchreftext between %s and %s order by searchref asc;",(startfullref, endfullref)], 'PAR': ["select distinct link, title from se_link where searchref between %s and %s", (startref,stopref)] }) results = {} for key, cursor in cursors.items(): results[key] = cursor.fetchall() self.render('stack.html', passage=passage, verses=results, version_id = version_id)
def getPassage(scripture_inp, version='KJV'): # check if the scripture is valid scripture = scriptures.extract(scripture_inp) # [(book, startBook, startVerse, endBook, endVerse ] if scripture == []: print("Your input is invalid, check please") else: script_str = scriptures.reference_to_string(*scripture[0]) url_open = urllib.quote(script_str.encode("utf-8")) url = "http://mobile.biblegateway.com/passage/?search="+url_open+\ "&version="+version+"\&interface=print" passage_raw = PyQuery(url) passage = passage_raw(".passage").remove("h3").find('[class^="text"]').\ remove(".chapternum").\ remove(".crossrefs").remove(".footnote") passage = passage.text().encode("utf-8") return passage
def __init__(self, passage, version="nrsv"): self.version = version # try: self.reference = scriptures.extract(passage)[0] self.passage = scriptures.reference_to_string(*self.reference) self.passage = self.passage.replace("III ", "3 ") self.passage = self.passage.replace("II ", "2 ") self.passage = self.passage.replace("I ", "1 ") # except Exception as e: # print(e) # self.text = "" # self.html = "" # self.headings = [] # return self.markup = self._get_markup() self.soup = BeautifulSoup(self.markup, "html5lib") self.html = self._set_html() self.text = self._set_text() self.headings = self._set_headings()
print(line) if "PING" in line: #looks for twitch's ping and sends response back s.send(line.replace("PING", "PONG")) break user = getUser(line) message = getMessage(line) print(user) + " typed: " + message try: if "!verse niggalations 4 20" in message: sendMessage(s, "Haha, Nice try.") elif "!verse" in message: #looks for !verse command in twitch chat scriptFind = message.split() book, chapter, verse = scriptFind[1], scriptFind[ 2], scriptFind[3] passage = scriptures.reference_to_string(bookname=book, chapter=chapter, verse=verse) scripture = str( biblegateway_api.get_passage( passage, VERSION, )) sendMessage(s, passage + " (" + VERSION + "): " + scripture) time.sleep(CMDDELAY) elif "!votd" in message: #looks for votd command in twitch chat votd = biblegateway_api.getVotd(VERSION) sendMessage(s, votd) time.sleep(CMDDELAY) except IndentationError: sendMessage( s, "I'm sorry, " + user +
from pdfminer.high_level import extract_text import scriptures import re import os questionPath = '/media/data/data/Media/BSF/2020-2021/Adult Questions' for filename in sorted(os.listdir(questionPath)): text = extract_text(f'{questionPath}/{filename}') p = re.compile('Lesson \d+') lesson = p.findall(text)[0] print(f'## {lesson}') verses = scriptures.extract(text) for verse in verses: str = scriptures.reference_to_string(verse[0], verse[1], verse[2], verse[3], verse[4]) str = str.replace('Revelation of Jesus Christ', 'Revelation') urlStr = str.replace(' ', '+').replace(':', '%3A') url = f'https://www.biblegateway.com/passage/?search={urlStr}&version=NLT&interface=print' print(f'- [{str}]({url})')
def GetVerseString(verse): str = scriptures.reference_to_string(verse[0], verse[1], verse[2], verse[3], verse[4]) return str.replace('Revelation of Jesus Christ', 'Revelation')
for ref in refs: if ref[1] == ref[3]: book = ref[0] book_db = book.replace('III ','3 ').replace('II ','2 ').replace('I ','1 ').replace('Revelation of Jesus Christ','Revelation') startchap = ref[1] startverse = ref[2] endchap = ref[3] endverse = ref[4] #reference = scriptures.reference_to_string(book,startchap,startverse,endchap,endverse) for verse in range(startverse,endverse+1): if scriptures.is_valid_reference(book, startchap, verse): notes.add({ 'question_id': question[0], 'link':question[1], 'reference': scriptures.reference_to_string(book, startchap, verse ).replace('III ','3 ').replace('II ','2 ').replace('I ','1 ').replace('Revelation of Jesus Christ','Revelation') }) else: print ref '''book = ref[0] book_db = book.replace('III ','3 ').replace('II ','2 ').replace('I ','1 ') startchap = ref[1] startverse = ref[2] endchap = ref[3] endverse = ref[4] reference = scriptures.reference_to_string(book,startchap,startverse,endchap,endverse) maxverse = endverse chapter = endchap cur.execute("select id from book where value = %s", (book_db,))
def get(self,passage,version_id): print passage, version_id if not passage: self.redirect("/") ref = scriptures.extract(passage)[0] book_name = ref[0] startchap = ref[1] endchap = ref[3] startverse = ref[2] endverse = ref[4] startfullref = scriptures.reference_to_string(book_name,startchap,startverse) endfullref = scriptures.reference_to_string(book_name,endchap,endverse) if len(startfullref) - (startfullref.index(':') + 1) == 1: startfullref = startfullref.replace(':',':0') if len(endfullref) - (endfullref.index(':') + 1) == 1: endfullref = endfullref.replace(':',':0') results = OrderedDict() cursor = yield gen.Task(self.db.execute, 'select reference, chapter_num, verse_num, version_id, analysis_text, parsed_text from verse where version_id = %s and searchreftext between %s and %s order by searchref asc, version_id desc;', (version_id,startfullref,endfullref)) for verse in cursor.fetchall(): results[verse[0]] = [] print 'ZOMG BBQ!!!' results[verse[0]].append(verse[5]) '''for verse in cursor.fetchall(): queries = {} id = 0 for word in verse[4].split(' '): queries[id] = ['select * from worddetailsbyword(%s);',(word,)] id += 1 cursors = yield gen.Task(self.db.batch, queries) for key,cursor in cursors.items(): worddata = {} if verse[0] not in results.keys(): results[verse[0]] = [] datapoints = cursor.fetchone() results[verse[0]].append( { 'wordid': datapoints[0], 'word': datapoints[1], 'inflectedmeaning': datapoints[2], 'root': datapoints[3], 'rootmeaning': datapoints[4], 'case': datapoints[5], 'person': datapoints[6], 'gender': datapoints[7], 'number': datapoints[8], 'tense': datapoints[9], 'voice': datapoints[10], 'mood': datapoints[11], } ) for word in verse[4].split(' '): cursor = yield gen.Task(self.db.execute, 'select * from worddetailsbyword(%s);', (word,)) if verse[0] not in results.keys(): results[verse[0]] = [] datapoints = cursor.fetchone() results[verse[0]].append( { 'wordid': datapoints[0], 'word': datapoints[1], 'inflectedmeaning': datapoints[2], 'root': datapoints[3], 'rootmeaning': datapoints[4], 'case': datapoints[5], 'person': datapoints[6], 'gender': datapoints[7], 'number': datapoints[8], 'tense': datapoints[9], 'voice': datapoints[10], 'mood': datapoints[11], })''' self.render('analyze.html', passage=passage, versedata=results)
def get_devo(delta=0): def strip_markdown(string): return string.replace('*', ' ').replace('_', ' ') today_date = datetime.utcnow() + timedelta(hours=8, days=delta) date_url = today_date.strftime('%Y-%m-%d') devo_url = 'http://qt.swim.org/user_dir/living/user_print_web.php?edit_all=' + date_url try: result = urlfetch.fetch(devo_url, deadline=10) except Exception as e: logging.warning('Error fetching devo:\n' + str(e)) return None try: html = result.content soup = BeautifulSoup(html, 'lxml') date = today_date.strftime('%b %-d, %Y ({})').format(today_date.strftime('%a').upper()) heading = strip_markdown(soup.select_one('.main_title').text).strip() verse = strip_markdown(soup.select_one('.bible_no').text).lstrip('[ ').rstrip(' ]') verse = scriptures.reference_to_string(*scriptures.extract(verse)[0]) first_word = verse.partition(' ')[0] if first_word in ('I', 'II', 'III'): verse = str(len(first_word)) + verse.lstrip('I') elif first_word == 'Revelation': verse = first_word + verse[26:] lines = soup.select_one('.main_body').text.splitlines() passage = '' for line in lines: idx = line.find(' ') num = '_' + strip_markdown(line[:idx]).rstrip('.') + '_' rest_of_line = strip_markdown(line[idx:]).strip() passage += '{} {}\n'.format(num, rest_of_line) passage = passage.strip() ref_soup = soup.select_one('.main_body2') for tag in ref_soup.select('b'): text = strip_markdown(tag.text).strip() tag.string = '*' + text.replace(' ', '\a') + '*' reflection = ref_soup.text.strip() + '\n\n' reflection += strip_markdown(soup.select_one('.main_body3').text).strip() prayer = strip_markdown(soup.select('.main_body2')[1].text).strip() daynames = ['Yesterday\'s', 'Today\'s', 'Tomorrow\'s'] devo = u'\U0001F4C5' + ' ' + daynames[delta + 1] + ' QT - _' + date + '_\n\n' + \ '*' + heading + '*\n' + verse + '\n\n' + \ u'\U0001F4D9' + ' *Scripture* _(NIV)_\n\n' + passage + '\n\n' + \ u'\U0001F4DD' + ' *Reflection*\n\n' + reflection + '\n\n' + \ u'\U0001F64F' + ' *Prayer*\n\n' + prayer return devo except: if delta == -1: return 'Sorry, the LLJ website is no longer hosting yesterday\'s material.' elif delta == 0: return 'Sorry, the LLJ website does not have today\'s material yet.' else: return 'Sorry, the LLJ website hasn\'t made tomorrow\'s material available yet.'
def get(self,passage): refsearch = scriptures.extract(passage) ''' Extract the passage range ''' ref = refsearch[0] book_name = ref[0] startchap = ref[1] endchap = ref[3] startverse = ref[2] endverse = ref[4] startfullref = scriptures.reference_to_string(book_name,startchap,startverse) endfullref = scriptures.reference_to_string(book_name,endchap,endverse) if book_name in ['2 John','Philemon','Jude','Obadiah','3 John']: startfullref = '%s %s' % (book_name,startverse) endfullref = '%s %s' % (book_name,endverse) else: startfullref = '%s %s:%s' % (book_name,startchap,startverse) endfullref = '%s %s:%s' % (book_name,endchap,endverse) print startfullref,endfullref self.cur.execute('select searchref from verse where reference in (%s,%s) order by searchref', (startfullref,endfullref)) results = self.cur.fetchall() if len(results) == 2: startsearchref = results[0]['searchref'] endsearchref = results[1]['searchref'] else: startsearchref = endsearchref = results[0]['searchref'] ''' Get verse information ''' self.cur.execute('select displaytext from verse where searchref between %s and %s', (startsearchref,endsearchref)) versetext = self.cur.fetchall() self.cur.execute('select * from getanalysis(%s,%s)', (startsearchref,endsearchref)) analysistext = self.cur.fetchall() self.cur.execute('select * from getwordriver(%s,%s,%s)', (4,startsearchref,endsearchref)) wordriver = self.cur.fetchall() '''tenseriver = [['Reference', 'Present', 'Perfect','Imperfect','Pluperfect','Aorist','Future'],] for row in wordriver: tenseriver.append([row['reference'],row['present'],row['perfect'],row['imperfect'],row['pluperfect'], row['aorist'],row['future']]) ''' tenses = ['future','present','perfect','imperfect','pluperfect','aorist','noneorunknowntense'] voices = ['active','passive','middle','noneorunknownvoice'] moods = ['infinitive','indicative','imperative','optative','subjunctive','participial','noneorunknownmood'] #tenseaggs = {key:[] for key in tenses} tenseticks = [] tenseriver = [] rid = 1 for row in wordriver: tenseticks.append([rid,row['reference']]) rid += 1 for tense in tenses: tenseagg = {} tensedata = [] rid = 1 for row in wordriver: tensedata.append([rid,row[tense]]) rid += 1 tenseagg['data'] = tensedata tenseagg['label'] = tense tenseriver.append(tenseagg) #tenseaggs = {key:[] for key in tenses} voiceticks = [] voiceriver = [] rid = 1 for row in wordriver: voiceticks.append([rid,row['reference']]) rid += 1 for voice in voices: voiceagg = {} voicedata = [] rid = 1 for row in wordriver: voicedata.append([rid,row[voice]]) rid += 1 voiceagg['data'] = voicedata voiceagg['label'] = voice voiceriver.append(voiceagg) #tenseaggs = {key:[] for key in tenses} moodticks = [] moodriver = [] rid = 1 for row in wordriver: moodticks.append([rid,row['reference']]) rid += 1 for mood in moods: moodagg = {} mooddata = [] rid = 1 for row in wordriver: mooddata.append([rid,row[mood]]) rid += 1 moodagg['data'] = mooddata moodagg['label'] = mood moodriver.append(moodagg) self.cur.execute('select displaytext from verse where searchref between %s and %s', (startsearchref,endsearchref)) versetext = self.cur.fetchall() self.cur.execute('select * from getanalysis(%s,%s)', (startsearchref,endsearchref)) analysistext = self.cur.fetchall() #self.write('%s<br />%s' % (json.dumps(tenseriver),ticks)) self.render("passage.html",versetext=versetext,analysistext=analysistext,passage=passage, tenseriver=json.dumps(tenseriver),tenseticks=json.dumps(tenseticks), voiceriver=json.dumps(voiceriver),voiceticks=json.dumps(voiceticks), moodriver=json.dumps(moodriver),moodticks=json.dumps(moodticks) )
def parse_passage(self, passage): print(passage) try: return scriptures.reference_to_string(*passage) except: return None
def linkname(self): n = scriptures.reference_to_string(self.book, self.chap1, self.verse1, self.chapN, self.verseN) n = n.replace(' of Jesus Christ', '') return n