diff --git a/README.rst b/README.rst index 9ca16ee..23814c2 100644 --- a/README.rst +++ b/README.rst @@ -221,6 +221,10 @@ To work around API limitation, you must first generate a Changes ======= +4.0 (2023-07-22) +---------------- + +* [BREAKING] drop support for other configuration file formats than yaml * Ensure git pull is always done in fast-forward mode 3.0.1 (2022-09-21) diff --git a/git_aggregator/config.py b/git_aggregator/config.py index 8a3af96..0043e84 100644 --- a/git_aggregator/config.py +++ b/git_aggregator/config.py @@ -6,7 +6,8 @@ import os from string import Template -import kaptan +import yaml + from .exception import ConfigException from ._compat import string_types @@ -148,7 +149,11 @@ def load_config(config, expand_env=False, env_file=None, force=False): raise ConfigException('Unable to find configuration file: %s' % config) file_extension = os.path.splitext(config)[1][1:] - conf = kaptan.Kaptan(handler=kaptan.HANDLER_EXT.get(file_extension)) + if file_extension not in ("yaml", "yml"): + raise ConfigException( + "Only .yaml and .yml configuration files are supported " + "(got %s)" % file_extension + ) if expand_env: environment = {} @@ -165,6 +170,9 @@ def load_config(config, expand_env=False, env_file=None, force=False): with open(config, 'r') as file_handler: config = Template(file_handler.read()) config = config.substitute(environment) + else: + config = open(config, 'r').read() + + conf = yaml.load(config, Loader=yaml.SafeLoader) - conf.import_config(config) - return get_repos(conf.export('dict') or {}, force) + return get_repos(conf or {}, force) diff --git a/setup.py b/setup.py index be72d56..04b2be6 100644 --- a/setup.py +++ b/setup.py @@ -36,7 +36,7 @@ 'setuptools_scm', ], install_requires=[ - 'kaptan', + 'PyYAML>=5', 'argcomplete', 'colorama', 'requests', diff --git a/tests/test_config.py b/tests/test_config.py index a5e070f..0c9fa50 100644 --- a/tests/test_config.py +++ b/tests/test_config.py @@ -4,9 +4,10 @@ import os import tempfile import unittest -import kaptan from textwrap import dedent +import yaml + from git_aggregator import config from git_aggregator.exception import ConfigException from git_aggregator._compat import PY2 @@ -15,9 +16,7 @@ class TestConfig(unittest.TestCase): def _parse_config(self, config_str): - conf = kaptan.Kaptan(handler='yaml') - conf.import_config(config_str) - return conf.export('dict') + return yaml.load(config_str, Loader=yaml.SafeLoader) def test_load(self): config_yaml = """