Skip to content

Commit 0491848

Browse files
authored
Merge pull request #76 from acsone/drop-kaptan
Drop support for other configuration file formats than yaml
2 parents 319a937 + 6ab5170 commit 0491848

File tree

4 files changed

+20
-9
lines changed

4 files changed

+20
-9
lines changed

README.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,10 @@ To work around API limitation, you must first generate a
221221
Changes
222222
=======
223223

224+
4.0 (2023-07-22)
225+
----------------
226+
227+
* [BREAKING] drop support for other configuration file formats than yaml
224228
* Ensure git pull is always done in fast-forward mode
225229

226230
3.0.1 (2022-09-21)

git_aggregator/config.py

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@
66
import os
77
from string import Template
88

9-
import kaptan
9+
import yaml
10+
1011
from .exception import ConfigException
1112
from ._compat import string_types
1213

@@ -148,7 +149,11 @@ def load_config(config, expand_env=False, env_file=None, force=False):
148149
raise ConfigException('Unable to find configuration file: %s' % config)
149150

150151
file_extension = os.path.splitext(config)[1][1:]
151-
conf = kaptan.Kaptan(handler=kaptan.HANDLER_EXT.get(file_extension))
152+
if file_extension not in ("yaml", "yml"):
153+
raise ConfigException(
154+
"Only .yaml and .yml configuration files are supported "
155+
"(got %s)" % file_extension
156+
)
152157

153158
if expand_env:
154159
environment = {}
@@ -165,6 +170,9 @@ def load_config(config, expand_env=False, env_file=None, force=False):
165170
with open(config, 'r') as file_handler:
166171
config = Template(file_handler.read())
167172
config = config.substitute(environment)
173+
else:
174+
config = open(config, 'r').read()
175+
176+
conf = yaml.load(config, Loader=yaml.SafeLoader)
168177

169-
conf.import_config(config)
170-
return get_repos(conf.export('dict') or {}, force)
178+
return get_repos(conf or {}, force)

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
'setuptools_scm',
3737
],
3838
install_requires=[
39-
'kaptan',
39+
'PyYAML>=5',
4040
'argcomplete',
4141
'colorama',
4242
'requests',

tests/test_config.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,10 @@
44
import os
55
import tempfile
66
import unittest
7-
import kaptan
87
from textwrap import dedent
98

9+
import yaml
10+
1011
from git_aggregator import config
1112
from git_aggregator.exception import ConfigException
1213
from git_aggregator._compat import PY2
@@ -15,9 +16,7 @@
1516
class TestConfig(unittest.TestCase):
1617

1718
def _parse_config(self, config_str):
18-
conf = kaptan.Kaptan(handler='yaml')
19-
conf.import_config(config_str)
20-
return conf.export('dict')
19+
return yaml.load(config_str, Loader=yaml.SafeLoader)
2120

2221
def test_load(self):
2322
config_yaml = """

0 commit comments

Comments
 (0)