def MergeConfigurationFileOptions(options):
  """Process configuration file, merge configuration with OptionParser.

  Args:
    options: optparse.OptionParser() object

  Returns:
    options: optparse.OptionParser() object

  Raises:
    ValueError: If we are unable to find a usable configuration file.
  """
  config = ConfigParser.ConfigParser()
  full_path = util.FindDataFile(options.config)
  config.read(full_path)
  if not config or not config.has_section('general'):
    raise ValueError('Could not find usable configuration in %s (%s)' % (full_path, options.config))
  general = dict(config.items('general'))

  # -U implies -u
  if options.site_url:
    options.upload_results = True

  for option in general:
    if not getattr(options, option, None):
      if 'timeout' in option:
        value = float(general[option])
      elif 'count' in option or 'num' in option or 'hide' in option:
        value = int(general[option])
      else:
        value = general[option]
      setattr(options, option, value)

  for key in ('input_file', 'output_file', 'csv_file', 'input_source'):
    value = getattr(options, key, None)
    if value:
      setattr(options, key, os.path.expanduser(value))

  # This makes it easier to pass around later. Lazy-hack.
  options.version = version.VERSION
  return options
dataset/ETHPy150Open catap/namebench/libnamebench/config.py/MergeConfigurationFileOptions/original