diff --git a/README.rst b/README.rst index 033b83c..37891dd 100644 --- a/README.rst +++ b/README.rst @@ -221,6 +221,12 @@ To work around API limitation, you must first generate a Changes ======= +UNRELEASED +------------------ + +* Replace Kaptan with PyYAML. + + 3.0.1 (2022-09-21) ------------------ diff --git a/git_aggregator/config.py b/git_aggregator/config.py index 8a3af96..620d31a 100644 --- a/git_aggregator/config.py +++ b/git_aggregator/config.py @@ -6,11 +6,11 @@ import os from string import Template -import kaptan +import yaml + from .exception import ConfigException from ._compat import string_types - log = logging.getLogger(__name__) @@ -148,7 +148,6 @@ 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 expand_env: environment = {} @@ -166,5 +165,16 @@ def load_config(config, expand_env=False, env_file=None, force=False): config = Template(file_handler.read()) config = config.substitute(environment) - conf.import_config(config) - return get_repos(conf.export('dict') or {}, force) + if os.path.isfile(config): + if file_extension in ["yaml", "yml"]: + config = open(config, 'r').read() + else: + raise NotImplementedError( + f"{file_extension} not supported in {config}") + + conf = yaml.load( + config, + Loader=yaml.SafeLoader, + ) + + return get_repos(conf or {}, force) diff --git a/setup.py b/setup.py index be72d56..dbc3dac 100644 --- a/setup.py +++ b/setup.py @@ -36,7 +36,7 @@ 'setuptools_scm', ], install_requires=[ - 'kaptan', + 'PyYAML', 'argcomplete', 'colorama', 'requests', diff --git a/tests/test_config.py b/tests/test_config.py index a5e070f..e19ffd1 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,11 @@ class TestConfig(unittest.TestCase): def _parse_config(self, config_str): - conf = kaptan.Kaptan(handler='yaml') - conf.import_config(config_str) - return conf.export('dict') + content = yaml.load( + config_str, + Loader=yaml.SafeLoader, + ) + return content def test_load(self): config_yaml = """