All pastes #794970 Raw Edit

Untitled

public python v1 · immutable
#794970 ·published 2007-11-23 15:56 UTC
rendered paste body
#Compare 4 Translationsdef compare_chapter4(request, translations, book, chapter, start_verse = -1, end_verse = -1): # modifying this function to be a 'catch all' for ch, verse, range etc - ah 11/23        #Grab Current Book Data        book_no_dashes = string.replace(book, '-', ' ')        b = Book.objects.get(name=book_no_dashes)        #translation string could bee 'KJV' or 'KJV-ASV-BBE' and it wil return an array of translations        p = re.compile('[A-Za-z]+')        trans_array = p.findall(translations)        trans_num = len(trans_array)        translation_set = Translation.objects.filter(activated=1)        for trans in trans_array:                translation_set = translation_set.exclude(acronym=trans)        if (start_verse != -1 and end_verse != -1):                # we have a range lookup                scripture_set = grab_verse_range(trans_acronym, book_id, chapter, start_verse, end_verse)        elif(start_verse != -1 and end_verse == -1):                # we have a single verse lookup                scripture_set = Scripture.objects.filter(translation__activated=1, verse__book=b.id, verse__chapter=chapter, verse__verse=start_verse)        else:                # we have a chapter lookup                scripture_set = Scripture.objects.filter(translation__activated=1, verse__book=b.id, verse__chapter=chapter)        #Find chapter for all translations passed        for trans in translation_set:                ac = trans.acronym                scripture_set = scripture_set.exclude(translation__acronym=trans.acronym)        #Find Next Book and Chapter To Pass To Template        next_chap = next_chapter(book_no_dashes, chapter)        #Find Previous Book and Chapter To Pass To Template        previous_chap = previous_chapter(book_no_dashes, chapter)        scripture_rows = scripture_set.count()        loops = scripture_rows/trans_num        translation_comparison = 'Before IF<br />' + ac + '<br />loops:' + str(loops) + '<br />scripture_rows:' + str(scripture_rows) + '<br />trans_num:' + str(trans_num)        translation_comparison = '<h1>Yikes</h1>loops:' + str(loops) + 'scripture_rows:' + str(scripture_rows) + 'trans_num:' + str(trans_num)        row=0        i=1        while i<=loops:                x=0                translation_comparison += '<tr>'                while x<trans_num:                        translation_comparison += '<td><p><sup><a title="View this scripture" href="/bible/%s/%s/%s/%s/">%s</a></sup> %s</p></td>' % (trans_array[x], book, chapter, scripture_set[row].verse.verse, scripture_set[row].verse.verse, scripture_set[row].scripture)                        row += 1                        x += 1                translation_comparison += '</tr>'                i += 1        return render_to_response('parallel/chapter/compare_test.html',        {        'translation_comparison':       translation_comparison,        'trans_array':                  trans_array,        'trans_string':                 translations,        'next_book':                    next_chap[0],        'next_chapter':                 next_chap[1],        'previous_book':                previous_chap[0],        'previous_chapter':             previous_chap[1],        'book_no_dashes':               book_no_dashes,        'book':                         book,        'chapter':                      chapter        })