diff options
author | Thanasis Antoniou | 2019-07-10 13:58:05 +0300 |
---|---|---|
committer | Thanasis Antoniou | 2019-07-10 13:59:31 +0300 |
commit | f2f91fa773b737e1315489cd1f775e5c23f5515a (patch) | |
tree | 2fb44f7f6f73a276d639b966cdbfe6f289f378c8 /devtools/create_bladerunner/subtitles/quotesSpreadsheetCreator | |
parent | 78912960947d619511f4d37e95815a1dd9c6c4cb (diff) | |
download | scummvm-rg350-f2f91fa773b737e1315489cd1f775e5c23f5515a.tar.gz scummvm-rg350-f2f91fa773b737e1315489cd1f775e5c23f5515a.tar.bz2 scummvm-rg350-f2f91fa773b737e1315489cd1f775e5c23f5515a.zip |
DEVTOOLS: BLADERUNNER: Improved command line for TRE, FON, AUD libs
Diffstat (limited to 'devtools/create_bladerunner/subtitles/quotesSpreadsheetCreator')
-rw-r--r-- | devtools/create_bladerunner/subtitles/quotesSpreadsheetCreator/audFileLib.py | 49 | ||||
-rw-r--r-- | devtools/create_bladerunner/subtitles/quotesSpreadsheetCreator/treFileLib.py | 61 |
2 files changed, 63 insertions, 47 deletions
diff --git a/devtools/create_bladerunner/subtitles/quotesSpreadsheetCreator/audFileLib.py b/devtools/create_bladerunner/subtitles/quotesSpreadsheetCreator/audFileLib.py index 3c72521c0d..60dc3d6ab8 100644 --- a/devtools/create_bladerunner/subtitles/quotesSpreadsheetCreator/audFileLib.py +++ b/devtools/create_bladerunner/subtitles/quotesSpreadsheetCreator/audFileLib.py @@ -372,32 +372,43 @@ class audFile: # if __name__ == '__main__': # main() - # (by default) assumes a file of name 000000.AUD in same directory + errorFound = False + # By default assumes a file of name 000000.AUD in same directory # otherwise tries to use the first command line argument as input file inAUDFile = None inAUDFileName = '00000000.AUD' + if len(sys.argv[1:]) > 0 \ and os.path.isfile(os.path.join('.', sys.argv[1])) \ - and len(sys.argv[1]) > 5 \ - and sys.argv[1][-3:] == 'AUD': + and len(sys.argv[1]) >= 5 \ + and sys.argv[1][-3:].upper() == 'AUD': inAUDFileName = sys.argv[1] - print "[Info] Using %s as input AUD file..." % (inAUDFileName) - - errorFound = False - try: - inAUDFile = open(os.path.join('.', inAUDFileName), 'rb') - except: + print "[Info] Attempting to use %s as input AUD file..." % (inAUDFileName) + elif os.path.isfile(os.path.join('.', inAUDFileName)): + print "[Info] Using default %s as input AUD file..." % (inAUDFileName) + else: + print "[Error] No valid input file argument was specified and default input file %s is missing." % (inAUDFileName) errorFound = True - print "[Error] Unexpected event:", sys.exc_info()[0] - raise - if not errorFound: - allOfAudFileInBuffer = inAUDFile.read() - audFileInstance = audFile(True) - if audFileInstance.m_traceModeEnabled: - print "[Debug] Running %s (%s) as main module" % (MY_MODULE_NAME, MY_MODULE_VERSION) - audFileInstance.loadAudFile(allOfAudFileInBuffer, len(allOfAudFileInBuffer), inAUDFileName) - audFileInstance.export_as_wav(allOfAudFileInBuffer, './tmp.wav') - inAUDFile.close() + + if not errorFound: + try: + print "[Info] Opening %s" % (inAUDFileName) + inAUDFile = open(os.path.join('.', inAUDFileName), 'rb') + except: + errorFound = True + print "[Error] Unexpected event:", sys.exc_info()[0] + raise + if not errorFound: + allOfAudFileInBuffer = inAUDFile.read() + audFileInstance = audFile(True) + if audFileInstance.m_traceModeEnabled: + print "[Debug] Running %s (%s) as main module" % (MY_MODULE_NAME, MY_MODULE_VERSION) + if audFileInstance.loadAudFile(allOfAudFileInBuffer, len(allOfAudFileInBuffer), inAUDFileName): + print "[Info] Audio file (AUD) loaded successfully!" + audFileInstance.export_as_wav(allOfAudFileInBuffer, './tmp.wav') + else: + print "[Error] Error while loading Audio file (AUD)!" + inAUDFile.close() else: #debug #print "[Debug] Running %s (%s) imported from another module" % (MY_MODULE_NAME, MY_MODULE_VERSION) diff --git a/devtools/create_bladerunner/subtitles/quotesSpreadsheetCreator/treFileLib.py b/devtools/create_bladerunner/subtitles/quotesSpreadsheetCreator/treFileLib.py index 18a23ba5f0..a76673ef0c 100644 --- a/devtools/create_bladerunner/subtitles/quotesSpreadsheetCreator/treFileLib.py +++ b/devtools/create_bladerunner/subtitles/quotesSpreadsheetCreator/treFileLib.py @@ -110,13 +110,14 @@ class treFile: # This works ok. # allTextsFound = treBytesBuff[currOffset:].split('\x00') - ## check "problematic" character cases: - if self.m_traceModeEnabled: - if currOffset == 5982 or currOffset == 6050 or currOffset == 2827 or currOffset == 2880: - print "[Debug] Offs: %d\tFound String: %s" % ( currOffset,''.join(allTextsFound[0]) ) + ### check "problematic" character cases: + ##if self.m_traceModeEnabled: + ## if currOffset == 5982 or currOffset == 6050 or currOffset == 2827 or currOffset == 2880: + ## print "[Debug] Offs: %d\tFound String: %s" % ( currOffset,''.join(allTextsFound[0]) ) (theId, stringOfIdx) = self.stringEntriesLst[idx] self.stringEntriesLst[idx] = (theId, ''.join(allTextsFound[0])) - #print "[Debug] ID: %d\tFound String: %s" % ( theId,''.join(allTextsFound[0]) ) + if self.m_traceModeEnabled: + print "[Trace] ID: %d\tFound String: %s" % ( theId,''.join(allTextsFound[0]) ) return True except: print "[Error] Loading Text Resource %s failed!" % (self.simpleTextResourceFileName) @@ -129,38 +130,42 @@ class treFile: # if __name__ == '__main__': # main() - # (by default) assumes a file of name ACTORS.TRE in same directory + errorFound = False + # By default assumes a file of name ACTORS.TRE in same directory # otherwise tries to use the first command line argument as input file inTREFile = None inTREFileName = 'ACTORS.TRE' if len(sys.argv[1:]) > 0 \ and os.path.isfile(os.path.join('.', sys.argv[1])) \ - and len(sys.argv[1]) > 5 \ - and sys.argv[1][-3:] == 'TRE': + and len(sys.argv[1]) >= 5 \ + and sys.argv[1][-3:].upper() == 'TRE': inTREFileName = sys.argv[1] - print "[Info] Using %s as input TRE file..." % (inTREFileName) - - errorFound = False - - try: - print "[Info] Opening %s" % (inTREFileName) - inTREFile = open(os.path.join('.',inTREFileName), 'rb') - except: + print "[Info] Attempting to use %s as input TRE file..." % (inTREFileName) + elif os.path.isfile(os.path.join('.', inTREFileName)): + print "[Info] Using default %s as input TRE file..." % (inTREFileName) + else: + print "[Error] No valid input file argument was specified and default input file %s is missing." % (inTREFileName) errorFound = True - print "[Error] Unexpected event: ", sys.exc_info()[0] - raise + if not errorFound: - allOfTreFileInBuffer = inTREFile.read() - treFileInstance = treFile(True) - if treFileInstance.m_traceModeEnabled: - print "[Debug] Running %s (%s) as main module" % (MY_MODULE_NAME, MY_MODULE_VERSION) - - if (treFileInstance.loadTreFile(allOfTreFileInBuffer, len(allOfTreFileInBuffer, inTREFileName))): - print "[Info] Text Resource file loaded successfully!" - else: - print "[Error] Error while loading Text Resource file!" - inTREFile.close() + try: + print "[Info] Opening %s" % (inTREFileName) + inTREFile = open(os.path.join('.',inTREFileName), 'rb') + except: + errorFound = True + print "[Error] Unexpected event: ", sys.exc_info()[0] + raise + if not errorFound: + allOfTreFileInBuffer = inTREFile.read() + treFileInstance = treFile(True) + if treFileInstance.m_traceModeEnabled: + print "[Debug] Running %s (%s) as main module" % (MY_MODULE_NAME, MY_MODULE_VERSION) + if treFileInstance.loadTreFile(allOfTreFileInBuffer, len(allOfTreFileInBuffer), inTREFileName): + print "[Info] Text Resource file loaded successfully!" + else: + print "[Error] Error while loading Text Resource file!" + inTREFile.close() else: #debug #print "[Debug] Running %s (%s) imported from another module" % (MY_MODULE_NAME, MY_MODULE_VERSION) |