Add a command line flag to disable .reviewboardrc
Review Request #10044 — Created June 28, 2018 and discarded
One can now prevent the Review board server from reading .reviewboardrc
file by typing the command--diasble-reviewboardrc
in the command
line.
Description | From | Last Updated |
---|---|---|
To unit test this, we can extract the parsing and default-applying code out of run_from_argv and create_arg_parser into a method: … |
brennie | |
Can you undo your docstring changes? |
brennie | |
This is mostly true, except default IS supported by argparse. |
brennie | |
Instead of doing this, we should check for action='append' and set the value to [] in our default checking code. |
brennie | |
Here too |
brennie | |
Missing a docstring. |
brennie | |
We need to set self.config to a default, empty config (with e.g. ALIASES, etc) set in the else. |
brennie | |
Instead of looping twice, we can loop once: ```python for option in self.all_options(): try: default = option.attrs['default'] except KeyError: # … |
brennie | |
Undo this, too |
brennie |
- People:
-
-
To unit test this, we can extract the parsing and default-applying code out of
run_from_argv
andcreate_arg_parser
into a method:def parse_args(self, argv): parser = argparse.ArgumentParser( prog=RB_MAIN, usage=self.usage(), add_help=False, formatter_lass=SmartHelpFormatter, argument_default=argparse.SUPPRESS) for option in self.option_list: option.add_to(parser) for option in self._global_options: opion.add_to(parser) options = parser.parse_args(argv[2:]) if getattr(self.options, 'disable_reviewboardrc', False): config = { # .. default sane config } else: config = load_config() for option in self.all_options(): # Apply values from config ... for option in self.all_options(): # Figure out defaults ... return config, options def run_from_argv(self, argv): self.config, self.options = self.parse_args(argv) self.args = self.options.args # ...
Then we can unit test
parse_args
and check theconfig, options
it returns. -
-
-
Instead of doing this, we should check for
action='append'
and set the value to[]
in our default checking code. -
-
-
-
Instead of looping twice, we can loop once:
```python
for option in self.all_options():
try:
default = option.attrs['default']
except KeyError:
# If the option does not have an explicit default, it may have an
# implied default.
action = option.attrs.get('action')if action == 'append': default = [] elif action == 'store_true': default = False elif action == 'store_false': default = True else: # This option does not have a default. continue option_name = option.attrs['dest'] if not hasattr(self.options, option_name): setattr(self.options, option_name, default)
``
-