def parse_args(self, args = None): # Parse TrialRunner arguments. parser = argparse.ArgumentParser() parser.add_argument('-v', '--verbose', action='count', default=0, help='verbosity level') traits_argparse.add_config_arguments(parser, self) parser.add_argument('runner_args', metavar='RUNNER-ARGS', nargs=argparse.REMAINDER, help='arguments for runner ' '(see available arguments with -h)') namespace = parser.parse_args(args) self.verbose = self.base_runner.verbose = namespace.verbose # Parse sub-Runner arguments. prog = '{} {}'.format(os.path.basename(sys.argv[0]), self.base_runner.__class__.__name__) parser = argparse.ArgumentParser(prog=prog) traits_argparse.add_config_arguments(parser, self.base_runner, exclude=['outfile']) parser.parse_args(namespace.runner_args) # Validate TrialRunner and sub-Runner argument compatibility. for name in self.stats: if not is_number_trait(self.base_runner.trait(name)): raise ValueError('%r is not a numeric attribute' % name)
def parse_args(self, args = None): """ Parse commandline arguments and update configurable traits. """ # Special case verbosity flag to permit counting. parser = argparse.ArgumentParser() parser.add_argument('-v', '--verbose', action='count', default=0, help='verbosity level') traits_argparse.add_config_arguments(parser, self) namespace = parser.parse_args(args) self.verbose = namespace.verbose