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


Python Bible.addBook方法代码示例

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


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

示例1: getParsedContent

# 需要导入模块: from Bible import Bible [as 别名]
# 或者: from Bible.Bible import addBook [as 别名]
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,代码行数:73,代码来源:BibleParser.py


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