def set_option(self, optname, value, action=None, optdict=None):
if optdict is None:<EOL><INDENT>optdict = self.get_option_def(optname)<EOL><DEDENT>if value is not None:<EOL><INDENT>value = _validate(value, optdict, optname)<EOL><DEDENT>if action is None:<EOL><INDENT>action = optdict.get("<STR_LIT:action>", "<STR_LIT:store>")<EOL><DEDENT>if action == "<STR_LIT:store>":<EOL><INDENT>setattr(self.config, self.option_attrname(optname, optdict), value)<EOL><DEDENT>elif action in ("<STR_LIT:store_true>", "<STR_LIT:count>"):<EOL><INDENT>setattr(self.config, self.option_attrname(optname, optdict), <NUM_LIT:0>)<EOL><DEDENT>elif action == "<STR_LIT>":<EOL><INDENT>setattr(self.config, self.option_attrname(optname, optdict), <NUM_LIT:1>)<EOL><DEDENT>elif action == "<STR_LIT>":<EOL><INDENT>optname = self.option_attrname(optname, optdict)<EOL>_list = getattr(self.config, optname, None)<EOL>if _list is None:<EOL><INDENT>if isinstance(value, (list, tuple)):<EOL><INDENT>_list = value<EOL><DEDENT>elif value is not None:<EOL><INDENT>_list = []<EOL>_list.append(value)<EOL><DEDENT>setattr(self.config, optname, _list)<EOL><DEDENT>elif isinstance(_list, tuple):<EOL><INDENT>setattr(self.config, optname, _list + (value,))<EOL><DEDENT>else:<EOL><INDENT>_list.append(value)<EOL><DEDENT><DEDENT>elif action == "<STR_LIT>":<EOL><INDENT>optdict["<STR_LIT>"](None, optname, value, None)<EOL><DEDENT>else:<EOL><INDENT>raise UnsupportedAction(action)<EOL><DEDENT>
method called to set an option (registered in the options list)