2015-10-07 07:35:11 +02:00
|
|
|
"""
|
|
|
|
"""
|
2016-01-02 08:23:06 +01:00
|
|
|
import getopt
|
|
|
|
import sys
|
2015-10-07 07:35:11 +02:00
|
|
|
from re import sub
|
|
|
|
|
2016-01-02 08:23:06 +01:00
|
|
|
|
2015-10-07 07:35:11 +02:00
|
|
|
def parse(argv, options, long_options, usage):
|
|
|
|
try:
|
|
|
|
opts, args = getopt.getopt(argv, options, long_options)
|
|
|
|
except getopt.GetoptError:
|
2015-10-14 05:26:55 +02:00
|
|
|
print usage
|
2015-10-07 07:35:11 +02:00
|
|
|
sys.exit(2)
|
2016-01-02 08:23:06 +01:00
|
|
|
|
2015-10-07 07:35:11 +02:00
|
|
|
return_arguments = {}
|
|
|
|
for opt, arg in opts:
|
|
|
|
if opt == '-h':
|
2015-10-14 05:26:55 +02:00
|
|
|
print usage
|
2015-10-07 07:35:11 +02:00
|
|
|
sys.exit()
|
|
|
|
else:
|
|
|
|
return_arguments[sub('^-+', '', opt)] = arg
|
2015-10-14 05:26:55 +02:00
|
|
|
|
2015-10-07 07:35:11 +02:00
|
|
|
return return_arguments
|