예제 #1
0
 def generateDict(self):
     bookNumDict = {}
     parser = BibleVerseParser(config.parserStandarisation)
     bookName = "Gen."
     bookNum = parser.bookNameToNum(bookName)
     bookNumDict[bookName] = bookNum
     for key in bookNumDict.keys():
         print('"{0}": "{1}",'.format(key, bookNumDict[key]))
예제 #2
0
def generateCharts(text):
    # Extract bible verse references
    useLiteVerseParsing = config.useLiteVerseParsing
    config.useLiteVerseParsing = False
    parser = BibleVerseParser(config.parserStandarisation)
    verses = parser.extractAllReferences(text, False)
    config.useLiteVerseParsing = useLiteVerseParsing
    if verses:
        # Sort by Books
        counts = countVersesByBook(verses)
        # Formulate Table Data
        data = []
        for bookNo in sorted(counts):
            bookName = parser.standardFullBookName[str(bookNo)]
            references = []
            for bcv in sorted(counts[bookNo]):
                reference = parser.bcvToVerseReference(*bcv)
                if len(bcv) == 3:
                    references.append(
                        '<ref onclick="bcv({0},{1},{2})">{3}</ref>'.format(
                            *bcv, reference))
                else:
                    references.append(
                        '<ref onclick="bcv({0},{1},{2},{3},{4})">{5}</ref>'.
                        format(*bcv, reference))
            data.append(
                "  <tr><td>{0}</td><td>{1}</td><td>{2}</td></tr>".format(
                    bookName, "; ".join(references), len(references)))
        # Display a Table
        config.mainWindow.studyView.currentWidget().openPopover(
            html=getTableHtml("\n".join(data), str(len(verses))))
        # Formulate Charts Data
        data = [
            "  ['{0}', {1}]".format(parser.standardAbbreviation[str(bookNo)],
                                    len(counts[bookNo]))
            for bookNo in sorted(counts)
        ]
        # Display a Bar Chart
        html = getBarChartHtml(",\n".join(data), str(len(verses)),
                               len(counts.keys()))
        html = config.mainWindow.wrapHtml(html)
        config.mainWindow.barChart = QWebEngineView()
        config.mainWindow.barChart.setHtml(html, config.baseUrl)
        config.mainWindow.barChart.setMinimumSize(900, 550)
        config.mainWindow.barChart.show()
        # Display a Pie Chart
        html = getPieChartHtml(",\n".join(data), str(len(verses)))
        html = config.mainWindow.wrapHtml(html)
        config.mainWindow.pieChart = QWebEngineView()
        config.mainWindow.pieChart.setHtml(html, config.baseUrl)
        config.mainWindow.pieChart.setMinimumSize(700, 380)
        config.mainWindow.pieChart.show()
    else:
        config.mainWindow.displayMessage(
            config.thisTranslation["message_noReference"])
예제 #3
0
 def setUp(self):
     config.standardAbbreviation = 'ENG'
     config.noOfLinesPerChunkForParsing = 100
     config.convertChapterVerseDotSeparator = True
     config.parseBookChapterWithoutSpace = True
     config.parseBooklessReferences = True
     config.parseEnglishBooksOnly = False
     config.searchBibleIfCommandNotFound = True
     config.regexSearchBibleIfCommandNotFound = False
     config.parseClearSpecialCharacters = False
     self.parser = BibleVerseParser(config.standardAbbreviation)
예제 #4
0
 def setupVariables(self):
     self.isRefreshing = False
     bibleVerseParser = BibleVerseParser(config.parserStandarisation)
     bookNo2Abb = bibleVerseParser.standardAbbreviation
     #bookNo2Name = bibleVerseParser.standardFullBookName
     bookList = [i + 1 for i in range(66)]
     self.searchList = [
         config.thisTranslation["filter"], "{0}-{1}".format(
             bookNo2Abb["1"], bookNo2Abb["66"]), "{0}-{1}".format(
                 bookNo2Abb["1"], bookNo2Abb["39"]), "{0}-{1}".format(
                     bookNo2Abb["40"], bookNo2Abb["66"])
     ] + [bookNo2Abb[str(b)] for b in bookList]
예제 #5
0
 def getHighlightedBcvList(self, highlight, reference):
     highlight = highlight.lower()
     if highlight == "" or highlight == "all":
         where = "WHERE 1=1 "
     else:
         code = self.decode(highlight)
         where = "WHERE CODE='{0}' ".format(code)
     if reference == "nt":
         where += "AND Book >= 40"
     elif reference == "ot":
         where += "AND Book < 40"
     elif not (reference == "" or reference == "all"):
         ref = BibleVerseParser(
             config.standardAbbreviation).extractAllReferences(
                 "{0} 1".format(reference))
         if ref:
             where += "AND Book={0}".format(ref[0][0])
     return self.getHighlightedVerses(where)
예제 #6
0
    def __init__(self, parent, bcvTextTuple):
        super().__init__()

        self.parent = parent
        self.b, self.c, self.v, self.text = bcvTextTuple
        self.bcvChain = False
        self.biblesSqlite = BiblesSqlite()
        bibleVerseParser = BibleVerseParser(config.parserStandarisation)
        self.bookNo2Abb = bibleVerseParser.standardAbbreviation
        self.bookNo2Name = bibleVerseParser.standardFullBookName
        self.bookLabel = QLabel("")
        self.chapterLabel = QLabel("")
        self.verseLabel = QLabel("")

        # set title
        self.setWindowTitle(config.thisTranslation["menu_bible"])
        # setup interface
        self.setupUI()
예제 #7
0
def presentReferenceOnFullScreen(command, source):
    if ":::" in command:
        screenNo, reference, *_ = command.split(":::")
    else:
        screenNo = config.presentationScreenNo
        reference = command
    verseList = BibleVerseParser(
        config.parserStandarisation).extractAllReferences(reference, False)
    if command.count(":::") == 2:
        style = command.split(":::")[2]
    else:
        style = "font-size:{0}em;margin-left:{1}px;margin-right:{1}px;color:{2}".format(
            config.presentationFontSize, config.presentationMargin,
            config.presentationColorOnDarkTheme if config.theme == "dark" else
            config.presentationColorOnLightTheme)
    content = command if not verseList or not config.presentationParser else BiblesSqlite(
    ).readMultipleVerses(config.mainText, verseList, presentMode=True)
    content = "<div style='display:flex;'><div style='position: absolute;top: {2}%;transform: translateY(-{3}%);{1}'>{0}</div></div>".format(
        re.sub("\n", "<br>",
               content), style, config.presentationVerticalPosition,
        config.presentationHorizontalPosition)
    return ("popover.fullscreen".format(screenNo), content, {})
예제 #8
0
    def resetItems(self):
        from util.BibleVerseParser import BibleVerseParser
        from qtpy.QtGui import QStandardItem

        # Empty the model before reset
        self.dataViewModel.clear()
        # Reset
        # Parse entered reference
        reference = self.searchEntry.text().strip()
        verses = BibleVerseParser(
            config.parserStandarisation).extractAllReferences(
                reference, False)
        if verses:
            # Search morphology database
            bcv = verses[0][0:3]
            query = "SELECT * FROM morphology WHERE Book = ? AND Chapter = ? AND Verse = ?"
            self.cursor.execute(query, bcv)
            self.results = self.cursor.fetchall()
            # Display data
            # TABLE morphology (WordID INT, ClauseID INT, Book INT, Chapter INT, Verse INT, Word TEXT, LexicalEntry TEXT, MorphologyCode TEXT, Morphology TEXT, Lexeme TEXT, Transliteration TEXT, Pronunciation TEXT, Interlinear TEXT, Translation TEXT, Gloss TEXT)
            #for wordID, clauseID, b, c, v, textWord, lexicalEntry, morphologyCode, morphology, lexeme, transliteration, pronuciation, interlinear, translation, gloss in self.results:
            for row, result in enumerate(self.results):
                for column in range(0, len(result)):
                    text = str(
                        result[column]) if column < 5 else result[column]
                    item = QStandardItem(text)
                    self.dataViewModel.setItem(row, column, item)
            self.dataViewModel.setHorizontalHeaderLabels([
                "WordID", "ClauseID", "Book", "Chapter", "Verse", "Word",
                "LexicalEntry", "MorphologyCode", "Morphology", "Lexeme",
                "Transliteration", "Pronunciation", "Interlinear",
                "Translation", "Gloss"
            ])
        else:
            self.results = []
            self.displayMessage(self.translation[2])
        self.dataView.resizeColumnsToContents()
예제 #9
0
    def setupUI(self):
        textButtonStyle = "QPushButton {background-color: #151B54; color: white;} QPushButton:hover {background-color: #333972;} QPushButton:pressed { background-color: #515790;}"

        mainLayout = QGridLayout()

        commandBox = QVBoxLayout()
        commandBox.setSpacing(3)

        commandBar = QWidget()
        commandLayout1 = QBoxLayout(QBoxLayout.LeftToRight)
        commandLayout1.setSpacing(5)
        self.searchLineEdit = QLineEdit()
        self.searchLineEdit.setClearButtonEnabled(True)
        self.searchLineEdit.setToolTip(
            config.thisTranslation["enter_command_here"])
        self.searchLineEdit.returnPressed.connect(self.searchLineEntered)
        self.searchLineEdit.setFixedWidth(450)
        commandLayout1.addWidget(self.searchLineEdit)

        enterButton = QPushButton(config.thisTranslation["enter"])
        enterButton.setFixedWidth(100)
        enterButton.clicked.connect(self.searchLineEntered)
        commandLayout1.addWidget(enterButton)

        # commandLayout1.addStretch()
        commandBox.addLayout(commandLayout1)

        if config.showMiniKeyboardInMiniControl:
            commandLayout2 = QBoxLayout(QBoxLayout.LeftToRight)
            commandLayout2.setSpacing(5)

            keys = [
                '1', '2', '3', '4', '5', '6', '7', '8', '9', '0', ':', '-',
                ',', '.', ' ', '<', 'X'
            ]
            for key in keys:
                button = QPushButton(key)
                button.setMaximumWidth(30)
                button.clicked.connect(partial(self.keyEntryAction, key))
                commandLayout2.addWidget(button)

            commandLayout2.addStretch()
            commandBox.addLayout(commandLayout2)

        if config.showMiniKeyboardInMiniControl and config.isTtsInstalled:
            ttsLayout = QBoxLayout(QBoxLayout.LeftToRight)
            ttsLayout.setSpacing(5)

            self.languageCombo = QComboBox()
            ttsLayout.addWidget(self.languageCombo)
            if config.espeak:
                languages = TtsLanguages().isoLang2epeakLang
            else:
                languages = TtsLanguages().isoLang2qlocaleLang
            self.languageCodes = list(languages.keys())
            for code in self.languageCodes:
                self.languageCombo.addItem(languages[code][1])
            # Check if selected tts engine has the language user specify.
            if not (config.ttsDefaultLangauge in self.languageCodes):
                config.ttsDefaultLangauge = "en"
            # Set initial item
            initialIndex = self.languageCodes.index(config.ttsDefaultLangauge)
            self.languageCombo.setCurrentIndex(initialIndex)

            # setting tts default language here is confusing; better place in menu
            #setDefaultButton = QPushButton(config.thisTranslation["setDefault"])
            #setDefaultButton.setFixedWidth(130)
            #setDefaultButton.clicked.connect(self.setTtsDefaultLanguage)
            #ttsLayout.addWidget(setDefaultButton)

            speakButton = QPushButton(config.thisTranslation["speak"])
            speakButton.setFixedWidth(100)
            speakButton.clicked.connect(self.speakCommandFieldText)
            ttsLayout.addWidget(speakButton)

            stopButton = QPushButton(config.thisTranslation["stop"])
            stopButton.setFixedWidth(100)
            stopButton.clicked.connect(
                self.parent.textCommandParser.stopTtsAudio)
            ttsLayout.addWidget(stopButton)

            ttsLayout.addStretch()

            commandBox.addLayout(ttsLayout)

        commandBar.setLayout(commandBox)
        mainLayout.addWidget(commandBar, 0, 0, Qt.AlignCenter)

        self.tabs = QTabWidget()
        self.tabs.currentChanged.connect(self.tabChanged)
        mainLayout.addWidget(self.tabs, 1, 0, Qt.AlignCenter)

        parser = BibleVerseParser(config.parserStandarisation)
        self.bookMap = parser.standardAbbreviation
        bookNums = list(self.bookMap.keys())
        self.bookNumGps = [
            bookNums[0:10],
            bookNums[10:20],
            bookNums[20:30],
            bookNums[30:39],
            bookNums[39:49],
            bookNums[49:59],
            bookNums[59:69],
            bookNums[69:79],
            bookNums[79:86],
            bookNums[86:94],
            bookNums[94:99],
            bookNums[99:104],
            bookNums[104:110],
            bookNums[110:119],
            bookNums[119:124],
            bookNums[124:129],
            bookNums[129:139],
            bookNums[139:149],
            bookNums[149:159],
            bookNums[159:169],
            bookNums[169:174],
            bookNums[174:179],
            bookNums[179:189],
            bookNums[189:199],
        ]

        # Bible books tab

        self.bible = QWidget()
        self.populateBooksButtons(config.mainText)
        self.tabs.addTab(self.bible, config.thisTranslation["bible"])

        # Bible translations tab

        self.biblesBox = QWidget()
        self.biblesBoxContainer = QVBoxLayout()
        collectionsLayout = self.newRowLayout()
        if len(config.bibleCollections) > 0:
            button = QPushButton("All")
            button.setStyleSheet(textButtonStyle)
            button.clicked.connect(partial(self.selectCollection, "All"))
            collectionsLayout.addWidget(button)
            count = 0
            for collection in sorted(config.bibleCollections.keys()):
                button = QPushButton(collection)
                button.setStyleSheet(textButtonStyle)
                button.clicked.connect(
                    partial(self.selectCollection, collection))
                collectionsLayout.addWidget(button)
                count += 1
                if count > 5:
                    count = 0
                    self.biblesBoxContainer.addLayout(collectionsLayout)
                    collectionsLayout = self.newRowLayout()

        self.biblesBoxContainer.addLayout(collectionsLayout)
        self.bibleBoxWidget = QWidget()
        self.bibleBoxLayout = QVBoxLayout()
        self.bibleBoxLayout.setContentsMargins(0, 0, 0, 0)
        self.bibleBoxLayout.setSpacing(1)
        row_layout = self.newRowLayout()
        row_layout.setContentsMargins(0, 0, 0, 0)
        row_layout.setSpacing(1)
        biblesSqlite = BiblesSqlite()
        bibles = biblesSqlite.getBibleList()
        count = 0
        for bible in bibles:
            button = QPushButton(bible)
            if bible in config.bibleDescription:
                button.setToolTip("{0}".format(config.bibleDescription[bible]))
            button.clicked.connect(partial(self.bibleAction, bible))
            row_layout.addWidget(button)
            count += 1
            if count > 6:
                count = 0
                self.bibleBoxLayout.addLayout(row_layout)
                row_layout = self.newRowLayout()
            self.bibleButtons[bible] = button
        self.bibleBoxLayout.addLayout(row_layout)
        self.bibleBoxLayout.addStretch()
        self.biblesBoxContainer.addLayout(self.bibleBoxLayout)
        self.biblesBoxContainer.addStretch()
        self.biblesBox.setLayout(self.biblesBoxContainer)
        self.tabs.addTab(self.biblesBox,
                         config.thisTranslation["translations"])

        # Commentaries tab

        commentaries_box = QWidget()
        box_layout = QVBoxLayout()
        box_layout.setContentsMargins(0, 0, 0, 0)
        box_layout.setSpacing(1)
        row_layout = self.newRowLayout()
        button = QPushButton(config.thisTranslation["activeOnly"])
        button.setStyleSheet(textButtonStyle)
        button.clicked.connect(self.activeCommentaries)
        row_layout.addWidget(button)
        box_layout.addLayout(row_layout)
        row_layout = self.newRowLayout()
        commentaries = Commentary().getCommentaryList()
        count = 0
        for commentary in commentaries:
            button = QPushButton(commentary)
            button.setToolTip(Commentary.fileLookup[commentary])
            button.clicked.connect(partial(self.commentaryAction, commentary))
            self.commentaryButtons[commentary] = button
            row_layout.addWidget(button)
            count += 1
            if count > 6:
                count = 0
                box_layout.addLayout(row_layout)
                row_layout = self.newRowLayout()
        box_layout.addLayout(row_layout)
        box_layout.addStretch()
        commentaries_box.setLayout(box_layout)

        self.tabs.addTab(commentaries_box,
                         config.thisTranslation["commentaries"])

        # Lexicons tab

        lexicons_box = QWidget()
        box_layout = QVBoxLayout()
        box_layout.setContentsMargins(0, 0, 0, 0)
        box_layout.setSpacing(1)
        row_layout = self.newRowLayout()
        lexicons = LexiconData().lexiconList
        count = 0
        for lexicon in lexicons:
            button = QPushButton(lexicon)
            if lexicon in config.lexiconDescription:
                button.setToolTip("{0}".format(
                    config.lexiconDescription[lexicon]))
            button.clicked.connect(partial(self.lexiconAction, lexicon))
            row_layout.addWidget(button)
            count += 1
            if count > 6:
                count = 0
                box_layout.addLayout(row_layout)
                row_layout = self.newRowLayout()
        box_layout.addLayout(row_layout)
        box_layout.addStretch()
        lexicons_box.setLayout(box_layout)

        self.tabs.addTab(lexicons_box, config.thisTranslation["lexicons"])

        # Dictionaries tab

        dictionaries_box = QWidget()
        box_layout = QVBoxLayout()
        box_layout.setContentsMargins(0, 0, 0, 0)
        box_layout.setSpacing(1)
        row_layout = self.newRowLayout()
        dictionaries = IndexesSqlite().dictionaryList
        count = 0
        for dictionary in dictionaries:
            button = QPushButton(dictionary[0])
            button.setToolTip(dictionary[1])
            button.clicked.connect(
                partial(self.dictionaryAction, dictionary[0]))
            row_layout.addWidget(button)
            count += 1
            if count > 6:
                count = 0
                box_layout.addLayout(row_layout)
                row_layout = self.newRowLayout()
        box_layout.addLayout(row_layout)
        box_layout.addStretch()
        dictionaries_box.setLayout(box_layout)

        self.tabs.addTab(dictionaries_box,
                         config.thisTranslation["dictionaries"])

        # Book intros tab

        bookIntros_box = QWidget()
        box_layout = QVBoxLayout()
        box_layout.setContentsMargins(0, 0, 0, 0)
        box_layout.setSpacing(1)
        row_layout = self.newRowLayout()
        button = QPushButton(config.thisTranslation["activeOnly"])
        button.setStyleSheet(textButtonStyle)
        button.clicked.connect(self.activeBookIntros)
        row_layout.addWidget(button)
        box_layout.addLayout(row_layout)
        row_layout = self.newRowLayout()
        commentaries = Commentary().getCommentaryList()
        count = 0
        for commentary in commentaries:
            button = QPushButton(commentary)
            button.setToolTip(Commentary.fileLookup[commentary])
            button.clicked.connect(partial(self.bookIntroAction, commentary))
            self.bookIntroButtons[commentary] = button
            row_layout.addWidget(button)
            count += 1
            if count > 6:
                count = 0
                box_layout.addLayout(row_layout)
                row_layout = self.newRowLayout()
        box_layout.addLayout(row_layout)
        box_layout.addStretch()
        bookIntros_box.setLayout(box_layout)

        self.tabs.addTab(bookIntros_box, config.thisTranslation["bookIntro"])

        # Devotionals tab

        if len(self.devotionals) > 0:
            devotionals_box = QWidget()
            box_layout = QVBoxLayout()
            box_layout.setContentsMargins(0, 0, 0, 0)
            box_layout.setSpacing(1)
            row_layout = self.newRowLayout()
            count = 0
            for file in self.devotionals:
                name = Path(file).stem
                button = QPushButton(name)
                # button.setToolTip(dictionary[1])
                button.clicked.connect(partial(self.devotionalAction, name))
                row_layout.addWidget(button)
                count += 1
                if count > 2:
                    count = 0
                    box_layout.addLayout(row_layout)
                    row_layout.addStretch()
                    row_layout = self.newRowLayout()
            for i in range(count, 3):
                button = QPushButton("")
                row_layout.addWidget(button)
            box_layout.addLayout(row_layout)
            box_layout.addStretch()
            devotionals_box.setLayout(box_layout)

            self.tabs.addTab(devotionals_box,
                             config.thisTranslation["devotionals"])

        self.tabs.setCurrentIndex(config.miniControlInitialTab)
        self.setLayout(mainLayout)
예제 #10
0
 def test_skip_image(self):
     input = """<html><body>John 1:1, Acts 10:10, <p><img src="data:image/png;base64,iVBOTkSuQmCC" alt="UniqueBibleApp_black" /></p>Rev 22:1</body></html>"""
     res = BibleVerseParser("YES").parseText(input, False, False)
     expected = """<html><body><ref onclick="bcv(43,1,1)">John 1:1</ref>, <ref onclick="bcv(44,10,10)">Acts 10:10</ref>, <p><img src="data:image/png;base64,iVBOTkSuQmCC" alt="UniqueBibleApp_black" /></p>\n<ref onclick="bcv(66,22,1)">Rev 22:1</ref></body></html>"""
     self.assertEqual(expected, res)
예제 #11
0
class BibleVerseParserTestCase(unittest.TestCase):
    def setUp(self):
        config.standardAbbreviation = 'ENG'
        config.noOfLinesPerChunkForParsing = 100
        config.convertChapterVerseDotSeparator = True
        config.parseBookChapterWithoutSpace = True
        config.parseBooklessReferences = True
        config.parseEnglishBooksOnly = False
        config.searchBibleIfCommandNotFound = True
        config.regexSearchBibleIfCommandNotFound = False
        config.parseClearSpecialCharacters = False
        self.parser = BibleVerseParser(config.standardAbbreviation)

    def test_gen_parseText(self):
        input = "Genesis 1:1-3:1"
        expected = '<ref onclick="bcv(1,1,1,3,1)">Genesis 1:1-3:1</ref>'
        res = self.parser.parseText(input)
        self.assertEqual(expected, res)

    def test_prov_parseText(self):
        input = "Prov 1:1"
        expected = '<ref onclick="bcv(20,1,1)">Prov 1:1</ref>'
        res = self.parser.parseText(input)
        self.assertEqual(expected, res)

    def test_prov_extractAllReferences(self):
        input = "Prov 1:1"
        expected = [(20, 1, 1)]
        res = self.parser.extractAllReferences(input)
        self.assertEqual(expected, res)

    def test_matt_extractAllReferences(self):
        input = "Matt 28:18-20"
        expected = [(40, 28, 18, 28, 20)]
        res = self.parser.extractAllReferences(input)
        self.assertEqual(expected, res)

    def test_1cor_extractAllReferences(self):
        input = "1 Cor 13"
        expected = [(46, 13, 1)]
        res = self.parser.extractAllReferences(input)
        self.assertEqual(expected, res)

    def test_rev_extractAllReferences(self):
        input = "Rev. 1-10"
        expected = [(66, 1, 1, 10, 1)]
        res = self.parser.extractAllReferences(input)
        self.assertEqual(expected, res)

    def test_gen_verseReferenceToBCV(self):
        input = "gen"
        expected = (1, 1, 1)
        res = self.parser.verseReferenceToBCV(input)
        self.assertEqual(expected, res)

    def test_num_verseReferenceToBCV(self):
        input = "Num. 10"
        expected = (4, 10, 1)
        res = self.parser.verseReferenceToBCV(input)
        self.assertEqual(expected, res)

    def test_job_verseReferenceToBCV(self):
        input = "Job 2-10"
        expected = (18, 2, 1, 10, 1)
        res = self.parser.verseReferenceToBCV(input)
        self.assertEqual(expected, res)

    def test_psa_verseReferenceToBCV(self):
        input = "Psalms 23:1-10"
        expected = (19, 23, 1, 23, 10)
        res = self.parser.verseReferenceToBCV(input)
        self.assertEqual(expected, res)

    def test_pro_verseReferenceToBCV(self):
        input = "Prov. 2:1-10:6"
        expected = (20, 2, 1, 10, 6)
        res = self.parser.verseReferenceToBCV(input)
        self.assertEqual(expected, res)

    def test_1sam_verseReferenceToBCV(self):
        input = "1Sam. 4:5-   10:6"
        expected = (9, 4, 5, 10, 6)
        res = self.parser.verseReferenceToBCV(input)
        self.assertEqual(expected, res)

    def test_2kings_verseReferenceToBCV(self):
        input = "II Ki. 4:5 - 10:6"
        expected = (12, 4, 5, 10, 6)
        res = self.parser.verseReferenceToBCV(input)
        self.assertEqual(expected, res)

    def test_1sam_verseReferenceToBCV(self):
        input = "1 S.  4:5 - 10:9999"
        expected = (9, 4, 5, 10, 9999)
        res = self.parser.verseReferenceToBCV(input)
        self.assertEqual(expected, res)

    def test_mark_verseReferenceToBCV(self):
        input = "mar  3:2"
        expected = (41, 3, 2)
        res = self.parser.verseReferenceToBCV(input)
        self.assertEqual(expected, res)

    def test_2tim_verseReferenceToBCV(self):
        input = " 2 Timothy  5 "
        expected = (55, 5, 1)
        res = self.parser.verseReferenceToBCV(input)
        self.assertEqual(expected, res)

    def test_adddaniel_verseReferenceToBCV(self):
        input = "Additions to Daniel 10"
        expected = (71, 10, 1)
        res = self.parser.verseReferenceToBCV(input)
        self.assertEqual(expected, res)

    def test_skip_image(self):
        input = """<html><body>John 1:1, Acts 10:10, <p><img src="data:image/png;base64,iVBOTkSuQmCC" alt="UniqueBibleApp_black" /></p>Rev 22:1</body></html>"""
        res = BibleVerseParser("YES").parseText(input, False, False)
        expected = """<html><body><ref onclick="bcv(43,1,1)">John 1:1</ref>, <ref onclick="bcv(44,10,10)">Acts 10:10</ref>, <p><img src="data:image/png;base64,iVBOTkSuQmCC" alt="UniqueBibleApp_black" /></p>\n<ref onclick="bcv(66,22,1)">Rev 22:1</ref></body></html>"""
        self.assertEqual(expected, res)
예제 #12
0
 def getSearchedVerseList(self, searchString):
     searchString = "%{0}%".format(searchString)
     query = "SELECT DISTINCT Book, Chapter, Verse FROM VerseNote WHERE Note LIKE ? ORDER BY Book, Chapter, Verse"
     self.cursor.execute(query, (searchString,))
     parser = BibleVerseParser(config.parserStandarisation)
     return ["<ref onclick='document.title=\"_openversenote:::{0}.{1}.{2}\"'>{3}</ref>".format(book, chapter, verse, parser.bcvToVerseReference(book, chapter, verse)) for book, chapter, verse in self.cursor.fetchall()]
예제 #13
0
 def getSearchedBookList(self, searchString):
     searchString = "%{0}%".format(searchString)
     query = "SELECT DISTINCT Book FROM BookNote WHERE Note LIKE ? ORDER BY Book"
     self.cursor.execute(query, (searchString,))
     standardAbbreviation = BibleVerseParser(config.parserStandarisation).standardAbbreviation
     return ["<ref onclick='document.title=\"_openbooknote:::{0}\"'>{1}</ref>".format(book[0], standardAbbreviation[str(book[0])]) for book in self.cursor.fetchall()]
예제 #14
0
    def getMenu(command, source="main"):
        biblesSqlite = BiblesSqlite()
        parser = BibleVerseParser(config.parserStandarisation)
        items = command.split(".", 3)
        text = items[0]
        versions = biblesSqlite.getBibleList()
        # provide a link to go back the last opened bible verse
        if source == "study":
            mainVerseReference = parser.bcvToVerseReference(
                config.studyB, config.studyC, config.studyV)
            menu = "<ref onclick='document.title=\"_stayOnSameTab:::\"; document.title=\"BIBLE:::{0}:::{1}\"'>&lt;&lt;&lt; {0} - {1}</ref>".format(
                config.studyText, mainVerseReference)
        else:
            mainVerseReference = parser.bcvToVerseReference(
                config.mainB, config.mainC, config.mainV)
            menu = "<ref onclick='document.title=\"_stayOnSameTab:::\"; document.title=\"BIBLE:::{0}:::{1}\"'>&lt;&lt;&lt; {0} - {1}</ref>".format(
                config.mainText, mainVerseReference)
        # select bible versions
        menu += "<hr><b>{1}</b> {0}".format(
            biblesSqlite.getTexts(), config.thisTranslation["html_bibles"])
        if text:
            # i.e. text specified; add book menu
            if config.openBibleInMainViewOnly or config.enableHttpServer:
                menu += "<br><br><b>{2}</b> <span style='color: brown;' onmouseover='textName(\"{0}\")'>{0}</span> <button class='feature' onclick='document.title=\"_stayOnSameTab:::\"; document.title=\"BIBLE:::{0}:::{1}\"'>{3}</button>".format(
                    text, mainVerseReference,
                    config.thisTranslation["html_current"],
                    config.thisTranslation["html_open"])
            else:
                if source == "study":
                    anotherView = "<button class='feature' onclick='document.title=\"MAIN:::{0}:::{1}\"'>{2}</button>".format(
                        text, mainVerseReference,
                        config.thisTranslation["html_openMain"])
                else:
                    anotherView = "<button class='feature' onclick='document.title=\"STUDY:::{0}:::{1}\"'>{2}</button>".format(
                        text, mainVerseReference,
                        config.thisTranslation["html_openStudy"])
                menu += "<br><br><b>{2}</b> <span style='color: brown;' onmouseover='textName(\"{0}\")'>{0}</span> <button class='feature' onclick='document.title=\"_stayOnSameTab:::\"; document.title=\"BIBLE:::{0}:::{1}\"'>{3}</button> {4}".format(
                    text, mainVerseReference,
                    config.thisTranslation["html_current"],
                    config.thisTranslation["html_openHere"], anotherView)
            menu += "<hr><b>{1}</b> {0}".format(
                biblesSqlite.getBooks(text),
                config.thisTranslation["html_book"])
            # create a list of inters b, c, v
            bcList = [int(i) for i in items[1:]]
            if bcList:
                check = len(bcList)
                bookNo = bcList[0]
                engFullBookName = BibleBooks().eng[str(bookNo)][-1]
                engFullBookNameWithoutNumber = engFullBookName
                matches = re.match("^[0-9]+? (.*?)$", engFullBookName)
                if matches:
                    engFullBookNameWithoutNumber = matches.group(1)
                # Book specific buttons
                if check >= 1:
                    # i.e. book specified; add chapter menu
                    bookReference = parser.bcvToVerseReference(bookNo, 1, 1)
                    bookAbb = bookReference[:-4]
                    # build open book button
                    if config.openBibleInMainViewOnly or config.enableHttpServer:
                        openOption = "<button class='feature' onclick='document.title=\"_stayOnSameTab:::\"; document.title=\"BIBLE:::{0}:::{1}\"'>{2}</button>".format(
                            text, bookReference,
                            config.thisTranslation["html_open"])
                    else:
                        if source == "study":
                            anotherView = "<button class='feature' onclick='document.title=\"MAIN:::{0}:::{1}\"'>{2}</button>".format(
                                text, bookReference,
                                config.thisTranslation["html_openMain"])
                        else:
                            anotherView = "<button class='feature' onclick='document.title=\"STUDY:::{0}:::{1}\"'>{2}</button>".format(
                                text, bookReference,
                                config.thisTranslation["html_openStudy"])
                        openOption = "<button class='feature' onclick='document.title=\"_stayOnSameTab:::\"; document.title=\"BIBLE:::{0}:::{1}\"'>{3}</button> {2}".format(
                            text, bookReference, anotherView,
                            config.thisTranslation["html_openHere"])
                    # build search book by book introduction button
                    introductionButton = "<button class='feature' onclick='document.title=\"SEARCHBOOKCHAPTER:::Tidwell_The_Bible_Book_by_Book:::{0}\"'>{1}</button>".format(
                        engFullBookName,
                        config.thisTranslation["html_introduction"])
                    # build search timelines button
                    timelinesButton = "<button class='feature' onclick='document.title=\"SEARCHBOOKCHAPTER:::Timelines:::{0}\"'>{1}</button>".format(
                        engFullBookName,
                        config.thisTranslation["html_timelines"])
                    # build search encyclopedia button
                    encyclopediaButton = "<button class='feature' onclick='document.title=\"SEARCHTOOL:::{0}:::{1}\"'>{2}</button>".format(
                        config.encyclopedia, engFullBookNameWithoutNumber,
                        config.thisTranslation["context1_encyclopedia"])
                    # build search dictionary button
                    dictionaryButton = "<button class='feature' onclick='document.title=\"SEARCHTOOL:::{0}:::{1}\"'>{2}</button>".format(
                        config.dictionary, engFullBookNameWithoutNumber,
                        config.thisTranslation["context1_dict"])
                    # display selected book
                    menu += "<br><br><b>{2}</b> <span style='color: brown;' onmouseover='bookName(\"{0}\")'>{0}</span> {1}<br>{3} {4} {5} {6}".format(
                        bookAbb, openOption,
                        config.thisTranslation["html_current"],
                        introductionButton, timelinesButton, dictionaryButton,
                        encyclopediaButton)
                    # display book commentaries
                    menu += "<br><br><b>{1}:</b> <span style='color: brown;' onmouseover='bookName(\"{0}\")'>{0}</span>".format(
                        bookAbb, config.thisTranslation["commentaries"])
                    list = Commentary().getCommentaryListThatHasBookAndChapter(
                        bookNo, 0)
                    for commentary in list:
                        button = " <button class='feature' onmouseover='instantInfo(\"{2}\")' onclick='document.title=\"COMMENTARY:::{0}:::{1}\"'>{0}</button>".format(
                            commentary[0], engFullBookName, commentary[1])
                        menu += button
                    # Chapter specific buttons
                    # add chapter menu
                    menu += "<hr><b>{1}</b> {0}".format(
                        biblesSqlite.getChapters(bookNo, text),
                        config.thisTranslation["html_chapter"])
                if check >= 2:
                    chapterNo = bcList[1]
                    # i.e. both book and chapter specified; add verse menu
                    chapterReference = parser.bcvToVerseReference(
                        bookNo, chapterNo, 1)
                    # build open chapter button
                    if config.openBibleInMainViewOnly or config.enableHttpServer:
                        openOption = "<button class='feature' onclick='document.title=\"_stayOnSameTab:::\"; document.title=\"BIBLE:::{0}:::{1}\"'>{2}</button>".format(
                            text, chapterReference,
                            config.thisTranslation["html_open"])
                    else:
                        if source == "study":
                            anotherView = "<button class='feature' onclick='document.title=\"MAIN:::{0}:::{1}\"'>{2}</button>".format(
                                text, chapterReference,
                                config.thisTranslation["html_openMain"])
                        else:
                            anotherView = "<button class='feature' onclick='document.title=\"STUDY:::{0}:::{1}\"'>{2}</button>".format(
                                text, chapterReference,
                                config.thisTranslation["html_openStudy"])
                        openOption = "<button class='feature' onclick='document.title=\"_stayOnSameTab:::\"; document.title=\"BIBLE:::{0}:::{1}\"'>{3}</button> {2}".format(
                            text, chapterReference, anotherView,
                            config.thisTranslation["html_openHere"])
                    # overview button
                    overviewButton = "<button class='feature' onclick='document.title=\"OVERVIEW:::{0} {1}\"'>{2}</button>".format(
                        bookAbb, chapterNo,
                        config.thisTranslation["html_overview"])
                    # chapter index button
                    chapterIndexButton = "<button class='feature' onclick='document.title=\"CHAPTERINDEX:::{0} {1}\"'>{2}</button>".format(
                        bookAbb, chapterNo,
                        config.thisTranslation["html_chapterIndex"])
                    # summary button
                    summaryButton = "<button class='feature' onclick='document.title=\"SUMMARY:::{0} {1}\"'>{2}</button>".format(
                        bookAbb, chapterNo,
                        config.thisTranslation["html_summary"])
                    # chapter commentary button
                    # chapterCommentaryButton = "<button class='feature' onclick='document.title=\"COMMENTARY:::{0} {1}\"'>{2}</button>".format(bookAbb, chapterNo, config.thisTranslation["menu4_commentary"])
                    # chapter note button
                    chapterNoteButton = " <button class='feature' onclick='document.title=\"_openchapternote:::{0}.{1}\"'>{2}</button>".format(
                        bookNo, chapterNo,
                        config.thisTranslation["menu6_notes"])
                    # selected chapter
                    menu += "<br><br><b>{3}</b> <span style='color: brown;' onmouseover='document.title=\"_info:::Chapter {1}\"'>{1}</span> {2}{4}<br>{5} {6} {7}".format(
                        bookNo, chapterNo, openOption,
                        config.thisTranslation["html_current"],
                        "" if config.enableHttpServer else chapterNoteButton,
                        overviewButton, chapterIndexButton, summaryButton)

                    # display chapter commentaries
                    menu += "<br><br><b>{1}:</b> <span style='color: brown;' onmouseover='instantInfo(\"Chapter {0}\")'>{0}</span>".format(
                        chapterNo, config.thisTranslation["commentaries"])
                    list = Commentary().getCommentaryListThatHasBookAndChapter(
                        bookNo, config.mainC)
                    for commentary in list:
                        button = " <button class='feature' onmouseover='instantInfo(\"{2}\")' onclick='document.title=\"COMMENTARY:::{0}:::{1} {3}\"'>{0}</button>".format(
                            commentary[0], engFullBookName, commentary[1],
                            config.mainC)
                        menu += button

                    # building verse list of slected chapter
                    menu += "<hr><b>{1}</b> {0}".format(
                        biblesSqlite.getVersesMenu(bookNo, chapterNo, text),
                        config.thisTranslation["html_verse"])
                # Verse specific buttons
                if check == 3:
                    verseNo = bcList[2]
                    if config.openBibleInMainViewOnly or config.enableHttpServer:
                        openOption = "<button class='feature' onclick='document.title=\"_stayOnSameTab:::\"; document.title=\"BIBLE:::{0}:::{1}\"'>{2}</button>".format(
                            text, mainVerseReference,
                            config.thisTranslation["html_open"])
                    else:
                        if source == "study":
                            anotherView = "<button class='feature' onclick='document.title=\"MAIN:::{0}:::{1}\"'>{2}</button>".format(
                                text, mainVerseReference,
                                config.thisTranslation["html_openMain"])
                        else:
                            anotherView = "<button class='feature' onclick='document.title=\"STUDY:::{0}:::{1}\"'>{2}</button>".format(
                                text, mainVerseReference,
                                config.thisTranslation["html_openStudy"])
                        openOption = "<button class='feature' onclick='document.title=\"_stayOnSameTab:::\"; document.title=\"BIBLE:::{0}:::{1}\"'>{3}</button> {2}".format(
                            text, mainVerseReference, anotherView,
                            config.thisTranslation["html_openHere"])
                    verseNoteButton = " <button class='feature' onclick='document.title=\"_openversenote:::{0}.{1}.{2}\"'>{3}</button>".format(
                        bookNo, chapterNo, verseNo,
                        config.thisTranslation["menu6_notes"])
                    menu += "<br><br><b>{5}</b> <span style='color: brown;' onmouseover='document.title=\"_instantVerse:::{0}:::{1}.{2}.{3}\"'>{3}</span> {4}{6}".format(
                        text, bookNo, chapterNo, verseNo, openOption,
                        config.thisTranslation["html_current"],
                        "" if config.enableHttpServer else verseNoteButton)
                    #menu += "<hr><b>{0}</b> ".format(config.thisTranslation["html_features"])
                    menu += "<br>"
                    features = (
                        ("COMPARE",
                         config.thisTranslation["menu4_compareAll"]),
                        ("CROSSREFERENCE",
                         config.thisTranslation["menu4_crossRef"]),
                        ("TSKE", config.thisTranslation["menu4_tske"]),
                        ("TRANSLATION",
                         config.thisTranslation["menu4_traslations"]),
                        ("DISCOURSE",
                         config.thisTranslation["menu4_discourse"]),
                        ("WORDS", config.thisTranslation["menu4_words"]),
                        ("COMBO", config.thisTranslation["menu4_tdw"]),
                        ("COMMENTARY",
                         config.thisTranslation["menu4_commentary"]),
                        ("INDEX", config.thisTranslation["menu4_indexes"]),
                    )
                    for keyword, description in features:
                        menu += "<button class='feature' onclick='document.title=\"{0}:::{1}\"'>{2}</button> ".format(
                            keyword, mainVerseReference, description)
                    #versions = biblesSqlite.getBibleList()
                    # Compare menu
                    menu += "<hr><b><span style='color: brown;' onmouseover='textName(\"{0}\")'>{0}</span> {1}</b><br>".format(
                        text, config.thisTranslation["html_and"])
                    for version in versions:
                        if not version == text:
                            menu += "<div style='display: inline-block' onmouseover='textName(\"{0}\")'>{0} <input type='checkbox' id='compare{0}'></div> ".format(
                                version)
                            menu += "<script>versionList.push('{0}');</script>".format(
                                version)
                    menu += "<br><button type='button' onclick='checkCompare();' class='feature'>{0}</button>".format(
                        config.thisTranslation["html_showCompare"])
                    # Parallel menu
                    menu += "<hr><b><span style='color: brown;' onmouseover='textName(\"{0}\")'>{0}</span> {1}</b><br>".format(
                        text, config.thisTranslation["html_and"])
                    for version in versions:
                        if not version == text:
                            menu += "<div style='display: inline-block' onmouseover='textName(\"{0}\")'>{0} <input type='checkbox' id='parallel{0}'></div> ".format(
                                version)
                    menu += "<br><button type='button' onclick='checkParallel();' class='feature'>{0}</button>".format(
                        config.thisTranslation["html_showParallel"])
                    # Diff menu
                    menu += "<hr><b><span style='color: brown;' onmouseover='textName(\"{0}\")'>{0}</span> {1}</b><br>".format(
                        text, config.thisTranslation["html_and"])
                    for version in versions:
                        if not version == text:
                            menu += "<div style='display: inline-block' onmouseover='textName(\"{0}\")'>{0} <input type='checkbox' id='diff{0}'></div> ".format(
                                version)
                    menu += "<br><button type='button' onclick='checkDiff();' class='feature'>{0}</button>".format(
                        config.thisTranslation["html_showDifference"])
        else:
            # menu - Search a bible
            if source == "study":
                defaultSearchText = config.studyText
            else:
                defaultSearchText = config.mainText
            menu += "<hr><b>{1}</b> <span style='color: brown;' onmouseover='textName(\"{0}\")'>{0}</span>".format(
                defaultSearchText, config.thisTranslation["html_searchBible2"])
            menu += "<br><br><input type='text' id='bibleSearch' style='width:95%' autofocus><br><br>"
            searchOptions = ("SEARCH", "SEARCHREFERENCE", "SEARCHOT",
                             "SEARCHNT", "SEARCHALL", "ANDSEARCH", "ORSEARCH",
                             "ADVANCEDSEARCH", "REGEXSEARCH")
            for searchMode in searchOptions:
                menu += "<button  id='{0}' type='button' onclick='checkSearch(\"{0}\", \"{1}\");' class='feature'>{0}</button> ".format(
                    searchMode, defaultSearchText)
            # menu - Search multiple bibles
            menu += "<hr><b>{0}</b> ".format(
                config.thisTranslation["html_searchBibles2"])
            for version in versions:
                if version == defaultSearchText or version == config.favouriteBible:
                    menu += "<div style='display: inline-block' onmouseover='textName(\"{0}\")'>{0} <input type='checkbox' id='search{0}' checked></div> ".format(
                        version)
                else:
                    menu += "<div style='display: inline-block' onmouseover='textName(\"{0}\")'>{0} <input type='checkbox' id='search{0}'></div> ".format(
                        version)
                menu += "<script>versionList.push('{0}');</script>".format(
                    version)
            menu += "<br><br><input type='text' id='multiBibleSearch' style='width:95%'><br><br>"
            for searchMode in searchOptions:
                menu += "<button id='multi{0}' type='button' onclick='checkMultiSearch(\"{0}\");' class='feature'>{0}</button> ".format(
                    searchMode)
            # Perform search when "ENTER" key is pressed
            menu += biblesSqlite.inputEntered("bibleSearch", "SEARCH")
            menu += biblesSqlite.inputEntered("multiBibleSearch",
                                              "multiSEARCH")
        return menu