sipp11
10 years ago
5 changed files with 110 additions and 0 deletions
File diff suppressed because one or more lines are too long
|
|
@ -0,0 +1,49 @@
|
||||
# -*- coding: utf-8 -*- |
||||
#!/usr/bin/env python |
||||
from __future__ import absolute_import, print_function |
||||
import sys |
||||
import getopt |
||||
import time |
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
def usage(): |
||||
print('Help:') |
||||
|
||||
|
||||
def main(): |
||||
override = False |
||||
try: |
||||
opts, args = getopt.getopt(sys.argv[1:], 'm:r:v', ['model=', 'rtype=']) |
||||
except getopt.GetoptError: |
||||
usage() |
||||
sys.exit(2) |
||||
verbose = False |
||||
model_value = rtype_value = None |
||||
for opt, arg in opts: |
||||
if opt == "-v": |
||||
verbose = True |
||||
elif opt in ('-m', '--model'): |
||||
## TODO: filter model availabel and throw exception if invalid |
||||
if len(arg) != 4: |
||||
usage() |
||||
sys.exit(2) |
||||
model_value = arg.upper() |
||||
elif opt in ('-r', '--rtype'): |
||||
if arg not in '1234': |
||||
usage() |
||||
sys.exit(2) |
||||
rtype_value = arg |
||||
|
||||
print('model: %s | r_type: %s | verbose: %s' % ( |
||||
model_value, rtype_value, verbose)) |
||||
|
||||
if __name__ == '__main__': |
||||
main() |
@ -0,0 +1,58 @@
|
||||
# -*- coding: utf-8 -*- |
||||
#!/usr/bin/env python |
||||
from __future__ import absolute_import, print_function |
||||
import sys |
||||
import getopt |
||||
import time |
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
def usage(): |
||||
print('Help:') |
||||
|
||||
|
||||
def main(): |
||||
override = False |
||||
try: |
||||
opts, args = getopt.getopt(sys.argv[1:], 'm:r:k:v', ['model=', 'rtype=', 'ksearch=']) |
||||
except getopt.GetoptError: |
||||
usage() |
||||
sys.exit(2) |
||||
verbose = False |
||||
model_value = rtype_value = k_value = None |
||||
for opt, arg in opts: |
||||
if opt == "-v": |
||||
verbose = True |
||||
elif opt in ('-m', '--model'): |
||||
## TODO: filter model availabel and throw exception if invalid |
||||
if len(arg) != 4: |
||||
usage() |
||||
sys.exit(2) |
||||
model_value = arg.upper() |
||||
elif opt in ('-r', '--rtype'): |
||||
if arg not in '1234': |
||||
usage() |
||||
sys.exit(2) |
||||
rtype_value = arg |
||||
elif opt in ('-k', '--ksearch'): |
||||
if arg.upper() not in 'ABCDEFGHIJKLMNOPQRS': |
||||
usage() |
||||
sys.exit(2) |
||||
k_value = arg.upper() |
||||
|
||||
if not (model_value and rtype_value and k_value): |
||||
usage() |
||||
sys.exit(2) |
||||
|
||||
print('model: %s | r_type: %s | k_search: %s | verbose: %s' % ( |
||||
model_value, rtype_value, k_value, verbose)) |
||||
|
||||
if __name__ == '__main__': |
||||
main() |
Loading…
Reference in new issue