MCPcopy Index your code
hub / github.com/RustPython/RustPython / add_option

Method add_option

Lib/optparse.py:985–1013  ·  view source on GitHub ↗

add_option(Option) add_option(opt_str, ..., kwarg=val, ...)

(self, *args, **kwargs)

Source from the content-addressed store, hash-verified

983 c_option.container.option_list.remove(c_option)
984
985 def add_option(self, *args, **kwargs):
986 """add_option(Option)
987 add_option(opt_str, ..., kwarg=val, ...)
988 """
989 if isinstance(args[0], str):
990 option = self.option_class(*args, **kwargs)
991 elif len(args) == 1 and not kwargs:
992 option = args[0]
993 if not isinstance(option, Option):
994 raise TypeError("not an Option instance: %r" % option)
995 else:
996 raise TypeError("invalid arguments")
997
998 self._check_conflict(option)
999
1000 self.option_list.append(option)
1001 option.container = self
1002 for opt in option._short_opts:
1003 self._short_opt[opt] = option
1004 for opt in option._long_opts:
1005 self._long_opt[opt] = option
1006
1007 if option.dest is not None: # option has a dest, we need a default
1008 if option.default is not NO_DEFAULT:
1009 self.defaults[option.dest] = option.default
1010 elif option.dest not in self.defaults:
1011 self.defaults[option.dest] = None
1012
1013 return option
1014
1015 def add_options(self, option_list):
1016 for option in option_list:

Callers 15

add_optionsMethod · 0.95
_add_help_optionMethod · 0.80
_add_version_optionMethod · 0.80
test_decimal.pyFile · 0.80
setUpMethod · 0.80
test_refleakMethod · 0.80
test_type_objectMethod · 0.80
setUpMethod · 0.80
test_process_defaultMethod · 0.80
test_option_defaultMethod · 0.80

Calls 4

_check_conflictMethod · 0.95
isinstanceFunction · 0.85
lenFunction · 0.85
appendMethod · 0.45

Tested by 15

setUpMethod · 0.64
test_refleakMethod · 0.64
test_type_objectMethod · 0.64
setUpMethod · 0.64
test_process_defaultMethod · 0.64
test_option_defaultMethod · 0.64
test_parser_default_1Method · 0.64
test_parser_default_2Method · 0.64
test_no_defaultMethod · 0.64
test_default_none_1Method · 0.64