changed from getopt to argparse, you made need to easy_installa rgparse if you dont have it already
This commit is contained in:
parent
f426082d87
commit
31846835a3
25
pyedf.py
25
pyedf.py
@ -7,7 +7,7 @@ Created by Ray Slakinski on 2010-09-14.
|
|||||||
Copyright (c) 2010 Ray Slakinski. All rights reserved.
|
Copyright (c) 2010 Ray Slakinski. All rights reserved.
|
||||||
"""
|
"""
|
||||||
import sys
|
import sys
|
||||||
import getopt
|
import argparse
|
||||||
import re
|
import re
|
||||||
|
|
||||||
|
|
||||||
@ -45,15 +45,18 @@ def read_edf_file(fileobj):
|
|||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
argv = sys.argv
|
# create the parser
|
||||||
opts, args = getopt.getopt(argv[1:], "f", ["file="])
|
parser = argparse.ArgumentParser(description='Process a given EDF File.')
|
||||||
# option processing
|
parser.add_argument(
|
||||||
for option, value in opts:
|
'-f',
|
||||||
if option == "-f" or option == '--file':
|
'--file',
|
||||||
f = open(value, 'r')
|
type=argparse.FileType('r'),
|
||||||
data = read_edf_file(f)
|
help='EDF File to be processed.',
|
||||||
f.close()
|
)
|
||||||
print data
|
args = parser.parse_args()
|
||||||
|
data = read_edf_file(args.file)
|
||||||
|
args.file.close()
|
||||||
|
print data
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
main()
|
main()
|
||||||
|
Reference in New Issue
Block a user