def _loadBookMP(self, BBB: str) -> Optional[BibleBook]: """ Multiprocessing version! Load the requested book if it's not already loaded (but doesn't save it as that is not safe for multiprocessing) Parameter is a 2-tuple containing BBB and the filename. """ fnPrint(debuggingThisModule, f"loadBookMP( {BBB} )") assert BBB not in self.books self.triedLoadingBook[BBB] = True if BBB in self.givenBookList: if BibleOrgSysGlobals.verbosityLevel > 2 or BibleOrgSysGlobals.debugFlag: vPrint( 'Quiet', debuggingThisModule, ' ' + "Loading {} from {} from {}…".format( BBB, self.name, self.sourceFolder)) bcvBB = uWOBSBibleBook(self, BBB) bcvBB.load() bcvBB.validateMarkers() if BibleOrgSysGlobals.verbosityLevel > 2 or BibleOrgSysGlobals.debugFlag: vPrint('Quiet', debuggingThisModule, _(" Finishing loading uW OBS book {}.").format(BBB)) return bcvBB else: logging.info( "uW OBS book {} is not listed as being available".format(BBB))
def searchReposFuzzy(self, wantedRepoOwner=None, wantedRepoTitle=None): """ Search thru the list of available online Bibles to find a match of the optional title and optional owner. Returns the dictionary for the resource (or a list of dictionaries if there's multiple matches) """ fnPrint( debuggingThisModule, f"DCSBibles.searchReposFuzzy( {wantedRepoOwner!r}, {wantedRepoTitle!r} )…" ) resultsList = [] for entryDict in self.BibleList: #dPrint( 'Quiet', debuggingThisModule, 'entryDict', type(entryDict), len(entryDict), repr(entryDict), '\n' ) assert entryDict and isinstance(entryDict, dict) and len(entryDict) >= 23 ownerName = entryDict['owner']['full_name'] if not ownerName: ownerName = entryDict['owner']['username'] if (wantedRepoOwner is None or wantedRepoOwner in ownerName) \ and (wantedRepoTitle is None or wantedRepoTitle in entryDict['name']): resultsList.append(entryDict) if len(resultsList) == 1: return resultsList[0] return resultsList
def doListAppend(self, BBB: str, filename, givenList, caller) -> None: """ Check that BBB and filename are not in the givenList, then add them as a 2-tuple. If there is a duplicate, remove both (as we're obviously unsure). """ fnPrint( debuggingThisModule, f"USXFilenames.doListAppend( {BBB}, {filename}, {givenList}, {caller} )" ) removeBBB = removeFilename = None for existingBBB, existingFilename in givenList: if existingBBB == BBB: logging.warning( "{} tried to add duplicate {} {} when already had {} (removed both)" .format(caller, BBB, filename, existingFilename)) removeBBB, removeFilename = existingBBB, existingFilename if existingFilename == filename: logging.warning( "{} tried to add duplicate {} {} when already had {} (removed both)" .format(caller, filename, BBB, existingBBB)) removeBBB, removeFilename = existingBBB, existingFilename if removeFilename: givenList.remove((removeBBB, removeFilename)) else: givenList.append((BBB, filename))
def __init__(self, sourceFolder, givenName, encoding='utf-8') -> None: """ Constructor: just sets up the Bible object. """ fnPrint( debuggingThisModule, _("DrupalBible__init__ ( {!r}, {!r}, {!r} )").format( sourceFolder, givenName, encoding)) assert sourceFolder assert givenName # Setup and initialise the base class first Bible.__init__(self) self.objectNameString = 'DrupalBible Bible object' self.objectTypeString = 'DrupalBible' # Now we can set our object variables self.sourceFolder, self.givenName, self.encoding = sourceFolder, givenName, encoding self.sourceFilepath = os.path.join(self.sourceFolder, self.givenName + '.bc') # Do a preliminary check on the readability of our file if not os.access(self.sourceFilepath, os.R_OK): logging.critical( _("DrupalBible: File {!r} is unreadable").format( self.sourceFilepath)) self.name = self.givenName
def fetchAllLanguages(self): """ Download the language lists from FCBH. This can be quite slow. Populates self.languageList (1733 entries as of 2014-10) Each list entry is a dictionary, e.g. {'language_family_code': 'CTD', 'language_name': 'Zokam', 'language_iso_name': 'Tedim Chin', 'english_name': 'Zokam', 'language_code': 'CTD', 'language_iso_2B': '', 'language_iso': 'ctd', 'language_iso_1': '', 'language_iso_2T': ''} {'language_family_code': 'ZOS', 'language_name': 'Zoque de Francisco León', 'language_iso_name': 'Francisco León Zoque', 'english_name': 'Zoque de Francisco Leon', 'language_code': 'ZOS', 'language_iso_2B': '', 'language_iso': 'zos', 'language_iso_1': '', 'language_iso_2T': ''} {'language_family_code': 'GND', 'language_name': 'Zulgo', 'language_iso_name': 'Zulgo-Gemzek', 'english_name': 'Zulgo', 'language_code': 'GND', 'language_iso_2B': '', 'language_iso': 'gnd', 'language_iso_1': '', 'language_iso_2T': ''} {'language_family_code': 'ZUN', 'language_name': 'Zuni', 'language_iso_name': 'Zuni', 'english_name': 'Zuni', 'language_code': 'ZUN', 'language_iso_2B': 'zun', 'language_iso': 'zun', 'language_iso_1': '', 'language_iso_2T': 'zun'} """ fnPrint(debuggingThisModule, "DBPBibles.fetchAllLanguages()") vPrint('Info', debuggingThisModule, _("Downloading list of available languages from FCBH…")) if self.onlineVersion: # Get a list of available data sets self.languageList = self.getOnlineData( "library/language" ) # Get an alphabetically ordered list of dictionaries -- one for each language dPrint('Quiet', debuggingThisModule, " languageList", len(self.languageList)) #, self.languageList ) return self.languageList
def fetchAllVersions(self): """ Download the version lists from FCBH. This can be quite slow. Populates self.versionList (323 entries as of 2014-10) Each list entry is a dictionary, e.g. {'version_name': '', 'version_code': 'ABB', 'english_name': ''} {'version_name': '', 'version_code': 'ABM', 'english_name': ''} {'version_name': '', 'version_code': 'ABS', 'english_name': ''} … {'version_name': 'Biblia de América', 'version_code': 'BDA', 'english_name': ' Biblia de America'} {'version_name': 'Hermanos Libres del Ecuador', 'version_code': 'HLE', 'english_name': ' Hermanos Libres del Ecuador'} {'version_name': '1545 Luther Bibel', 'version_code': 'L45', 'english_name': '1545 Luther Bibel'} … {'version_name': 'Yessan-Mayo Yamano Version', 'version_code': 'YYV', 'english_name': 'Yessan-Mayo Yamano Version'} {'version_name': 'Yessan-Mayo Yawu', 'version_code': 'YWV', 'english_name': 'Yessan-Mayo Yawu'} {'version_name': 'Ze Zoo Zersion', 'version_code': 'ZZQ', 'english_name': 'Ze Zoo Zersion'} """ fnPrint(debuggingThisModule, "DBPBibles.fetchAllVersions()") vPrint('Info', debuggingThisModule, _("Downloading list of available versions from FCBH…")) if self.onlineVersion: # Get a list of available data sets self.versionList = self.getOnlineData( 'library/version' ) # Get an alphabetically ordered list of dictionaries -- one for each version dPrint('Quiet', debuggingThisModule, " versionList", len(self.versionList)) #, self.versionList ) return self.versionList
def loadBook(self, BBB: str): """ Load the requested book into self.books if it's not already loaded. NOTE: You should ensure that preload() has been called first. """ fnPrint(debuggingThisModule, "GoBible.loadBook( {} )".format(BBB)) if BBB in self.books: return # Already loaded if BBB in self.triedLoadingBook: logging.warning( "We had already tried loading GoBible {} for {}".format( BBB, self.name)) return # We've already attempted to load this book self.triedLoadingBook[BBB] = True if BBB in self.bookList: if BibleOrgSysGlobals.verbosityLevel > 2 or BibleOrgSysGlobals.debugFlag: vPrint( 'Quiet', debuggingThisModule, _(" GoBible: Loading {} from {} from {}…").format( BBB, self.name, self.sourceFolder)) GoBibleBk = GoBibleBook(self, BBB) GoBibleBk.load(self.bookList.index(BBB)) GoBibleBk.validateMarkers() self.stashBook(GoBibleBk) #else: logging.info( "GoBible book {} was completely blank".format( BBB ) ) else: logging.info( "GoBible book {} is not listed as being available".format(BBB))
def __init__(self) -> None: """ Constructor: just sets up the file converter object. """ fnPrint(debuggingThisModule, "GreekStrongsFileConverter.__init__()") self.title = self.version = self.date = None self.XMLTree = self.header = self.StrongsEntries = None
def __init__(self, myType, indexToAdjText, noteText, cleanNoteText, location) -> None: """ Accept the parameters and double-check them if requested. location parameter is just for better error messages and is not currently stored. """ fnPrint( debuggingThisModule, "InternalBibleExtra.__init__( {}, {}, {!r}, {!r}, {} )".format( myType, indexToAdjText, noteText, cleanNoteText, location)) if BibleOrgSysGlobals.debugFlag or BibleOrgSysGlobals.strictCheckingFlag: assert myType and isinstance( myType, str) and myType in BOS_EXTRA_TYPES # Mustn't be blank assert '\\' not in myType and ' ' not in myType and '*' not in myType assert isinstance(indexToAdjText, int) and indexToAdjText >= 0 assert noteText and isinstance(noteText, str) # Mustn't be blank assert '\n' not in noteText and '\r' not in noteText for letters in ('f', 'x', 'fe', 'ef'): # footnote, cross-ref, endnotes, studynotes assert '\\' + letters + ' ' not in noteText assert '\\' + letters + '*' not in noteText assert isinstance(cleanNoteText, str) if debuggingThisModule: assert cleanNoteText # Mustn't be blank assert '\\' not in cleanNoteText and '\n' not in cleanNoteText and '\r' not in cleanNoteText self.myType, self.index, self.noteText, self.cleanNoteText = myType, indexToAdjText, noteText, cleanNoteText
def getUSFMIDsFromFiles( self, givenFolder ): """ Go through all the files in the given folder and see how many USFM IDs we can find. Populates the two dictionaries. Returns the number of files found. """ fnPrint( debuggingThisModule, f"getUSFMIDsFromFiles( {givenFolder} )" ) # Empty the two dictionaries self._fileDictionary = {} # The keys are 2-tuples of folder, filename, the values are all valid BBB values self._BBBDictionary = {} # The keys are valid BBB values, the values are all 2-tuples of folder, filename folderFilenames = os.listdir( givenFolder ) for possibleFilename in folderFilenames: pFUpper = possibleFilename.upper() if pFUpper in FILENAMES_TO_IGNORE: continue pFUpperProper, pFUpperExt = os.path.splitext( pFUpper ) ignore = False for ending in FILENAME_ENDINGS_TO_IGNORE: if pFUpper.endswith( ending): ignore=True; break if ignore: continue if pFUpper[-1]!='~' and not pFUpperExt[1:] in EXTENSIONS_TO_IGNORE: # Compare without the first dot filepath = os.path.join( givenFolder, possibleFilename ) if os.path.isfile( filepath ): # It's a file not a folder USFMId = self.getUSFMIDFromFile( givenFolder, possibleFilename, filepath ) if USFMId: assert filepath not in self._fileDictionary BBB = BibleOrgSysGlobals.loadedBibleBooksCodes.getBBBFromUSFMAbbreviation( USFMId ) self._fileDictionary[(givenFolder,possibleFilename,)] = BBB if BBB in self._BBBDictionary: logging.error( "{}Oops, already found {!r} in {}, now we have a duplicate in {}".format( 'getUSFMIDsFromFiles: ' if BibleOrgSysGlobals.debugFlag else '', BBB, self._BBBDictionary[BBB], possibleFilename ) ) self._BBBDictionary[BBB] = (givenFolder,possibleFilename,) if len(self._fileDictionary) != len(self._BBBDictionary): logging.warning( "getUSFMIDsFromFiles: Oops, something went wrong because dictionaries have {} and {} entries".format( len(self._fileDictionary), len(self._BBBDictionary) ) ) #dPrint( 'Quiet', debuggingThisModule, "fD2", self._fileDictionary ) return len(self._fileDictionary)
def searchBibles(self, languageCode=None, BibleTitle=None): """ Search thru the list of available online Bibles to find a match of the optional language and optional title. Returns the dictionary for the resource (or a list of dictionaries if there's multiple matches) """ fnPrint( debuggingThisModule, f"Door43CatalogResources.searchBibles( {languageCode!r}, {BibleTitle!r} )…" ) resultsList = [] for entry in self.BibleList: #dPrint( 'Quiet', debuggingThisModule, 'entry', type(entry), len(entry), repr(entry), '\n' ) assert entry and isinstance(entry, tuple) and len(entry) == 3 lg, title, entryDict = entry if (languageCode is None or languageCode in lg) \ and (BibleTitle is None or BibleTitle in title): assert isinstance(entryDict, dict) if 'language' not in entryDict: entryDict['language'] = lg assert 'title' in entryDict and entryDict['title'] == title resultsList.append(entryDict) if len(resultsList) == 1: return resultsList[0] return resultsList
def loadBook(self, BBB: str) -> None: """ Load the requested book into self.books if it's not already loaded. NOTE: You should ensure that preload() has been called first. """ fnPrint(debuggingThisModule, f"uWOBSBible.loadBook( {BBB} )") if BBB in self.books: return # Already loaded if BBB in self.triedLoadingBook: logging.warning( "We had already tried loading uW OBS {} for {}".format( BBB, self.name)) return # We've already attempted to load this book self.triedLoadingBook[BBB] = True if BBB in self.givenBookList: vPrint( 'Verbose', debuggingThisModule, _(" uWOBSBible: Loading {} from {} from {}…").format( BBB, self.name, self.sourceFolder)) bcvBB = uWOBSBibleBook(self, BBB) bcvBB.load() if bcvBB._rawLines: self.stashBook(bcvBB) bcvBB.validateMarkers() else: logging.info("uW OBS book {} was completely blank".format(BBB)) self.availableBBBs.add(BBB) else: logging.info( "uW OBS book {} is not listed as being available".format(BBB))
def getBBBFromText(self, someText: str) -> str: """ Attempt to return the BBB reference abbreviation string for the given book information (text). Only works for English. BibleBooksNames.py has a more generic version. Returns BBB or None. """ fnPrint(debuggingThisModule, "BibleBooksCodes.getBBBFromText( {} )".format(someText)) if debuggingThisModule or BibleOrgSysGlobals.debugFlag or BibleOrgSysGlobals.strictCheckingFlag: assert someText and isinstance(someText, str) SomeUppercaseText = someText.upper() #dPrint( 'Quiet', debuggingThisModule, '\nrAD', len(self.__DataDicts['referenceAbbreviationDict']), [BBB for BBB in self.__DataDicts['referenceAbbreviationDict']] ) if SomeUppercaseText in self.__DataDicts['referenceAbbreviationDict']: return SomeUppercaseText # it's already a BBB code #if someText.isdigit() and 1 <= int(someText) <= 999: #return self.__DataDicts['referenceNumberDict'][int(someText)]['referenceAbbreviation'] #dPrint( 'Quiet', debuggingThisModule, '\naAD1', len(self.__DataDicts['allAbbreviationsDict']), sorted([BBB for BBB in self.__DataDicts['allAbbreviationsDict']]) ) #dPrint( 'Quiet', debuggingThisModule, '\naAD2', len(self.__DataDicts['allAbbreviationsDict']), self.__DataDicts['allAbbreviationsDict'] ) if SomeUppercaseText in self.__DataDicts['allAbbreviationsDict']: return self.__DataDicts['allAbbreviationsDict'][SomeUppercaseText] # Ok, let's try guessing matchCount, foundBBB = 0, None for BBB in self.__DataDicts['referenceAbbreviationDict']: if BBB in SomeUppercaseText: #dPrint( 'Quiet', debuggingThisModule, 'getBBB1', BBB, SomeUppercaseText ) matchCount += 1 foundBBB = BBB #dPrint( 'Quiet', debuggingThisModule, 'getBBB2', repr(someText), matchCount, foundBBB ) if matchCount == 1: return foundBBB # it's non-ambiguous
def getEntryHTML(self, key: str) -> Optional[str]: """ The key can be a Hebrew Strong's number (string) like 'H1979'. Returns an HTML li entry for the given key. Returns None if the key is not found. e.g., for H1, returns: <li value="1" id="ot:1"><i title="{awb}" xml:lang="hbo">אָב</i> a primitive word; father, in a literal and immediate, or figurative and remote application): <span class="kjv_def">chief, (fore-)father(-less), X patrimony, principal</span>. Compare names in "Abi-".</li> <li value="165" id="ot:165"><i title="{e-hee'}" xml:lang="hbo">אֱהִי</i> apparently an orthographical variation for <a href="#ot:346"><i title="{ah-yay'}" xml:lang="hbo">אַיֵּה</i></a>; where: <span class="kjv_def">I will be (Hos</span>. 13:10, 14) (which is often the rendering of the same Hebrew form from <a href="#ot:1961"><i title="{haw-yaw}" xml:lang="hbo">הָיָה</i></a>).</li> """ fnPrint(debuggingThisModule, "BibleLexicon.getEntryHTML( {} )".format(repr(key))) if not key: return if key[0] == 'H' and key[1:].isdigit(): return self.hLexicon.getStrongsEntryHTML(key) if key[0] == 'G' and key[1:].isdigit(): return self.gLexicon.getStrongsEntryHTML(key) if '.' in key: return self.hLexicon.getBrDrBrEntryHTML(key)
def __init__(self, HebrewXMLFolder=None, GreekXMLFolder=None, preload: bool = False) -> None: """ Constructor: expects the filepath of the source XML file. Does not actually cause the XML to be loaded (very slow). """ fnPrint( debuggingThisModule, "BibleLexicon.__init__( {}, {}, {} )".format( HebrewXMLFolder, GreekXMLFolder, preload)) self.HebrewXMLFolder, self.GreekXMLFolder = HebrewXMLFolder, GreekXMLFolder fnfCount = 0 try: self.hLexicon = HebrewLexicon.HebrewLexicon( self.HebrewXMLFolder, preload) # Create the object except FileNotFoundError: logging.critical( _("BibleLexicon could not find Hebrew lexicon at {}").format( HebrewXMLFolder)) fnfCount += 1 self.hLexicon = None try: self.gLexicon = GreekLexicon.GreekLexicon( self.GreekXMLFolder, preload) # Create the object except FileNotFoundError: logging.critical( _("BibleLexicon could not find Greek lexicon at {}").format( GreekXMLFolder)) fnfCount += 1 self.gLexicon = None if fnfCount >= 2: raise FileNotFoundError
def __init__(self, sourceFileOrFolder, givenName=None) -> None: """ Constructor: just sets up the Bible object. """ fnPrint(debuggingThisModule, f"GoBible.__init__( '{sourceFileOrFolder}', {givenName!r} )") # Setup and initialise the base class first Bible.__init__(self) self.objectNameString = 'Go Bible object' self.objectTypeString = 'GoBible' # Now we can set our object variables self.sourceFileOrFolder, self.givenName = sourceFileOrFolder, givenName if sourceFileOrFolder.endswith(GOBIBLE_FILENAME_END): assert os.path.isfile(sourceFileOrFolder) self.sourceFilepath = sourceFileOrFolder self.sourceFolder = os.path.dirname(sourceFileOrFolder) else: # assume it's a folder assert os.path.isdir(sourceFileOrFolder) self.sourceFolder = sourceFileOrFolder self.sourceFilepath = os.path.join( self.sourceFolder, self.givenName + GOBIBLE_FILENAME_END) # Do a preliminary check on the readability of our file if not os.access(self.sourceFilepath, os.R_OK): logging.critical( _("GoBible: File '{}' is unreadable").format( self.sourceFilepath)) self.name = self.givenName
def load(self) -> None: """ Load the pickled data if possible. Otherwise lLoad the actual XML lexicon (slow). """ fnPrint(debuggingThisModule, "HebrewLexicon.load()") standardPickleFilepath = BibleOrgSysGlobals.BOS_DISTRIBUTED_FILES_FOLDERPATH.joinpath( 'HebrewLexicon_Tables.1.pickle') if standardPickleFilepath.is_file(): import pickle self.hlix = HebrewLexiconIndex() vPrint('Info', debuggingThisModule, f"Loading pickle file {standardPickleFilepath}…") with open( standardPickleFilepath, 'rb' ) as pickleFile: # The protocol version used is detected automatically, so we do not have to specify it self.hlix.indexEntries1 = pickle.load( pickleFile) # Augmented Strongs self.hlix.indexEntries2 = pickle.load( pickleFile) # Augmented Strongs self.hlix.indexEntries = pickle.load(pickleFile) # lix.entries self.StrongsEntries = pickle.load(pickleFile) # hlc.entries self.BrownDriverBriggsEntries = pickle.load( pickleFile) # bdb.entries else: # Load the original XML HebrewLexiconSimple.load(self) assert self.hlix is None self.hlix = HebrewLexiconIndex( self.XMLFolder) # Load and process the XML self.hlix.load()
def refreshAllRemoteSources(self) -> None: """ Get a list of available modules from all the remote repositories (irrespective of self.currentRepoName). Places the information in self.availableModules (which is cleared first). """ fnPrint(debuggingThisModule, "SwordInstallManager.refreshRemoteSource()") if not self.downloadSources: logging.critical( _("No remote Sword repository/repositories specified.")) return False if not self.userDisclaimerConfirmed: logging.critical(_("User security disclaimer not yet confirmed.")) return False vPrint( 'Normal', debuggingThisModule, _("Refreshing/Downloading index files from {} repositories…"). format(len(self.downloadSources))) saveRepo = self.currentRepoName # Remember this self.availableModules = {} # Go through each repo and get the source list for repoName in self.downloadSources: self.currentRepoName = repoName self.refreshRemoteSource(clearFirst=False) self.currentRepoName = saveRepo
def getOnlineData(self, fieldREST, additionalParameters=None): """ Given a string, e.g., "api/apiversion" Does an HTTP GET to our site. Receives the JSON result (hopefully) Converts the JSON bytes to a JSON string Loads the JSON string into a dictionary Returns the dictionary. Returns None if the data cannot be fetched. """ fnPrint( debuggingThisModule, "DBPBible.getOnlineData( {!r} {!r} )".format( fieldREST, additionalParameters)) vPrint( 'Info', debuggingThisModule, "Requesting data from {} for {}…".format(URL_BASE, self.damRoot)) requestString = "{}{}{}{}".format( URL_BASE, fieldREST, self.URLFixedData, '&' + additionalParameters if additionalParameters else '') #dPrint( 'Quiet', debuggingThisModule, "Request string is", repr(requestString) ) try: responseJSON = urllib.request.urlopen(requestString) except urllib.error.URLError: if BibleOrgSysGlobals.debugFlag: logging.critical( "DBPBible.getOnlineData: error fetching {!r} {!r}".format( fieldREST, additionalParameters)) return None responseSTR = responseJSON.read().decode('utf-8') return json.loads(responseSTR)
def fetchAllEnglishTextVolumes(self): """ Download the volume lists from FCBH if necessary. (This can be quite slow.) Populates self.EnglishVolumeNameDict (847 entries as of 2014-10) Dictionary keys are version names, entries are a list of indexes to self.volumeList, e.g. 'Popoloca San Juan Atzingo 1982 Edition' [1143] 'Zokam 1994 Zokam International Version' [334] 'ಕನ್ನಡ Easy-to-Read Version' [413] … 'English 2001 English Standard' [393, 395] 'English English Version for the Deaf' [396, 397] 'English King James' [399, 401, 403, 405] 'English 1995 Edition' [406, 407] 'English 1986 New Life Version (Easy to Read)' [408] 'English World English Bible' [410, 411] … 'Español La Biblia de las Americas' [1302, 1303] 'Mam, Northern 1993 Edition' [825, 826] 'Русский 1876 Synodal Bible' [1246, 1247] """ fnPrint(debuggingThisModule, "DBPBibles.fetchAllEnglishTextVolumes()") vPrint('Info', debuggingThisModule, _("Creating list of available English text volumes from FCBH…")) if self.volumeList is None: self.fetchAllVolumes() self.EnglishVolumeNameDict = {} if self.volumeList: # Create a list of resource types for j, volume in enumerate(self.volumeList): assert volume['language_family_code'] if volume['language_family_code'] == 'ENG': assert volume['volume_name'] ourName = '{}: {}'.format(volume['version_code'], volume['volume_name']) #ourName = volume['volume_name'] assert volume['media'] and volume['delivery'] and volume[ 'collection_code'] if volume['media'] == 'text': if 'web' in volume['delivery']: self.EnglishVolumeNameDict[ourName] = volume[ 'dam_id'][: 6] # Just remember the 6-character damRoot #if ourName in self.EnglishVolumeNameDict: self.EnglishVolumeNameDict[ourName].append( j ) #else: self.EnglishVolumeNameDict[ourName] = [j] else: vPrint('Info', debuggingThisModule, "No web delivery in", repr(ourName), "only", volume['delivery']) elif volume['media'] not in ('audio', 'video'): vPrint('Quiet', debuggingThisModule, "No text in", ourName, volume['media']) dPrint( 'Quiet', debuggingThisModule, "EnglishVolumeNameDict", len(self.EnglishVolumeNameDict)) #, self.EnglishVolumeNameDict ) return self.EnglishVolumeNameDict
def append(self, newBibleEntry): """ Append the newBibleEntry to the InternalBibleEntryList. """ fnPrint(debuggingThisModule, f"InternalBibleEntryList.append( {newBibleEntry} )") assert isinstance(newBibleEntry, InternalBibleEntry) self.data.append(newBibleEntry)
def __init__(self) -> None: """ Create the internal Bibles object. """ fnPrint(debuggingThisModule, "Door43CatalogResources.__init__()") self.subjectJsonList = self.subjectNameList = self.subjectsJsonList = self.subjectDict = None self.catalogDict = self.languageDict = self.resourceList = self.BibleList = None
def __init__( self ) -> None: # We can't give this parameters because of the singleton """ Constructor: """ fnPrint(debuggingThisModule, "BibleBookOrderSystems:__init__()") self.__DataDicts = self.__DataLists = None # We'll import into these in loadData
def __init__(self, XMLFolder=None) -> None: """ Constructor: expects the filepath of the source XML file. Loads (and crudely validates the XML file) into an element tree. """ fnPrint(debuggingThisModule, "HebrewLexiconIndex.__init__( {} )".format(XMLFolder)) self.XMLFolder = XMLFolder
def clearSources(self) -> None: """ Clear our list of available sources. """ fnPrint(debuggingThisModule, "SwordInstallManager.clearSources()") self.downloadSources = {} self.currentRepoName = None
def __getitem__(self, keyIndex): """ Given an index, return the book object (or raise an IndexError) """ fnPrint(debuggingThisModule, f"GenericOnlineBible.__getitem__( {keyIndex} )…") return list(self.books.items())[keyIndex][ 1] # element 0 is BBB, element 1 is the book object
def getPossibleFilenameTuples(self, strictCheck: bool = False ) -> List[Tuple[str, str]]: """ Return a list of filenames just derived from the list of files in the folder, i.e., look only externally at the filenames. If the strictCheck flag is set, the program also looks at the first line(s) inside the files. """ fnPrint(debuggingThisModule, f"USXFilenames.getPossibleFilenameTuples( {strictCheck} )") #dPrint( 'Quiet', debuggingThisModule, "self.fileList", len(self.fileList), self.fileList ) resultList = [] for possibleFilename in self.fileList: # dPrint( 'Quiet', debuggingThisModule, f" USXFilenames.getPossibleFilenameTuples looking for: {possibleFilename}" ) pFUpper = possibleFilename.upper() if pFUpper in filenamesToIgnore: continue pFUpperProper, pFUpperExt = os.path.splitext(pFUpper) for USFMBookCode, USFMDigits, BBB in self._USFMBooksCodeNumberTriples: ignore = False for ending in filenameEndingsToIgnore: if pFUpper.endswith(ending): ignore = True break if ignore: continue checkString = pFUpperProper[ 3:] if self.pattern == 'dddBBB' else pFUpperProper # Otherwise 051COL.usx gets confused between 1Co and Col if USFMBookCode.upper() in checkString: if pFUpper[-1] != '~' and not pFUpperExt[ 1:] in extensionsToIgnore: # Compare without the first dot if strictCheck or BibleOrgSysGlobals.strictCheckingFlag: firstLines = BibleOrgSysGlobals.peekIntoFile( possibleFilename, self.givenFolderName, numLines=3) if not firstLines or len(firstLines) < 3: continue if not ( firstLines[0].startswith( '<?xml version="1.0"' ) or firstLines[0].startswith( "<?xml version='1.0'" ) ) \ and not ( firstLines[0].startswith( '\ufeff<?xml version="1.0"' ) or firstLines[0].startswith( "\ufeff<?xml version='1.0'" ) ): # same but with BOM vPrint( 'Verbose', debuggingThisModule, "USXB (unexpected) first line was {!r} in {}" .format(firstLines, thisFilename)) if '<usx' not in firstLines[ 0] and '<usx' not in firstLines[1]: continue # so it doesn't get added self.doListAppend( BibleOrgSysGlobals.loadedBibleBooksCodes. getBBBFromUSFMAbbreviation(USFMBookCode), possibleFilename, resultList, "getPossibleFilenameTuplesExt") self.lastTupleList = resultList #dPrint( 'Quiet', debuggingThisModule, "final resultList", len(resultList), resultList ) return BibleOrgSysGlobals.loadedBibleBooksCodes.getSequenceList( resultList)
def setCleanText(self, newValue: str) -> None: """ Allows the entry to be changed if it has no extras """ fnPrint( debuggingThisModule, f"InternalBibleEntry.setCleanText( {newValue} ) for {self.marker}") assert not self.extras self.cleanText = self.adjustedText = self.originalText = newValue
def __init__(self, XMLFolder=None, preload=False) -> None: """ Constructor: expects the filepath of the source XML file. Loads (and crudely validates the XML file) into an element tree. """ fnPrint(debuggingThisModule, "HebrewLexiconSimple.__init__( {} )".format(XMLFolder)) self.XMLFolder = XMLFolder self.StrongsEntries = self.BrownDriverBriggsEntries = None if preload: self.load()
def getContextVerseData(self, key): """ Given a BCV key, get the verse data with context. (Most platforms don't provide the context so an empty list is returned.) """ fnPrint(debuggingThisModule, f"GenericOnlineBible.getContextVerseData( {key} )…") return self.getVerseDataList(key), [] # No context