How to use the autohooks.config.Config function in autohooks

To help you get started, we’ve selected a few autohooks examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github greenbone / autohooks / tests / test_config.py View on Github external
def test_config_dict(self):
        config_dict = {
            'tool': {'autohooks': {'lorem': 'ipsum'}},
            'foo': {'lorem': 'ipsum'},
        }
        config = Config(config_dict)

        self.assertFalse(config.is_empty())

        foo_config = config.get('foo')

        self.assertFalse(foo_config.is_empty())

        self.assertEqual(foo_config.get_value('lorem'), 'ipsum')
        self.assertEqual(foo_config.get_value('lorem', 'dolor'), 'ipsum')
        self.assertEqual(foo_config.get_value('bar', 'dolor'), 'dolor')
github greenbone / autohooks / tests / test_config.py View on Github external
def test_config_point_syntax(self):
        config_dict = {
            'tool': {'autohooks': {'plugins': {'bar': {'lorem': 'ipsum'}}}}
        }

        config = Config(config_dict)

        self.assertFalse(config.is_empty())

        bar_config = config.get('tool', 'autohooks', 'plugins', 'bar')
        self.assertFalse(bar_config.is_empty())
        self.assertEqual(bar_config.get_value('lorem'), 'ipsum')
github greenbone / autohooks / tests / test_config.py View on Github external
def test_empty_config(self):
        config = Config()

        self.assertTrue(config.is_empty())

        bar_config = config.get('foo').get('bar')
        self.assertTrue(bar_config.is_empty())

        self.assertTrue(config.get_value('foo', True))
        self.assertListEqual(config.get_value('foo', ['a']), ['a'])
github greenbone / autohooks / autohooks / config.py View on Github external
def __init__(self, config_dict: Dict = None) -> None:
        self._config = Config(config_dict)
github greenbone / autohooks / autohooks / config.py View on Github external
def get(self, *keys: str) -> 'Config':
        config_dict = self._config_dict

        for key in keys:
            config_dict = config_dict.get(key, {})

        return Config(config_dict)