• 
      

    Add a command line flag to disable .reviewboardrc

    Review Request #10044 — Created June 28, 2018 and discarded

    Information

    RBTools
    master

    Reviewers

    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: …

    brenniebrennie

    Can you undo your docstring changes?

    brenniebrennie

    This is mostly true, except default IS supported by argparse.

    brenniebrennie

    Instead of doing this, we should check for action='append' and set the value to [] in our default checking code.

    brenniebrennie

    Here too

    brenniebrennie

    Missing a docstring.

    brenniebrennie

    We need to set self.config to a default, empty config (with e.g. ALIASES, etc) set in the else.

    brenniebrennie

    Instead of looping twice, we can loop once: ```python for option in self.all_options(): try: default = option.attrs['default'] except KeyError: # …

    brenniebrennie

    Undo this, too

    brenniebrennie
    mandeep
    brennie
    1. 
        
    2. Show all issues

      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:

      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 the config, options it returns.

    3. Show all issues

      Can you undo your docstring changes?

    4. rbtools/commands/__init__.py (Diff revision 1)
       
       
       
       
       
      Show all issues

      This is mostly true, except default IS supported by argparse.

    5. rbtools/commands/__init__.py (Diff revision 1)
       
       
      Show all issues

      Instead of doing this, we should check for action='append' and set the value to [] in our default checking code.

    6. rbtools/commands/__init__.py (Diff revision 1)
       
       
      Show all issues

      Here too

    7. rbtools/commands/__init__.py (Diff revision 1)
       
       
      Show all issues

      Missing a docstring.

    8. rbtools/commands/__init__.py (Diff revision 1)
       
       
       
      Show all issues

      We need to set self.config to a default, empty config (with e.g. ALIASES, etc) set in the else.

    9. rbtools/commands/__init__.py (Diff revision 1)
       
       
       
       
       
       
       
       
       
       
       
       
       
       
      Show all issues

      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)
      

      ``

    10. rbtools/commands/__init__.py (Diff revision 1)
       
       
       
       
       
      Show all issues

      Undo this, too

    11. 
        
    david
    Review request changed
    Status:
    Discarded