本文整理汇总了Python中Bible.Bible.__init__方法的典型用法代码示例。如果您正苦于以下问题:Python Bible.__init__方法的具体用法?Python Bible.__init__怎么用?Python Bible.__init__使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Bible.Bible
的用法示例。
在下文中一共展示了Bible.__init__方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from Bible import Bible [as 别名]
# 或者: from Bible.Bible import __init__ [as 别名]
def __init__( self, givenFolderName, givenName=None, encoding='utf-8' ):
"""
Create the internal USX Bible object.
"""
# Setup and initialise the base class first
Bible.__init__( self )
self.objectNameString = "USX XML Bible object"
self.objectTypeString = "USX"
self.givenFolderName, self.givenName, self.encoding = givenFolderName, givenName, encoding # Remember our parameters
# Now we can set our object variables
self.name = self.givenName
if not self.name: self.name = os.path.basename( self.givenFolderName )
if not self.name: self.name = os.path.basename( self.givenFolderName[:-1] ) # Remove the final slash
if not self.name: self.name = "USX Bible"
# Do a preliminary check on the readability of our folder
if not os.access( self.givenFolderName, os.R_OK ):
logging.error( "USXXMLBible: File {!r} is unreadable".format( self.givenFolderName ) )
# Find the filenames of all our books
self.USXFilenamesObject = USXFilenames( self.givenFolderName )
self.possibleFilenameDict = {}
for BBB,filename in self.USXFilenamesObject.getConfirmedFilenames():
self.possibleFilenameDict[BBB] = filename
示例2: __init__
# 需要导入模块: from Bible import Bible [as 别名]
# 或者: from Bible.Bible import __init__ [as 别名]
def __init__( self, sourceFolder, givenName, encoding='utf-8' ):
"""
Constructor: just sets up the XML Bible file converter object.
"""
# Setup and initialise the base class first
if BibleOrgSysGlobals.debugFlag: print( "OpenSongXMLBible( {}, {}, {} )".format( sourceFolder, givenName, encoding ) )
Bible.__init__( self )
self.objectNameString = "OpenSong XML Bible object"
self.objectTypeString = "OpenSong"
# 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 )
self.tree = None # Will hold the XML data
# Get the data tables that we need for proper checking
#self.ISOLanguages = ISO_639_3_Languages().loadData()
self.genericBOS = BibleOrganizationalSystem( "GENERIC-KJV-66-ENG" )
# Do a preliminary check on the readability of our file
if not os.access( self.sourceFilepath, os.R_OK ):
print( "OpenSongXMLBible: File {!r} is unreadable".format( self.sourceFilepath ) )
self.name = self.givenName
示例3: __init__
# 需要导入模块: from Bible import Bible [as 别名]
# 或者: from Bible.Bible import __init__ [as 别名]
def __init__( self, sourceFolder, givenName=None, givenAbbreviation=None ):
"""
Create the internal ESFM Bible object.
"""
# Setup and initialise the base class first
Bible.__init__( self )
self.objectNameString = "ESFM Bible object"
self.objectTypeString = "ESFM"
# Now we can set our object variables
self.sourceFolder, self.givenName, self.abbreviation = sourceFolder, givenName, givenAbbreviation
# Do a preliminary check on the contents of our folder
foundFiles, foundFolders = [], []
for something in os.listdir( self.sourceFolder ):
somepath = os.path.join( self.sourceFolder, something )
if os.path.isdir( somepath ): foundFolders.append( something )
elif os.path.isfile( somepath ): foundFiles.append( something )
else: logging.error( "Not sure what {!r} is in {}!".format( somepath, self.sourceFolder ) )
if foundFolders:
unexpectedFolders = []
for folderName in foundFolders:
if folderName.startswith( 'Interlinear_'): continue
if folderName in ('__MACOSX'): continue
unexpectedFolders.append( folderName )
if unexpectedFolders:
logging.info( "ESFMBible.load: Surprised to see subfolders in {!r}: {}".format( self.sourceFolder, unexpectedFolders ) )
if not foundFiles:
if BibleOrgSysGlobals.verbosityLevel > 0: print( "ESFMBible: Couldn't find any files in {!r}".format( self.sourceFolder ) )
return # No use continuing
self.USFMFilenamesObject = USFMFilenames( self.sourceFolder )
if BibleOrgSysGlobals.verbosityLevel > 3 or (BibleOrgSysGlobals.debugFlag and debuggingThisModule):
print( self.USFMFilenamesObject )
# Attempt to load the SSF file
self.ssfFilepath, self.settingsDict = {}, {}
ssfFilepathList = self.USFMFilenamesObject.getSSFFilenames( searchAbove=True, auto=True )
if len(ssfFilepathList) == 1: # Seems we found the right one
self.ssfFilepath = ssfFilepathList[0]
self.loadSSFData( self.ssfFilepath )
self.name = self.givenName
if self.name is None:
for field in ('FullName','Name',):
if field in self.settingsDict: self.name = self.settingsDict[field]; break
if not self.name: self.name = os.path.basename( self.sourceFolder )
if not self.name: self.name = os.path.basename( self.sourceFolder[:-1] ) # Remove the final slash
if not self.name: self.name = "ESFM Bible"
# Find the filenames of all our books
self.maximumPossibleFilenameTuples = self.USFMFilenamesObject.getMaximumPossibleFilenameTuples() # Returns (BBB,filename) 2-tuples
self.possibleFilenameDict = {}
for BBB, filename in self.maximumPossibleFilenameTuples:
self.possibleFilenameDict[BBB] = filename
self.dontLoadBook = []
self.spellingDict, self.StrongsDict, self.hyphenationDict, self.semanticDict = {}, {}, {}, {}
示例4: __init__
# 需要导入模块: from Bible import Bible [as 别名]
# 或者: from Bible.Bible import __init__ [as 别名]
def __init__( self, sourceFolder, givenName=None, givenAbbreviation=None, encoding=None ):
"""
Create the internal BCV Bible object.
Note that sourceFolder can be None if we don't know that yet.
"""
# Setup and initialise the base class first
Bible.__init__( self )
self.objectNameString = 'BCV Bible object'
self.objectTypeString = 'BCV'
# Now we can set our object variables
self.sourceFolder, self.givenName, self.abbreviation, self.encoding = sourceFolder, givenName, givenAbbreviation, encoding
示例5: __init__
# 需要导入模块: from Bible import Bible [as 别名]
# 或者: from Bible.Bible import __init__ [as 别名]
def __init__(self, sourceFolder, givenName, encoding="utf-8"):
"""
Constructor: just sets up the Bible object.
"""
# Setup and initialise the base class first
Bible.__init__(self)
self.objectNameString = "Unbound Bible object"
self.objectTypeString = "Unbound"
# 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 + "_utf8.txt")
# Do a preliminary check on the readability of our file
if not os.access(self.sourceFilepath, os.R_OK):
logging.critical(_("UnboundBible: File {!r} is unreadable").format(self.sourceFilepath))
self.name = self.givenName
示例6: __init__
# 需要导入模块: from Bible import Bible [as 别名]
# 或者: from Bible.Bible import __init__ [as 别名]
def __init__( self, sourceFolder, givenFilename, encoding='utf-8' ):
"""
Constructor: just sets up the Bible object.
"""
# Setup and initialise the base class first
Bible.__init__( self )
self.objectNameString = 'e-Sword Bible object'
self.objectTypeString = 'e-Sword'
# Now we can set our object variables
self.sourceFolder, self.sourceFilename, self.encoding = sourceFolder, givenFilename, encoding
self.sourceFilepath = os.path.join( self.sourceFolder, self.sourceFilename )
# Do a preliminary check on the readability of our file
if not os.access( self.sourceFilepath, os.R_OK ):
logging.critical( _("ESwordBible: File {} is unreadable").format( repr(self.sourceFilepath) ) )
filenameBits = os.path.splitext( self.sourceFilename )
self.name = filenameBits[0]
self.fileExtension = filenameBits[1]
示例7: __init__
# 需要导入模块: from Bible import Bible [as 别名]
# 或者: from Bible.Bible import __init__ [as 别名]
def __init__( self, sourceFolder, givenName, encoding='utf-8' ):
"""
Constructor: just sets up the Bible object.
"""
if BibleOrgSysGlobals.verbosityLevel > 2: print( _("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
示例8: __init__
# 需要导入模块: from Bible import Bible [as 别名]
# 或者: from Bible.Bible import __init__ [as 别名]
def __init__( self, sourceFolder, sourceFilename ):
"""
Constructor: just sets up the Bible object.
"""
# Setup and initialise the base class first
Bible.__init__( self )
self.objectNameString = 'EasyWorship Bible object'
self.objectTypeString = 'EWB'
# Now we can set our object variables
self.sourceFolder, self.sourceFilename = sourceFolder, sourceFilename
self.sourceFilepath = os.path.join( self.sourceFolder, self.sourceFilename )
# Do a preliminary check on the readability of our file
if not os.access( self.sourceFilepath, os.R_OK ):
logging.critical( _("EasyWorshipBible: File {!r} is unreadable").format( self.sourceFilepath ) )
global BOS
if BOS is None: BOS = BibleOrganizationalSystem( 'GENERIC-KJV-66-ENG' )
assert FILENAME_ENDING in self.sourceFilename.upper()
self.abbreviation = os.path.splitext( self.sourceFilename)[0] # Remove file extension
示例9: __init__
# 需要导入模块: from Bible import Bible [as 别名]
# 或者: from Bible.Bible import __init__ [as 别名]
def __init__( self, sourceFilepath, givenName=None, encoding='utf-8' ):
"""
Constructor: expects the filepath of the source folder.
Loads (and crudely validates the file(s)) into ???.
"""
# Setup and initialise the base class first
Bible.__init__( self )
self.objectNameString = "Greek NT Bible object"
self.objectTypeString = "GreekNT"
# Now we can set our object variables
self.sourceFilepath, self.givenName, self.encoding = sourceFilepath, givenName, encoding
self.title = self.version = self.date = None
self.tree = self.header = self.frontMatter = self.divs = self.divTypesString = None
#self.bkData, self.USFMBooks = OrderedDict(), OrderedDict()
self.lang = self.language = None
# Do a preliminary check on the readability of our files
self.possibleFilenames = []
if os.path.isdir( self.sourceFilepath ): # We've been given a folder -- see if we can find the files
# There's no standard for OSIS xml file naming
fileList = os.listdir( self.sourceFilepath )
#print( len(fileList), fileList )
# First try looking for OSIS book names
for filename in fileList:
if filename.lower().endswith('.txt'):
thisFilepath = os.path.join( self.sourceFilepath, filename )
#if Globals.debugFlag: print( "Trying {}...".format( thisFilepath ) )
if os.access( thisFilepath, os.R_OK ): # we can read that file
self.possibleFilenames.append( filename )
elif not os.access( self.sourceFilepath, os.R_OK ):
logging.critical( "GreekNT: File '{}' is unreadable".format( self.sourceFilepath ) )
return # No use continuing
#print( self.possibleFilenames ); halt
self.name = self.givenName
示例10: __init__
# 需要导入模块: from Bible import Bible [as 别名]
# 或者: from Bible.Bible import __init__ [as 别名]
def __init__( self, sourceFolder, givenName, encoding='utf-8' ):
"""
Constructor: just sets up the Haggai Bible object.
"""
# Setup and initialise the base class first
Bible.__init__( self )
self.objectNameString = 'Haggai XML Bible object'
self.objectTypeString = 'Haggai'
# 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 )
self.XMLTree = self.header = None # Will hold the XML data
# Get the data tables that we need for proper checking
#self.ISOLanguages = ISO_639_3_Languages().loadData()
self.genericBOS = BibleOrganizationalSystem( 'GENERIC-KJV-66-ENG' )
# Do a preliminary check on the readability of our file
if not os.access( self.sourceFilepath, os.R_OK ):
print( "HaggaiXMLBible: File {!r} is unreadable".format( self.sourceFilepath ) )
self.name = self.givenName
示例11: __init__
# 需要导入模块: from Bible import Bible [as 别名]
# 或者: from Bible.Bible import __init__ [as 别名]
def __init__( self, sourceFolder, givenName=None, encoding='utf-8' ):
"""
Create the internal USFX Bible object.
"""
# Setup and initialise the base class first
Bible.__init__( self )
self.objectNameString = "USFX XML Bible object"
self.objectTypeString = "USFX"
self.sourceFolder, self.givenName, self.encoding = sourceFolder, givenName, encoding # Remember our parameters
# Now we can set our object variables
self.name = self.givenName
if not self.name: self.name = os.path.basename( self.sourceFolder )
if not self.name: self.name = os.path.basename( self.sourceFolder[:-1] ) # Remove the final slash
if not self.name: self.name = "USFX Bible"
if self.name.endswith( '_usfx' ): self.name = self.name[:-5] # Remove end of name for Haiola projects
# Do a preliminary check on the readability of our folder
if not os.access( self.sourceFolder, os.R_OK ):
logging.error( "USFXXMLBible: Folder {!r} is unreadable".format( self.sourceFolder ) )
# Do a preliminary check on the contents of our folder
self.sourceFilename = self.sourceFilepath = None
foundFiles, foundFolders = [], []
for something in os.listdir( self.sourceFolder ):
somepath = os.path.join( self.sourceFolder, something )
if os.path.isdir( somepath ): foundFolders.append( something )
elif os.path.isfile( somepath ):
somethingUpper = something.upper()
somethingUpperProper, somethingUpperExt = os.path.splitext( somethingUpper )
ignore = False
for ending in filenameEndingsToIgnore:
if somethingUpper.endswith( ending): ignore=True; break
if ignore: continue
if not somethingUpperExt[1:] in extensionsToIgnore: # Compare without the first dot
foundFiles.append( something )
else: logging.error( "Not sure what {!r} is in {}!".format( somepath, self.sourceFolder ) )
if foundFolders: logging.info( "USFXXMLBible: Surprised to see subfolders in {!r}: {}".format( self.sourceFolder, foundFolders ) )
if not foundFiles:
if BibleOrgSysGlobals.verbosityLevel > 0: print( "USFXXMLBible: Couldn't find any files in {!r}".format( self.sourceFolder ) )
return # No use continuing
#print( self.sourceFolder, foundFolders, len(foundFiles), foundFiles )
numFound = 0
for thisFilename in sorted( foundFiles ):
firstLines = BibleOrgSysGlobals.peekIntoFile( thisFilename, sourceFolder, numLines=3 )
if not firstLines or len(firstLines)<2: continue
if not firstLines[0].startswith( '<?xml version="1.0"' ) \
and not firstLines[0].startswith( '\ufeff<?xml version="1.0"' ): # same but with BOM
if BibleOrgSysGlobals.verbosityLevel > 2: print( "USFXB (unexpected) first line was {!r} in {}".format( firstLines, thisFilename ) )
continue
if "<usfx " not in firstLines[0]:
continue
lastFilenameFound = thisFilename
numFound += 1
if numFound:
if BibleOrgSysGlobals.verbosityLevel > 2: print( "USFXXMLBible got", numFound, sourceFolder, lastFilenameFound )
if numFound == 1:
self.sourceFilename = lastFilenameFound
self.sourceFilepath = os.path.join( self.sourceFolder, self.sourceFilename )
elif looksHopeful and BibleOrgSysGlobals.verbosityLevel > 2: print( " Looked hopeful but no actual files found" )
示例12: __init__
# 需要导入模块: from Bible import Bible [as 别名]
# 或者: from Bible.Bible import __init__ [as 别名]
def __init__( self, sourceFolder, givenName=None, givenAbbreviation=None, encoding=None ):
"""
Create the internal USFM Bible object.
"""
# Setup and initialise the base class first
Bible.__init__( self )
self.objectNameString = "USFM Bible object"
self.objectTypeString = "USFM"
# Now we can set our object variables
self.sourceFolder, self.givenName, self.abbreviation, self.encoding = sourceFolder, givenName, givenAbbreviation, encoding
# Do a preliminary check on the contents of our folder
foundFiles, foundFolders = [], []
for something in os.listdir( self.sourceFolder ):
somepath = os.path.join( self.sourceFolder, something )
if os.path.isdir( somepath ): foundFolders.append( something )
elif os.path.isfile( somepath ): foundFiles.append( something )
else: logging.error( t("__init__: Not sure what '{}' is in {}!").format( somepath, self.sourceFolder ) )
if foundFolders:
unexpectedFolders = []
for folderName in foundFolders:
if folderName.startswith( 'Interlinear_'): continue
if folderName in ('__MACOSX'): continue
unexpectedFolders.append( folderName )
if unexpectedFolders:
logging.info( t("__init__: Surprised to see subfolders in '{}': {}").format( self.sourceFolder, unexpectedFolders ) )
if not foundFiles:
if Globals.verbosityLevel > 0: print( t("__init__: Couldn't find any files in '{}'").format( self.sourceFolder ) )
raise FileNotFoundError # No use continuing
self.USFMFilenamesObject = USFMFilenames( self.sourceFolder )
if Globals.verbosityLevel > 3 or (Globals.debugFlag and debuggingThisModule):
print( "USFMFilenamesObject", self.USFMFilenamesObject )
# Attempt to load the SSF file
self.ssfFilepath, self.settingsDict = {}, {}
ssfFilepathList = self.USFMFilenamesObject.getSSFFilenames( searchAbove=True, auto=True )
if len(ssfFilepathList) == 1: # Seems we found the right one
self.ssfFilepath = ssfFilepathList[0]
self.loadSSFData( self.ssfFilepath )
if self.encoding is None and 'Encoding' in self.ssfDict: # See if the SSF file gives some help to us
ssfEncoding = self.ssfDict['Encoding']
if ssfEncoding == '65001': self.encoding = 'utf-8'
else:
if Globals.verbosityLevel > 0:
print( t("__init__: File encoding in SSF is set to '{}'").format( ssfEncoding ) )
if ssfEncoding.isdigit():
self.encoding = 'cp' + ssfEncoding
if Globals.verbosityLevel > 0:
print( t("__init__: Switched to '{}' file encoding").format( self.encoding ) )
else:
logging.critical( t("__init__: Unsure how to handle '{}' file encoding").format( ssfEncoding ) )
self.name = self.givenName
if self.name is None:
for field in ('FullName','Name',):
if field in self.settingsDict: self.name = self.settingsDict[field]; break
if not self.name: self.name = os.path.basename( self.sourceFolder )
if not self.name: self.name = os.path.basename( self.sourceFolder[:-1] ) # Remove the final slash
if not self.name: self.name = "USFM Bible"
# Find the filenames of all our books
self.maximumPossibleFilenameTuples = self.USFMFilenamesObject.getMaximumPossibleFilenameTuples() # Returns (BBB,filename) 2-tuples
self.possibleFilenameDict = {}
for BBB, filename in self.maximumPossibleFilenameTuples:
self.possibleFilenameDict[BBB] = filename