code: def ParseOptions(cls, options, configuration_object):
      
      if not isinstance(configuration_object, tools.CLITool):
        raise errors.BadConfigObject(
            'Configuration object is not an instance of CLITool')
  
      output_format = getattr(options, 'output_format', 'dynamic')
      output_filename = getattr(options, 'write', None)
  
      if output_format != 'list':
        if not output_manager.OutputManager.HasOutputClass(output_format):
          raise errors.BadConfigOption(
              'Unsupported output format: {0:s}.'.format(output_format))
  
      if output_manager.OutputManager.IsLinearOutputModule(output_format):
        if not output_filename:
          raise errors.BadConfigOption((
              'Output format: {0:s} requires an output file').format(
                  output_format))
  
        if os.path.exists(output_filename):
          raise errors.BadConfigOption(
              'Output file already exists: {0:s}.'.format(output_filename))
  
      setattr(configuration_object, '_output_format', output_format)
      setattr(configuration_object, '_output_filename', output_filename)
docs: Parses and validates options.
  
      Args:
        options (argparse.Namespace): parser options.
        configuration_object (CLITool): object to be configured by the argument
            helper.
  
      Raises:
        BadConfigObject: when the configuration object is of the wrong type.