• Home
  • Raw
  • Download

Lines Matching refs:parser

63         (options, positional_args) = self.parser.parse_args(args)
145 self.parser.parse_args(cmdline_args)
164 self.parser.parse_args(cmdline_args)
187 def assertHelp(self, parser, expected_help): argument
188 actual_help = parser.format_help()
203 self.parser = OptionParser(usage=SUPPRESS_USAGE)
327 self.parser = OptionParser()
328 self.parser.add_option("-v", "--verbose", "-n", "--noisy",
330 self.parser.add_option("-q", "--quiet", "--silent",
334 self.assertTypeError(self.parser.add_option,
338 self.assertTypeError(self.parser.add_option,
342 opt1 = self.parser.get_option("-v")
350 opt1 = self.parser.get_option("-v")
351 opt2 = self.parser.get_option("--verbose")
352 opt3 = self.parser.get_option("-n")
353 opt4 = self.parser.get_option("--noisy")
357 self.assertTrue(self.parser.has_option("-v"))
358 self.assertTrue(self.parser.has_option("--verbose"))
361 self.assertTrue(self.parser.get_option("-v") is None)
362 self.assertTrue(self.parser.get_option("--verbose") is None)
363 self.assertTrue(self.parser.get_option("-n") is None)
364 self.assertTrue(self.parser.get_option("--noisy") is None)
366 self.assertFalse(self.parser.has_option("-v"))
367 self.assertFalse(self.parser.has_option("--verbose"))
368 self.assertFalse(self.parser.has_option("-n"))
369 self.assertFalse(self.parser.has_option("--noisy"))
371 self.assertTrue(self.parser.has_option("-q"))
372 self.assertTrue(self.parser.has_option("--silent"))
375 self.parser.remove_option("-n")
379 self.parser.remove_option("--verbose")
383 self.assertRaises(self.parser.remove_option, ('foo',), None,
394 parser = OptionParser()
395 parser.add_option("-a", "--aaarggh")
396 parser.big_thing = big_thing
398 parser.destroy()
400 del parser
427 self.parser = OptionParser()
430 self.parser.add_option("-s", type="str")
431 self.assertEqual(self.parser.get_option("-s").type, "string")
434 self.parser.add_option("-s", type=str)
435 self.assertEqual(self.parser.get_option("-s").type, "string")
436 self.parser.add_option("-x", type=int)
437 self.assertEqual(self.parser.get_option("-x").type, "int")
440 self.parser.add_option("-s", type=types.StringType)
441 self.assertEqual(self.parser.get_option("-s").type, "string")
442 self.parser.add_option("-x", type=types.IntType)
443 self.assertEqual(self.parser.get_option("-x").type, "int")
466 self.parser = OptionParser()
467 self.parser.add_option("-v", "--verbose", default=True)
468 self.parser.add_option("-q", "--quiet", dest='verbose')
469 self.parser.add_option("-n", type="int", default=37)
470 self.parser.add_option("-m", type="int")
471 self.parser.add_option("-s", default="foo")
472 self.parser.add_option("-t")
473 self.parser.add_option("-u", default=None)
482 self.assertEqual(self.parser.get_default_values(), self.expected)
485 self.parser.set_defaults(n=42, m=-100)
487 self.assertEqual(self.parser.get_default_values(), self.expected)
490 self.parser.set_defaults(x="barf", y="blah")
491 self.parser.add_option("-x", default="frob")
492 self.parser.add_option("-y")
495 self.assertEqual(self.parser.get_default_values(), self.expected)
497 self.parser.remove_option("-y")
498 self.parser.add_option("-y", default=None)
500 self.assertEqual(self.parser.get_default_values(), self.expected)
503 self.parser.option_class = DurationOption
504 self.parser.add_option("-d", type="duration", default=300)
505 self.parser.add_option("-e", type="duration", default="6m")
506 self.parser.set_defaults(n="42")
508 self.assertEqual(self.parser.get_default_values(), self.expected)
510 self.parser.set_process_default_values(False)
512 self.assertEqual(self.parser.get_default_values(), self.expected)
521 def assertUsage(self, parser, expected_usage): argument
522 self.assertEqual(parser.get_usage(), expected_usage)
524 def assertVersion(self, parser, expected_version): argument
525 self.assertEqual(parser.get_version(), expected_version)
533 parser = OptionParser("%prog ...", version="%prog 1.2")
535 self.assertUsage(parser, expected_usage)
536 self.assertVersion(parser, "baz.py 1.2")
537 self.assertHelp(parser,
546 parser = OptionParser(prog="thingy",
549 parser.remove_option("-h")
550 parser.remove_option("--version")
552 self.assertUsage(parser, expected_usage)
553 self.assertVersion(parser, "thingy 0.1")
554 self.assertHelp(parser, expected_usage + "\n")
559 self.parser = OptionParser(prog="test")
573 self.parser.add_option("-f", "--file",
576 self.assertHelp(self.parser, self.expected_help_file)
579 self.parser.add_option("-f", "--file",
581 self.parser.set_default('file', "foo.txt")
582 self.assertHelp(self.parser, self.expected_help_file)
585 self.parser.add_option("-f", "--file",
587 self.parser.set_defaults(file="foo.txt")
588 self.assertHelp(self.parser, self.expected_help_file)
591 self.parser.add_option("-f", "--file",
593 self.assertHelp(self.parser, self.expected_help_none)
596 self.parser.add_option("-f", "--file",
599 self.assertHelp(self.parser, self.expected_help_none)
602 self.parser.add_option("-f", "--file",
604 self.parser.set_defaults(file=None)
605 self.assertHelp(self.parser, self.expected_help_none)
608 self.parser.add_option(
611 self.parser.set_defaults(prob=0.43)
614 self.assertHelp(self.parser, expected_help)
617 self.parser.add_option("-f", "--file",
620 self.parser.formatter.default_tag = "*DEFAULT*"
621 self.assertHelp(self.parser, self.expected_help_file)
624 self.parser.add_option("-f", "--file",
627 self.parser.formatter.default_tag = None
630 self.assertHelp(self.parser, expected_help)
641 self.parser = InterceptingOptionParser(usage=SUPPRESS_USAGE,
714 (options, args) = self.parser.parse_args([])
715 defaults = self.parser.get_default_values()
719 self.parser.add_option("--foz", action="store",
769 self.parser.add_option("-t", action="store_true")
774 self.parser.add_option(u"-u", u"--unicode", action="store_true")
791 self.parser = OptionParser(option_list = options)
817 self.parser = InterceptingOptionParser(usage=SUPPRESS_USAGE)
818 self.parser.add_option("-c", action="store", type="choice",
832 self.parser.add_option("-d", "--default",
834 opt = self.parser.get_option("-d")
840 self.parser = InterceptingOptionParser(usage=SUPPRESS_USAGE)
842 self.parser.add_option(self.v_opt)
843 self.parser.add_option("--verbose", type="int", dest="verbose")
844 self.parser.add_option("-q", "--quiet",
875 self.parser.disable_interspersed_args()
888 self.parser.set_default('verbose', 0)
892 self.parser.set_default('verbose', 0)
898 self.parser = InterceptingOptionParser(usage=SUPPRESS_USAGE)
899 self.parser.add_option("-p", "--point",
923 self.parser = InterceptingOptionParser(usage=SUPPRESS_USAGE)
924 self.parser.add_option("-p", "--point", action="store", nargs=3,
926 self.parser.add_option("-f", "--foo", action="append", nargs=2,
928 self.parser.add_option("-z", "--zero", action="append_const",
952 self.parser = InterceptingOptionParser(usage=SUPPRESS_USAGE,
962 self.parser = InterceptingOptionParser(usage=SUPPRESS_USAGE)
971 self.parser = OptionParser(option_list=[
975 self.parser.add_option("-q", action="store_false", dest="verbose",
980 self.parser.add_option("-q", action="store_false", dest="verbose",
986 self.parser = OptionParser(usage=SUPPRESS_USAGE)
989 group = OptionGroup(self.parser, "Spam")
990 self.parser.add_option_group(group)
996 self.assertTypeError(self.parser.add_option_group,
1000 self.assertTypeError(self.parser.add_option_group,
1004 group = OptionGroup(self.parser, "Spam")
1005 group.parser = OptionParser()
1006 self.assertRaises(self.parser.add_option_group, (group,), None,
1010 group = self.parser.add_option_group("Group 2",
1014 self.assertTrue(self.parser.get_option_group("--bacon"), group)
1020 self.parser = InterceptingOptionParser(usage=SUPPRESS_USAGE,
1022 self.parser.add_option("-a", None, type="string", dest="a")
1023 self.parser.add_option("-f", "--file", type="file", dest="file")
1065 self.parser = OptionParser(option_list=options)
1072 def take_action(self, action, dest, opt, value, values, parser): argument
1077 Option.take_action(self, action, dest, opt, parser, value,
1104 self.parser = OptionParser(option_list=options)
1110 self.assertTrue(parser_ is self.parser)
1118 self.assertTrue(parser_ is self.parser)
1135 parser = OptionParser(usage=SUPPRESS_USAGE)
1136 parser.remove_option("-h")
1137 parser.add_option("-t", "--test", action="callback",
1143 self.assertHelp(parser, expected_help)
1152 self.parser = OptionParser(option_list=options)
1176 self.parser = OptionParser(option_list=options)
1206 self.parser = OptionParser(option_list=options)
1227 self.parser = OptionParser()
1228 self.parser.add_option("--foo-bar", action="callback",
1231 def check_abbrev(self, option, opt, value, parser): argument
1243 self.parser = InterceptingOptionParser(usage=SUPPRESS_USAGE,
1246 def variable_args(self, option, opt, value, parser): argument
1249 rargs = parser.rargs
1258 setattr(parser.values, option.dest, value)
1294 self.parser = InterceptingOptionParser(usage=SUPPRESS_USAGE,
1297 def show_version(self, option, opt, value, parser): argument
1298 parser.values.show_version = 1
1314 self.assertTrueconflict_error(self.parser.add_option)
1317 group = OptionGroup(self.parser, "Group 1")
1322 self.parser.set_conflict_handler, ('foo',), None,
1329 self.parser.set_conflict_handler("resolve")
1330 self.parser.add_option("-v", "--version", action="callback",
1334 v_opt = self.parser.get_option("-v")
1335 verbose_opt = self.parser.get_option("--verbose")
1336 version_opt = self.parser.get_option("--version")
1371 self.parser = InterceptingOptionParser(usage=SUPPRESS_USAGE)
1372 self.parser.set_conflict_handler("resolve")
1373 self.parser.add_option("-n", "--dry-run",
1376 self.parser.add_option("--dry-run", "-n",
1381 opt = self.parser.get_option("--dry-run")
1483 self.parser = self.make_parser(80)
1508 encoding = self.parser._get_encoding(sys.stdout)
1523 self.parser.set_usage("Usage: %prog [options]")
1527 self.parser.formatter.short_first = 0
1533 self.parser.formatter = TitledHelpFormatter()
1540 self.parser = self.make_parser(60)
1542 self.parser = self.make_parser(0)
1546 self.parser = InterceptingOptionParser(usage=SUPPRESS_USAGE)
1547 self.parser.add_option("-a", action="store_true", help=u"ol\u00E9!")
1556 self.parser = InterceptingOptionParser(usage=SUPPRESS_USAGE,
1567 self.parser.set_description(
1572 self.parser, "Dangerous Options",
1576 self.parser.add_option_group(group)
1600 self.parser.epilog = "Please report bugs to /dev/null."
1623 self.parser = InterceptingOptionParser()
1624 self.parser.add_option("-n", type=int)
1625 self.parser.add_option("-l", type=long)