Пример #1
0
    def passage(self, start_reference, end_reference=None):
        """
        Takes textual passage information and returns the Verse(s).
        Note: you can't just input 'Romans 1:1-2:3',
        you'll need to do ('Romans 1:1', 'Romans 2:3') for the time being.
        """
        if not end_reference:  # Probably just a single verse, return a list anyway.
            end_reference = start_reference

        if self.model.translation and start_reference[
                -3] != self.model.translation:
            start_reference += ' ' + self.model.translation
        if self.model.translation and end_reference[
                -3] != self.model.translation:
            end_reference += ' ' + self.model.translation

        # NB: len(passage) gives us the number of Verses in the passage.
        passage = bible.Passage(start_reference, end_reference)
        # We'll get the number of verses from the start like so to save a db lookup:
        in_the_beginning = 'Genesis 1:1'
        if self.model.translation:
            in_the_beginning += ' ' + self.model.translation
        start_pk = len(bible.Passage(in_the_beginning, start_reference))
        return self.get_query_set().order_by('id').filter(
            pk__gte=start_pk)[:len(passage)]
Пример #2
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')
Пример #3
0
 def setUp(self):
     self.romans = bible.Passage('Romans 1:1', 'Romans 16:27')
     self.romans_smaller = bible.Passage('Romans 2:1', 'Romans 2:4')
     self.acts = bible.Passage('Acts 10:22', 'Acts 10:27')
     self.acts_skewed = bible.Passage('Acts 10:14', 'Acts 10:22')
     self.acts_disjoint = bible.Passage('Acts 10:14', 'Acts 10:21')
     self.two_books = bible.Passage('Acts 1:1', 'Romans 16:27')
Пример #4
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
Пример #5
0
 def __unicode__(self):
     if self.end_verse:
         return bible.Passage(self.start_verse, self.end_verse).format()
     return self.start_verse
Пример #6
0
 def test_translation(self):
     passage = bible.Passage('44-8-37-esv', '45-16-27-esv')
     self.assertEqual(str(passage.start), 'Acts 8:37')
     self.assertEqual(str(passage.end), 'Romans 16:27')