def load(self): config = Config() short_options = 'hdvo:d:v:s:z:idvo:tdvo:b:n:cdvo' long_options = ['help', 'debug', 'verbose', 'strategy=', 'profile_size=', 'init', 'train', 'because', 'nrecommendation', 'contribute'] try: opts, args = getopt.getopt(sys.argv[1:], short_options, long_options) self.options = opts except getopt.GetoptError as error: config.set_logger() logging.error('Bad syntax: {}'.format(str(error))) self.usage() sys.exit() for o, p in opts: if o in ('-h', '--help'): self.usage() sys.exit() elif o in ('-d', '--debug'): config.debug = 1 elif o in ('-v', '--verbose'): config.verbose = 1 elif o in ('-s', '--strategy'): config.strategy = p elif o in ('-z', '--profile_size'): config.profile_size = int(p) elif o in ('-i', '--init'): continue elif o in ('-t', '--train'): continue elif o in ('-b', '--because'): config.because = True elif o in ('-n', '--num-recommendations'): config.num_recommendations = int(p) elif o in ('-c', '--contribute'): continue else: assert False, "unhandled option"