/
pylocator
44 lines (37 loc) · 1.09 KB
/
pylocator
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#! /usr/bin/python
"""Run pylocator"""
import getopt
import sys
from pylocator import __version__
from pylocator.main import run_pylocator
USAGE = """PyLocator Version %s
Usage: %s [options] <Nifti-file>
options:
--help -h print this message""" % (__version__, sys.argv[0])
def main():
"""Reads the command line options and launches PyLocator"""
def info_exit(option = None, value = None):
"""Print usage information and abort execution"""
if not (option in ["-h", "--help"] or option == None):
print "Wrong argument:", option, ",", value
print USAGE
sys.exit(0)
try:
options, args = getopt.getopt(
sys.argv[1:],
'h', ['help'])
except (getopt.GetoptError):
info_exit()
filename = None
if len(args)>1:
info_exit()
elif len(args)==1:
filename = args[0]
else:
args = None
for option, value in options:
if option in ('-h', '--help'):
info_exit(option, value)
run_pylocator(filename=filename)
if __name__ == "__main__":
main()