Changeset 20097


Ignore:
Timestamp:
02/09/16 10:48:17 (9 years ago)
Author:
dlcheng
Message:

CHG: Fixing incorrect file read, adding -o output file flag.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • issm/trunk-jpl/scripts/BinRead.py

    r16306 r20097  
    66import math
    77import struct
     8import argparse
     9from MatlabFuncs import *
     10from EnumDefinitions import *
     11from EnumToString import EnumToString
    812
    9 def BinRead(filin,filout=''):
    10 
    11         from MatlabFuncs import *
    12         from EnumDefinitions import *
    13         from EnumToString import EnumToString
     13def BinRead(filin,filout=''): #{{{
    1414
    1515        print "reading binary file."
     
    105105
    106106                elif code == FormatToCode('MatArray'):
    107                         fid.seek(reclen-4,1)
     107                        f.seek(reclen-4,1)
    108108                        print "skipping %d bytes for code %d." % (code, reclen-4)
    109109
    110110                elif code == FormatToCode('StringArray'):
    111                         fid.seek(reclen-4,1)
     111                        f.seek(reclen-4,1)
    112112                        print "skipping %d bytes for code %d." % (code, reclen-4)
    113113
     
    116116
    117117        f.close()
    118 
     118#}}}
    119119def FormatToCode(format): # {{{
    120120        """
     
    123123        sent.
    124124        """
    125         from MatlabFuncs import *
    126125
    127126        if   strcmpi(format,'Boolean'):
     
    149148# }}}
    150149
    151 if __name__ == '__main__':
     150if __name__ == '__main__': #{{{
    152151        if 'PYTHONSTARTUP' in os.environ:
    153152                PYTHONSTARTUP=os.environ['PYTHONSTARTUP']
     
    161160                        print "PYTHONSTARTUP file '%s' does not exist." % PYTHONSTARTUP
    162161
    163         import argparse
    164162        parser = argparse.ArgumentParser(description='BinRead - function to read binary input file.')
    165163        parser.add_argument('-f','--filin', help='name of binary input file', default='')
     164        parser.add_argument('-o','--filout', help='optional name of text output file', default='')
    166165        args = parser.parse_args()
    167166
    168         BinRead(args.filin)
    169 
     167        BinRead(args.filin, args.filout)
     168#}}}
Note: See TracChangeset for help on using the changeset viewer.