def _combaine_config(path, name): path = path.rstrip('/') L = CommonLogger() cfg = [_cfg for _cfg in ("%s/%s.%s" % (path, name, ext) for ext in constants.VALID_CONFIG_EXTENSIONS) if os.path.isfile(_cfg)] if len(cfg) == 0: raise MissingConfigError("%s/%s" % (path, name)) elif len(cfg) > 1: L.warning("More than one config with name %s. Use %s" % (name, cfg[0])) with open(cfg[0]) as f: _data = f.read() data = _handle_yaml(_data) or _handle_json(_data) if data is None: raise FormatError("%s/%s" % (path, name)) else: return data