docs: def load_config():
      """Load a config file. This function looks for a config (*.ini) file in the
      following order::
  
          (1) ./*.ini
          (2) ~/.config/hydra/
          (3) /etc/hydra
          (4) /path/to/hydra_base/*.ini
  
      (1) will override (2) will override (3) will override (4). Parameters not
      defined in (1) will be taken from (2). Parameters not defined in (2) will
      be taken from (3).  (3) is the config folder that will be checked out from
      the svn repository.  (2) Will be be provided as soon as an installable
      distribution is available. (1) will usually be written individually by
      every user."""
      global localfiles
      global localfile
      global repofile
      global repofiles
      global userfile
      global userfiles
      global sysfile
      global sysfiles
      global CONFIG
      logging.basicConfig(level='INFO')
  
      config = ConfigParser.ConfigParser(allow_no_value=True)
  
      modulepath = os.path.dirname(os.path.abspath(__file__))
  
      localfile = os.path.join(os.getcwd(), 'hydra.ini')
      localfiles = glob.glob(localfile)
  
      repofile = os.path.join(modulepath, 'hydra.ini')
      repofiles = glob.glob(repofile)
  
      if os.name == 'nt':
          import winpaths
          userfile = os.path.join(os.path.expanduser('~'),'AppData','Local','hydra.ini')
          userfiles = glob.glob(userfile)
  
          sysfile = os.path.join(winpaths.get_common_documents(), 'Hydra','hydra.ini')
          sysfiles = glob.glob(sysfile)
      else:
          userfile = os.path.join(os.path.expanduser('~'), '.hydra', 'hydra.ini')
          userfiles = glob.glob(userfile)
  
          sysfile = os.path.join('etc','hydra','hydra.ini')
          sysfiles = glob.glob(sysfile)
  
  
      for ini_file in repofiles:
          logging.debug("Repofile: %s"%ini_file)
          config.read(ini_file)
      for ini_file in sysfiles:
          logging.debug("Sysfile: %s"%ini_file)
          config.read(ini_file)
      for ini_file in userfiles:
          logging.debug("Userfile: %s"%ini_file)
          config.read(ini_file)
      for ini_file in localfiles:
          logging.info("Localfile: %s"%ini_file)
          config.read(ini_file)
  
      env_value = os.environ.get('HYDRA_CONFIG')
      if env_value is not None:
          if os.path.exists(env_value):
              config.read(ini_file)
          else:
              logging.warning('HYDRA_CONFIG set as %s but file does not exist', env_value)
  
  
      if os.name == 'nt':
          set_windows_env_variables(config)
  
      try:
          home_dir = config.get('DEFAULT', 'home_dir')
      except:
          home_dir = os.environ.get('HYDRA_HOME_DIR', '~')
      config.set('DEFAULT', 'home_dir', os.path.expanduser(home_dir))
  
      try:
          hydra_base = config.get('DEFAULT', 'hydra_base_dir')
      except:
          hydra_base = os.environ.get('HYDRA_BASE_DIR', modulepath)
      config.set('DEFAULT', 'hydra_base_dir', os.path.expanduser(hydra_base))
  
      read_values_from_environment(config, 'mysqld', 'server_name')
  
  
      CONFIG = config
  
      return config