Пример #1
0
def main(args=None):
  prog = None
  if args is None:
    args = sys.argv[1:]
    cmd = os.path.basename(sys.argv[0])
    if cmd.startswith('dr-'):
      if cmd.endswith('-py'):
        args.insert(0, cmd[3:-3])
      else:
        args.insert(0, cmd[3:])
      prog = 'dr'
  load_plugins(os.path.join(os.path.dirname(__file__), 'plugins/evaluators'))
  load_plugins(os.path.join(os.path.dirname(__file__), 'plugins/apps'))
  parser = argparse.ArgumentParser(prog=prog)
  add_subparsers(parser, sorted(App.CLASSES.items()), 'app_cls', title='apps')
  if argcomplete is not None:
    argcomplete.autocomplete(parser)
  args = parser.parse_args(args)
  args.app_cls(parser, args)()
Пример #2
0
def get_evaluator_ap(extra={}):
  from api import add_subparsers, Evaluator
  res = ArgumentParser(add_help=False)
  add_subparsers(res, sorted(extra.items()) + sorted(Evaluator.CLASSES.items()), 'eval_cls', title='evaluators')
  return res