コード例 #1
0
def testVPL( VPLfolder ):
    # Crudely demonstrate the VPL Bible class
    from BibleOrgSys.Reference import VerseReferences

    vPrint( 'Normal', debuggingThisModule, _("Demonstrating the VPL Bible class…") )
    vPrint( 'Quiet', debuggingThisModule, "  Test folder is {!r}".format( VPLfolder ) )
    vb = VPLBible( VPLfolder, "demo" )
    vb.load() # Load and process the file
    vPrint( 'Normal', debuggingThisModule, vb ) # Just print a summary
    if BibleOrgSysGlobals.strictCheckingFlag:
        vb.check()
        #vPrint( 'Quiet', debuggingThisModule, UsfmB.books['GEN']._processedLines[0:40] )
        vBErrors = vb.getCheckResults()
        # vPrint( 'Quiet', debuggingThisModule, vBErrors )
    if BibleOrgSysGlobals.commandLineArguments.export:
        ##vb.toDrupalBible()
        vb.doAllExports( wantPhotoBible=False, wantODFs=False, wantPDFs=False )
    for reference in ( ('OT','GEN','1','1'), ('OT','GEN','1','3'), ('OT','PSA','3','0'), ('OT','PSA','3','1'), \
                        ('OT','DAN','1','21'),
                        ('NT','MAT','3','5'), ('NT','JDE','1','4'), ('NT','REV','22','21'), \
                        ('DC','BAR','1','1'), ('DC','MA1','1','1'), ('DC','MA2','1','1',), ):
        (t, b, c, v) = reference
        if t=='OT' and len(vb)==27: continue # Don't bother with OT references if it's only a NT
        if t=='NT' and len(vb)==39: continue # Don't bother with NT references if it's only a OT
        if t=='DC' and len(vb)<=66: continue # Don't bother with DC references if it's too small
        svk = VerseReferences.SimpleVerseKey( b, c, v )
        #vPrint( 'Quiet', debuggingThisModule, svk, ob.getVerseDataList( reference ) )
        shortText = svk.getShortText()
        try:
            verseText = vb.getVerseText( svk )
        except KeyError:
            verseText = "Verse not available!"
        vPrint( 'Normal', debuggingThisModule, reference, shortText, verseText )
コード例 #2
0
def testYB(TUBfilename):
    # Crudely demonstrate the YET Bible class
    from BibleOrgSys.Reference import VerseReferences
    TUBfolder = Path(
        '/mnt/SSDs/Bibles/YET modules/')  # Must be the same as below

    vPrint('Normal', debuggingThisModule,
           _("Demonstrating the YET Bible class…"))
    vPrint('Quiet', debuggingThisModule,
           "  Test folder is {!r} {!r}".format(TUBfolder, TUBfilename))
    yb = YETBible(TUBfolder, TUBfilename)
    yb.load()  # Load and process the file
    vPrint('Normal', debuggingThisModule, yb)  # Just print a summary
    if BibleOrgSysGlobals.strictCheckingFlag: yb.check()
    if BibleOrgSysGlobals.commandLineArguments.export:
        yb.doAllExports(wantPhotoBible=False, wantODFs=False, wantPDFs=False)
    for reference in ( ('OT','GEN','1','1'), ('OT','GEN','1','3'), ('OT','PSA','3','0'), ('OT','PSA','3','1'), \
                        ('OT','DAN','1','21'),
                        ('NT','MAT','3','5'), ('NT','JDE','1','4'), ('NT','REV','22','21'), \
                        ('DC','BAR','1','1'), ('DC','MA1','1','1'), ('DC','MA2','1','1',), ):
        (t, b, c, v) = reference
        if t == 'OT' and len(yb) == 27:
            continue  # Don't bother with OT references if it's only a NT
        if t == 'NT' and len(yb) == 39:
            continue  # Don't bother with NT references if it's only a OT
        if t == 'DC' and len(yb) <= 66:
            continue  # Don't bother with DC references if it's too small
        svk = VerseReferences.SimpleVerseKey(b, c, v)
        #dPrint( 'Quiet', debuggingThisModule, svk, ob.getVerseDataList( reference ) )
        shortText = svk.getShortText()
        try:
            verseText = yb.getVerseText(svk)
        except KeyError:
            verseText = "Verse not available!"
        vPrint('Normal', debuggingThisModule, reference, shortText, verseText)
コード例 #3
0
def briefDemo() -> None:
    """
    Main program to handle command line parameters and then run what they want.
    """
    BibleOrgSysGlobals.introduceProgram( __name__, programNameVersion, LAST_MODIFIED_DATE )

    #testFolder = Path( '/mnt/SSDs/Bibles/OpenSong Bibles/' ) # These are quite similar
    testFolder = BibleOrgSysGlobals.BOS_TEST_DATA_FOLDERPATH.joinpath( 'VerseViewXML/' )

    if 1: # demo the file checking code
        vPrint( 'Quiet', debuggingThisModule, "TestA1", VerseViewXMLBibleFileCheck( testFolder ) )
        vPrint( 'Quiet', debuggingThisModule, "TestA2", VerseViewXMLBibleFileCheck( testFolder, autoLoad=True ) )
        vPrint( 'Quiet', debuggingThisModule, "TestA3", VerseViewXMLBibleFileCheck( testFolder, autoLoadBooks=True ) )


    if 1:
        count = totalBooks = 0
        if os.access( testFolder, os.R_OK ): # check that we can read the test data
            for something in sorted( os.listdir( testFolder ) ):
                somepath = os.path.join( testFolder, something )
                if os.path.isfile( somepath ) and something.endswith( '.xml' ):
                    count += 1
                    vPrint( 'Quiet', debuggingThisModule, "\nH B{}/ {}".format( count, something ) )
                    vvB = VerseViewXMLBible( testFolder, something )
                    vvB.load()
                    vPrint( 'Quiet', debuggingThisModule, vvB )
                    if BibleOrgSysGlobals.strictCheckingFlag:
                        vvB.check()
                        #UBErrors = UB.getCheckResults()
                        #dPrint( 'Quiet', debuggingThisModule, UBErrors )
                    #dPrint( 'Quiet', debuggingThisModule, UB.getVersification() )
                    #dPrint( 'Quiet', debuggingThisModule, UB.getAddedUnits() )
                    #for ref in ('GEN','Genesis','GeNeSiS','Gen','MrK','mt','Prv','Xyz',):
                        ##dPrint( 'Quiet', debuggingThisModule, "Looking for", ref )
                        #dPrint( 'Quiet', debuggingThisModule, "Tried finding {!r} in {!r}: got {!r}".format( ref, name, UB.getXRefBBB( ref ) ) )
                    if 1: # Test verse lookup
                        from BibleOrgSys.Reference import VerseReferences
                        for reference in ( ('OT','GEN','1','1'), ('OT','GEN','1','3'), ('OT','PSA','3','0'), ('OT','PSA','3','1'), \
                                            ('OT','DAN','1','21'),
                                            ('NT','MAT','3','5'), ('NT','JDE','1','4'), ('NT','REV','22','21'), \
                                            ('DC','BAR','1','1'), ('DC','MA1','1','1'), ('DC','MA2','1','1',), ):
                            (t, b, c, v) = reference
                            if t=='OT' and len(vvB)==27: continue # Don't bother with OT references if it's only a NT
                            if t=='NT' and len(vvB)==39: continue # Don't bother with NT references if it's only a OT
                            if t=='DC' and len(vvB)<=66: continue # Don't bother with DC references if it's too small
                            svk = VerseReferences.SimpleVerseKey( b, c, v )
                            #dPrint( 'Quiet', debuggingThisModule, svk, ob.getVerseDataList( reference ) )
                            try: vPrint( 'Quiet', debuggingThisModule, reference, svk.getShortText(), vvB.getVerseText( svk ) )
                            except KeyError: vPrint( 'Quiet', debuggingThisModule, something, reference, "doesn't exist" )
                    if BibleOrgSysGlobals.commandLineArguments.export:
                        vvB.doAllExports( wantPhotoBible=False, wantODFs=False, wantPDFs=False )
                    #else:
                        #vvB.toHaggaiXML()
                    break
                else: vPrint( 'Quiet', debuggingThisModule, "Sorry, skipping {}.".format( something ) )
            if count: vPrint( 'Quiet', debuggingThisModule, "\n{} total VerseView Bibles processed.".format( count ) )
        else: vPrint( 'Quiet', debuggingThisModule, f"Sorry, test folder '{testFolder}' is not readable on this computer." )
コード例 #4
0
ファイル: MySwordBible.py プロジェクト: pkabore/BibleOrgSys
def testMySwB(indexString, MySwBfolder, MySwBfilename):
    """
    Crudely demonstrate the MySword Bible class.
    """
    #dPrint( 'Quiet', debuggingThisModule, "tMSB", MySwBfolder )
    from BibleOrgSys.Reference import VerseReferences
    #testFolder = Path( '/mnt/SSDs/Bibles/MySword modules/' ) # Must be the same as below

    #TUBfolder = os.path.join( MySwBfolder, MySwBfilename )
    vPrint('Normal', debuggingThisModule,
           _("Demonstrating the MySword Bible class {}…").format(indexString))
    vPrint('Quiet', debuggingThisModule,
           "  Test folder is {!r} {!r}".format(MySwBfolder, MySwBfilename))
    MySwB = MySwordBible(MySwBfolder, MySwBfilename)
    MySwB.preload()
    #MySwB.load() # Load and process the file
    vPrint('Normal', debuggingThisModule, MySwB)  # Just print a summary
    #dPrint( 'Quiet', debuggingThisModule, MySwB.suppliedMetadata['MySword'] )
    if MySwB is not None:
        if BibleOrgSysGlobals.strictCheckingFlag: MySwB.check()
        for reference in ( ('OT','GEN','1','1'), ('OT','GEN','1','3'), ('OT','PSA','3','0'), ('OT','PSA','3','1'), \
                            ('OT','DAN','1','21'),
                            ('NT','MAT','3','5'), ('NT','JDE','1','4'), ('NT','REV','22','21'), \
                            ('DC','BAR','1','1'), ('DC','MA1','1','1'), ('DC','MA2','1','1',), ):
            (t, b, c, v) = reference
            if t == 'OT' and len(MySwB) == 27:
                continue  # Don't bother with OT references if it's only a NT
            if t == 'NT' and len(MySwB) == 39:
                continue  # Don't bother with NT references if it's only a OT
            if t == 'DC' and len(MySwB) <= 66:
                continue  # Don't bother with DC references if it's too small
            svk = VerseReferences.SimpleVerseKey(b, c, v)
            #dPrint( 'Quiet', debuggingThisModule, svk, ob.getVerseDataList( reference ) )
            try:
                shortText, verseText = svk.getShortText(), MySwB.getVerseText(
                    svk)
                vPrint('Normal', debuggingThisModule, reference, shortText,
                       verseText)
            except KeyError:
                vPrint('Normal', debuggingThisModule, reference,
                       "not found!!!")

        if 0:  # Now export the Bible and compare the round trip
            MySwB.createMySwordModule()
            #doaResults = MySwB.doAllExports( wantPhotoBible=False, wantODFs=False, wantPDFs=False )
            if BibleOrgSysGlobals.strictCheckingFlag:  # Now compare the original and the derived USX XML files
                outputFolder = "BOSOutputFiles/BOS_MySword_Reexport/"
                vPrint('Normal', debuggingThisModule,
                       "\nComparing original and re-exported MySword files…")
                result = BibleOrgSysGlobals.fileCompare(
                    MySwBfilename, MySwBfilename, MySwBfolder, outputFolder)
                if BibleOrgSysGlobals.debugFlag:
                    if not result: halt
コード例 #5
0
def testUB(TUBfilename):
    # Crudely demonstrate the Unbound Bible class
    from BibleOrgSys.Reference import VerseReferences
    testFolder = BibleOrgSysGlobals.BOS_LIBRARY_BASE_FOLDERPATH.joinpath(
        '../../../../../../mnt/SSDs/Bibles/Biola Unbound modules/'
    )  # Must be the same as below

    TUBfolder = os.path.join(testFolder, TUBfilename + '/')
    vPrint('Normal', debuggingThisModule,
           _("Demonstrating the Unbound Bible class…"))
    vPrint('Quiet', debuggingThisModule,
           "  Test folder is {!r} {!r}".format(TUBfolder, TUBfilename))
    ub = UnboundBible(TUBfolder, TUBfilename)
    ub.load()  # Load and process the file
    vPrint('Normal', debuggingThisModule, ub)  # Just print a summary
    if BibleOrgSysGlobals.strictCheckingFlag:
        ub.check()
        #vPrint( 'Quiet', debuggingThisModule, UsfmB.books['GEN']._processedLines[0:40] )
        uBErrors = ub.getCheckResults()
        # vPrint( 'Quiet', debuggingThisModule, uBErrors )
    if BibleOrgSysGlobals.commandLineArguments.export:
        ##ub.toDrupalBible()
        ub.doAllExports(wantPhotoBible=False, wantODFs=False, wantPDFs=False)
    for reference in ( ('OT','GEN','1','1'), ('OT','GEN','1','3'), ('OT','PSA','3','0'), ('OT','PSA','3','1'), \
                        ('OT','DAN','1','21'),
                        ('NT','MAT','3','5'), ('NT','JDE','1','4'), ('NT','REV','22','21'), \
                        ('DC','BAR','1','1'), ('DC','MA1','1','1'), ('DC','MA2','1','1',), ):
        (t, b, c, v) = reference
        if t == 'OT' and len(ub) == 27:
            continue  # Don't bother with OT references if it's only a NT
        if t == 'NT' and len(ub) == 39:
            continue  # Don't bother with NT references if it's only a OT
        if t == 'DC' and len(ub) <= 66:
            continue  # Don't bother with DC references if it's too small
        svk = VerseReferences.SimpleVerseKey(b, c, v)
        #vPrint( 'Quiet', debuggingThisModule, svk, ob.getVerseDataList( reference ) )
        shortText = svk.getShortText()
        try:
            verseText = ub.getVerseText(svk)
        except KeyError:
            verseText = "Verse not available!"
        vPrint('Normal', debuggingThisModule, reference, shortText, verseText)
コード例 #6
0
def testSwB( SwFolderpath, SwModuleName=None ):
    """
    Crudely demonstrate and test the Sword Bible class
    """
    from BibleOrgSys.Reference import VerseReferences

    vPrint( 'Normal', debuggingThisModule, _("Demonstrating the Sword Bible class…") )
    vPrint( 'Quiet', debuggingThisModule, "  Test folder is {!r} {!r}".format( SwFolderpath, SwModuleName ) )
    SwBible = SwordBible( SwFolderpath, SwModuleName )
    SwBible.loadBooks() # Load and process the file
    vPrint( 'Normal', debuggingThisModule, SwBible ) # Just print a summary
    if BibleOrgSysGlobals.strictCheckingFlag:
        SwBible.check()
        #vPrint( 'Quiet', debuggingThisModule, UsfmB.books['GEN']._processedLines[0:40] )
        SwBErrors = SwBible.getCheckResults()
        # vPrint( 'Quiet', debuggingThisModule, SwBErrors )
    if BibleOrgSysGlobals.commandLineArguments.export:
        ##SwBible.toDrupalBible()
        SwBible.doAllExports( wantPhotoBible=False, wantODFs=False, wantPDFs=False )
    for reference in ( ('OT','GEN','1','1'), ('OT','GEN','1','3'), ('OT','PSA','3','0'), ('OT','PSA','3','1'),
                        ('OT','DAN','1','21'),
                        ('NT','MAT','1','1'), ('NT','MAT','3','5'), ('NT','MAT','3','8'),
                        ('NT','JDE','1','4'), ('NT','REV','22','21'),
                        ('DC','BAR','1','1'), ('DC','MA1','1','1'), ('DC','MA2','1','1',), ):
        (T, BBB, C, V) = reference
        if T=='OT' and len(SwBible)==27: continue # Don't bother with OT references if it's only a NT
        if T=='NT' and len(SwBible)==39: continue # Don't bother with NT references if it's only a OT
        if T=='DC' and len(SwBible)<=66: continue # Don't bother with DC references if it's too small
        svk = VerseReferences.SimpleVerseKey( BBB, C, V )
        #vPrint( 'Quiet', debuggingThisModule, svk, SwBible.getVerseDataList( reference ) )
        shortText = svk.getShortText()
        try:
            verseText = SwBible.getVerseText( svk )
            #vPrint( 'Quiet', debuggingThisModule, "verseText", verseText )
            fullVerseText = SwBible.getVerseText( svk, fullTextFlag=True )
        except KeyError:
            verseText = fullVerseText = "Verse not available!"
        if BibleOrgSysGlobals.verbosityLevel > 1:
            if BibleOrgSysGlobals.debugFlag: vPrint( 'Quiet', debuggingThisModule, '' )
            vPrint( 'Quiet', debuggingThisModule, reference, shortText, verseText )
            if BibleOrgSysGlobals.debugFlag: vPrint( 'Quiet', debuggingThisModule, '  {}'.format( fullVerseText ) )
    return SwBible
コード例 #7
0
def fullDemo() -> None:
    """
    Full demo to check class is working
    """
    BibleOrgSysGlobals.introduceProgram(__name__, programNameVersion,
                                        LAST_MODIFIED_DATE)

    #testFolder = BibleOrgSysGlobals.BOS_TEST_DATA_FOLDERPATH.joinpath( 'VerseViewXML/' ) # These are very similar
    testFolder = Path('/mnt/SSDs/Bibles/OpenSong Bibles/')
    single1 = ("KJV.xmm", )
    single2 = ("BIBLIA warszawska", )
    good = ( "KJV.xmm", "AMP.xmm", "Chinese_SU.xmm", "Contemporary English Version.xmm", "ESV", "MKJV", \
        "MSG.xmm", "NASB.xmm", "NIV", "NKJV.xmm", "NLT", "telugu.xmm", )
    nonEnglish = ( "BIBLIA warszawska", "Chinese Union Version Simplified.txt", "hun_karoli", "KNV_HU", "LBLA.xmm", \
        "Nowe Przymierze", "NVI.xmm", "NVI_PT", "PRT-IBS.xmm", "RV1960", "SVL.xmm", "UJPROT_HU", "vdc", \
        "Vietnamese Bible.xmm", )
    bad = ("EPS99", )
    allOfThem = good + nonEnglish + bad

    if 1:  # demo the file checking code -- first with the whole folder and then with only one folder
        resultA1 = OpenSongXMLBibleFileCheck(testFolder)
        vPrint('Quiet', debuggingThisModule, "TestA1", resultA1)
        resultA2 = OpenSongXMLBibleFileCheck(testFolder, autoLoad=True)
        vPrint('Quiet', debuggingThisModule, "TestA2", resultA2)
        resultA3 = OpenSongXMLBibleFileCheck(testFolder, autoLoadBooks=True)
        vPrint('Quiet', debuggingThisModule, "TestA3", resultA3)

        testSubfolder = os.path.join(testFolder, 'nrsv_update/')
        resultB1 = OpenSongXMLBibleFileCheck(testSubfolder)
        vPrint('Quiet', debuggingThisModule, "TestB1", resultB1)
        resultB2 = OpenSongXMLBibleFileCheck(testSubfolder, autoLoad=True)
        vPrint('Quiet', debuggingThisModule, "TestB2", resultB2)
        resultB3 = OpenSongXMLBibleFileCheck(testSubfolder, autoLoadBooks=True)
        vPrint('Quiet', debuggingThisModule, "TestB3", resultB3)

    if 1:
        for j, testFilename in enumerate(allOfThem):
            vPrint('Quiet', debuggingThisModule,
                   "\n\nOpnSng B{}/ {}".format(j + 1, testFilename))
            testFilepath = os.path.join(testFolder, testFilename)

            # Demonstrate the OpenSong XML Bible class
            vPrint('Normal', debuggingThisModule,
                   "Demonstrating the OpenSong XML Bible class…")
            vPrint('Quiet', debuggingThisModule,
                   "  Test filepath is {!r}".format(testFilepath))
            xb = OpenSongXMLBible(testFolder, testFilename)
            xb.load()  # Load and process the XML
            vPrint('Quiet', debuggingThisModule, xb)  # Just print a summary
            #dPrint( 'Quiet', debuggingThisModule, xb.books['JDE']._processedLines )
            if 1:  # Test verse lookup
                from BibleOrgSys.Reference import VerseReferences
                for reference in ( ('OT','GEN','1','1'), ('OT','GEN','1','3'), ('OT','PSA','3','0'), ('OT','PSA','3','1'), \
                                    ('OT','DAN','1','21'),
                                    ('NT','MAT','3','5'), ('NT','JDE','1','4'), ('NT','REV','22','21'), \
                                    ('DC','BAR','1','1'), ('DC','MA1','1','1'), ('DC','MA2','1','1',), ):
                    (t, b, c, v) = reference
                    if t == 'OT' and len(xb) == 27:
                        continue  # Don't bother with OT references if it's only a NT
                    if t == 'NT' and len(xb) == 39:
                        continue  # Don't bother with NT references if it's only a OT
                    if t == 'DC' and len(xb) <= 66:
                        continue  # Don't bother with DC references if it's too small
                    svk = VerseReferences.SimpleVerseKey(b, c, v)
                    #dPrint( 'Quiet', debuggingThisModule, svk, ob.getVerseDataList( reference ) )
                    try:
                        vPrint('Normal', debuggingThisModule, reference,
                               svk.getShortText(), xb.getVerseText(svk))
                    except KeyError:
                        vPrint('Normal', debuggingThisModule, reference,
                               svk.getShortText(),
                               "KEY ERROR: Verse doesn't seem to exist!")
            if BibleOrgSysGlobals.debugFlag and debuggingThisModule and not xb:
                halt  # if no books