def __init__( self, systemName ): """ Constructor: """ self.__boss = BibleOrganizationalSystems().loadData() # Doesn't reload the XML unnecessarily :) result = self.__boss.getOrganizationalSystem( systemName ) if result is None: self.__dataDict = self.__systemName = None return # else: self.__dataDict = result self.__systemName = systemName #print( self.__dataDict ) # Now initialize the inherited classes value1 = self.getOrganizationalSystemValue( 'bookOrderSystem' ) if value1: BibleBookOrderSystem.__init__( self, value1 ) value2 = self.getOrganizationalSystemValue( 'versificationSystem' ) if value2: BibleVersificationSystem.__init__( self, value2 ) value3 = self.getOrganizationalSystemValue( 'punctuationSystem' ) if value3: BiblePunctuationSystem.__init__( self, value3 ) value4 = self.getOrganizationalSystemValue( 'booksNamesSystem' ) if value4: BibleBooksNamesSystem.__init__( self, value4, BibleBookOrderSystem.getBookList(self) ) # Does one extra step To create the input abbreviations
def __init__( self, systemName ): """ Constructor: """ def getOrganizationalSystemValue( valueName ): """ Gets a value for the system. """ def getMoreBasicTypes(): """ Returns a list of more basic (original) types. """ ix = allowedTypes.index( self.__dataDict["type"] ) return allowedTypes[ix+1:] # end of getMoreBasicTypes #print( "q0", valueName ) if valueName in self.__dataDict: return self.__dataDict[valueName] # else maybe we can find the value in a derived text #print( "q1", self.getOrganizationalSystemName() ) for tryType in getMoreBasicTypes(): if 'usesText' in self.__dataDict: for trySystemName in self.__dataDict['usesText']: #print( "q2", "{} is trying usesText of {}".format(self.__systemName,trySystemName) ) result = self.__boss.getOrganizationalSystemValue( trySystemName, valueName ) #print( " 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: print( "trySystemName for 'derivedFrom' is a string: {!r}".format( trySystemName ) ) elif isinstance( trySystemName, list ): #print( "trySystemName for 'derivedFrom' is a list: {!r}".format( trySystemName ) ) trySystemName = trySystemName[0] # Take the first string from the list #print( "q3", "{} is trying derivedFrom of {}".format(self.__systemName,trySystemName) ) result = self.__boss.getOrganizationalSystemValue( trySystemName, valueName ) #print( " result is", result ) if result is not None: return result # else we couldn't find it anywhere logging.error( _("{} Bible Organizational System has no {} specified (b)").format(self.__systemName,valueName) ) # end of getOrganizationalSystemValue if BibleOrgSysGlobals.verbosityLevel > 2: print( "Loading {!r} system".format( systemName ) ) assert( systemName and isinstance( systemName, str ) ) self.__boss = BibleOrganizationalSystems().loadData() # Doesn't reload the XML unnecessarily :) result = self.__boss.getOrganizationalSystem( systemName ) if result is None: self.__dataDict = self.__systemName = None del self return # else: self.__dataDict = result self.__systemName = systemName #print( self.__dataDict ) # Now initialize the inherited classes bookOrderSystemName = self.getOrganizationalSystemValue( 'bookOrderSystem' ) versificationSystemName = self.getOrganizationalSystemValue( 'versificationSystem' ) punctuationSystemName = self.getOrganizationalSystemValue( 'punctuationSystem' ) booksNamesSystemName = self.getOrganizationalSystemValue( 'booksNamesSystem' ) if BibleOrgSysGlobals.debugFlag: print( "Got organisation bits: BOS={}, VS={}, PS={}, BNS={}".format( bookOrderSystemName, versificationSystemName, punctuationSystemName, booksNamesSystemName ) ) if bookOrderSystemName and bookOrderSystemName!='None' and bookOrderSystemName!='Unknown': if BibleOrgSysGlobals.verbosityLevel > 2: print( "Uses {!r} book order system".format( bookOrderSystemName ) ) BibleBookOrderSystem.__init__( self, bookOrderSystemName ) if versificationSystemName and versificationSystemName!='None' and versificationSystemName!='Unknown': if BibleOrgSysGlobals.verbosityLevel > 2: print( "Uses {!r} versification system".format( versificationSystemName ) ) BibleVersificationSystem.__init__( self, versificationSystemName ) if punctuationSystemName and punctuationSystemName!='None' and punctuationSystemName!='Unknown': if BibleOrgSysGlobals.verbosityLevel > 2: print( "Uses {!r} punctuation system".format( punctuationSystemName ) ) BiblePunctuationSystem.__init__( self, punctuationSystemName ) if booksNamesSystemName and booksNamesSystemName!='None' and booksNamesSystemName!='Unknown': if BibleOrgSysGlobals.verbosityLevel > 2: print( "Uses {!r} books name system".format( booksNamesSystemName ) ) BibleBooksNamesSystem.__init__( self, booksNamesSystemName, getOrganizationalSystemValue( "includesBooks" ) ) # Does one extra step To create the input abbreviations # Do some cross-checking myBooks = getOrganizationalSystemValue( "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 ) ) )
def __init__(self, systemName): """ Constructor: """ def getOrganizationalSystemValue(valueName): """ Gets a value for the system. """ def getMoreBasicTypes(): """ Returns a list of more basic (original) types. """ ix = allowedTypes.index(self.__dataDict["type"]) return allowedTypes[ix + 1:] # end of getMoreBasicTypes #print( "q0", valueName ) if valueName in self.__dataDict: return self.__dataDict[valueName] # else maybe we can find the value in a derived text #print( "q1", self.getOrganizationalSystemName() ) for tryType in getMoreBasicTypes(): if 'usesText' in self.__dataDict: for trySystemName in self.__dataDict['usesText']: #print( "q2", "{} is trying usesText of {}".format(self.__systemName,trySystemName) ) result = self.__boss.getOrganizationalSystemValue( trySystemName, valueName) #print( " 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: print( "trySystemName for 'derivedFrom' is a string: {!r}" .format(trySystemName)) elif isinstance(trySystemName, list): #print( "trySystemName for 'derivedFrom' is a list: {!r}".format( trySystemName ) ) trySystemName = trySystemName[ 0] # Take the first string from the list #print( "q3", "{} is trying derivedFrom of {}".format(self.__systemName,trySystemName) ) result = self.__boss.getOrganizationalSystemValue( trySystemName, valueName) #print( " result is", result ) if result is not None: return result # else we couldn't find it anywhere logging.error( _("{} Bible Organizational System has no {} specified (b)"). format(self.__systemName, valueName)) # end of getOrganizationalSystemValue if BibleOrgSysGlobals.verbosityLevel > 2: print("Loading {!r} system".format(systemName)) assert systemName and isinstance(systemName, str) self.__boss = BibleOrganizationalSystems().loadData( ) # Doesn't reload the XML unnecessarily :) result = self.__boss.getOrganizationalSystem(systemName) if result is None: self.__dataDict = self.__systemName = None del self return # else: self.__dataDict = result self.__systemName = systemName #print( self.__dataDict ) # Now initialize the inherited classes bookOrderSystemName = self.getOrganizationalSystemValue( 'bookOrderSystem') versificationSystemName = self.getOrganizationalSystemValue( 'versificationSystem') punctuationSystemName = self.getOrganizationalSystemValue( 'punctuationSystem') booksNamesSystemName = self.getOrganizationalSystemValue( 'booksNamesSystem') if BibleOrgSysGlobals.debugFlag: print("Got organisation bits: BOS={}, VS={}, PS={}, BNS={}".format( bookOrderSystemName, versificationSystemName, punctuationSystemName, booksNamesSystemName)) if bookOrderSystemName and bookOrderSystemName != 'None' and bookOrderSystemName != 'Unknown': if BibleOrgSysGlobals.verbosityLevel > 2: print( "Uses {!r} book order system".format(bookOrderSystemName)) BibleBookOrderSystem.__init__(self, bookOrderSystemName) if versificationSystemName and versificationSystemName != 'None' and versificationSystemName != 'Unknown': if BibleOrgSysGlobals.verbosityLevel > 2: print("Uses {!r} versification system".format( versificationSystemName)) BibleVersificationSystem.__init__(self, versificationSystemName) if punctuationSystemName and punctuationSystemName != 'None' and punctuationSystemName != 'Unknown': if BibleOrgSysGlobals.verbosityLevel > 2: print("Uses {!r} punctuation system".format( punctuationSystemName)) BiblePunctuationSystem.__init__(self, punctuationSystemName) if booksNamesSystemName and booksNamesSystemName != 'None' and booksNamesSystemName != 'Unknown': if BibleOrgSysGlobals.verbosityLevel > 2: print( "Uses {!r} books name system".format(booksNamesSystemName)) BibleBooksNamesSystem.__init__( self, booksNamesSystemName, getOrganizationalSystemValue('includesBooks') ) # Does one extra step To create the input abbreviations # Do some cross-checking myBooks = getOrganizationalSystemValue('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)))