当前位置: 首页>>代码示例>>Python>>正文


Python Bible.Bible类代码示例

本文整理汇总了Python中Bible.Bible的典型用法代码示例。如果您正苦于以下问题:Python Bible类的具体用法?Python Bible怎么用?Python Bible使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Bible类的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: __init__

    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
开发者ID:alerque,项目名称:BibleOrgSys,代码行数:25,代码来源:OpenSongXMLBible.py

示例2: __init__

    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
开发者ID:alerque,项目名称:BibleOrgSys,代码行数:26,代码来源:USXXMLBible.py

示例3: __init__

    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 = {}, {}, {}, {}
开发者ID:alerque,项目名称:BibleOrgSys,代码行数:58,代码来源:ESFMBible.py

示例4: __init__

    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
开发者ID:openscriptures,项目名称:BibleOrgSys,代码行数:13,代码来源:BCVBible.py

示例5: __init__

    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
开发者ID:openscriptures,项目名称:BibleOrgSys,代码行数:18,代码来源:UnboundBible.py

示例6: __init__

    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]
开发者ID:dimleyk,项目名称:BibleOrgSys,代码行数:20,代码来源:ESwordBible.py

示例7: __init__

    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
开发者ID:openscriptures,项目名称:BibleOrgSys,代码行数:22,代码来源:DrupalBible.py

示例8: __init__

    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
开发者ID:openscriptures,项目名称:BibleOrgSys,代码行数:22,代码来源:EasyWorshipBible.py

示例9: __init__

    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
开发者ID:dimleyk,项目名称:BibleOrgSys,代码行数:37,代码来源:GreekNT.py

示例10: __init__

    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
开发者ID:openscriptures,项目名称:BibleOrgSys,代码行数:24,代码来源:HaggaiXMLBible.py

示例11: __init__

    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" )
开发者ID:alerque,项目名称:BibleOrgSys,代码行数:62,代码来源:USFXXMLBible.py

示例12: getParsedContent

def getParsedContent():
    bookName = ""

    bible = Bible()
    book = Book("Genesis")
    chapter = Chapter(1)

    file = open("bible.txt")
    bookname = ""
    for line in  file:
	    splitLine = line.split()

	    # Aquires Book Title Name of current line
	    if (splitLine[0].isdigit()):
		    bookName = splitLine[0] + " " + splitLine[1]
	    elif (splitLine[0] == "Song"):
		    bookName = splitLine[0] + " " + splitLine[1] + " " + splitLine[2]
	    else:
		    bookName = splitLine[0]

	    # Aquires Book Chapter number and verse number of current line
	    if (splitLine[0].isdigit()):
		    chapNumAndVerseNum = splitLine[2].split(sep=":")
	    elif (splitLine[0] == "Song"):
		    chapNumAndVerseNum = splitLine[3].split(sep=":")
	    else:
		    chapNumAndVerseNum = splitLine[1].split(sep=":")

	    # Uses chapNumandVerseNum to get the chapter number
	    # and the verse Number
	    currentChapNum = chapNumAndVerseNum[0]
	    currentVerseNum = chapNumAndVerseNum[1]

	    verseString = ""

	    # Aquires the Verse String from the current line.
	    if (splitLine[0].isdigit()):
		    for index in range(3, len(splitLine)):
		        verseString += splitLine[index] + " "
	    elif (splitLine[0] == "Song"):
		    for index in range(4, len(splitLine)):
		        verseString += splitLine[index] + " "
	    else:
		    for index in range(2, len(splitLine)):
		        verseString += splitLine[index] + " "

	    # Uses generated verse String to create a new bible verse
	    currentBibleVerse = Verse(currentVerseNum, verseString)

	    # When Book Title Changes, add the current book to the bible.
	    # Then, create new book.
	    if (book.bookTitle != bookName):
		    book.addChapter(chapter)
		    chapter = Chapter(currentChapNum)
		    bible.addBook(book.bookTitle, book)
		    book = Book(bookName)  # Resets Book Object
		    book.bookTitle = bookName

	    # When Book Number Changes, add the current chapter to the current book
	    # Then, Create a new book.
	    elif(currentChapNum != chapter.chapterNum):
	        book.addChapter(chapter)
	        chapter = Chapter(currentChapNum)

	    # Adds each verse to the correct chapter
	    chapter.addVerse(currentBibleVerse)

	# Adds Revelations [Edge Case]
    book.addChapter(chapter)
    bible.addBook(bookName, book)
    return bible
开发者ID:AlecGriffin,项目名称:FindYourStrengthProject,代码行数:71,代码来源:BibleParser.py

示例13: __init__

    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
开发者ID:beniza,项目名称:BibleOrgSys,代码行数:68,代码来源:USFMBible.py


注:本文中的Bible.Bible类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。