def load_configs_from_directory(config_dir, overrides):
  """
  Returns a master configuration object and a list of configuration objects

  :param config_dir: the directory where the configuration files are located
  :param overrides: mapping of the command line overrides
  """
  MASTER_CONFIG_FILE_NAME = "master"
  DEFAULT_CONFIG_NAME = "single execution"
  EMPTY_MAP = {}

  master_config = None
  config_objs = []

  # get master config and default mapping
  config_subdirs = []
  default_mapping = {}
  for dir_item in os.listdir(config_dir):
    full_path = os.path.join(config_dir, dir_item)
    if os.path.isdir(full_path):
      config_subdirs.append(full_path)  # save subdirs for processing later
    elif os.path.isfile(full_path):
      config_name = os.path.splitext(os.path.basename(full_path))[0]
      try:
        mapping = utils.parse_config_file(full_path)
      except ValueError:
        logger.debug("Ignored " + full_path + "as configuration due to file extension")
      else:
        if MASTER_CONFIG_FILE_NAME in config_name:
          master_config = Config(MASTER_CONFIG_FILE_NAME, mapping)
        else:
          default_mapping.update(mapping)
  if master_config is None:
    master_config = Config(MASTER_CONFIG_FILE_NAME, EMPTY_MAP)

  if len(config_subdirs) == 0:
    default_mapping.update(overrides)
    config_objs.append(Config(DEFAULT_CONFIG_NAME, default_mapping))
  else:
    # make a config object for each subdir
    for config_subdir in config_subdirs:
      config_files = [os.path.join(config_subdir, config_file) for config_file in os.listdir(config_subdir)
                      if os.path.isfile(os.path.join(config_subdir, config_file))]
      subdir_mapping = default_mapping.copy()  # initialize the configuration as default
      config_name = os.path.basename(config_subdir)
      for config_file in config_files:
        try:
          mapping = utils.parse_config_file(config_file)
        except __HOLE__:
          logger.debug("Ignored " + config_file + "as configuration due to file extension")
        else:
          subdir_mapping.update(mapping)
      subdir_mapping.update(overrides)
      config_objs.append(Config(config_name, subdir_mapping))

  return master_config, config_objs
dataset/ETHPy150Open linkedin/Zopkio/zopkio/test_runner_helper.py/load_configs_from_directory