MCPcopy Create free account
hub / github.com/RT-Thread/env-windows / add_option

Method add_option

tools/python-3.11.9-amd64/Lib/optparse.py:995–1023  ·  view source on GitHub ↗

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

(self, *args, **kwargs)

Source from the content-addressed store, hash-verified

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

Callers 6

add_optionsMethod · 0.95
mainFunction · 0.45
testFunction · 0.45
mainFunction · 0.45
_add_help_optionMethod · 0.45
_add_version_optionMethod · 0.45

Calls 2

_check_conflictMethod · 0.95
appendMethod · 0.45

Tested by

no test coverage detected