Skip to content

Commit

Permalink
Bring up to code standards
Browse files Browse the repository at this point in the history
  • Loading branch information
RobH123 committed May 13, 2020
1 parent 4b49a0a commit 4bb7ad7
Show file tree
Hide file tree
Showing 28 changed files with 124 additions and 117 deletions.
24 changes: 11 additions & 13 deletions Apps/ReorderSongs.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,20 +45,9 @@
etc.
"""

from gettext import gettext as _

LAST_MODIFIED_DATE = '2017-09-27' # by RJH
SHORT_PROGRAM_NAME = "ReorderSongs"
PROGRAM_NAME = "Reorder Songs"
PROGRAM_VERSION = '0.03'
programNameVersion = f'{SHORT_PROGRAM_NAME} v{PROGRAM_VERSION}'

debuggingThisModule = False


import sys
import os #, logging
import os

if __name__ == '__main__':
import sys
Expand All @@ -69,6 +58,15 @@
from BibleOrgSys.InputOutput import SFMFile


LAST_MODIFIED_DATE = '2017-09-27' # by RJH
SHORT_PROGRAM_NAME = "ReorderSongs"
PROGRAM_NAME = "Reorder Songs"
PROGRAM_VERSION = '0.03'
programNameVersion = f'{SHORT_PROGRAM_NAME} v{PROGRAM_VERSION}'

debuggingThisModule = False


testFolder = 'Tests/DataFilesForTests/'
testFile = 'Songs.sfm'
outputFolder = BibleOrgSysGlobals.DEFAULT_WRITEABLE_OUTPUT_FOLDERPATH
Expand All @@ -87,7 +85,7 @@ def main() -> None:
# Left the four default parameters at the end of the next line so you can see what's available
songs.read( songsInputFilepath, key='c', ignoreSFMs=None, ignoreEntries=None, changePairs=None, encoding='utf-8' )
vPrint( 'Normal', debuggingThisModule, " {} songs loaded".format( len(songs.records) ) )
if BibleOrgSysGlobals.debugFlag and debuggingThisModule: vPrint( 'Quiet', debuggingThisModule, songs )
vPrint( 'Never', debuggingThisModule, songs )

# Extract the information out of the file that we want to use for sorting
# (We get the \s field, plus keep track of the index of each record)
Expand Down
3 changes: 2 additions & 1 deletion BibleOrgSys/BibleOrgSysGlobals.py
Original file line number Diff line number Diff line change
Expand Up @@ -1314,8 +1314,8 @@ def setVerbosity( verbosityLevelParameter ):
"""
Sets the VerbosityLevel global variable to an integer value depending on the Verbosity control.
"""

global verbosityString, verbosityLevel

if isinstance( verbosityLevelParameter, str ):
if verbosityLevelParameter == 'Silent':
verbosityString = verbosityLevelParameter
Expand All @@ -1333,6 +1333,7 @@ def setVerbosity( verbosityLevelParameter ):
verbosityString = verbosityLevelParameter
verbosityLevel = 4
else: logging.error( f"Invalid '{verbosityLevelParameter}' verbosity parameter" )

else: # assume it's an integer
if verbosityLevelParameter == 0:
verbosityLevel = verbosityLevelParameter
Expand Down
26 changes: 13 additions & 13 deletions BibleOrgSys/BibleWriter.py
Original file line number Diff line number Diff line change
Expand Up @@ -673,7 +673,7 @@ def toUSFM2( self, outputFolderpath:Optional[Path]=None, removeVerseBridges=Fals
ignoredMarkers.add( pseudoMarker )
continue
#fullText = cleanText # (temp)
#if BibleOrgSysGlobals.debugFlag and debuggingThisModule: vPrint( 'Quiet', debuggingThisModule, "toUSFM: pseudoMarker = {!r} fullText = {!r}".format( pseudoMarker, fullText ) )
#vPrint( 'Never', debuggingThisModule, "toUSFM: pseudoMarker = {!r} fullText = {!r}".format( pseudoMarker, fullText ) )
if removeVerseBridges and pseudoMarker in ('v','c',):
if vBridgeStartInt and vBridgeEndInt:
for vNum in range( vBridgeStartInt+1, vBridgeEndInt+1 ): # Fill in missing verse numbers
Expand Down Expand Up @@ -844,7 +844,7 @@ def toUSFM3( self, outputFolderpath:Optional[Path]=None, removeVerseBridges=Fals
addedUSFMfield = True

#fullText = cleanText # (temp)
#if BibleOrgSysGlobals.debugFlag and debuggingThisModule: vPrint( 'Quiet', debuggingThisModule, "toUSFM: pseudoMarker = {!r} fullText = {!r}".format( pseudoMarker, fullText ) )
#vPrint( 'Never', debuggingThisModule, "toUSFM: pseudoMarker = {!r} fullText = {!r}".format( pseudoMarker, fullText ) )
if removeVerseBridges and pseudoMarker in ('v','c',):
if vBridgeStartInt and vBridgeEndInt:
for vNum in range( vBridgeStartInt+1, vBridgeEndInt+1 ): # Fill in missing verse numbers
Expand Down Expand Up @@ -1019,7 +1019,7 @@ def toESFM( self, outputFolderpath:Optional[Path]=None ): #, removeVerseBridges=
continue

#value = cleanText # (temp)
#if BibleOrgSysGlobals.debugFlag and debuggingThisModule: vPrint( 'Quiet', debuggingThisModule, "toESFM: pseudoMarker = {!r} value = {!r}".format( pseudoMarker, value ) )
#vPrint( 'Never', debuggingThisModule, "toESFM: pseudoMarker = {!r} value = {!r}".format( pseudoMarker, value ) )
if 0 and removeVerseBridges and pseudoMarker in ('v','c',):
if vBridgeStartInt and vBridgeEndInt:
for vNum in range( vBridgeStartInt+1, vBridgeEndInt+1 ): # Fill in missing verse numbers
Expand Down Expand Up @@ -1583,7 +1583,7 @@ def processFigure( MDfigure ):
extra = ''
elif extraType == 'vp':
extra = "\\vp {}\\vp*".format( extraText ) # Will be handled later
elif BibleOrgSysGlobals.debugFlag and debuggingThisModule: vPrint( 'Quiet', debuggingThisModule, 'eT', extraType ); halt
elvPrint( 'Never', debuggingThisModule, 'eT', extraType ); halt
#vPrint( 'Quiet', debuggingThisModule, "was", verse )
if extra:
adjText = adjText[:adjIndex] + str(extra) + adjText[adjIndex:]
Expand Down Expand Up @@ -1964,7 +1964,7 @@ def processFigure( HTML5figure, ourGlobals ):
extra = ''
elif extraType == 'vp':
extra = "\\vp {}\\vp*".format( extraText ) # Will be handled later
elif BibleOrgSysGlobals.debugFlag and debuggingThisModule: vPrint( 'Quiet', debuggingThisModule, 'eT', extraType ); halt
elvPrint( 'Never', debuggingThisModule, 'eT', extraType ); halt
#vPrint( 'Quiet', debuggingThisModule, "was", verse )
adjText = adjText[:adjIndex] + str(extra) + adjText[adjIndex:]
offset -= len( extra )
Expand Down Expand Up @@ -2654,7 +2654,7 @@ def savePreviousSection() -> None:
ignoredMarkers.add( pseudoMarker )
continue
#fullText = cleanText # (temp)
#if BibleOrgSysGlobals.debugFlag and debuggingThisModule: vPrint( 'Quiet', debuggingThisModule, "toUSFM: pseudoMarker = {!r} fullText = {!r}".format( pseudoMarker, fullText ) )
#vPrint( 'Never', debuggingThisModule, "toUSFM: pseudoMarker = {!r} fullText = {!r}".format( pseudoMarker, fullText ) )
#vPrint( 'Quiet', debuggingThisModule, 'BDText2', BBB, pseudoMarker, repr(fullText) )

if (BBB=='FRT' and pseudoMarker=='is1') \
Expand Down Expand Up @@ -3776,7 +3776,7 @@ def handleInternalTextMarkersForUSX2( originalText ):
"""
if not originalText: return ''
if '\\' not in originalText: return originalText
if BibleOrgSysGlobals.debugFlag and debuggingThisModule: vPrint( 'Quiet', debuggingThisModule, "toUSX2XML:hITM4USX:", BBB, C, V, marker, "'"+originalText+"'" )
vPrint( 'Never', debuggingThisModule, "toUSX2XML:hITM4USX:", BBB, C, V, marker, "'"+originalText+"'" )
markerList = sorted( BibleOrgSysGlobals.loadedUSFMMarkers.getMarkerListFromText( originalText ),
key=lambda s: -len(s[4])) # Sort by longest characterContext first (maximum nesting)
# for insideMarker, iMIndex, nextSignificantChar, fullMarker, characterContext, endIndex, markerField in markerList: # check for internal markers
Expand Down Expand Up @@ -4081,7 +4081,7 @@ def processFootnote( USXfootnote ):
extra = '' # temp
elif extraType == 'vp':
extra = "\\vp {}\\vp*".format( extraText ) # Will be handled later
elif BibleOrgSysGlobals.debugFlag and debuggingThisModule: vPrint( 'Quiet', debuggingThisModule, extraType ); halt
elvPrint( 'Never', debuggingThisModule, extraType ); halt
#vPrint( 'Quiet', debuggingThisModule, "was", verse )
adjText = adjText[:adjIndex] + str(extra) + adjText[adjIndex:]
offset -= len( extra )
Expand Down Expand Up @@ -4347,7 +4347,7 @@ def handleInternalTextMarkersForUSFX( originalText ):
"""
if not originalText: return ''
if '\\' not in originalText: return originalText
if BibleOrgSysGlobals.debugFlag and debuggingThisModule: vPrint( 'Quiet', debuggingThisModule, "toUSFXXML:hITM4USFX:", BBB, C, V, marker, "'"+originalText+"'" )
vPrint( 'Never', debuggingThisModule, "toUSFXXML:hITM4USFX:", BBB, C, V, marker, "'"+originalText+"'" )
markerList = sorted( BibleOrgSysGlobals.loadedUSFMMarkers.getMarkerListFromText( originalText ),
key=lambda s: -len(s[4])) # Sort by longest characterContext first (maximum nesting)
for insideMarker, iMIndex, nextSignificantChar, fullMarker, characterContext, endIndex, markerField in markerList: # check for internal markers
Expand Down Expand Up @@ -4591,7 +4591,7 @@ def processFootnote( USFXfootnote ):
extra = '' # temp
elif extraType == 'vp':
extra = "\\vp {}\\vp*".format( extraText ) # Will be handled later
elif BibleOrgSysGlobals.debugFlag and debuggingThisModule: vPrint( 'Quiet', debuggingThisModule, extraType ); halt
elvPrint( 'Never', debuggingThisModule, extraType ); halt
#vPrint( 'Quiet', debuggingThisModule, "was", verse )
adjText = adjText[:adjIndex] + str(extra) + adjText[adjIndex:]
offset -= len( extra )
Expand Down Expand Up @@ -5142,7 +5142,7 @@ def processFootnote( USFMfootnote ):
extra = '' # temp
elif extraType == 'vp':
extra = "\\vp {}\\vp*".format( extraText ) # Will be handled later
elif BibleOrgSysGlobals.debugFlag and debuggingThisModule: vPrint( 'Quiet', debuggingThisModule, extraType ); halt
elvPrint( 'Never', debuggingThisModule, extraType ); halt
#vPrint( 'Quiet', debuggingThisModule, "was", verse )
verse = verse[:adjIndex] + str(extra) + verse[adjIndex:]
offset -= len( extra )
Expand Down Expand Up @@ -5927,7 +5927,7 @@ def processFootnote( USFMfootnote ):
extra = '' # temp
elif extraType == 'vp':
extra = "\\vp {}\\vp*".format( extraText ) # Will be handled later
elif BibleOrgSysGlobals.debugFlag and debuggingThisModule: vPrint( 'Quiet', debuggingThisModule, extraType ); halt
elvPrint( 'Never', debuggingThisModule, extraType ); halt
#vPrint( 'Quiet', debuggingThisModule, "was", verse )
verse = verse[:adjIndex] + str(extra) + verse[adjIndex:]
offset -= len( extra )
Expand Down Expand Up @@ -9710,7 +9710,7 @@ def doAllExports( self, givenOutputFolderName=None, wantPhotoBible=None, wantODF

if not self.projectName: self.projectName = self.getAName() # Seems no post-processing was done???

if givenOutputFolderName == None:
if givenOutputFolderName is None:
givenOutputFolderName = BibleOrgSysGlobals.DEFAULT_WRITEABLE_OUTPUT_FOLDERPATH
if not os.access( givenOutputFolderName, os.F_OK ):
vPrint( 'Info', debuggingThisModule, "BibleWriter.doAllExports: " + _("creating {!r} output folder").format( givenOutputFolderName ) )
Expand Down
3 changes: 2 additions & 1 deletion BibleOrgSys/Formats/BCVBible.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
Module for defining and manipulating complete or partial BCV Bibles.
"""
from gettext import gettext as _
from typing import Optional
import os
import logging
import multiprocessing
Expand All @@ -41,7 +42,7 @@
from BibleOrgSys.Internals.InternalBibleInternals import InternalBibleEntryList, InternalBibleEntry


LAST_MODIFIED_DATE = '2020-04-18' # by RJH
LAST_MODIFIED_DATE = '2020-05-06' # by RJH
SHORT_PROGRAM_NAME = "BCVBible"
PROGRAM_NAME = "BCV Bible handler"
PROGRAM_VERSION = '0.22'
Expand Down
2 changes: 1 addition & 1 deletion BibleOrgSys/Formats/PTX8Bible.py
Original file line number Diff line number Diff line change
Expand Up @@ -2634,7 +2634,7 @@ def loadPTX8TermRenderings( self ):
BibleOrgSysGlobals.checkXMLNoAttributes( sub2element, sub2location )
BibleOrgSysGlobals.checkXMLNoSubelements( sub2element, sub2location )
BibleOrgSysGlobals.checkXMLNoTail( sub2element, sub2location )
if termRenderingEntryDict[subelement.tag] == None:
if termRenderingEntryDict[subelement.tag] is None:
termRenderingEntryDict[subelement.tag] = []
#if sub2element.tag == 'VerseRef':
## Process the VerseRef attributes first
Expand Down
7 changes: 4 additions & 3 deletions BibleOrgSys/Formats/PickledBible.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ class PickledBible( Bible )
loadBooks( self )
"""
from gettext import gettext as _
from typing import Optional
import os
from pathlib import Path
import logging
Expand All @@ -59,13 +60,13 @@ class PickledBible( Bible )
sys.path.insert( 0, aboveAboveFolderpath )
from BibleOrgSys import BibleOrgSysGlobals
from BibleOrgSys.BibleOrgSysGlobals import vPrint
from BibleOrgSys.Bible import Bible
from BibleOrgSys.Bible import Bible, BibleBook
from BibleOrgSys.Internals.InternalBibleBook import InternalBibleBook
from BibleOrgSys.Internals.InternalBibleInternals import InternalBibleEntryList
from BibleOrgSys.Internals.InternalBibleIndexes import InternalBibleCVIndex, InternalBibleSectionIndex


LAST_MODIFIED_DATE = '2020-04-15' # by RJH
LAST_MODIFIED_DATE = '2020-05-07' # by RJH
SHORT_PROGRAM_NAME = "PickledBible"
PROGRAM_NAME = "Pickle Bible handler"
PROGRAM_VERSION = '0.17'
Expand Down Expand Up @@ -546,7 +547,7 @@ def __str__( self ) -> str:
@return: the name of a Bible object formatted as a string
@rtype: string
"""
if BibleOrgSysGlobals.debugFlag and debuggingThisModule: vPrint( 'Quiet', debuggingThisModule, "PickledBible.__str__()" )
vPrint( 'Never', debuggingThisModule, "PickledBible.__str__()" )

set1 = ( 'Title', 'Description', 'Version', 'Revision', ) # Ones to print at verbosityLevel > 1
set2 = ( 'Status', 'Font', 'Copyright', 'Licence', ) # Ones to print at verbosityLevel > 2
Expand Down
Loading

0 comments on commit 4bb7ad7

Please sign in to comment.