Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Small fixes

  • Loading branch information...
commit 8da41487c9bb410b01222e106745dff5e0001fce 1 parent 942f94a
@RobH123 RobH123 authored
View
23 InternalBible.py
@@ -27,19 +27,15 @@
The calling class needs to call this base class __init__ routine and also set:
self.objectType (with "USFM" or "USX")
- self.objectNameString (with a description of the type of BibleBook object)
+ self.objectNameString (with a description of the type of Bible object)
It also needs to provide a "load" routine that sets:
- self.bookReferenceCode (BBB)
- self.isOneChapterBook (True or False)
self.sourceFolder
- self.sourceFilename
- self.sourceFilepath = os.path.join( sourceFolder, sourceFilename )
-and then calls
- self.appendLine (in order to fill self._RawLines)
+and then fills
+ self.books
"""
progName = "Internal Bible handler"
-versionString = "0.02"
+versionString = "0.03"
import os, logging, datetime
@@ -56,12 +52,14 @@ class InternalBible:
Class to load and manipulate InternalBibles.
"""
- def __init__( self, name ):
+ def __init__( self, name, logErrorsFlag ):
"""
Create the object.
"""
- # Set up empty containers for the object
self.name = name
+ self.logErrorsFlag = logErrorsFlag
+
+ # Set up empty containers for the object
self.books = OrderedDict()
self.ssfPathName, self.ssfData = '', {}
self.BBBToNameDict, self.bookNameDict, self.combinedBookNameDict, self.bookAbbrevDict = {}, {}, {}, {} # Used to store book name and abbreviations (pointing to the BBB codes)
@@ -82,7 +80,7 @@ def __str__( self ):
@rtype: string
"""
result = self.objectNameString
- if self.name: result += ('\n' if result else '') + self.name
+ if self.name: result += ('\n' if result else '') + " Name: " + self.name
if self.sourceFolder: result += ('\n' if result else '') + " From: " + self.sourceFolder
result += ('\n' if result else '') + " Number of books = " + str(len(self.books))
return result
@@ -565,7 +563,8 @@ def main():
if Globals.verbosityLevel > 0: print( "{} V{}".format( progName, versionString ) )
# Since this is only designed to be a base class, it can't actually do much at all
- IB = InternalBible( "Test internal Bible" )
+ IB = InternalBible( "Test internal Bible", False ) # The second parameter is the logErrorsFlag
+ IB.objectNameString = "Dummy test Internal Bible object"
IB.sourceFolder = "Nowhere"
if Globals.verbosityLevel > 0: print( IB )
if __name__ == '__main__':
View
150 InternalBibleBook.py
@@ -1,7 +1,7 @@
#!/usr/bin/python3
#
# InternalBibleBook.py
-# Last modified: 2012-05-28 by RJH (also update versionString below)
+# Last modified: 2012-05-29 by RJH (also update versionString below)
#
# Module handling the USFM markers for Bible books
#
@@ -39,7 +39,7 @@
"""
progName = "Internal Bible book handler"
-versionString = "0.03"
+versionString = "0.04"
import os, logging
@@ -65,14 +65,14 @@ class InternalBibleBook:
The load routine (which populates self._rawLines) must be provided.
"""
- def __init__( self ):
+ def __init__( self, logErrorsFlag ):
"""
Create the USFM Bible book object.
"""
+ self.logErrorsFlag = logErrorsFlag
self.bookReferenceCode = None
self._rawLines = [] # Contains 2-tuples which contain the actual Bible text -- see appendRawLine below
self._processed = self._indexed = False
- self.logErrors = False
self.errorDictionary = OrderedDict()
self.errorDictionary['Priority Errors'] = [] # Put this one first in the ordered dictionary
self.givenAngleBracketWarning = self.givenDoubleQuoteWarning = False
@@ -155,7 +155,7 @@ def processLineFix( originalMarker, text ):
# Remove trailing spaces
if adjText and adjText[-1].isspace():
#print( 10, self.bookReferenceCode, c, v, _("Trailing space at end of line") )
- if self.logErrors: logging.warning( _("Removed trailing space after {} {}:{} in \\{}: '{}'").format( self.bookReferenceCode, c, v, originalMarker, text ) )
+ if self.logErrorsFlag: logging.warning( _("Removed trailing space after {} {}:{} in \\{}: '{}'").format( self.bookReferenceCode, c, v, originalMarker, text ) )
self.addPriorityError( 10, c, v, _("Trailing space at end of line") )
adjText = adjText.rstrip()
#print( originalMarker, "'"+text+"'", "'"+adjText+"'" )
@@ -164,14 +164,14 @@ def processLineFix( originalMarker, text ):
if '<' in adjText or '>' in adjText:
if not self.givenAngleBracketWarning: # Just give the warning once (per book)
#fixErrors.append( _("{} {}:{} Replaced angle brackets in {}: {}").format( self.bookReferenceCode, c, v, originalMarker, text ) )
- if self.logErrors: logging.info( _("Replaced angle bracket(s) after {} {}:{} in \\{}: {}").format( self.bookReferenceCode, c, v, originalMarker, text ) )
+ if self.logErrorsFlag: logging.info( _("Replaced angle bracket(s) after {} {}:{} in \\{}: {}").format( self.bookReferenceCode, c, v, originalMarker, text ) )
self.addPriorityError( 3, '', '', _("Book contains angle brackets") )
self.givenAngleBracketWarning = True
adjText = adjText.replace('<<','').replace('>>','').replace('<','').replace('>','') # Replace angle brackets with the proper opening and close quote marks
if '"' in adjText:
if not self.givenDoubleQuoteWarning: # Just give the warning once (per book)
fixErrors.append( _("{} {}:{} Replaced \" in \\{}: {}").format( self.bookReferenceCode, c, v, originalMarker, adjText ) )
- if self.logErrors: logging.info( _("Replaced \" after {} {}:{} in \\{}: {}").format( self.bookReferenceCode, c, v, originalMarker, adjText ) )
+ if self.logErrorsFlag: logging.info( _("Replaced \" after {} {}:{} in \\{}: {}").format( self.bookReferenceCode, c, v, originalMarker, adjText ) )
self.addPriorityError( 8, '', '', _("Book contains straight quote signs") )
self.givenDoubleQuoteWarning = True
adjText = adjText.replace(' "','').replace('"','') # Try to replace double-quote marks with the proper opening and closing quote marks
@@ -195,12 +195,12 @@ def processLineFix( originalMarker, text ):
thisOne, this1 = "cross-reference", "xr"
if ix2 == -1: # no closing marker
fixErrors.append( _("{} {}:{} Found unmatched {} open in \\{}: {}").format( self.bookReferenceCode, c, v, thisOne, originalMarker, adjText ) )
- if self.logErrors: logging.error( _("Found unmatched {} open after {} {}:{} in \\{}: {}").format( thisOne, self.bookReferenceCode, c, v, originalMarker, adjText ) )
+ if self.logErrorsFlag: logging.error( _("Found unmatched {} open after {} {}:{} in \\{}: {}").format( thisOne, self.bookReferenceCode, c, v, originalMarker, adjText ) )
self.addPriorityError( 84, c, v, _("Marker {} is unmatched").format( thisOne ) )
ix2 = 99999 # Go to the end
elif ix2 < ix1: # closing marker is before opening marker
fixErrors.append( _("{} {}:{} Found unmatched {} in \\{}: {}").format( self.bookReferenceCode, c, v, thisOne, originalMarker, adjText ) )
- if self.logErrors: logging.error( _("Found unmatched {} after {} {}:{} in \\{}: {}").format( thisOne, self.bookReferenceCode, c, v, thisOne, originalMarker, adjText ) )
+ if self.logErrorsFlag: logging.error( _("Found unmatched {} after {} {}:{} in \\{}: {}").format( thisOne, self.bookReferenceCode, c, v, thisOne, originalMarker, adjText ) )
self.addPriorityError( 84, c, v, _("Marker {} is unmatched").format( thisOne ) )
ix1, ix2 = ix2, ix1 # swap them then
# Remove the footnote or xref
@@ -208,17 +208,17 @@ def processLineFix( originalMarker, text ):
note = adjText[ix1+3:ix2] # Get the note text (without the beginning and end markers)
if not note:
fixErrors.append( _("{} {}:{} Found empty {} in \\{}: {}").format( self.bookReferenceCode, c, v, thisOne, originalMarker, adjText ) )
- if self.logErrors: logging.error( _("Found empty {} after {} {}:{} in \\{}: {}").format( thisOne, self.bookReferenceCode, c, v, originalMarker, adjText ) )
+ if self.logErrorsFlag: logging.error( _("Found empty {} after {} {}:{} in \\{}: {}").format( thisOne, self.bookReferenceCode, c, v, originalMarker, adjText ) )
self.addPriorityError( 53, c, v, _("Empty {}").format( thisOne ) )
else: # there is a note
if note[0].isspace():
fixErrors.append( _("{} {}:{} Found {} starting with space in \\{}: {}").format( self.bookReferenceCode, c, v, thisOne, originalMarker, adjText ) )
- if self.logErrors: logging.error( _("Found {} starting with space after {} {}:{} in \\{}: {}").format( thisOne, self.bookReferenceCode, c, v, originalMarker, adjText ) )
+ if self.logErrorsFlag: logging.error( _("Found {} starting with space after {} {}:{} in \\{}: {}").format( thisOne, self.bookReferenceCode, c, v, originalMarker, adjText ) )
self.addPriorityError( 12, c, v, _("{} starts with space").format( thisOne.title() ) )
note = note.lstrip()
if note and note[-1].isspace():
fixErrors.append( _("{} {}:{} Found {} ending with space in \\{}: {}").format( self.bookReferenceCode, c, v, thisOne, originalMarker, adjText ) )
- if self.logErrors: logging.error( _("Found {} ending with space after {} {}:{} in \\{}: {}").format( thisOne, self.bookReferenceCode, c, v, originalMarker, adjText ) )
+ if self.logErrorsFlag: logging.error( _("Found {} ending with space after {} {}:{} in \\{}: {}").format( thisOne, self.bookReferenceCode, c, v, originalMarker, adjText ) )
self.addPriorityError( 11, c, v, _("{} ends with space").format( thisOne.title() ) )
note = note.rstrip()
adjText = adjText[:ix1] + adjText[ix2+3:] # Remove the note completely from the text
@@ -231,13 +231,13 @@ def processLineFix( originalMarker, text ):
if '\\f' in lcAdjText or '\\x' in lcAdjText:
fixErrors.append( _("{} {}:{} Unable to properly process footnotes and cross-references in \\{}: {}").format( self.bookReferenceCode, c, v, originalMarker, adjText ) )
- if self.logErrors: logging.error( _("Unable to properly process footnotes and cross-references {} {}:{} in \\{}: {}").format( self.bookReferenceCode, c, v, originalMarker, adjText ) )
+ if self.logErrorsFlag: logging.error( _("Unable to properly process footnotes and cross-references {} {}:{} in \\{}: {}").format( self.bookReferenceCode, c, v, originalMarker, adjText ) )
self.addPriorityError( 82, c, v, _("Invalid footnotes or cross-refernces") )
# Check trailing spaces again now
if adjText and adjText[-1].isspace():
#print( 10, self.bookReferenceCode, c, v, _("Trailing space before note at end of line") )
- if self.logErrors: logging.warning( _("Removed trailing space before note after {} {}:{} in \\{}: '{}'").format( self.bookReferenceCode, c, v, originalMarker, text ) )
+ if self.logErrorsFlag: logging.warning( _("Removed trailing space before note after {} {}:{} in \\{}: '{}'").format( self.bookReferenceCode, c, v, originalMarker, text ) )
self.addPriorityError( 10, c, v, _("Trailing space before note at end of line") )
adjText = adjText.rstrip()
#print( originalMarker, "'"+text+"'", "'"+adjText+"'" )
@@ -274,7 +274,7 @@ def processLine( originalMarker, text ):
if self.USFMMarkers.isNewlineMarker(insideMarker): # Need to split the line for everything else to work properly
if ix==0:
fixErrors.append( _("{} {}:{} Marker '{}' shouldn't appear within line in \\{}: '{}'").format( self.bookReferenceCode, c, v, insideMarker, marker, text ) )
- if self.logErrors: logging.error( _("Marker '{}' shouldn't appear within line after {} {}:{} in \\{}: '{}'").format( insideMarker, self.bookReferenceCode, c, v, marker, text ) ) # Only log the first error in the line
+ if self.logErrorsFlag: logging.error( _("Marker '{}' shouldn't appear within line after {} {}:{} in \\{}: '{}'").format( insideMarker, self.bookReferenceCode, c, v, marker, text ) ) # Only log the first error in the line
self.addPriorityError( 96, c, v, _("Marker \\{} shouldn't be inside a line").format( insideMarker ) )
thisText = text[ix:iMIndex].rstrip()
adjText, extras = processLineFix( originalMarker, thisText )
@@ -336,36 +336,36 @@ def validateUSFM( self ):
if text: c = text.split()[0]
else:
validationErrors.append( _("{} {}:{} Missing chapter number").format( self.bookReferenceCode, c, v ) )
- if self.logErrors: logging.error( _("Missing chapter number after {} {}:{}").format( self.bookReferenceCode, c, v ) )
+ if self.logErrorsFlag: logging.error( _("Missing chapter number after {} {}:{}").format( self.bookReferenceCode, c, v ) )
v = '0'
if marker == 'v':
if text: v = text.split()[0]
else:
validationErrors.append( _("{} {}:{} Missing verse number").format( self.bookReferenceCode, c, v ) )
- if self.logErrors: logging.error( _("Missing verse number after {} {}:{}").format( self.bookReferenceCode, c, v ) )
+ if self.logErrorsFlag: logging.error( _("Missing verse number after {} {}:{}").format( self.bookReferenceCode, c, v ) )
if marker == 'v+': marker = 'v' # Makes it easier
# Do a rough check of the SFMs
if marker=='id' and j!=0:
validationErrors.append( _("{} {}:{} Marker 'id' should only appear as the first marker in a book but found on line {} in {}: {}").format( self.bookReferenceCode, c, v, j, marker, text ) )
- if self.logErrors: logging.error( _("Marker 'id' should only appear as the first marker in a book but found on line {} after {} {}:{} in {}: {}").format( j, self.bookReferenceCode, c, v, marker, text ) )
+ if self.logErrorsFlag: logging.error( _("Marker 'id' should only appear as the first marker in a book but found on line {} after {} {}:{} in {}: {}").format( j, self.bookReferenceCode, c, v, marker, text ) )
if not self.USFMMarkers.isNewlineMarker( marker ):
validationErrors.append( _("{} {}:{} Unexpected '\\{}' newline marker in Bible book (Text is '{}')").format( self.bookReferenceCode, c, v, marker, text ) )
- if self.logErrors: logging.warning( _("Unexpected '\\{}' newline marker in Bible book after {} {}:{} (Text is '{}')").format( marker, self.bookReferenceCode, c, v, text ) )
+ if self.logErrorsFlag: logging.warning( _("Unexpected '\\{}' newline marker in Bible book after {} {}:{} (Text is '{}')").format( marker, self.bookReferenceCode, c, v, text ) )
if self.USFMMarkers.isDeprecatedMarker( marker ):
validationErrors.append( _("{} {}:{} Deprecated '\\{}' newline marker in Bible book (Text is '{}')").format( self.bookReferenceCode, c, v, marker, text ) )
- if self.logErrors: logging.warning( _("Deprecated '\\{}' newline marker in Bible book after {} {}:{} (Text is '{}')").format( marker, self.bookReferenceCode, c, v, text ) )
+ if self.logErrorsFlag: logging.warning( _("Deprecated '\\{}' newline marker in Bible book after {} {}:{} (Text is '{}')").format( marker, self.bookReferenceCode, c, v, text ) )
markerList = self.USFMMarkers.getMarkerListFromText( text )
#if markerList: print( "\nText = {}:'{}'".format(marker,text)); print( markerList )
for insideMarker, nextSignificantChar, iMIndex in markerList: # check character markers
if self.USFMMarkers.isDeprecatedMarker( insideMarker ):
validationErrors.append( _("{} {}:{} Deprecated '\\{}' internal marker in Bible book (Text is '{}')").format( self.bookReferenceCode, c, v, insideMarker, text ) )
- if self.logErrors: logging.warning( _("Deprecated '\\{}' internal marker in Bible book after {} {}:{} (Text is '{}')").format( insideMarker, self.bookReferenceCode, c, v, text ) )
+ if self.logErrorsFlag: logging.warning( _("Deprecated '\\{}' internal marker in Bible book after {} {}:{} (Text is '{}')").format( insideMarker, self.bookReferenceCode, c, v, text ) )
ix = 0
for insideMarker, nextSignificantChar, iMIndex in markerList: # check newline markers
if self.USFMMarkers.isNewlineMarker(insideMarker):
validationErrors.append( _("{} {}:{} Marker '\\{}' shouldn't appear within line in {}: {}").format( self.bookReferenceCode, c, v, insideMarker, marker, text ) )
- if self.logErrors: logging.error( _("Marker '\\{}' shouldn't appear within line after {} {}:{} in {}: {}").format( insideMarker, self.bookReferenceCode, c, v, marker, text ) )
+ if self.logErrorsFlag: logging.error( _("Marker '\\{}' shouldn't appear within line after {} {}:{} in {}: {}").format( insideMarker, self.bookReferenceCode, c, v, marker, text ) )
if validationErrors: self.errorDictionary['Validation Errors'] = validationErrors
# end of validateUSFM
@@ -447,25 +447,25 @@ def getVersification( self ):
chapterText = text.strip()
if ' ' in chapterText: # Seems that we can have footnotes here :)
versificationErrors.append( _("{} {}:{} Unexpected space in USFM chapter number field '{}'").format( self.bookReferenceCode, lastChapterNumber, lastVerseNumberString, chapterText, lastChapterNumber ) )
- if self.logErrors: logging.info( _("Unexpected space in USFM chapter number field '{}' after chapter {} of {}").format( chapterText, lastChapterNumber, self.bookReferenceCode ) )
+ if self.logErrorsFlag: logging.info( _("Unexpected space in USFM chapter number field '{}' after chapter {} of {}").format( chapterText, lastChapterNumber, self.bookReferenceCode ) )
chapterText = chapterText.split( None, 1)[0]
#print( "{} chapter {}".format( self.bookReferenceCode, chapterText ) )
chapterNumber = int( chapterText)
if chapterNumber != lastChapterNumber+1:
versificationErrors.append( _("{} ({} after {}) USFM chapter numbers out of sequence in Bible book").format( self.bookReferenceCode, chapterNumber, lastChapterNumber ) )
- if self.logErrors: logging.error( _("USFM chapter numbers out of sequence in Bible book {} ({} after {})").format( self.bookReferenceCode, chapterNumber, lastChapterNumber ) )
+ if self.logErrorsFlag: logging.error( _("USFM chapter numbers out of sequence in Bible book {} ({} after {})").format( self.bookReferenceCode, chapterNumber, lastChapterNumber ) )
lastChapterNumber = chapterNumber
verseText = verseNumberString = lastVerseNumberString = '0'
elif marker == 'cp':
versificationErrors.append( _("{} {}:{} Encountered cp field {}").format( self.bookReferenceCode, chapterNumber, lastVerseNumberString, text ) )
- if self.logErrors: logging.warning( _("Encountered cp field {} after {}:{} of {}").format( text, chapterNumber, lastVerseNumberString, self.bookReferenceCode ) )
+ if self.logErrorsFlag: logging.warning( _("Encountered cp field {} after {}:{} of {}").format( text, chapterNumber, lastVerseNumberString, self.bookReferenceCode ) )
elif marker == 'v':
if chapterText == '0':
versificationErrors.append( _("{} {} Missing chapter number field before verse {}").format( self.bookReferenceCode, chapterText, text ) )
- if self.logErrors: logging.warning( _("Missing chapter number field before verse {} in chapter {} of {}").format( text, chapterText, self.bookReferenceCode ) )
+ if self.logErrorsFlag: logging.warning( _("Missing chapter number field before verse {} in chapter {} of {}").format( text, chapterText, self.bookReferenceCode ) )
if not text:
versificationErrors.append( _("{} {} Missing USFM verse number after {}").format( self.bookReferenceCode, chapterNumber, lastVerseNumberString ) )
- if self.logErrors: logging.warning( _("Missing USFM verse number after {} in chapter {} of {}").format( lastVerseNumberString, chapterNumber, self.bookReferenceCode ) )
+ if self.logErrorsFlag: logging.warning( _("Missing USFM verse number after {} in chapter {} of {}").format( lastVerseNumberString, chapterNumber, self.bookReferenceCode ) )
continue
verseText = text
doneWarning = False
@@ -473,12 +473,12 @@ def getVersification( self ):
if char in verseText:
if not doneWarning:
versificationErrors.append( _("{} {} Removing letter(s) from USFM verse number {} in Bible book").format( self.bookReferenceCode, chapterText, verseText ) )
- if self.logErrors: logging.info( _("Removing letter(s) from USFM verse number {} in Bible book {} {}").format( verseText, self.bookReferenceCode, chapterText ) )
+ if self.logErrorsFlag: logging.info( _("Removing letter(s) from USFM verse number {} in Bible book {} {}").format( verseText, self.bookReferenceCode, chapterText ) )
doneWarning = True
verseText = verseText.replace( char, '' )
if '-' in verseText or '' in verseText: # we have a range like 7-9 with hyphen or en-dash
#versificationErrors.append( _("{} {}:{} Encountered combined verses field {}").format( self.bookReferenceCode, chapterNumber, lastVerseNumberString, verseText ) )
- if self.logErrors: logging.info( _("Encountered combined verses field {} after {}:{} of {}").format( verseText, chapterNumber, lastVerseNumberString, self.bookReferenceCode ) )
+ if self.logErrorsFlag: logging.info( _("Encountered combined verses field {} after {}:{} of {}").format( verseText, chapterNumber, lastVerseNumberString, self.bookReferenceCode ) )
bits = verseText.replace('','-').split( '-', 1 ) # Make sure that it's a hyphen then split once
verseNumberString, verseNumber = bits[0], 0
endVerseNumberString, endVerseNumber = bits[1], 0
@@ -486,20 +486,20 @@ def getVersification( self ):
verseNumber = int( verseNumberString )
except:
versificationErrors.append( _("{} {} Invalid USFM verse range start '{}' in '{}' in Bible book").format( self.bookReferenceCode, chapterText, verseNumberString, verseText ) )
- if self.logErrors: logging.error( _("Invalid USFM verse range start '{}' in '{}' in Bible book {} {}").format( verseNumberString, verseText, self.bookReferenceCode, chapterText ) )
+ if self.logErrorsFlag: logging.error( _("Invalid USFM verse range start '{}' in '{}' in Bible book {} {}").format( verseNumberString, verseText, self.bookReferenceCode, chapterText ) )
try:
endVerseNumber = int( endVerseNumberString )
except:
versificationErrors.append( _("{} {} Invalid USFM verse range end '{}' in '{}' in Bible book").format( self.bookReferenceCode, chapterText, endVerseNumberString, verseText ) )
- if self.logErrors: logging.error( _("Invalid USFM verse range end '{}' in '{}' in Bible book {} {}").format( endVerseNumberString, verseText, self.bookReferenceCode, chapterText ) )
+ if self.logErrorsFlag: logging.error( _("Invalid USFM verse range end '{}' in '{}' in Bible book {} {}").format( endVerseNumberString, verseText, self.bookReferenceCode, chapterText ) )
if verseNumber >= endVerseNumber:
versificationErrors.append( _("{} {} ({}-{}) USFM verse range out of sequence in Bible book").format( self.bookReferenceCode, chapterText, verseNumberString, endVerseNumberString ) )
- if self.logErrors: logging.error( _("USFM verse range out of sequence in Bible book {} {} ({}-{})").format( self.bookReferenceCode, chapterText, verseNumberString, endVerseNumberString ) )
+ if self.logErrorsFlag: logging.error( _("USFM verse range out of sequence in Bible book {} {} ({}-{})").format( self.bookReferenceCode, chapterText, verseNumberString, endVerseNumberString ) )
#else:
combinedVerses.append( (chapterText, verseText,) )
elif ',' in verseText: # we have a range like 7,8
versificationErrors.append( _("{} {}:{} Encountered comma combined verses field {}").format( self.bookReferenceCode, chapterNumber, lastVerseNumberString, verseText ) )
- if self.logErrors: logging.info( _("Encountered comma combined verses field {} after {}:{} of {}").format( verseText, chapterNumber, lastVerseNumberString, self.bookReferenceCode ) )
+ if self.logErrorsFlag: logging.info( _("Encountered comma combined verses field {} after {}:{} of {}").format( verseText, chapterNumber, lastVerseNumberString, self.bookReferenceCode ) )
bits = verseText.split( ',', 1 )
verseNumberString, verseNumber = bits[0], 0
endVerseNumberString, endVerseNumber = bits[1], 0
@@ -507,15 +507,15 @@ def getVersification( self ):
verseNumber = int( verseNumberString )
except:
versificationErrors.append( _("{} {} Invalid USFM verse list start '{}' in '{}' in Bible book").format( self.bookReferenceCode, chapterText, verseNumberString, verseText ) )
- if self.logErrors: logging.error( _("Invalid USFM verse list start '{}' in '{}' in Bible book {} {}").format( verseNumberString, verseText, self.bookReferenceCode, chapterText ) )
+ if self.logErrorsFlag: logging.error( _("Invalid USFM verse list start '{}' in '{}' in Bible book {} {}").format( verseNumberString, verseText, self.bookReferenceCode, chapterText ) )
try:
endVerseNumber = int( endVerseNumberString )
except:
versificationErrors.append( _("{} {} Invalid USFM verse list end '{}' in '{}' in Bible book").format( self.bookReferenceCode, chapterText, endVerseNumberString, verseText ) )
- if self.logErrors: logging.error( _("Invalid USFM verse list end '{}' in '{}' in Bible book {} {}").format( endVerseNumberString, verseText, self.bookReferenceCode, chapterText ) )
+ if self.logErrorsFlag: logging.error( _("Invalid USFM verse list end '{}' in '{}' in Bible book {} {}").format( endVerseNumberString, verseText, self.bookReferenceCode, chapterText ) )
if verseNumber >= endVerseNumber:
versificationErrors.append( _("{} {} ({}-{}) USFM verse list out of sequence in Bible book").format( self.bookReferenceCode, chapterText, verseNumberString, endVerseNumberString ) )
- if self.logErrors: logging.error( _("USFM verse list out of sequence in Bible book {} {} ({}-{})").format( self.bookReferenceCode, chapterText, verseNumberString, endVerseNumberString ) )
+ if self.logErrorsFlag: logging.error( _("USFM verse list out of sequence in Bible book {} {} ({}-{})").format( self.bookReferenceCode, chapterText, verseNumberString, endVerseNumberString ) )
#else:
combinedVerses.append( (chapterText, verseText,) )
else: # Should be just a single verse number
@@ -525,7 +525,7 @@ def getVersification( self ):
verseNumber = int( verseNumberString )
except:
versificationErrors.append( _("{} {} {} Invalid verse number digits in Bible book").format( self.bookReferenceCode, chapterText, verseNumberString ) )
- if self.logErrors: logging.error( _("Invalid verse number digits in Bible book {} {} {}").format( self.bookReferenceCode, chapterText, verseNumberString ) )
+ if self.logErrorsFlag: logging.error( _("Invalid verse number digits in Bible book {} {} {}").format( self.bookReferenceCode, chapterText, verseNumberString ) )
newString = ''
for char in verseNumberString:
if char.isdigit(): newString += char
@@ -542,11 +542,11 @@ def getVersification( self ):
if verseNumber != lastVerseNumber+1:
if verseNumber <= lastVerseNumber:
versificationErrors.append( _("{} {} ({} after {}) USFM verse numbers out of sequence in Bible book").format( self.bookReferenceCode, chapterText, verseText, lastVerseNumberString ) )
- if self.logErrors: logging.warning( _("USFM verse numbers out of sequence in Bible book {} {} ({} after {})").format( self.bookReferenceCode, chapterText, verseText, lastVerseNumberString ) )
+ if self.logErrorsFlag: logging.warning( _("USFM verse numbers out of sequence in Bible book {} {} ({} after {})").format( self.bookReferenceCode, chapterText, verseText, lastVerseNumberString ) )
reorderedVerses.append( (chapterText, lastVerseNumberString, verseText,) )
else: # Must be missing some verse numbers
versificationErrors.append( _("{} {} Missing USFM verse number(s) between {} and {} in Bible book").format( self.bookReferenceCode, chapterText, lastVerseNumberString, verseNumberString ) )
- if self.logErrors: logging.info( _("Missing USFM verse number(s) between {} and {} in Bible book {} {}").format( lastVerseNumberString, verseNumberString, self.bookReferenceCode, chapterText ) )
+ if self.logErrorsFlag: logging.info( _("Missing USFM verse number(s) between {} and {} in Bible book {} {}").format( lastVerseNumberString, verseNumberString, self.bookReferenceCode, chapterText ) )
for number in range( lastVerseNumber+1, verseNumber ):
omittedVerses.append( (chapterText, str(number),) )
lastVerseNumberString = endVerseNumberString
@@ -583,7 +583,7 @@ def getAddedUnits( self ):
#print( self.bookReferenceCode, chapterText, marker, text )
if not text:
addedUnitErrors.append( _("{} {} Missing USFM verse number after {}").format( self.bookReferenceCode, chapterText, verseText ) )
- if self.logErrors: logging.warning( _("Missing USFM verse number after {} in chapter {} of {}").format( verseText, chapterText, self.bookReferenceCode ) )
+ if self.logErrorsFlag: logging.warning( _("Missing USFM verse number after {} in chapter {} of {}").format( verseText, chapterText, self.bookReferenceCode ) )
self.addPriorityError( 86, chapterText, verseText, _("Missing verse number") )
continue
verseText = text
@@ -645,7 +645,7 @@ def checkAddedUnits( self, typicalAddedUnitData, severe=False, ):
if reference in paragraphReferences:
if typical == 'F':
addedUnitNotices.append( _("{} {} Paragraph break is less common after {}").format( self.bookReferenceCode, c, v ) )
- if self.logErrors: logging.info( _("Paragraph break is less common after {} in chapter {} of {}").format( v, c, self.bookReferenceCode ) )
+ if self.logErrorsFlag: logging.info( _("Paragraph break is less common after {} in chapter {} of {}").format( v, c, self.bookReferenceCode ) )
self.addPriorityError( 17, c, v, _("Less common to have a paragraph break after") )
#print( "Surprise", self.bookReferenceCode, reference, typical, present )
elif typical == 'S' and severe:
@@ -654,7 +654,7 @@ def checkAddedUnits( self, typicalAddedUnitData, severe=False, ):
else: # we didn't have it
if typical == 'A':
addedUnitNotices.append( _("{} {} Paragraph break normally inserted after {}").format( self.bookReferenceCode, c, v ) )
- if self.logErrors: logging.info( _("Paragraph break normally inserted after {} in chapter {} of {}").format( v, c, self.bookReferenceCode ) )
+ if self.logErrorsFlag: logging.info( _("Paragraph break normally inserted after {} in chapter {} of {}").format( v, c, self.bookReferenceCode ) )
self.addPriorityError( 27, c, v, _("Paragraph break normally inserted after") )
#print( "All", self.bookReferenceCode, reference, typical, present )
elif typical == 'M' and severe:
@@ -666,7 +666,7 @@ def checkAddedUnits( self, typicalAddedUnitData, severe=False, ):
c, v = reference[0], reference[1]
if len(reference)==3: v += reference[2] # append the suffix
addedUnitNotices.append( _("{} {} Paragraph break is unusual after {}").format( self.bookReferenceCode, c, v ) )
- if self.logErrors: logging.info( _("Paragraph break is unusual after {} in chapter {} of {}").format( v, c, self.bookReferenceCode ) )
+ if self.logErrorsFlag: logging.info( _("Paragraph break is unusual after {} in chapter {} of {}").format( v, c, self.bookReferenceCode ) )
self.addPriorityError( 37, c, v, _("Unusual to have a paragraph break after") )
#print( "Weird paragraph after", self.bookReferenceCode, reference )
if addedUnitNotices:
@@ -685,7 +685,7 @@ def checkAddedUnits( self, typicalAddedUnitData, severe=False, ):
if reference in qReferences:
if typical == 'F':
addedUnitNotices.append( _("{} {} Quote Paragraph is less common after {}").format( self.bookReferenceCode, c, v ) )
- if self.logErrors: logging.info( _("Quote Paragraph is less common after {} in chapter {} of {}").format( v, c, self.bookReferenceCode ) )
+ if self.logErrorsFlag: logging.info( _("Quote Paragraph is less common after {} in chapter {} of {}").format( v, c, self.bookReferenceCode ) )
self.addPriorityError( 17, c, v, _("Less common to have a Quote Paragraph after") )
#print( "Surprise", self.bookReferenceCode, reference, typical, present )
elif typical == 'S' and severe:
@@ -694,7 +694,7 @@ def checkAddedUnits( self, typicalAddedUnitData, severe=False, ):
else: # we didn't have it
if typical == 'A':
addedUnitNotices.append( _("{} {} Quote Paragraph normally inserted after {}").format( self.bookReferenceCode, c, v ) )
- if self.logErrors: logging.info( _("Quote Paragraph normally inserted after {} in chapter {} of {}").format( v, c, self.bookReferenceCode ) )
+ if self.logErrorsFlag: logging.info( _("Quote Paragraph normally inserted after {} in chapter {} of {}").format( v, c, self.bookReferenceCode ) )
self.addPriorityError( 27, c, v, _("Quote Paragraph normally inserted after") )
#print( "All", self.bookReferenceCode, reference, typical, present )
elif typical == 'M' and severe:
@@ -706,7 +706,7 @@ def checkAddedUnits( self, typicalAddedUnitData, severe=False, ):
c, v = reference[0], reference[1]
if len(reference)==3: v += reference[2] # append the suffix
addedUnitNotices.append( _("{} {} Quote Paragraph is unusual after {}").format( self.bookReferenceCode, c, v ) )
- if self.logErrors: logging.info( _("Quote Paragraph is unusual after {} in chapter {} of {}").format( v, c, self.bookReferenceCode ) )
+ if self.logErrorsFlag: logging.info( _("Quote Paragraph is unusual after {} in chapter {} of {}").format( v, c, self.bookReferenceCode ) )
self.addPriorityError( 37, c, v, _("Unusual to have a Quote Paragraph after") )
#print( "Weird qParagraph after", self.bookReferenceCode, reference )
if addedUnitNotices:
@@ -725,7 +725,7 @@ def checkAddedUnits( self, typicalAddedUnitData, severe=False, ):
if reference in sectionHeadings:
if typical == 'F':
addedUnitNotices.append( _("{} {} Section Heading is less common after {}").format( self.bookReferenceCode, c, v ) )
- if self.logErrors: logging.info( _("Section Heading is less common after {} in chapter {} of {}").format( v, c, self.bookReferenceCode ) )
+ if self.logErrorsFlag: logging.info( _("Section Heading is less common after {} in chapter {} of {}").format( v, c, self.bookReferenceCode ) )
self.addPriorityError( 17, c, v, _("Less common to have a Section Heading after") )
#print( "Surprise", self.bookReferenceCode, reference, typical, present )
elif typical == 'S' and severe:
@@ -734,7 +734,7 @@ def checkAddedUnits( self, typicalAddedUnitData, severe=False, ):
else: # we didn't have it
if typical == 'A':
addedUnitNotices.append( _("{} {} Section Heading normally inserted after {}").format( self.bookReferenceCode, c, v ) )
- if self.logErrors: logging.info( _("Section Heading normally inserted after {} in chapter {} of {}").format( v, c, self.bookReferenceCode ) )
+ if self.logErrorsFlag: logging.info( _("Section Heading normally inserted after {} in chapter {} of {}").format( v, c, self.bookReferenceCode ) )
self.addPriorityError( 27, c, v, _("Section Heading normally inserted after") )
#print( "All", self.bookReferenceCode, reference, typical, present )
elif typical == 'M' and severe:
@@ -747,7 +747,7 @@ def checkAddedUnits( self, typicalAddedUnitData, severe=False, ):
c, v = reference[0], reference[1]
if len(reference)==3: v += reference[2] # append the suffix
addedUnitNotices.append( _("{} {} Section Heading is unusual after {}").format( self.bookReferenceCode, c, v ) )
- if self.logErrors: logging.info( _("Section Heading is unusual after {} in chapter {} of {}").format( v, c, self.bookReferenceCode ) )
+ if self.logErrorsFlag: logging.info( _("Section Heading is unusual after {} in chapter {} of {}").format( v, c, self.bookReferenceCode ) )
self.addPriorityError( 37, c, v, _("Unusual to have a Section Heading after") )
#print( "Weird section heading after", self.bookReferenceCode, reference )
if addedUnitNotices:
@@ -765,7 +765,7 @@ def checkAddedUnits( self, typicalAddedUnitData, severe=False, ):
if reference in sectionReferences:
if typical == 'F':
addedUnitNotices.append( _("{} {} Section Reference is less common after {}").format( self.bookReferenceCode, c, v ) )
- if self.logErrors: logging.info( _("Section Reference is less common after {} in chapter {} of {}").format( v, c, self.bookReferenceCode ) )
+ if self.logErrorsFlag: logging.info( _("Section Reference is less common after {} in chapter {} of {}").format( v, c, self.bookReferenceCode ) )
self.addPriorityError( 17, c, v, _("Less common to have a Section Reference after") )
#print( "Surprise", self.bookReferenceCode, reference, typical, present )
elif typical == 'S' and severe:
@@ -774,7 +774,7 @@ def checkAddedUnits( self, typicalAddedUnitData, severe=False, ):
else: # we didn't have it
if typical == 'A':
addedUnitNotices.append( _("{} {} Section Reference normally inserted after {}").format( self.bookReferenceCode, c, v ) )
- if self.logErrors: logging.info( _("Section Reference normally inserted after {} in chapter {} of {}").format( v, c, self.bookReferenceCode ) )
+ if self.logErrorsFlag: logging.info( _("Section Reference normally inserted after {} in chapter {} of {}").format( v, c, self.bookReferenceCode ) )
self.addPriorityError( 27, c, v, _("Section Reference normally inserted after") )
#print( "All", self.bookReferenceCode, reference, typical, present )
elif typical == 'M' and severe:
@@ -787,7 +787,7 @@ def checkAddedUnits( self, typicalAddedUnitData, severe=False, ):
c, v = reference[0], reference[1]
if len(reference)==3: v += reference[2] # append the suffix
addedUnitNotices.append( _("{} {} Section Reference is unusual after {}").format( self.bookReferenceCode, c, v ) )
- if self.logErrors: logging.info( _("Section Reference is unusual after {} in chapter {} of {}").format( v, c, self.bookReferenceCode ) )
+ if self.logErrorsFlag: logging.info( _("Section Reference is unusual after {} in chapter {} of {}").format( v, c, self.bookReferenceCode ) )
self.addPriorityError( 37, c, v, _("Unusual to have a Section Reference after") )
#print( "Weird Section Reference after", self.bookReferenceCode, reference )
if addedUnitNotices:
@@ -826,8 +826,12 @@ def checkSFMs( self ):
elif marker=='r':
functionalCounts['Section Cross-References'] = 1 if 'Section Cross-References' not in functionalCounts else (functionalCounts['Section Cross-References'] + 1)
- if marker!='v+': assert( marker in allAvailableNewlineMarkers ) # Should have been checked at load time
- newlineMarkerCounts[marker] = 1 if marker not in newlineMarkerCounts else (newlineMarkerCounts[marker] + 1)
+ if marker == 'v+':
+ lastMarker, lastMarkerEmpty = 'v', markerEmpty
+ continue
+ else: # it's not our (non-USFM) v+ marker
+ assert( marker in allAvailableNewlineMarkers ) # Should have been checked at load time
+ newlineMarkerCounts[marker] = 1 if marker not in newlineMarkerCounts else (newlineMarkerCounts[marker] + 1)
# Check the progression through the various sections
newSection = self.USFMMarkers.markerOccursIn( marker if marker!='v+' else 'v' )
@@ -952,7 +956,7 @@ def checkSFMs( self ):
if markerShouldHaveContent == 'N': # Never
newlineMarkerErrors.append( _("{} {}:{} Marker '{}' should not have content: '{}'").format( self.bookReferenceCode, c, v, marker, text ) )
- if self.logErrors: logging.warning( _("Marker '{}' should not have content after {} {}:{} with: '{}'").format( marker, self.bookReferenceCode, c, v, text ) )
+ if self.logErrorsFlag: logging.warning( _("Marker '{}' should not have content after {} {}:{} with: '{}'").format( marker, self.bookReferenceCode, c, v, text ) )
self.addPriorityError( 83, c, v, _("Marker {} shouldn't have content").format( marker ) )
markerList = self.USFMMarkers.getMarkerListFromText( text )
#if markerList: print( "\nText {} {}:{} = {}:'{}'".format(self.bookReferenceCode, c, v, marker, text)); print( markerList )
@@ -960,34 +964,34 @@ def checkSFMs( self ):
for insideMarker, nextSignificantChar, iMIndex in markerList: # check character markers
if not self.USFMMarkers.isInternalMarker( insideMarker ): # these errors have probably been noted already
internalMarkerErrors.append( _("{} {}:{} Non-internal {} marker in {}: {}").format( self.bookReferenceCode, c, v, insideMarker, marker, text ) )
- if self.logErrors: logging.warning( _("Non-internal {} marker after {} {}:{} in {}: {}").format( insideMarker, self.bookReferenceCode, c, v, marker, text ) )
+ if self.logErrorsFlag: logging.warning( _("Non-internal {} marker after {} {}:{} in {}: {}").format( insideMarker, self.bookReferenceCode, c, v, marker, text ) )
self.addPriorityError( 66, c, v, _("Non-internal {} marker").format( insideMarker, ) )
else:
if not openList: # no open markers
if nextSignificantChar in ('',' '): openList.append( insideMarker ) # Got a new marker
else:
internalMarkerErrors.append( _("{} {}:{} Unexpected {}{} marker in {}: {}").format( self.bookReferenceCode, c, v, insideMarker, nextSignificantChar, marker, text ) )
- if self.logErrors: logging.warning( _("Unexpected {}{} marker after {} {}:{} in {}: {}").format( insideMarker, nextSignificantChar, self.bookReferenceCode, c, v, marker, text ) )
+ if self.logErrorsFlag: logging.warning( _("Unexpected {}{} marker after {} {}:{} in {}: {}").format( insideMarker, nextSignificantChar, self.bookReferenceCode, c, v, marker, text ) )
self.addPriorityError( 66, c, v, _("Unexpected {}{} marker").format( insideMarker, nextSignificantChar ) )
else: # have at least one open marker
if nextSignificantChar=='*':
if insideMarker==openList[-1]: openList.pop() # We got the correct closing marker
else:
internalMarkerErrors.append( _("{} {}:{} Wrong {}* closing marker for {} in {}: {}").format( self.bookReferenceCode, c, v, insideMarker, openList[-1], marker, text ) )
- if self.logErrors: logging.warning( _("Wrong {}* closing marker for {} after {} {}:{} in {}: {}").format( insideMarker, openList[-1], self.bookReferenceCode, c, v, marker, text ) )
+ if self.logErrorsFlag: logging.warning( _("Wrong {}* closing marker for {} after {} {}:{} in {}: {}").format( insideMarker, openList[-1], self.bookReferenceCode, c, v, marker, text ) )
self.addPriorityError( 66, c, v, _("Wrong {}* closing marker for {}").format( insideMarker, openList[-1] ) )
else: # it's not an asterisk so appears to be another marker
if not self.USFMMarkers.isNestingMarker( openList[-1] ): openList.pop() # Let this marker close the last one
openList.append( insideMarker ) # Now have multiple entries in the openList
if openList:
internalMarkerErrors.append( _("{} {}:{} Marker(s) {} don't appear to be closed in {}: {}").format( self.bookReferenceCode, c, v, openList, marker, text ) )
- if self.logErrors: logging.warning( _("Marker(s) {} don't appear to be closed after {} {}:{} in {}: {}").format( openList, self.bookReferenceCode, c, v, marker, text ) )
+ if self.logErrorsFlag: logging.warning( _("Marker(s) {} don't appear to be closed after {} {}:{} in {}: {}").format( openList, self.bookReferenceCode, c, v, marker, text ) )
self.addPriorityError( 36, c, v, _("Marker(s) {} should be closed").format( openList ) )
if len(openList) == 1: text += '\\' + openList[-1] + '*' # Try closing the last one for them
else: # There's no text
if markerShouldHaveContent == 'A': # Always
newlineMarkerErrors.append( _("{} {}:{} Marker '{}' has no content").format( self.bookReferenceCode, c, v, marker ) )
- if self.logErrors: logging.warning( _("Marker '{}' has no content after {} {}:{}").format( marker, self.bookReferenceCode, c, v ) )
+ if self.logErrorsFlag: logging.warning( _("Marker '{}' has no content after {} {}:{}").format( marker, self.bookReferenceCode, c, v ) )
self.addPriorityError( 47, c, v, _("Marker {} should have content").format( marker ) )
if extras:
@@ -1089,29 +1093,29 @@ def checkSFMs( self ):
if (ix==0 or modifiedMarkerList[ix-1]!='mt1') and (ix==len(modifiedMarkerList)-1 or modifiedMarkerList[ix+1]!='mt1'):
newlineMarkerErrors.append( _("{} Expected mt2 marker to be next to an mt1 marker in {}...").format( self.bookReferenceCode, modifiedMarkerList[:10] ) )
- if 'SFMs' not in self.errorDictionary: self.errorDictionary['SFMs'] = OrderedDict() # So we hopefully get the errors first
- if newlineMarkerErrors: self.errorDictionary['SFMs']['Newline Marker Errors'] = newlineMarkerErrors
- if internalMarkerErrors: self.errorDictionary['SFMs']['Internal Marker Errors'] = internalMarkerErrors
- if noteMarkerErrors: self.errorDictionary['SFMs']['Footnote and Cross-Reference Marker Errors'] = noteMarkerErrors
+ if 'USFMs' not in self.errorDictionary: self.errorDictionary['USFMs'] = OrderedDict() # So we hopefully get the errors first
+ if newlineMarkerErrors: self.errorDictionary['USFMs']['Newline Marker Errors'] = newlineMarkerErrors
+ if internalMarkerErrors: self.errorDictionary['USFMs']['Internal Marker Errors'] = internalMarkerErrors
+ if noteMarkerErrors: self.errorDictionary['USFMs']['Footnote and Cross-Reference Marker Errors'] = noteMarkerErrors
if modifiedMarkerList:
modifiedMarkerList.insert( 0, '['+self.bookReferenceCode+']' )
- self.errorDictionary['SFMs']['Modified Marker List'] = modifiedMarkerList
+ self.errorDictionary['USFMs']['Modified Marker List'] = modifiedMarkerList
if newlineMarkerCounts:
total = 0
for marker in newlineMarkerCounts: total += newlineMarkerCounts[marker]
- self.errorDictionary['SFMs']['All Newline Marker Counts'] = newlineMarkerCounts
- self.errorDictionary['SFMs']['All Newline Marker Counts']['Total'] = total
+ self.errorDictionary['USFMs']['All Newline Marker Counts'] = newlineMarkerCounts
+ self.errorDictionary['USFMs']['All Newline Marker Counts']['Total'] = total
if internalMarkerCounts:
total = 0
for marker in internalMarkerCounts: total += internalMarkerCounts[marker]
- self.errorDictionary['SFMs']['All Text Internal Marker Counts'] = internalMarkerCounts
- self.errorDictionary['SFMs']['All Text Internal Marker Counts']['Total'] = total
+ self.errorDictionary['USFMs']['All Text Internal Marker Counts'] = internalMarkerCounts
+ self.errorDictionary['USFMs']['All Text Internal Marker Counts']['Total'] = total
if noteMarkerCounts:
total = 0
for marker in noteMarkerCounts: total += noteMarkerCounts[marker]
- self.errorDictionary['SFMs']['All Footnote and Cross-Reference Internal Marker Counts'] = noteMarkerCounts
- self.errorDictionary['SFMs']['All Footnote and Cross-Reference Internal Marker Counts']['Total'] = total
- if functionalCounts: self.errorDictionary['SFMs']['Functional Marker Counts'] = functionalCounts
+ self.errorDictionary['USFMs']['All Footnote and Cross-Reference Internal Marker Counts'] = noteMarkerCounts
+ self.errorDictionary['USFMs']['All Footnote and Cross-Reference Internal Marker Counts']['Total'] = total
+ if functionalCounts: self.errorDictionary['USFMs']['Functional Marker Counts'] = functionalCounts
# end of checkSFMs
@@ -1657,7 +1661,7 @@ def main():
if Globals.verbosityLevel > 0: print( "{} V{}".format( progName, versionString ) )
# Since this is only designed to be a base class, it can't actually do much at all
- IBB = InternalBibleBook()
+ IBB = InternalBibleBook( False ) # The parameter is the logErrorsFlag
# The following fields would normally be filled in a by "load" routine in the derived class
IBB.objectType = "DUMMY"
IBB.objectNameString = "Dummy test Internal Bible Book object"
View
19 USFMBible.py
@@ -1,7 +1,7 @@
#!/usr/bin/python3
#
# USFMBible.py
-# Last modified: 2012-05-28 by RJH (also update versionString below)
+# Last modified: 2012-05-29 by RJH (also update versionString below)
#
# Module handling compilations of USFM Bible books
#
@@ -27,7 +27,7 @@
"""
progName = "USFM Bible handler"
-versionString = "0.23"
+versionString = "0.24"
import os, logging, datetime
@@ -35,7 +35,6 @@
from collections import OrderedDict
import Globals
-#import ControlFiles
from USFMBibleBook import USFMBibleBook
from InternalBible import InternalBible
@@ -45,17 +44,17 @@ class USFMBible( InternalBible ):
Class to load and manipulate USFM Bibles.
"""
- def __init__( self, name ):
+ def __init__( self, name, logErrorsFlag ):
"""
Create the internal USFM Bible object.
"""
- InternalBible.__init__( self, name ) # Initialise the base class
+ InternalBible.__init__( self, name, logErrorsFlag ) # Initialise the base class
self.objectType = "USFM"
self.objectNameString = "USFM Bible object"
# end of __init_
- def load( self, folder, encoding='utf-8', logErrors=True ):
+ def load( self, folder, encoding='utf-8' ):
"""
Load the books.
"""
@@ -147,7 +146,7 @@ def loadSSFData( ssfFilepath, encoding='utf-8' ):
# Load the books one by one -- assuming that they have regular Paratext style filenames
for BBB,filename in self.USFMFilenamesObject.getActualFilenames():
- UBB = USFMBibleBook()
+ UBB = USFMBibleBook( self.logErrorsFlag )
UBB.load( BBB, folder, filename, encoding )
UBB.validateUSFM()
#print( UBB )
@@ -177,7 +176,7 @@ def loadSSFData( ssfFilepath, encoding='utf-8' ):
isUSFM = True
break # We only look at the first line
if isUSFM:
- UBB = USFMBibleBook()
+ UBB = USFMBibleBook( self.logErrorsFlag )
UBB.load( BBB, folder, thisFilename, encoding, logErrors )
UBB.validateUSFM()
print( UBB )
@@ -209,8 +208,8 @@ def main():
name, encoding, testFolder = "Matigsalug", "utf-8", "/mnt/Data/Matigsalug/Scripture/MBTV" # You can put your test folder here
if os.access( testFolder, os.R_OK ):
- UB = USFMBible( name )
- UB.load( testFolder, encoding, logErrors=False )
+ UB = USFMBible( name, False ) # The second parameter is the logErrorsFlag
+ UB.load( testFolder, encoding )
if Globals.verbosityLevel > 0: print( UB )
UB.check()
#UBErrors = UB.getErrors()
View
22 USFMBibleBook.py
@@ -1,7 +1,7 @@
#!/usr/bin/python3
#
# USFMBibleBook.py
-# Last modified: 2012-05-28 by RJH (also update versionString below)
+# Last modified: 2012-05-29 by RJH (also update versionString below)
#
# Module handling the USFM markers for Bible books
#
@@ -27,12 +27,11 @@
"""
progName = "USFM Bible book handler"
-versionString = "0.21"
+versionString = "0.22"
import os, logging
from gettext import gettext as _
-#from collections import OrderedDict
import Globals
from InternalBibleBook import InternalBibleBook
@@ -43,11 +42,11 @@ class USFMBibleBook( InternalBibleBook ):
Class to load and manipulate a single USFM file / book.
"""
- def __init__( self ):
+ def __init__( self, logErrorsFlag ):
"""
Create the USFM Bible book object.
"""
- InternalBibleBook.__init__( self ) # Initialise the base class
+ InternalBibleBook.__init__( self, logErrorsFlag ) # Initialise the base class
self.objectType = "USFM"
self.objectNameString = "USFM Bible Book object"
# end of __init__
@@ -85,10 +84,10 @@ def load( self, bookReferenceCode, folder, filename, encoding='utf-8' ):
elif self.USFMMarkers.isInternalMarker( marker ): # the line begins with an internal marker -- append it to the previous line
if text:
loadErrors.append( _("{} {}:{} Found '\\{}' internal marker at beginning of line with text: {}").format( self.bookReferenceCode, c, v, marker, text ) )
- if self.logErrors: logging.warning( _("Found '\\{}' internal marker after {} {}:{} at beginning of line with text: {}").format( marker, self.bookReferenceCode, c, v, text ) )
+ if self.logErrorsFlag: logging.warning( _("Found '\\{}' internal marker after {} {}:{} at beginning of line with text: {}").format( marker, self.bookReferenceCode, c, v, text ) )
else: # no text
loadErrors.append( _("{} {}:{} Found '\\{}' internal marker at beginning of line (with no text)").format( self.bookReferenceCode, c, v, marker ) )
- if self.logErrors: logging.warning( _("Found '\\{}' internal marker after {} {}:{} at beginning of line (with no text)").format( marker, self.bookReferenceCode, c, v ) )
+ if self.logErrorsFlag: logging.warning( _("Found '\\{}' internal marker after {} {}:{} at beginning of line (with no text)").format( marker, self.bookReferenceCode, c, v ) )
self.addPriorityError( 97, c, v, _("Found \\{} internal marker on new line in file").format( marker ) )
#lastText += '' if lastText.endswith(' ') else ' ' # Not always good to add a space, but it's their fault!
lastText += '\\' + marker + ' ' + text
@@ -96,17 +95,17 @@ def load( self, bookReferenceCode, folder, filename, encoding='utf-8' ):
else: # the line begins with an unknown marker
if text:
loadErrors.append( _("{} {}:{} Found '\\{}' unknown marker at beginning of line with text: {}").format( self.bookReferenceCode, c, v, marker, text ) )
- if self.logErrors: logging.error( _("Found '\\{}' unknown marker after {} {}:{} at beginning of line with text: {}").format( marker, self.bookReferenceCode, c, v, text ) )
+ if self.logErrorsFlag: logging.error( _("Found '\\{}' unknown marker after {} {}:{} at beginning of line with text: {}").format( marker, self.bookReferenceCode, c, v, text ) )
else: # no text
loadErrors.append( _("{} {}:{} Found '\\{}' unknown marker at beginning of line (with no text").format( self.bookReferenceCode, c, v, marker ) )
- if self.logErrors: logging.error( _("Found '\\{}' unknown marker after {} {}:{} at beginning of line (with no text)").format( marker, self.bookReferenceCode, c, v ) )
+ if self.logErrorsFlag: logging.error( _("Found '\\{}' unknown marker after {} {}:{} at beginning of line (with no text)").format( marker, self.bookReferenceCode, c, v ) )
self.addPriorityError( 100, c, v, _("Found \\{} unknown marker on new line in file").format( marker ) )
for tryMarker in sorted( self.USFMMarkers.getNewlineMarkersList(), key=len, reverse=True ): # Try to do something intelligent here -- it might be just a missing space
if marker.startswith( tryMarker ): # Let's try changing it
if lastMarker: self.appendLine( lastMarker, lastText )
lastMarker, lastText = tryMarker, marker[len(tryMarker):] + ' ' + text
loadErrors.append( _("{} {}:{} Changed '\\{}' unknown marker to '{}' at beginning of line: {}").format( self.bookReferenceCode, c, v, marker, tryMarker, text ) )
- if self.logErrors: logging.warning( _("Changed '\\{}' unknown marker to '{}' after {} {}:{} at beginning of line: {}").format( marker, tryMarker, self.bookReferenceCode, c, v, text ) )
+ if self.logErrorsFlag: logging.warning( _("Changed '\\{}' unknown marker to '{}' after {} {}:{} at beginning of line: {}").format( marker, tryMarker, self.bookReferenceCode, c, v, text ) )
break
# Otherwise, don't bother processing this line -- it'll just cause more problems later on
if lastMarker: self.appendLine( lastMarker, lastText ) # Process the final line
@@ -135,8 +134,7 @@ def main():
fileList = USFMFilenames.USFMFilenames( testFolder ).getActualFilenames()
for bookReferenceCode,filename in fileList:
if Globals.verbosityLevel > 1: print( _("Loading {} from {}...").format( bookReferenceCode, filename ) )
- UBB = USFMBibleBook()
- UBB.logErrors = False
+ UBB = USFMBibleBook( False ) # The parameter is the logErrorsFlag
UBB.load( bookReferenceCode, testFolder, filename, encoding )
if Globals.verbosityLevel > 1: print( " ID is '{}'".format( UBB.getField( 'id' ) ) )
if Globals.verbosityLevel > 1: print( " Header is '{}'".format( UBB.getField( 'h' ) ) )
View
17 USXBible.py
@@ -1,7 +1,7 @@
#!/usr/bin/python3
#
# USXBible.py
-# Last modified: 2012-05-28 by RJH (also update versionString below)
+# Last modified: 2012-05-29 by RJH (also update versionString below)
#
# Module handling compilations of USX Bible books
#
@@ -27,7 +27,7 @@
"""
progName = "USX Bible handler"
-versionString = "0.01"
+versionString = "0.02"
import os, logging, datetime
@@ -35,7 +35,6 @@
from collections import OrderedDict
import Globals
-#import ControlFiles
from USXBibleBook import USXBibleBook
from InternalBible import InternalBible
@@ -45,11 +44,11 @@ class USXBible( InternalBible ):
Class to load and manipulate USX Bibles.
"""
- def __init__( self, name ):
+ def __init__( self, name, logErrorsFlag ):
"""
Create the internal USX Bible object.
"""
- InternalBible.__init__( self, name ) # Initialise the base class
+ InternalBible.__init__( self, name, logErrorsFlag ) # Initialise the base class
self.objectType = "USX"
self.objectNameString = "USX Bible object"
# end of __init_
@@ -148,7 +147,7 @@ def loadSSFData( ssfFilepath, encoding='utf-8' ):
# Load the books one by one -- assuming that they have regular Paratext style filenames
for BBB,filename in self.USXFilenamesObject.getActualFilenames():
- UBB = USXBibleBook()
+ UBB = USXBibleBook( self.logErrorsFlag )
UBB.load( BBB, folder, filename, encoding )
UBB.validateUSFM()
#print( UBB )
@@ -178,7 +177,7 @@ def loadSSFData( ssfFilepath, encoding='utf-8' ):
isUSX = True
break # We only look at the first line
if isUSX:
- UBB = USXBibleBook()
+ UBB = USXBibleBook( self.logErrorsFlag )
UBB.load( BBB, folder, thisFilename, encoding )
UBB.validateUSFM()
print( UBB )
@@ -210,8 +209,8 @@ def main():
name, encoding, testFolder = "Matigsalug", "utf-8", "/mnt/Work/VirtualBox_Shared_Folder/USXExports/Projects/MBTV/" # You can put your USX test folder here
if os.access( testFolder, os.R_OK ):
- UB = USXBible( name )
- UB.load( testFolder, encoding, logErrors=False )
+ UB = USXBible( name, False ) # The second parameter is the logErrorsFlag
+ UB.load( testFolder, encoding )
if Globals.verbosityLevel > 0: print( UB )
UB.check()
#UBErrors = UB.getErrors()
View
85 USXBibleBook.py
@@ -2,7 +2,7 @@
# -*- coding: utf-8 -*-
#
# USXBibleBook.py
-# Last modified: 2012-05-28 (also update versionString below)
+# Last modified: 2012-05-29 (also update versionString below)
#
# Module handling USX Bible Book xml
#
@@ -28,11 +28,10 @@
"""
progName = "USX Bible book handler"
-versionString = "0.02"
+versionString = "0.03"
import logging, os
from gettext import gettext as _
-#from collections import OrderedDict
from xml.etree.cElementTree import ElementTree
import Globals
@@ -43,11 +42,11 @@ class USXBibleBook( InternalBibleBook ):
"""
Class to load, validate, and manipulate a single Bible book in USX XML.
"""
- def __init__( self ):
+ def __init__( self, logErrorsFlag ):
"""
Create the USX Bible book object.
"""
- InternalBibleBook.__init__( self ) # Initialise the base class
+ InternalBibleBook.__init__( self, logErrorsFlag ) # Initialise the base class
self.objectType = "USX"
self.objectNameString = "USX Bible Book object"
# end of __init__
@@ -69,7 +68,7 @@ def loadParagraph( paragraphXML, paragraphlocation ):
if attrib=='style':
paragraphStyle = value # This is basically the USFM marker name
else:
- if self.logErrors: logging.warning( _("Unprocessed {} attribute ({}) in {}").format( attrib, value, location ) )
+ if self.logErrorsFlag: logging.warning( _("Unprocessed {} attribute ({}) in {}").format( attrib, value, location ) )
# Now process the paragraph text (or write a paragraph marker anyway)
self.appendLine( paragraphStyle, paragraphXML.text if paragraphXML.text and paragraphXML.text.strip() else '' )
@@ -89,9 +88,9 @@ def loadParagraph( paragraphXML, paragraphlocation ):
elif attrib=='style':
verseStyle = value
else:
- if self.logErrors: logging.warning( _("Unprocessed {} attribute ({}) in {}").format( attrib, value, location ) )
+ if self.logErrorsFlag: logging.warning( _("Unprocessed {} attribute ({}) in {}").format( attrib, value, location ) )
if verseStyle != 'v':
- if self.logErrors: logging.warning( _("Unexpected style attribute ({}) in {}").format( verseStyle, location ) )
+ if self.logErrorsFlag: logging.warning( _("Unexpected style attribute ({}) in {}").format( verseStyle, location ) )
self.appendLine( verseStyle, v + ' ' )
# Now process the tail (if there's one) which is the verse text
if element.tail:
@@ -107,7 +106,7 @@ def loadParagraph( paragraphXML, paragraphlocation ):
charStyle = value # This is basically the USFM character marker name
assert( not self.USFMMarkers.isNewlineMarker( charStyle ) )
else:
- if self.logErrors: logging.warning( _("Unprocessed {} attribute ({}) in {}").format( attrib, value, location ) )
+ if self.logErrorsFlag: logging.warning( _("Unprocessed {} attribute ({}) in {}").format( attrib, value, location ) )
# A character field must be added to the previous field
additionalText = "\\{} {}\\{}*{}".format( charStyle, element.text, charStyle, element.tail )
#print( c, v, paragraphStyle, charStyle )
@@ -123,7 +122,7 @@ def loadParagraph( paragraphXML, paragraphlocation ):
elif attrib=='caller':
noteCaller = value # Usually hyphen or a symbol to be used for the note
else:
- if self.logErrors: logging.warning( _("Unprocessed {} attribute ({}) in {}").format( attrib, value, location ) )
+ if self.logErrorsFlag: logging.warning( _("Unprocessed {} attribute ({}) in {}").format( attrib, value, location ) )
assert( noteStyle and noteCaller ) # both compulsory
noteLine = "\\{} {} ".format( noteStyle, noteCaller )
# Now process the subelements -- notes are one of the few multiply embedded fields in USX
@@ -142,11 +141,11 @@ def loadParagraph( paragraphXML, paragraphlocation ):
assert( value=='false' )
charClosed = False
else:
- if self.logErrors: logging.warning( _("Unprocessed {} attribute ({}) in {}").format( attrib, value, sublocation ) )
+ if self.logErrorsFlag: logging.warning( _("Unprocessed {} attribute ({}) in {}").format( attrib, value, sublocation ) )
noteLine += "\\{} {}".format( charStyle, subelement.text )
if charClosed: noteLine += "\\{}*".format( charStyle )
else:
- if self.logErrors: logging.warning( _("Unprocessed {} subelement after {} {}:{} in {}").format( subelement.tag, bookReferenceCode, c, v, sublocation ) )
+ if self.logErrorsFlag: logging.warning( _("Unprocessed {} subelement after {} {}:{} in {}").format( subelement.tag, bookReferenceCode, c, v, sublocation ) )
self.addPriorityError( 1, self.bookReferenceCode, c, v, _("Unprocessed {} subelement").format( subelement.tag ) )
if subelement.tail and subelement.tail.strip(): noteLine += subelement.tail
#noteLine += "\\{}*".format( charStyle )
@@ -154,7 +153,7 @@ def loadParagraph( paragraphXML, paragraphlocation ):
if element.tail: noteLine += element.tail
self.appendToLastLine( noteLine )
else:
- if self.logErrors: logging.warning( _("Unprocessed {} element after {} {}:{} in {}").format( element.tag, bookReferenceCode, c, v, location ) )
+ if self.logErrorsFlag: logging.warning( _("Unprocessed {} element after {} {}:{} in {}").format( element.tag, bookReferenceCode, c, v, location ) )
self.addPriorityError( 1, self.bookReferenceCode, c, v, _("Unprocessed {} element").format( element.tag ) )
for x in range(max(0,len(self)-10),len(self)): print( x, self._lines[x] )
halt
@@ -170,7 +169,7 @@ def loadParagraph( paragraphXML, paragraphlocation ):
assert( len ( self.tree ) ) # Fail here if we didn't load anything at all
c = v = '0'
- #loadErrors = []
+ loadErrors = []
# Find the main container
if self.tree.tag=='usx' or self.tree.tag=='usfm': # Not sure why both are allowable
@@ -181,7 +180,7 @@ def loadParagraph( paragraphXML, paragraphlocation ):
# Process the attributes first
self.schemaLocation = ''
for attrib,value in self.tree.items():
- if self.logErrors: logging.warning( _("Unprocessed {} attribute ({}) in {}").format( attrib, value, location ) )
+ if self.logErrorsFlag: logging.warning( _("Unprocessed {} attribute ({}) in {}").format( attrib, value, location ) )
# Now process the data
for element in self.tree:
@@ -195,13 +194,13 @@ def loadParagraph( paragraphXML, paragraphlocation ):
if attrib=='id' or attrib=='code':
idField = value # Should be USFM bookcode (not like bookReferenceCode which is BibleOrgSys BBB bookcode)
#if idField != bookReferenceCode:
- # if self.logErrors: logging.warning( _("Unexpected book code ({}) in {}").format( idField, sublocation ) )
+ # if self.logErrorsFlag: logging.warning( _("Unexpected book code ({}) in {}").format( idField, sublocation ) )
elif attrib=='style':
bookStyle = value
else:
- if self.logErrors: logging.warning( _("Unprocessed {} attribute ({}) in {}").format( attrib, value, sublocation ) )
+ if self.logErrorsFlag: logging.warning( _("Unprocessed {} attribute ({}) in {}").format( attrib, value, sublocation ) )
if bookStyle != 'id':
- if self.logErrors: logging.warning( _("Unexpected style attribute ({}) in {}").format( bookStyle, sublocation ) )
+ if self.logErrorsFlag: logging.warning( _("Unexpected style attribute ({}) in {}").format( bookStyle, sublocation ) )
idLine = idField
if element.text and element.text.strip(): idLine += ' ' + element.text
self.appendLine( 'id', idLine )
@@ -218,18 +217,52 @@ def loadParagraph( paragraphXML, paragraphlocation ):
elif attrib=='style':
chapterStyle = value
else:
- if self.logErrors: logging.warning( _("Unprocessed {} attribute ({}) in {}").format( attrib, value, sublocation ) )
+ if self.logErrorsFlag: logging.warning( _("Unprocessed {} attribute ({}) in {}").format( attrib, value, sublocation ) )
if chapterStyle != 'c':
- if self.logErrors: logging.warning( _("Unexpected style attribute ({}) in {}").format( chapterStyle, sublocation ) )
+ if self.logErrorsFlag: logging.warning( _("Unexpected style attribute ({}) in {}").format( chapterStyle, sublocation ) )
self.appendLine( 'c', c )
elif element.tag == 'para':
Globals.checkXMLNoTail( element, sublocation )
- loadParagraph( element, sublocation )
+ USFMMarker = element.attrib['style'] # Get the USFM code for the paragraph style
+ if self.USFMMarkers.isNewlineMarker( USFMMarker ):
+ #if lastMarker: self.appendLine( lastMarker, lastText )
+ #lastMarker, lastText = USFMMarker, text
+ loadParagraph( element, sublocation )
+ elif self.USFMMarkers.isInternalMarker( USFMMarker ): # the line begins with an internal USFM Marker -- append it to the previous line
+ halt # Not checked yet
+ text = element.text
+ if text:
+ loadErrors.append( _("{} {}:{} Found '\\{}' internal USFM marker at beginning of line with text: {}").format( self.bookReferenceCode, c, v, USFMMarker, text ) )
+ if self.logErrorsFlag: logging.warning( _("Found '\\{}' internal USFM Marker after {} {}:{} at beginning of line with text: {}").format( USFMMarker, self.bookReferenceCode, c, v, text ) )
+ else: # no text
+ loadErrors.append( _("{} {}:{} Found '\\{}' internal USFM Marker at beginning of line (with no text)").format( self.bookReferenceCode, c, v, USFMMarker ) )
+ if self.logErrorsFlag: logging.warning( _("Found '\\{}' internal USFM Marker after {} {}:{} at beginning of line (with no text)").format( USFMMarker, self.bookReferenceCode, c, v ) )
+ self.addPriorityError( 97, c, v, _("Found \\{} internal USFM Marker on new line in file").format( USFMMarker ) )
+ #lastText += '' if lastText.endswith(' ') else ' ' # Not always good to add a space, but it's their fault!
+ lastText += '\\' + USFMMarker + ' ' + text
+ #print( "{} {} {} Now have {}:'{}'".format( self.bookReferenceCode, c, v, lastMarker, lastText ) )
+ else: # the line begins with an unknown USFM Marker
+ text = element.text
+ if text:
+ loadErrors.append( _("{} {}:{} Found '\\{}' unknown USFM Marker at beginning of line with text: {}").format( self.bookReferenceCode, c, v, USFMMarker, text ) )
+ if self.logErrorsFlag: logging.error( _("Found '\\{}' unknown USFM Marker after {} {}:{} at beginning of line with text: {}").format( USFMMarker, self.bookReferenceCode, c, v, text ) )
+ else: # no text
+ loadErrors.append( _("{} {}:{} Found '\\{}' unknown USFM Marker at beginning of line (with no text").format( self.bookReferenceCode, c, v, USFMMarker ) )
+ if self.logErrorsFlag: logging.error( _("Found '\\{}' unknown USFM Marker after {} {}:{} at beginning of line (with no text)").format( USFMMarker, self.bookReferenceCode, c, v ) )
+ self.addPriorityError( 100, c, v, _("Found \\{} unknown USFM Marker on new line in file").format( USFMMarker ) )
+ for tryMarker in sorted( self.USFMMarkers.getNewlineMarkersList(), key=len, reverse=True ): # Try to do something intelligent here -- it might be just a missing space
+ if USFMMarker.startswith( tryMarker ): # Let's try changing it
+ if lastMarker: self.appendLine( lastMarker, lastText )
+ lastMarker, lastText = tryMarker, USFMMarker[len(tryMarker):] + ' ' + text
+ loadErrors.append( _("{} {}:{} Changed '\\{}' unknown USFM Marker to '{}' at beginning of line: {}").format( self.bookReferenceCode, c, v, USFMMarker, tryMarker, text ) )
+ if self.logErrorsFlag: logging.warning( _("Changed '\\{}' unknown USFM Marker to '{}' after {} {}:{} at beginning of line: {}").format( USFMMarker, tryMarker, self.bookReferenceCode, c, v, text ) )
+ break
+ # Otherwise, don't bother processing this line -- it'll just cause more problems later on
else:
- if self.logErrors: logging.warning( _("Unprocessed {} element after {} {}:{} in {}").format( element.tag, bookReferenceCode, c, v, sublocation ) )
+ if self.logErrorsFlag: logging.warning( _("Unprocessed {} element after {} {}:{} in {}").format( element.tag, bookReferenceCode, c, v, sublocation ) )
self.addPriorityError( 1, c, v, _("Unprocessed {} element").format( element.tag ) )
- #if loadErrors: self.errorDictionary['Load Errors'] = loadErrors
+ if loadErrors: self.errorDictionary['Load Errors'] = loadErrors
# end of load
@@ -259,8 +292,7 @@ def main():
'ROM','CO1','CO2','GAL','EPH','PHP','COL','TH1','TH2','TI1','TI2','TIT','PHM', \
'HEB','JAM','PE1','PE2','JN1','JN2','JN3','JDE','REV'):
if Globals.verbosityLevel > 1: print( _("Loading {} from {}...").format( bookReferenceCode, filename ) )
- UxBB = USXBibleBook()
- UxBB.logErrors = True
+ UxBB = USXBibleBook( True ) # The parameter is the logErrorsFlag
UxBB.load( bookReferenceCode, testFolder, filename, encoding )
if Globals.verbosityLevel > 1: print( " ID is '{}'".format( UxBB.getField( 'id' ) ) )
if Globals.verbosityLevel > 1: print( " Header is '{}'".format( UxBB.getField( 'h' ) ) )
@@ -284,8 +316,7 @@ def main():
found2 = True; break
if found2:
if Globals.verbosityLevel > 2: print( _("Loading {} from {}...").format( bookReferenceCode2, filename2 ) )
- UBB = USFMBibleBook.USFMBibleBook()
- UBB.logErrors = False
+ UBB = USFMBibleBook.USFMBibleBook( False ) # The parameter is the logErrorsFlag
UBB.load( bookReferenceCode, testFolder2, filename2, encoding2 )
#print( " ID is '{}'".format( UBB.getField( 'id' ) ) )
#print( " Header is '{}'".format( UBB.getField( 'h' ) ) )
Please sign in to comment.
Something went wrong with that request. Please try again.