コード例 #1
0
    def __init__(self, book, chapter, translation, user, channel, verse):
        """ Initializes a Verse object with book, chapter, verse (if
        exists), and translation (if exists). """

        self.book = book
        self.channel = channel.lower()
        book_num = books.get_book_number(self.book)
        if book_num <= 39:
            self.bible_section = "Old Testament"
        elif book_num <= 66:
            self.bible_section = "New Testament"
        else:
            self.bible_section = "Deuterocanon"

        self.chapter = int(chapter.replace(" ", ""))
        if verse != "":
            self.verse = verse.replace(" ", "")
            if "-" in self.verse:
                start_verse, end_verse = self.verse.split("-")
                if end_verse != "" and int(start_verse) > int(end_verse):
                    self.verse = None
                elif end_verse == "" or int(start_verse) == int(end_verse):
                    self.verse = start_verse
                    end_verse = int(start_verse)
                self.start_verse = int(start_verse)
                self.end_verse = int(end_verse)
            else:
                self.start_verse = int(self.verse)
                self.end_verse = self.start_verse
        else:
            self.verse = None
            self.start_verse = 0
            self.end_verse = 0
        if translation != "":
            trans = translation.upper().replace(" ", "")
            self.translation = trans
            '''
            if database.is_valid_trans(trans, self.bible_section):
                self.translation = trans
            else:
                self.determine_translation(user, channel)
            '''
        else:
            self.determine_translation(user, channel)

        self.translation_title = ""
        self.contents = ""
        self.permalink = ""
コード例 #2
0
    def __init__(self, book, chapter, translation, user, subreddit, verse):
        """ Initializes a Verse object with book, chapter, verse (if
        exists), and translation (if exists). """

        self.book = book
        self.subreddit = subreddit.lower()
        book_num = books.get_book_number(self.book)
        if book_num <= 39:
            self.bible_section = "Old Testament"
        elif book_num <= 66:
            self.bible_section = "New Testament"
        else:
            self.bible_section = "Deuterocanon"

        self.chapter = int(chapter.replace(" ", ""))
        if verse != "":
            self.verse = verse.replace(" ", "")
            if "-" in self.verse:
                start_verse, end_verse = self.verse.split("-")
                if end_verse != "" and int(start_verse) > int(end_verse):
                    self.verse = None
                elif end_verse == "" or int(start_verse) == int(end_verse):
                    self.verse = start_verse
                    end_verse = int(start_verse)
                self.start_verse = int(start_verse)
                self.end_verse = int(end_verse)
            else:
                self.start_verse = int(self.verse)
                self.end_verse = self.start_verse
        else:
            self.verse = None
            self.start_verse = 0
            self.end_verse = 0
        if translation != "":
            trans = translation.upper().replace(" ", "")
            if database.is_valid_trans(trans, self.bible_section):
                self.translation = trans
            else:
                self.determine_translation(user, subreddit)
        else:
            self.determine_translation(user, subreddit)

        self.translation_title = ""
        self.contents = ""
        self.permalink = ""
コード例 #3
0
ファイル: tests.py プロジェクト: jandersoncodes/versebot
 def test_book_number_retrieval(self):
     """ Tests book number retrieval. """
     self.assertTrue(books.get_book_number("Genesis") == 1)
     self.assertTrue(books.get_book_number("Bel and the Dragon") == 82)
     self.assertTrue(books.get_book_number("thisisntabook") == False)
コード例 #4
0
    def test_book_number_retrieval(self):
        """ Tests book number retrieval. """

        self.assertTrue(books.get_book_number("Genesis") == 1)
        self.assertTrue(books.get_book_number("Bel and the Dragon") == 82)
        self.assertTrue(books.get_book_number("thisisntabook") is None)