def __makeAbsoluteVerseList( self ):
     """
     Make up a list of four-tuples containing
         BBB, chapterNumber, firstVerseNumber, lastVerseNumber
     """
     accumulatedCount = 0
     for BBB in self.getBookList():
         #vPrint( 'Quiet', debuggingThisModule, BBB, BibleVersificationSystem.getNumVersesList( self, BBB ) )
         for j,numVerses in enumerate( BibleVersificationSystem.getNumVersesList( self, BBB ) ):
             #vPrint( 'Quiet', debuggingThisModule, BBB, j, numVerses )
             BibleOrganisationalSystem.__absoluteVerseDict[(BBB,j+1)] = (accumulatedCount+1,accumulatedCount+numVerses)
             accumulatedCount += numVerses
    def getNumVersesList( self, BBB:str, allowAlternatives=False ):
        """
        Returns a list containing an integer for each chapter indicating the number of verses.

        The length of the list is the number of chapters in the book.
        """
        vPrint( 'Never', debuggingThisModule, "getNumVersesList( {} )".format( BBB ) )
        if debuggingThisModule or BibleOrgSysGlobals.debugFlag or BibleOrgSysGlobals.strictCheckingFlag:
            assert len(BBB) == 3

        if not allowAlternatives: return BibleVersificationSystem.getNumVersesList( self, BBB )

        # Well, we are allowed alternatives, but try the given BBB first anyway
        bookVersesList = None
        try: bookVersesList = BibleVersificationSystem.getNumVersesList( self, BBB )
        except KeyError: # BBB doesn't exist in this BOS -- try an alternative
            # Next line will raise an error if no alternatives (coz returns None)
            for altBBB in BibleOrgSysGlobals.loadedBibleBooksCodes.getPossibleAlternativeBooksCodes( BBB ):
                try: bookVersesList = BibleVersificationSystem.getNumVersesList( self, altBBB ); break
                except KeyError: continue # BBB doesn't exist in this BOS -- try an alternative
            if bookVersesList is not None:
                vPrint( 'Quiet', debuggingThisModule, "Changed {} to {} in {!r} versification scheme".format( BBB, altBBB, BibleVersificationSystem.getVersificationSystemName( self ) ) )
        return bookVersesList
    def isValidBCVRef( self, referenceTuple, referenceString, extended=False ):
        """
        Returns True/False indicating if the given reference is valid in this system.
        Extended flag allows chapter and verse numbers of zero.
        """
        vPrint( 'Never', debuggingThisModule, "isValidBCVRef( {}, {}, {} )".format( referenceTuple, referenceString, extended ) )
        if debuggingThisModule or BibleOrgSysGlobals.debugFlag or BibleOrgSysGlobals.strictCheckingFlag:
            assert isinstance( referenceTuple, str ) or isinstance( referenceTuple, SimpleVerseKey )
        if isinstance( referenceTuple, SimpleVerseKey ): referenceTuple = referenceTuple.getBCVS()

        BBB, C, V, S = referenceTuple
        if BBB is None or not BBB: return False
        assert len(BBB) == 3
        if C and not C.isdigit(): # Should be no suffix on C (although it can be blank if the reference is for a whole book)
            vPrint( 'Quiet', debuggingThisModule, "BibleOrganisationalSystem.isValidBCVRef( {}, {}, {} ) expected C to be digits".format( referenceTuple, referenceString, extended ) )
        assert not V or V.isdigit() # Should be no suffix on V (although it can be blank if the reference is for a whole chapter)
        assert not S or len(S)==1 and S.isalpha() # Suffix should be only one lower-case letter if anything
        if BBB and BibleBookOrderSystem.containsBook( self, BBB ):
            return BibleVersificationSystem.isValidBCVRef( self, referenceTuple, referenceString, extended=extended )
        logging.error( _("{} {}:{} is invalid book for reference {!r} in {} versification system for {}").format(BBB,C,V,referenceString, self.getBookOrderSystemName(),self.getOrganisationalSystemName()) )
        return False
    def __init__( self, systemName ):
        """
        Constructor:
        """
        def getOrganisationalSystemValue( valueName ):
            """ Gets a value for the system. """
            def getMoreBasicTypes():
                """ Returns a list of more basic (original) types. """
                ix = BibleOrgSysGlobals.ALLOWED_ORGANISATIONAL_TYPES.index( self.__dataDict["type"] )
                return BibleOrgSysGlobals.ALLOWED_ORGANISATIONAL_TYPES[ix+1:]
            # end of getMoreBasicTypes

            #vPrint( 'Quiet', debuggingThisModule, "q0", valueName )
            if valueName in self.__dataDict: return self.__dataDict[valueName]
            # else maybe we can find the value in a derived text
            #vPrint( 'Quiet', debuggingThisModule, "q1", self.getOrganisationalSystemName() )
            for tryType in getMoreBasicTypes():
                if 'usesText' in self.__dataDict:
                    for trySystemName in self.__dataDict['usesText']:
                        #vPrint( 'Quiet', debuggingThisModule, "q2", "{} is trying usesText of {}".format(self.__systemName,trySystemName) )
                        result = self.__boss.getOrganisationalSystemValue( trySystemName, valueName )
                        #vPrint( 'Quiet', debuggingThisModule, "  result is", result )
                        if result is not None: return result
                if 'derivedFrom' in self.__dataDict:
                    trySystemName = self.__dataDict['derivedFrom']
                    if isinstance( trySystemName, str ):
                        if BibleOrgSysGlobals.debugFlag: vPrint( 'Quiet', debuggingThisModule, "trySystemName for 'derivedFrom' is a string: {!r}".format( trySystemName ) )
                    elif isinstance( trySystemName, list ):
                        #vPrint( 'Quiet', debuggingThisModule, "trySystemName for 'derivedFrom' is a list: {!r}".format( trySystemName ) )
                        trySystemName = trySystemName[0] # Take the first string from the list
                    #vPrint( 'Quiet', debuggingThisModule, "q3", "{} is trying derivedFrom of {}".format(self.__systemName,trySystemName) )
                    result = self.__boss.getOrganisationalSystemValue( trySystemName, valueName )
                    #vPrint( 'Quiet', debuggingThisModule, "  result is", result )
                    if result is not None: return result
            # else we couldn't find it anywhere
            logging.error( _("{} Bible Organisational System has no {} specified (b)").format(self.__systemName,valueName) )
        # end of getOrganisationalSystemValue

        vPrint( 'Info', debuggingThisModule, "Loading {!r} system".format( systemName ) )
        assert systemName and isinstance( systemName, str )
        self.__boss = BibleOrganisationalSystems().loadData() # Doesn't reload the XML unnecessarily :)
        result = self.__boss.getOrganisationalSystem( systemName )
        if result is None:
            logging.critical( _("No {!r} system in Bible Organisational Systems").format( systemName ) )
            self.__dataDict = self.__systemName = None
            del self
            return

        # else:
        self.__dataDict = result
        self.__systemName = systemName
        #vPrint( 'Quiet', debuggingThisModule, self.__dataDict )

        # Now initialize the inherited classes
        bookOrderSystemName = self.getOrganisationalSystemValue( 'bookOrderSystem' )
        versificationSystemName = self.getOrganisationalSystemValue( 'versificationSystem' )
        punctuationSystemName = self.getOrganisationalSystemValue( 'punctuationSystem' )
        booksNamesSystemName = self.getOrganisationalSystemValue( 'booksNamesSystem' )
        if BibleOrgSysGlobals.debugFlag: vPrint( 'Quiet', debuggingThisModule, "Got organisation bits: BOS={}, VS={}, PS={}, BNS={}".format( bookOrderSystemName, versificationSystemName, punctuationSystemName, booksNamesSystemName ) )
        if bookOrderSystemName and bookOrderSystemName!='None' and bookOrderSystemName!='Unknown':
            vPrint( 'Info', debuggingThisModule, "Uses {!r} book order system".format( bookOrderSystemName ) )
            BibleBookOrderSystem.__init__( self, bookOrderSystemName )
        if versificationSystemName and versificationSystemName!='None' and versificationSystemName!='Unknown':
            vPrint( 'Info', debuggingThisModule, "Uses {!r} versification system".format( versificationSystemName ) )
            BibleVersificationSystem.__init__( self, versificationSystemName )
        if punctuationSystemName and punctuationSystemName!='None' and punctuationSystemName!='Unknown':
            vPrint( 'Info', debuggingThisModule, "Uses {!r} punctuation system".format( punctuationSystemName ) )
            BiblePunctuationSystem.__init__( self, punctuationSystemName )
        if booksNamesSystemName and booksNamesSystemName!='None' and booksNamesSystemName!='Unknown':
            vPrint( 'Info', debuggingThisModule, "Uses {!r} books name system".format( booksNamesSystemName ) )
            BibleBooksNamesSystem.__init__( self, booksNamesSystemName, getOrganisationalSystemValue( 'includesBooks' ) ) # Does one extra step To create the input abbreviations

        # Do some cross-checking
        myBooks = getOrganisationalSystemValue( 'includesBooks' )
        if myBooks is not None:
            for BBB in myBooks:
                if not BibleBookOrderSystem.containsBook( self, BBB ):
                    logging.error( _("Book {!r} is included in {} system but missing from {} book order system").format( BBB, self.__systemName, BibleBookOrderSystem.getBookOrderSystemName( self ) ) )