示例#1
0
def populate_scripture_details(sender, instance, **kwargs):
    start = bible.Verse(instance.start_verse)
    instance.start_book_id = start.book
    instance.start_chapter_id = start.chapter
    instance.start_verse_id = start.verse
    if instance.end_verse:
        end = bible.Verse(instance.end_verse)
        if start.book == end.book:
            instance.end_book_id = instance.start_book_id
        else:
            instance.end_book_id = end.book
        instance.end_chapter_id = end.chapter
        instance.end_verse_id = end.verse
示例#2
0
def getRef(searchStr):
    if '-' not in searchStr:
        v = bible.Verse(searchStr)
        return v

    else:
        v1 = bible.Verse(searchStr)

        endingVerse = searchStr.rsplit("-", 1)[1]
        newSearchStr = v1.format("B C") + ":" + endingVerse
        v2 = bible.Verse(newSearchStr)

        p = bible.Passage(v1, v2)
        return p
示例#3
0
    def test_range(self):
        # a few tests to ensure range expressions are acceptable
        range_expr1 = bible.Passage('James 2:10-12')
        range_expr2 = bible.Passage('James 2:10-3:12')
        range_expr3 = bible.Passage('1 John 3:10-2 John 1:7')
        a_verse = bible.Verse('James 2:11')
        another_verse = bible.Verse('1 John 3:24')
        self.assertTrue(range_expr1.includes(a_verse))
        self.assertTrue(range_expr2.includes(a_verse))
        self.assertTrue(range_expr3.includes(another_verse))

        # failing test cases for ranges that don't include verses or even
        # chapters. If that feature gets added, these tests will fail
        # (and you can invert the logic)
        self.assertRaises(Exception, bible.Passage, 'James 2-3')
        self.assertRaises(Exception, bible.Passage, '1 John-2 John')
示例#4
0
 def verse(self, reference):
     " Takes textual verse information and returns the Verse. "
     if self.model.translation and reference[-3] != self.model.translation:
         reference += ' ' + self.model.translation
     verse = bible.Verse(reference)
     return self.get_query_set().get(book_id=verse.book,
                                     chapter_id=verse.chapter,
                                     verse_id=verse.verse)
示例#5
0
    def test_includes(self):
        self.assertFalse(self.romans.includes(bible.Verse('Gen 1:1')))
        self.assertTrue(self.romans.includes(bible.Verse('Rom 3:23')))
        self.assertTrue(self.two_books.includes(bible.Verse('Acts 2:39')))

        from bible import RangeError
        with self.assertRaises(RangeError):
            # no apocrypha / deuterocanon
            self.romans.includes(bible.Verse('1 Maccabees 1:8'))

        with self.assertRaises(RangeError):
            # acts 2 has 47 verses
            self.two_books.includes(bible.Verse('Acts 2:48'))

        # equivalenced includes to __contains__
        my_verse = bible.Verse('Romans 2:12')
        self.assertTrue(self, my_verse in self.romans)

        # testing for being NOT IN seems to break the assertFalse, like this:
        #   self.assertFalse(self, my_verse in self.acts)
        status = my_verse in self.acts
        self.assertTrue(self, not status)
示例#6
0
import bible
import csv
import sys
import re

if len(sys.argv) > 1:
    ref_args = sys.argv[1:]
    ref_string = ' '.join(ref_args)
else:
    ref_string = raw_input("Reference: ")

with open('tskxref.txt') as csvFile:
    csvReader = csv.DictReader(csvFile, delimiter='\t')
    tsk = list(csvReader)

reference = bible.Verse(ref_string)

print
print '# {0}'.format(reference.format())
print

for row in tsk:
    matches_book = int(row['book']) == reference.book
    matches_chapter = int(row['chapter']) == reference.chapter
    matches_verse = int(row['verse']) == reference.verse

    if matches_book and matches_chapter and matches_verse:
        print '## {0}'.format(row['words'])
        print

        # bible library chokes on mr as an abbreviation for Mark
示例#7
0
 def setUp(self):
     self.eph2_10 = bible.Verse('Eph 2:10')
     self.acts_8_37_kjv = bible.Verse(44, 8, 37, 'kvj')
     # Acts 8:37 doesn't exist in ESV, testing omissions from data.py
     self.acts_8_37_esv = bible.Verse(44, 8, 37, 'esv')
示例#8
0
 def test_equals_with_both_translations_set(self):
     self.assertTrue(
         bible.Verse(1, 2, 3, 'kjv') == bible.Verse(1, 2, 3, 'kjv'))
示例#9
0
 def test_equals(self):
     other = bible.Verse('Eph 2:10')
     self.assertTrue(self.eph2_10 == other)