in python/topsites.py [0:0]
def parse_options( argv ):
"""Parse command line options."""
opts = {}
urlargs = {}
try:
user_opts, user_args = getopt.getopt( \
argv, \
'k:a:c:o:?', \
[ 'key=', 'action=', 'country=', 'options=', 'help=' ] )
except Exception as e:
print('Command parse error:', e)
log.error( "Unable to parse command line" )
return None
if ( '-?', '' ) in user_opts or ( '--help', '' ) in user_opts:
opts['help'] = True
return opts
#
# Convert command line options to dictionary elements
#
for opt in user_opts:
if opt[0] == '-k' or opt[0] == '--key':
opts['key'] = opt[1]
elif opt[0] == '-a' or opt[0] == '--action':
opts['action'] = opt[1]
elif opt[0] == '-c' or opt[0] == '--country':
opts['country'] = opt[1]
elif opt[0] == '-o' or opt[0] == '--options':
opts['options'] = opt[1]
elif opt[0] == '-a' or opt[0] == '--action':
opts['action'] = opt[1]
elif opt[0] == '-v' or opt[0] == '--verbose':
log.verbose()
if 'key' not in opts or \
'action' not in opts or \
'country' not in opts:
return None
#
# Return a dictionary of settings
#
success = True
return opts