Skip to content

Commit 036325c

Browse files
committed
switched to argparse
1 parent ef5daf2 commit 036325c

File tree

1 file changed

+14
-14
lines changed

1 file changed

+14
-14
lines changed

bin/nipype_cmd.py

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"""
66
# stdlib imports
77
import os
8-
from optparse import OptionParser
8+
import argparse
99
import sys
1010

1111
def listClasses(module=None):
@@ -24,10 +24,8 @@ def add_options(parser=None, module=None, function=None):
2424
interface = getattr(sys.modules[module],function)()
2525

2626
for k,v in interface.inputs.items():
27-
parser.add_option("-%s"%k[0], "--%s"%k, dest="IXI%s"%k,
28-
metavar=k,
29-
action='store',type='string',
30-
help="you need help?",default='')
27+
parser.add_argument("--%s"%k, dest=k,
28+
help=v.desc)
3129
return parser, interface
3230

3331
def run_instance(interface, options):
@@ -63,19 +61,21 @@ def get_modfunc(args):
6361
return module, function
6462

6563
def parse_args():
66-
usage = "usage: %prog [options] module function"
67-
parser = OptionParser(usage=usage,version="%prog 1.0",
68-
conflict_handler="resolve")
69-
parser.add_option("--run", dest="run",
70-
action='store_true',help="Execute",
71-
default=False)
64+
parser = argparse.ArgumentParser(description='Nipype interface runner')
65+
parser.add_argument("--run", dest="run", help="Execute", default=False)
66+
67+
#
68+
# usage = "usage: %prog [options] module function"
69+
# parser = OptionParser(usage=usage,version="%prog 1.0",
70+
# conflict_handler="resolve")
71+
7272

7373
module, function = get_modfunc(sys.argv[1:])
7474
parser, interface = add_options(parser, module, function)
75-
(options, args) = parser.parse_args()
76-
if options.run and interface:
75+
args = parser.parse_args()
76+
if args.run and interface:
7777
#assign inputs
78-
run_instance(interface, options)
78+
run_instance(interface, args)
7979
else:
8080
parser.print_help()
8181
if module and not function:

0 commit comments

Comments
 (0)