Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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)
------------------

Expand Down
20 changes: 15 additions & 5 deletions git_aggregator/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -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__)


Expand Down Expand Up @@ -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 = {}
Expand All @@ -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)
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
'setuptools_scm',
],
install_requires=[
'kaptan',
'PyYAML',
'argcomplete',
'colorama',
'requests',
Expand Down
11 changes: 7 additions & 4 deletions tests/test_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 = """
Expand Down