Exemple #1
0
def briefDemo() -> None:
    """
    Main program to handle command line parameters and then run what they want.
    """
    BibleOrgSysGlobals.introduceProgram(__name__, programNameVersion,
                                        LAST_MODIFIED_DATE)

    fileFolder = BibleOrgSysGlobals.BADBAD_PARALLEL_RESOURCES_BASE_FOLDERPATH.joinpath(
        '../../ExternalPrograms/morphgnt/sblgnt/')

    # Demonstrate the Greek NT class
    vPrint('Normal', debuggingThisModule,
           "\nDemonstrating the Greek NT class…")
    testReference = SimpleVerseKey('MAT', '1', '1')
    #vPrint( 'Quiet', debuggingThisModule, testFolder, testReference )
    gNT = GreekNT(fileFolder)  # Load and process the XML
    gNT.loadBooks()
    #gNT.analyzeWords() # File and sort the Greek words for later use
    vPrint('Quiet', debuggingThisModule, gNT)  # Just print a summary
    vPrint('Quiet', debuggingThisModule, '')
    vPrint('Quiet', debuggingThisModule, testReference,
           gNT.getVerseDataList(testReference))
    vPrint('Quiet', debuggingThisModule, '')

    for testReference in SimpleVerseKey('MAT', '28', '1'), SimpleVerseKey(
            'MRK', '2', '2'), SimpleVerseKey('REV', '21', '21'):
        verseText = gNT.getVerseText(testReference)
        vPrint('Quiet', debuggingThisModule, testReference, verseText)
        vPrint('Quiet', debuggingThisModule, '')
Exemple #2
0
def fullDemo() -> None:
    """
    Full demo to check class is working
    """
    from BibleOrgSys.Reference.VerseReferences import SimpleVerseKey

    BibleOrgSysGlobals.introduceProgram( __name__, programNameVersion, LAST_MODIFIED_DATE )

    testRefs = ( ('GEN','1','1'), ('JER','33','3'), ('MAL','4','6'), ('MAT','1','1'), ('JHN','3','16'), ('JDE','1','14'), ('REV','22','21'), )

    if 1: # Test the GenericOnlineBible class
        vPrint( 'Quiet', debuggingThisModule, '' )
        dbpBible1 = GenericOnlineBible()
        vPrint( 'Quiet', debuggingThisModule, dbpBible1 )
        for testRef in testRefs:
            verseKey = SimpleVerseKey( *testRef )
            vPrint( 'Quiet', debuggingThisModule, verseKey )
            dbpBible1.cacheVerse( verseKey, [f"Verse text for {verseKey}"] )
            vPrint( 'Quiet', debuggingThisModule, f"  Cache length: {len(dbpBible1.cache)}" )
            vPrint( 'Quiet', debuggingThisModule, " ", dbpBible1.getCachedVerseDataList( verseKey ) )
         # Now test the GenericOnlineBible class caching
        vPrint( 'Quiet', debuggingThisModule, '' )
        for testRef in testRefs:
            verseKey = SimpleVerseKey( *testRef )
            vPrint( 'Quiet', debuggingThisModule, verseKey, "cached" )
            vPrint( 'Quiet', debuggingThisModule, " ", dbpBible1.getCachedVerseDataList( verseKey ) )
Exemple #3
0
 def processSearchResult(searchResult: dict,
                         downloadAllBooks: bool = False) -> None:
     if searchResult and isinstance(searchResult, dict):
         dcsBible1 = DCSBible(searchResult,
                              downloadAllBooks=downloadAllBooks)
         try:
             dcsBible1.preload()
         except FileNotFoundError:
             assert downloadAllBooks == False
         vPrint('Normal', debuggingThisModule, dcsBible1, end='\n\n')
         for testRef in testRefs:
             verseKey = SimpleVerseKey(*testRef)
             if BibleOrgSysGlobals.verbosityLevel > 0:
                 vPrint('Quiet', debuggingThisModule, verseKey)
                 vPrint('Quiet', debuggingThisModule, " ",
                        dcsBible1.getVerseDataList(verseKey))
     elif BibleOrgSysGlobals.verbosityLevel > 0:
         vPrint('Quiet', debuggingThisModule,
                f"Unexpected search result: {searchResult}")
def briefDemo() -> None:
    """
    Main program to handle command line parameters and then run what they want.
    """
    BibleOrgSysGlobals.introduceProgram(__name__, programNameVersion,
                                        LAST_MODIFIED_DATE)

    # Demo the BibleReferencesLinks object
    brl = BibleReferencesLinks().loadData(
    )  # Doesn't reload the XML unnecessarily :)
    vPrint('Quiet', debuggingThisModule, brl)  # Just print a summary

    testKeys = (
        'MAT_1:23',
        'MAT_3:12',
        'MRK_7:7',
        'ACT_7:8',
        'ISA_7:14',
    )

    vPrint('Quiet', debuggingThisModule, "\nTest full passage list…")
    for verseReferenceString in testKeys:
        svk = SimpleVerseKey(verseReferenceString)
        vPrint('Quiet', debuggingThisModule, svk.getShortText())
        #vPrint( 'Quiet', debuggingThisModule, svk, brl.getFullRelatedPassagesList( svk ) )
        relatedPassageList = brl.getFullRelatedPassagesList(svk)
        if relatedPassageList:
            for relatedPassage in relatedPassageList:
                #vPrint( 'Quiet', debuggingThisModule, ' ', relatedPassage )
                sourceReference, sourceComponent, parsedSourceReference, actualLinksList = relatedPassage
                vPrint('Quiet', debuggingThisModule, ' ', sourceReference)
                for actualLink in actualLinksList:
                    #vPrint( 'Quiet', debuggingThisModule, '    ', actualLink )
                    targetReference, targetComponent, parsedTargetReference, linkType = actualLink
                    vPrint('Quiet', debuggingThisModule, '    ', linkType,
                           targetReference)
        break

    vPrint('Quiet', debuggingThisModule, "\nTest passage list…")
    for verseReferenceString in testKeys:
        svk = SimpleVerseKey(verseReferenceString)
        vPrint('Quiet', debuggingThisModule, svk.getVerseKeyText(),
               brl.getRelatedPassagesList(svk))
        break
    def importDataToPython(self):
        """
        Loads (and pivots) the data (not including the header) into suitable Python containers to use in a Python program.
        (Of course, you can just use the elementTree in self._XMLTree if you prefer.)
        """
        def makeList(parameter1, parameter2):
            """
            Returns a list containing all parameters. Parameter1 may already be a list.
            """
            if isinstance(parameter1, list):
                #assert parameter2 not in parameter1
                parameter1.append(parameter2)
                return parameter1
            else:
                return [parameter1, parameter2]

        # end of makeList

        assert self._XMLTree
        if self.__DataList:  # We've already done an import/restructuring -- no need to repeat it
            return self.__DataList, self.__DataDict

        # We'll create a number of dictionaries with different elements as the key
        rawRefLinkList = []
        actualLinkCount = 0
        for element in self._XMLTree:
            #vPrint( 'Quiet', debuggingThisModule, BibleOrgSysGlobals.elementStr( element ) )

            # Get these first for helpful error messages
            sourceReference = element.find('sourceReference').text
            sourceComponent = element.find('sourceComponent').text
            assert sourceComponent in (
                'Section',
                'Verses',
                'Verse',
            )

            BibleOrgSysGlobals.checkXMLNoText(element, sourceReference, 'kls1')
            BibleOrgSysGlobals.checkXMLNoAttributes(element, sourceReference,
                                                    'kd21')
            BibleOrgSysGlobals.checkXMLNoTail(element, sourceReference, 'so20')

            actualRawLinksList = []
            for subelement in element:
                #vPrint( 'Quiet', debuggingThisModule, BibleOrgSysGlobals.elementStr( subelement ) )
                if subelement.tag in (
                        'sourceReference',
                        'sourceComponent',
                ):  # already processed these
                    BibleOrgSysGlobals.checkXMLNoAttributes(
                        subelement, sourceReference, 'ls12')
                    BibleOrgSysGlobals.checkXMLNoSubelements(
                        subelement, sourceReference, 'ks02')
                    BibleOrgSysGlobals.checkXMLNoTail(subelement,
                                                      sourceReference, 'sqw1')

                elif subelement.tag == 'BibleReferenceLink':
                    BibleOrgSysGlobals.checkXMLNoText(subelement,
                                                      sourceReference, 'haw9')
                    BibleOrgSysGlobals.checkXMLNoAttributes(
                        subelement, sourceReference, 'hs19')
                    BibleOrgSysGlobals.checkXMLNoTail(subelement,
                                                      sourceReference, 'jsd9')

                    targetReference = subelement.find('targetReference').text
                    targetComponent = subelement.find('targetComponent').text
                    assert targetComponent in (
                        'Section',
                        'Verses',
                        'Verse',
                    )
                    linkType = subelement.find('linkType').text
                    assert linkType in (
                        'TSK',
                        'QuotedOTReference',
                        'AlludedOTReference',
                        'PossibleOTReference',
                    )

                    actualRawLinksList.append((
                        targetReference,
                        targetComponent,
                        linkType,
                    ))
                    actualLinkCount += 1

            rawRefLinkList.append((
                sourceReference,
                sourceComponent,
                actualRawLinksList,
            ))

        vPrint(
            'Normal', debuggingThisModule,
            f"  {len(rawRefLinkList):,} raw links loaded (with {actualLinkCount:,} actual raw link entries)"
        )

        myRefLinkList = []
        actualLinkCount = 0
        BOS = BibleOrganisationalSystem('GENERIC-KJV-66-ENG')

        for j, (sourceReference, sourceComponent,
                actualRawLinksList) in enumerate(rawRefLinkList):
            # Just do some testing first
            if sourceComponent == 'Verse':
                x = SimpleVerseKey(sourceReference)
            else:
                flag = False
                try:
                    x = SimpleVerseKey(sourceReference, ignoreParseErrors=True)
                    flag = True
                except TypeError:
                    pass  # This should happen coz it should fail the SVK
                if flag:
                    logging.error("{} {!r} failed!".format(
                        sourceComponent, sourceReference))
                    raise TypeError
            # Now do the actual parsing
            parsedSourceReference = FlexibleVersesKey(sourceReference)
            if BibleOrgSysGlobals.debugFlag and debuggingThisModule:
                vPrint('Quiet', debuggingThisModule, j, sourceComponent,
                       sourceReference, parsedSourceReference)
                #assert parsedSourceReference.getShortText().replace(' ','_') == sourceReference
            actualLinksList = []
            for k, (targetReference, targetComponent,
                    linkType) in enumerate(actualRawLinksList):
                # Just do some testing first
                if targetComponent == 'Verse':
                    x = SimpleVerseKey(targetReference)
                else:
                    flag = False
                    try:
                        x = SimpleVerseKey(targetReference,
                                           ignoreParseErrors=True)
                        flag = True
                    except TypeError:
                        pass  # This should happen coz it should fail the SVK
                    if flag:
                        logging.error("{} {!r} failed!".format(
                            targetComponent, targetReference))
                        raise TypeError
                # Now do the actual parsing
                try:
                    parsedTargetReference = FlexibleVersesKey(targetReference)
                except TypeError:
                    logging.error(
                        "  Temporarily ignored {!r} (TypeError from FlexibleVersesKey)"
                        .format(targetReference))
                    parsedTargetReference = None
                if BibleOrgSysGlobals.debugFlag and debuggingThisModule:
                    vPrint('Quiet', debuggingThisModule, ' ', targetComponent,
                           targetReference, parsedTargetReference)
                    #assert parsedTargetReference.getShortText().replace(' ','_',1) == targetReference

                actualLinksList.append((
                    targetReference,
                    targetComponent,
                    parsedTargetReference,
                    linkType,
                ))
                actualLinkCount += 1

            myRefLinkList.append((
                sourceReference,
                sourceComponent,
                parsedSourceReference,
                actualLinksList,
            ))

        vPrint(
            'Normal', debuggingThisModule,
            "  {:,} links processed (with {:,} actual link entries)".format(
                len(rawRefLinkList), actualLinkCount))
        #vPrint( 'Quiet', debuggingThisModule, myRefLinkList ); halt
        self.__DataList = myRefLinkList

        # Now put it into my dictionaries for easy access
        # This part should be customized or added to for however you need to process the data

        # Create a link dictionary (by verse key)
        myRefLinkDict = {}
        for sourceReference, sourceComponent, parsedSourceReference, actualLinksList in myRefLinkList:
            #vPrint( 'Quiet', debuggingThisModule, sourceReference, sourceComponent, parsedSourceReference )
            #vPrint( 'Quiet', debuggingThisModule, sourceReference, sourceComponent, parsedSourceReference, actualLinksList )
            for verseRef in parsedSourceReference.getIncludedVerses():
                #vPrint( 'Quiet', debuggingThisModule, verseRef )
                assert isinstance(verseRef, SimpleVerseKey)
                if verseRef not in myRefLinkDict: myRefLinkDict[verseRef] = []
                myRefLinkDict[verseRef].append((
                    sourceReference,
                    sourceComponent,
                    parsedSourceReference,
                    actualLinksList,
                ))
            #vPrint( 'Quiet', debuggingThisModule, myRefLinkDict ); halt
        originalLinks = len(myRefLinkDict)
        vPrint(
            'Quiet', debuggingThisModule,
            "  {:,} verse links added to dictionary (includes filling out spans)"
            .format(originalLinks))
        #vPrint( 'Quiet', debuggingThisModule, myRefLinkDict ); halt

        # Create a reversed link dictionary (by verse key)
        for sourceReference, sourceComponent, parsedSourceReference, actualLinksList in myRefLinkList:
            #vPrint( 'Quiet', debuggingThisModule, sourceReference, sourceComponent, parsedSourceReference )
            #vPrint( 'Quiet', debuggingThisModule, sourceReference, sourceComponent, parsedSourceReference, actualLinksList )
            for targetReference, targetComponent, parsedTargetReference, linkType in actualLinksList:
                if parsedTargetReference is not None:
                    for verseRef in parsedTargetReference.getIncludedVerses():
                        #vPrint( 'Quiet', debuggingThisModule, verseRef )
                        assert isinstance(verseRef, SimpleVerseKey)
                        if linkType == 'TSK': reverseLinkType = 'TSKQuoted'
                        elif linkType == 'QuotedOTReference':
                            reverseLinkType = 'OTReferenceQuoted'
                        elif linkType == 'AlludedOTReference':
                            reverseLinkType = 'OTReferenceAlluded'
                        elif linkType == 'PossibleOTReference':
                            reverseLinkType = 'OTReferencePossible'
                        else:
                            halt  # Have a new linkType!
                        if verseRef not in myRefLinkDict:
                            myRefLinkDict[verseRef] = []
                        myRefLinkDict[verseRef].append(
                            (targetReference, targetComponent,
                             parsedTargetReference, [
                                 (sourceReference, sourceComponent,
                                  parsedSourceReference, reverseLinkType)
                             ]))
            #vPrint( 'Quiet', debuggingThisModule, myRefLinkDict ); halt
        totalLinks = len(myRefLinkDict)
        reverseLinks = totalLinks - originalLinks
        vPrint(
            'Quiet', debuggingThisModule,
            "  {:,} reverse links added to dictionary to give {:,} total".
            format(reverseLinks, totalLinks))
        #vPrint( 'Quiet', debuggingThisModule, myRefLinkDict ); halt

        self.__DataDict = myRefLinkDict

        # Let's find the most number of references for a verse
        mostReferences = totalReferences = 0
        for verseRef, entryList in self.__DataDict.items():
            numRefs = len(entryList)
            if numRefs > mostReferences:
                mostReferences, mostVerseRef = numRefs, verseRef
            totalReferences += numRefs
        vPrint(
            'Quiet', debuggingThisModule,
            "  {:,} maximum links for any one reference ({})".format(
                mostReferences, mostVerseRef.getShortText()))
        vPrint('Quiet', debuggingThisModule,
               "  {:,} total links for all references".format(totalReferences))

        return self.__DataList, self.__DataDict
Exemple #6
0
def fullDemo() -> None:
    """
    Full demo to check class is working
    """
    from BibleOrgSys.Reference.VerseReferences import SimpleVerseKey

    BibleOrgSysGlobals.introduceProgram( __name__, programNameVersion, LAST_MODIFIED_DATE )

    if 1: # Test the DBPBibles class
        vPrint( 'Quiet', debuggingThisModule, '' )
        dbpBibles = DBPBibles()
        vPrint( 'Quiet', debuggingThisModule, dbpBibles )
        #dbpBibles.load() # takes a minute
        #vPrint( 'Quiet', debuggingThisModule, dbpBibles )

        if 0:
            dbpBibles.fetchAllLanguages()
            vPrint( 'Quiet', debuggingThisModule, "\nLanguage list ({}):".format( len(dbpBibles.languageList) ) )
            for j, lgDict in enumerate( dbpBibles.languageList ):
                vPrint( 'Quiet', debuggingThisModule, 'Lg', j, repr(lgDict) )

        if 0:
            dbpBibles.fetchAllVersions()
            vPrint( 'Quiet', debuggingThisModule, "\nVersion list ({}):".format( len(dbpBibles.versionList) ) )
            for j, verDict in enumerate( dbpBibles.versionList ):
                vPrint( 'Quiet', debuggingThisModule, 'Ver', j, repr(verDict) )

        if 0:
            dbpBibles.fetchAllVolumes()
            vPrint( 'Quiet', debuggingThisModule, "\nVolume list ({}):".format( len(dbpBibles.volumeList) ) )
            for j, volDict in enumerate( dbpBibles.volumeList ):
                vPrint( 'Quiet', debuggingThisModule, ' ', j, repr(volDict) )
            vPrint( 'Quiet', debuggingThisModule, "393", dbpBibles.volumeList[393] )
            vPrint( 'Quiet', debuggingThisModule, "394", dbpBibles.volumeList[394] )
            vPrint( 'Quiet', debuggingThisModule, "395", dbpBibles.volumeList[395] )

        if 0:
            dbpBibles.fetchAllTextVolumes()
            vPrint( 'Quiet', debuggingThisModule, "\nVolume name dict ({}):".format( len(dbpBibles.volumeNameDict) ) )
            for j, someName in enumerate( dbpBibles.volumeNameDict ):
                #if 'English' in someName:
                    #vPrint( 'Quiet', debuggingThisModule, "English:", repr(someName), repr(dbpBibles.volumeNameDict[someName]) )
                vPrint( 'Quiet', debuggingThisModule, j, repr(someName), repr(dbpBibles.volumeNameDict[someName]) )
                #if 'English' in someName:
                    #vPrint( 'Quiet', debuggingThisModule, "  English:", repr(someName), repr(dbpBibles.volumeNameDict[someName]) )
            vPrint( 'Quiet', debuggingThisModule, "English search", dbpBibles.searchNames( "English" ) )
            vPrint( 'Quiet', debuggingThisModule, "MS search", dbpBibles.searchNames( "Salug" ) )

        if 1:
            dbpBibles.fetchAllEnglishTextVolumes()
            vPrint( 'Quiet', debuggingThisModule, "\nEnglish volume name dict ({}):".format( len(dbpBibles.EnglishVolumeNameDict) ) )
            for j, someName in enumerate( dbpBibles.EnglishVolumeNameDict ):
                #if 'English' in someName:
                    #vPrint( 'Quiet', debuggingThisModule, "English:", repr(someName), repr(dbpBibles.EnglishVolumeNameDict[someName]) )
                vPrint( 'Quiet', debuggingThisModule, "  {}/ {!r} {!r}".format( j, someName, dbpBibles.EnglishVolumeNameDict[someName] ) )
                #if 'English' in someName:
                    #vPrint( 'Quiet', debuggingThisModule, "  English:", repr(someName), repr(dbpBibles.EnglishVolumeNameDict[someName]) )


    testRefs = ( ('GEN','1','1'), ('JER','33','3'), ('MAL','4','6'), ('MAT','1','1'), ('JHN','3','16'), ('JDE','1','14'), ('REV','22','21'), )

    if 1: # Test the DBPBible class with the ESV
        vPrint( 'Quiet', debuggingThisModule, '' )
        dbpBible1 = DBPBible( 'ENGESV' )
        vPrint( 'Quiet', debuggingThisModule, dbpBible1 )
        for testRef in testRefs:
            verseKey = SimpleVerseKey( *testRef )
            vPrint( 'Quiet', debuggingThisModule, verseKey )
            vPrint( 'Quiet', debuggingThisModule, " ", dbpBible1.getVerseDataList( verseKey ) )
         # Now test the DBPBible class caching
        for testRef in testRefs:
            verseKey = SimpleVerseKey( *testRef )
            vPrint( 'Quiet', debuggingThisModule, verseKey, "cached" )
            vPrint( 'Quiet', debuggingThisModule, " ", dbpBible1.getVerseDataList( verseKey ) )


    if 1: # Test the DBPBible class with the MS
        vPrint( 'Quiet', debuggingThisModule, '' )
        dbpBible2 = DBPBible( 'MBTWBT' )
        vPrint( 'Quiet', debuggingThisModule, dbpBible2 )
        for testRef in testRefs:
            verseKey = SimpleVerseKey( *testRef )
            vPrint( 'Quiet', debuggingThisModule, verseKey )
            vPrint( 'Quiet', debuggingThisModule, " ", dbpBible2.getVerseDataList( verseKey ) )
def fullDemo() -> None:
    """
    Full demo to check class is working
    """
    from BibleOrgSys.Reference.VerseReferences import SimpleVerseKey

    BibleOrgSysGlobals.introduceProgram(__name__, programNameVersion,
                                        LAST_MODIFIED_DATE)

    # Test the Door43CatalogResources class
    door43CatalogResources = Door43CatalogResources()
    vPrint('Quiet', debuggingThisModule, door43CatalogResources)
    #Door43CatalogResources.load() # takes a minute
    #vPrint( 'Quiet', debuggingThisModule, Door43CatalogResources )

    door43CatalogResources.fetchCatalog()
    if BibleOrgSysGlobals.verbosityLevel > 0:
        vPrint('Quiet', debuggingThisModule, '')
        vPrint('Quiet', debuggingThisModule, door43CatalogResources)

    if BibleOrgSysGlobals.debugFlag and debuggingThisModule:
        vPrint(
            'Info', debuggingThisModule,
            f"\nLanguage list ({len(door43CatalogResources.languageDict)}):")
        for j, (lg, lgDict) in enumerate(
                door43CatalogResources.languageDict.items()):
            vPrint('Info', debuggingThisModule, '  Lg', j + 1, lg,
                   lgDict['direction'], lgDict['title'])
            # lgDict.keys() are lgDict['identifier']
            assert 4 <= len(
                lgDict.keys()
            ) <= 6  # 'category_labels', 'direction', 'identifier', 'resources', 'title', 'versification_labels'
            vPrint('Info', debuggingThisModule, '   ', len(lgDict.keys()),
                   lgDict.keys())
            for something in lgDict['resources']:
                assert isinstance(something, dict)
                vPrint(
                    'Info', debuggingThisModule,
                    f"   \"{something['title']}\" ({something['subject']}) ({len(something.keys())}) {something.keys()}"
                )
                if not something['subject']:
                    logging.critical(
                        f"Missing subject field from {lgDict['identifier']} {something['title']}"
                    )
                elif door43CatalogResources.subjectNameList and something[
                        'subject'] not in door43CatalogResources.subjectNameList:
                    logging.critical(
                        f"Unknown '{something['subject']}' subject field from {lgDict['identifier']} {something['title']}"
                    )
            if 'category_labels' in lgDict:
                vPrint('Info', debuggingThisModule, '    category_labels',
                       lgDict['category_labels'])
            if 'versification_labels' in lgDict:
                vPrint('Info', debuggingThisModule, '    versification_labels',
                       lgDict['versification_labels'])

    if BibleOrgSysGlobals.verbosityLevel > 2:  # Neatly list all available resources
        vPrint(
            'Quiet', debuggingThisModule,
            f"\n  Resource list ({len(door43CatalogResources.resourceList)}):")
        for j, (lg, resourceTitle, resourceEntry) in enumerate(
                door43CatalogResources.resourceList):
            vPrint(
                'Quiet', debuggingThisModule,
                f"    {j+1:3}/ {lg:5} '{resourceTitle}'   ({resourceEntry['subject']})"
            )
            if 'formats' in resourceEntry:
                formats = resourceEntry['formats']
            else:
                assert len(resourceEntry['projects']) == 1
                formats = resourceEntry['projects'][0]['formats']
            assert formats
            for formatEntry in formats:
                assert isinstance(formatEntry, dict)
                vPrint(
                    'Quiet', debuggingThisModule,
                    f"            '{formatEntry['format']}'  {formatEntry['url']}"
                )

    if BibleOrgSysGlobals.verbosityLevel > 1:
        # List all Bibles (i.e., all USFM format)
        vPrint('Quiet', debuggingThisModule,
               f"\n  Bible list ({len(door43CatalogResources.BibleList)}):")
        for j, (lg, resourceTitle,
                resourceEntry) in enumerate(door43CatalogResources.BibleList):
            vPrint(
                'Quiet', debuggingThisModule,
                f"    {j+1:3}/ {lg:5} '{resourceTitle}'   ({resourceEntry['subject']})"
            )
            if 'formats' in resourceEntry:
                formats = resourceEntry['formats']
            else:
                assert len(resourceEntry['projects']) == 1
                formats = resourceEntry['projects'][0]['formats']
            assert formats
            for formatEntry in formats:
                assert isinstance(formatEntry, dict)
                vPrint(
                    'Quiet', debuggingThisModule,
                    f"            '{formatEntry['format']}'  {formatEntry['url']}"
                )

        # List all Open Bible Stories
        OBSList = []
        for lg, lgEntry in door43CatalogResources.languageDict.items():
            for resourceEntry in lgEntry['resources']:
                assert isinstance(resourceEntry, dict)
                resourceTuple = lg, resourceEntry['title'], resourceEntry
                if 'Bible Stories' in resourceEntry['subject']:
                    OBSList.append(resourceTuple)
        vPrint('Quiet', debuggingThisModule,
               f"\n  Bible Stories list ({len(OBSList)}):")
        for j, (lg, resourceTitle, resourceEntry) in enumerate(OBSList):
            vPrint(
                'Quiet', debuggingThisModule,
                f"    {j+1:3}/ {lg:5} '{resourceTitle}'   ({resourceEntry['subject']})"
            )
            if 'formats' in resourceEntry:
                formats = resourceEntry['formats']
            else:
                assert len(resourceEntry['projects']) == 1
                formats = resourceEntry['projects'][0]['formats']
            assert formats
            for formatEntry in formats:
                assert isinstance(formatEntry, dict)
                vPrint(
                    'Quiet', debuggingThisModule,
                    f"            '{formatEntry['format']}'  {formatEntry['url']}"
                )

    testRefs = (
        ('GEN', '1', '1'),
        ('PSA', '150', '6'),
        ('JER', '33', '3'),
        ('MAL', '4', '6'),
        ('MAT', '1', '1'),
        ('JHN', '3', '16'),
        ('TIT', '2', '2'),
        ('JDE', '1', '14'),
        ('REV', '22', '21'),
    )

    if 1:  # Test the Door43CatalogBible class by finding a Bible
        for lgCode, desiredTitle in (
            ('ru', 'Russian Synodal Bible'),
            ('ru', 'Russian Unlocked Literal Bible'),
            ('ru', 'Russian Open Bible'),
            ('ru', 'Russion Literal Bible'),
            ('en', 'unfoldingWord Literal Text'),
            ('en', 'unfoldingWord Simplified Text'),
            ('fr', 'unfoldingWord Literal Text'),
            ('el-x-koine', 'unfoldingWord Greek New Testament'),
        ):
            vPrint('Quiet', debuggingThisModule, '')
            searchResultDict = door43CatalogResources.searchBibles(
                lgCode, desiredTitle)
            if searchResultDict:
                Door43CatalogBible1 = Door43CatalogBible(searchResultDict)
                vPrint('Quiet', debuggingThisModule, Door43CatalogBible1)
                Door43CatalogBible1.preload()
                vPrint('Quiet', debuggingThisModule, Door43CatalogBible1)
                for testRef in testRefs:
                    verseKey = SimpleVerseKey(*testRef)
                    if BibleOrgSysGlobals.verbosityLevel > 0:
                        vPrint('Quiet', debuggingThisModule, verseKey)
                        vPrint('Quiet', debuggingThisModule, " ",
                               Door43CatalogBible1.getVerseDataList(verseKey))
                vPrint('Quiet', debuggingThisModule, Door43CatalogBible1)
            elif BibleOrgSysGlobals.verbosityLevel > 0:
                vPrint('Quiet', debuggingThisModule,
                       f"{lgCode} '{desiredTitle}' was not found!")
def main() -> None:
    """
    This is the main program for the app

    Note that the standard verbosityLevel is 2:
        -s (silent) is 0
        -q (quiet) is 1
        -i (information) is 3
        -v (verbose) is 4.
    """
    BibleOrgSysGlobals.introduceProgram(__name__, programNameVersion,
                                        LAST_MODIFIED_DATE)

    # Download the online Door43 Resource Catalog
    door43CatalogResources = Door43CatalogResources()
    vPrint('Info', debuggingThisModule, door43CatalogResources)
    door43CatalogResources.fetchCatalog()
    vPrint('Info', debuggingThisModule, '\n{door43CatalogResources}\n\n')

    # Download and load all books from the UGNT = unfoldingWord® Greek New Testament
    UGNTDict = door43CatalogResources.searchBibles(
        'el-x-koine', 'unfoldingWord® Greek New Testament')
    if UGNTDict:
        Door43CatalogUGNTBible = Door43CatalogBible(UGNTDict)
        #dPrint( 'Quiet', debuggingThisModule, Door43CatalogUGNTBible )
        Door43CatalogUGNTBible.preload()
        #dPrint( 'Quiet', debuggingThisModule, Door43CatalogUGNTBible )
        Door43CatalogUGNTBible.load()
        vPrint('Quiet',
               debuggingThisModule,
               Door43CatalogUGNTBible,
               end='\n\n')

    # Download the ULT = unfoldingWord® Literal Text
    ULTDict = door43CatalogResources.searchBibles(
        'en', 'unfoldingWord® Literal Text')
    if ULTDict:
        Door43CatalogULTBible = Door43CatalogBible(ULTDict)
        #dPrint( 'Quiet', debuggingThisModule, Door43CatalogULTBible )
        Door43CatalogULTBible.preload()
        vPrint('Quiet', debuggingThisModule, Door43CatalogULTBible, end='\n\n')

    # Go through the UGNT verse by verse
    #   and do some comparisions with the matching ULT verses
    # NOTE: This code assumes matching versification systems
    count1 = count2 = 0
    for BBB, UGNTBook in Door43CatalogUGNTBible.books.items():
        for C in range(1, Door43CatalogUGNTBible.getNumChapters(BBB) + 1):
            for V in range(1, Door43CatalogUGNTBible.getNumVerses(BBB, C) + 1):
                ref = SimpleVerseKey(BBB, C, V)
                text1 = Door43CatalogUGNTBible.getVerseText(ref,
                                                            fullTextFlag=False)
                if not text1:
                    logging.warning(
                        f"Blank text at {ref.getShortText()} in UGNT")
                try:
                    # NOTE: The following line will automatically load the ULT book into memory as required
                    text2 = Door43CatalogULTBible.getVerseText(
                        ref, fullTextFlag=False)
                    if not text2:
                        logging.warning(
                            f"Blank text at {ref.getShortText()} in ULT")
                except KeyError:
                    logging.error(f"Can't find {ref.getShortText()} in ULT")
                    text2 = ''

                # Now that we have text1 and text2 for the verse specified in ref,
                #   do our analysis/comparison now
                J1 = 'Ἰησοῦς' in text1 or 'Ἰησοῦ' in text1 or 'Ἰησοῦν' in text1
                J2 = 'Jesus' in text2
                if J1 and not J2:
                    if BibleOrgSysGlobals.verbosityLevel > 1:
                        vPrint(
                            'Quiet', debuggingThisModule,
                            f"Found 'Jesus' in Grk {ref.getShortText()}: {text1}"
                        )
                        vPrint('Quiet', debuggingThisModule,
                               f"                              {text2}")
                    count1 += 1
                if J2 and not J1:
                    if BibleOrgSysGlobals.verbosityLevel > 1:
                        vPrint(
                            'Quiet', debuggingThisModule,
                            f"Found 'Jesus' in ULT {ref.getShortText()}: {text2}"
                        )
                        vPrint('Quiet', debuggingThisModule,
                               f"                              {text1}")
                    count2 += 1
    vPrint(
        'Quiet', debuggingThisModule,
        f"\nFound {count1} unmatched occurrences in UGNT, {count2} in ULT.")