Beispiel #1
0
def main():
    """
    This is the main program for the app
        which just tries to open and load some kind of Bible file(s)
            from the inputFolder that you specified
        and then export a USX Bible (in the default OutputFiles folder).

    Note that the standard verbosityLevel is 2:
        -s (silent) is 0
        -q (quiet) is 1
        -i (information) is 3
        -v (verbose) is 4.
    """
    inputFileOrFolder = defaultInputFolder

    if BibleOrgSysGlobals.verbosityLevel > 0:
        print(ProgNameVersion)
        print(
            f"\n{ShortProgName}: processing input folder {inputFileOrFolder!r} …"
        )

    # Try to detect and read/load the Bible file(s)
    unknownBible = UnknownBible(
        inputFileOrFolder)  # Tell it the folder to start looking in
    loadedBible = unknownBible.search(
        autoLoadAlways=True,
        autoLoadBooks=True)  # Load all the books if we find any
    if BibleOrgSysGlobals.verbosityLevel > 2:
        print(unknownBible)  # Display what Bible typed we found
    if BibleOrgSysGlobals.verbosityLevel > 1:
        print(loadedBible)  # Show how many books we loaded

    # If we were successful, do the export
    if loadedBible is not None:
        if BibleOrgSysGlobals.strictCheckingFlag: loadedBible.check()

        defaultOutputFolder = os.path.join(os.getcwd(), 'OutputFiles/',
                                           'BOS_USX2_Export/')
        if os.path.exists(defaultOutputFolder):
            if BibleOrgSysGlobals.verbosityLevel > 0:
                print(
                    f"\n{ShortProgName}: removing previous {defaultOutputFolder} folder…"
                )
                shutil.rmtree(defaultOutputFolder)

        if BibleOrgSysGlobals.verbosityLevel > 0:
            print(f"\n{ShortProgName}: starting export…")

        # We only want to do the USX export (from the BibleWriter.py module)
        result = loadedBible.toUSX2XML(
        )  # Export as USX files (USFM inside XML)
        # However, you could easily change this to do all exports
        #result = loadedBible.doAllExports( wantPhotoBible=False, wantODFs=False, wantPDFs=False )
        # Or you could choose a different export, for example:
        #result = loadedBible.toOSISXML()
        if BibleOrgSysGlobals.verbosityLevel > 2:
            print(f"  Result was: {result}")
        print(
            f"\n{ShortProgName}: output should be in {defaultOutputFolder} folder."
        )
def main():
    """
    This is the main program for the app
        which just tries to open and load some kind of Bible file(s)
            from the inputFolder that you specified
        and then export a PhotoBible (in the default OutputFiles folder).

    Note that the standard verbosityLevel is 2:
        -s (silent) is 0
        -q (quiet) is 1
        -i (information) is 3
        -v (verbose) is 4.
    """
    if BibleOrgSysGlobals.verbosityLevel > 0:
        print(ProgNameVersion)
        print("\n{}: processing input folder {!r} ...".format(
            ShortProgName, inputFolder))

    # Try to detect and read/load the Bible file(s)
    unknownBible = UnknownBible(
        inputFolder)  # Tell it the folder to start looking in
    loadedBible = unknownBible.search(
        autoLoadAlways=True,
        autoLoadBooks=True)  # Load all the books if we find any
    if BibleOrgSysGlobals.verbosityLevel > 2:
        print(unknownBible)  # Display what Bible typed we found
    if BibleOrgSysGlobals.verbosityLevel > 1:
        print(loadedBible)  # Show how many books we loaded

    # If we were successful, do the export
    if loadedBible is not None:
        if BibleOrgSysGlobals.strictCheckingFlag: loadedBible.check()
        if BibleOrgSysGlobals.verbosityLevel > 0:
            print(
                "\n{}: starting export (may take up to 60 minutes)...".format(
                    ShortProgName))

        # We only want to do the PhotoBible export (from the BibleWriter.py module)
        result = loadedBible.toPhotoBible(
        )  # Export as a series of small JPEG files (for cheap non-Java camera phones)
        # However, you could easily change this to do all exports
        #result = loadedBible.doAllExports( wantPhotoBible=True, wantODFs=True, wantPDFs=True )
        # Or you could choose a different export, for example:
        #result = loadedBible.toOSISXML()
        if BibleOrgSysGlobals.verbosityLevel > 2:
            print("  Result was: {}".format(result))
Beispiel #3
0
def main():
    """
    Main program to handle command line parameters and then run what they want.
    """
    from UnknownBible import UnknownBible
    if BibleOrgSysGlobals.verbosityLevel > 0: print( ProgNameVersion )
    #if BibleOrgSysGlobals.print( BibleOrgSysGlobals.commandLineArguments )

    fp1, fp2 = BibleOrgSysGlobals.commandLineArguments.Bible1, BibleOrgSysGlobals.commandLineArguments.Bible2
    allOkay = True
    if not os.path.exists( fp1 ): logging.critical( "Bible1 filepath {!r} is invalid—aborting".format( fp1 ) ); allOkay = False
    if not os.path.exists( fp2 ): logging.critical( "Bible2 filepath {!r} is invalid—aborting".format( fp2 ) ); allOkay = False

    if allOkay:
        UnkB1 = UnknownBible( fp1 )
        result1 = UnkB1.search( autoLoadAlways=True, autoLoadBooks=True )
        if BibleOrgSysGlobals.verbosityLevel > 1: print( "Bible1 loaded", result1 )
        if isinstance( result1, Bible ):
            Bible1 = result1
        else:
            logging.critical( "Unable to load Bible1 from {!r}—aborting".format( fp1 ) ); allOkay = False
    if allOkay:
        UnkB2 = UnknownBible( fp2 )
        result2 = UnkB2.search( autoLoadAlways=True, autoLoadBooks=True )
        if BibleOrgSysGlobals.verbosityLevel > 1: print( "Bible2 loaded", result2 )
        if isinstance( result2, Bible ):
            Bible2 = result2
        else:
            logging.critical( "Unable to load Bible2 from {!r}—aborting".format( fp2 ) ); allOkay = False

    if allOkay:
        results = compareBibles( Bible1, Bible2 )
        if BibleOrgSysGlobals.verbosityLevel > 0:
            name1 = Bible1.abbreviation if Bible1.abbreviation else Bible1.name
            name2 = Bible2.abbreviation if Bible2.abbreviation else Bible2.name
            print( "\nComparing the entire Bibles gave:" )
            for BBB,bookResults in results.items():
                if bookResults:
                    print( '\n{}:'.format( BBB ) )
                    for result in bookResults:
                        C, V, resultString = result[0][0], result[0][1], result[1]
                        resultString = resultString.replace( 'Bible1', name1 ).replace( 'Bible2', name2 )
                        print( '{}:{} {}'.format( C, V, resultString ) )
Beispiel #4
0
def main():
    """
    This is the main program for the app
        which just tries to open and load some kind of Bible file(s)
            from the inputFolder that you specified
        and then export a PhotoBible (in the default OutputFiles folder).

    Note that the standard verbosityLevel is 2:
        -s (silent) is 0
        -q (quiet) is 1
        -i (information) is 3
        -v (verbose) is 4.
    """
    if BibleOrgSysGlobals.verbosityLevel > 0:
        print( ProgNameVersion )
        print( "\n{}: processing input folder {!r} ...".format( ShortProgName, inputFolder ) )

    # Try to detect and read/load the Bible file(s)
    unknownBible = UnknownBible( inputFolder ) # Tell it the folder to start looking in
    loadedBible = unknownBible.search( autoLoadAlways=True, autoLoadBooks=True ) # Load all the books if we find any
    if BibleOrgSysGlobals.verbosityLevel > 2: print( unknownBible ) # Display what Bible typed we found
    if BibleOrgSysGlobals.verbosityLevel > 1: print( loadedBible ) # Show how many books we loaded

    # If we were successful, do the export
    if loadedBible is not None:
        if BibleOrgSysGlobals.strictCheckingFlag: loadedBible.check()
        if BibleOrgSysGlobals.verbosityLevel > 0:
            print( "\n{}: starting export (may take up to 60 minutes)...".format( ShortProgName ) )

        # We only want to do the PhotoBible export (from the BibleWriter.py module)
        result = loadedBible.toPhotoBible() # Export as a series of small JPEG files (for cheap non-Java camera phones)
        # However, you could easily change this to do all exports
        #result = loadedBible.doAllExports( wantPhotoBible=True, wantODFs=True, wantPDFs=True )
        # Or you could choose a different export, for example:
        #result = loadedBible.toOSISXML()
        if BibleOrgSysGlobals.verbosityLevel > 2: print( "  Result was: {}".format( result ) )
Beispiel #5
0
import BibleOrgSysGlobals
from UnknownBible import UnknownBible

ProgName = "USFM to USX (minimal)"
ProgVersion = '0.02'

# You must specify where to find a Bible to read --
#   this can be either a relative path (like my example where ../ means go to the folder above)
#   or an absolute path (which would start with / or maybe ~/ in Linux).
# Normally this is the only line in the program that you would need to change.
inputFolder = '/home/robert/Paratext8Projects/MBTV/'

# Configure basic Bible Organisational System (BOS) set-up
parser = BibleOrgSysGlobals.setup(ProgName, ProgVersion)
BibleOrgSysGlobals.addStandardOptionsAndProcess(parser)

# Do the actual Bible load and export work that we want
unknownBible = UnknownBible(
    inputFolder)  # Tell it the folder to start looking in
loadedBible = unknownBible.search(
    autoLoadAlways=True,
    autoLoadBooks=True)  # Load all the books if we find any
if loadedBible is not None:
    loadedBible.toUSX2XML()  # Export as USX files (USFM inside XML)
    print(
        f"\nOutput should be in {os.path.join( os.getcwd(), 'OutputFiles/', 'BOS_USX2_Export/' )} folder."
    )

# Do the BOS close-down stuff
BibleOrgSysGlobals.closedown(ProgName, ProgVersion)