Index: ../trunk-jpl/scripts/BinRead.py =================================================================== --- ../trunk-jpl/scripts/BinRead.py (revision 20096) +++ ../trunk-jpl/scripts/BinRead.py (revision 20097) @@ -5,13 +5,13 @@ import numpy import math import struct +import argparse +from MatlabFuncs import * +from EnumDefinitions import * +from EnumToString import EnumToString -def BinRead(filin,filout=''): +def BinRead(filin,filout=''): #{{{ - from MatlabFuncs import * - from EnumDefinitions import * - from EnumToString import EnumToString - print "reading binary file." f=open(filin,'rb') @@ -104,25 +104,24 @@ print "data[%d,%d] = %f" % (i,j,data[i][j]) elif code == FormatToCode('MatArray'): - fid.seek(reclen-4,1) + f.seek(reclen-4,1) print "skipping %d bytes for code %d." % (code, reclen-4) elif code == FormatToCode('StringArray'): - fid.seek(reclen-4,1) + f.seek(reclen-4,1) print "skipping %d bytes for code %d." % (code, reclen-4) else: raise TypeError('BinRead error message: data type: %d not supported yet! (%s)' % (code,EnumToString(enum)[0])) f.close() - +#}}} def FormatToCode(format): # {{{ """ This routine takes the format string, and hardcodes it into an integer, which is passed along the record, in order to identify the nature of the dataset being sent. """ - from MatlabFuncs import * if strcmpi(format,'Boolean'): code=1 @@ -148,7 +147,7 @@ return code # }}} -if __name__ == '__main__': +if __name__ == '__main__': #{{{ if 'PYTHONSTARTUP' in os.environ: PYTHONSTARTUP=os.environ['PYTHONSTARTUP'] print 'PYTHONSTARTUP =',PYTHONSTARTUP @@ -160,10 +159,10 @@ else: print "PYTHONSTARTUP file '%s' does not exist." % PYTHONSTARTUP - import argparse parser = argparse.ArgumentParser(description='BinRead - function to read binary input file.') parser.add_argument('-f','--filin', help='name of binary input file', default='') + parser.add_argument('-o','--filout', help='optional name of text output file', default='') args = parser.parse_args() - BinRead(args.filin) - + BinRead(args.filin, args.filout) +#}}} \ No newline at end of file