How to use the pkgcore.config.central.ConfigManager function in pkgcore

To help you get started, we’ve selected a few pkgcore 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 pkgcore / pkgcore / tests / module / config / test_central.py View on Github external
def test_prepend_inherit(self):
        manager = central.ConfigManager([{
                    'sect': basics.HardCodedConfigSection({
                            'inherit.prepend': ['self']})}])
        self.check_error(
            "Collapsing section named 'sect':\n"
            'Prepending or appending to the inherit list makes no sense',
            manager.collapse_named_section, 'sect')
github pkgcore / pkgcore / tests / module / config / test_central.py View on Github external
def test_no_object_returned(self):
        def noop():
            """Do not do anything."""
        manager = central.ConfigManager(
            [{'myrepo': basics.HardCodedConfigSection({'class': noop}),
              }])
        self.check_error(
            "Failed instantiating section 'myrepo':\n"
            "'No object returned' instantiating "
            "module.config.test_central.noop",
            manager.collapse_named_section('myrepo').instantiate)
github pkgcore / pkgcore / tests / module / config / test_central.py View on Github external
def test_autoexec(self):
        @configurable(typename='configsection')
        def autoloader():
            return {'spork': basics.HardCodedConfigSection({'class': repo,
                                                            'cache': 'test'})}

        manager = central.ConfigManager(
            [{'autoload-sub': basics.HardCodedConfigSection({
                            'class': autoloader,
                            })}])
        self.assertEqual(set(['autoload-sub', 'spork']), set(manager.sections()))
        self.assertEqual(['spork'], list(manager.objects.repo.keys()))
        self.assertEqual(
            'test',
            manager.collapse_named_section('spork').instantiate())
github pkgcore / pkgcore / tests / module / util / test_commandline.py View on Github external
def mk_config(*args, **kwds):
    return central.CompatConfigManager(
        central.ConfigManager(*args, **kwds))
github pkgcore / pkgcore / tests / module / ebuild / test_profiles.py View on Github external
def get_profile(self, profile, basepath=None, **kwds):
        config = central.ConfigManager()
        if basepath is None:
            basepath = self.dir
        return self.kls(basepath, profile, config, **kwds)
github pkgcore / pkgcore / tests / module / config / test_central.py View on Github external
def test_raises(self):
        def myrepo():
            raise ValueError('I raised')
        manager = central.ConfigManager(
            [{'myrepo': basics.HardCodedConfigSection({'class': myrepo})
              }])
        self.check_error(
            "Failed instantiating section 'myrepo':\n"
            "Failed instantiating section 'myrepo': exception caught from 'module.config.test_central.myrepo':\n"
            "I raised",
            self.get_config_obj, manager, 'myrepo', 'myrepo')
        manager = central.ConfigManager(
            [{'myrepo': basics.HardCodedConfigSection({'class': myrepo})
              }], debug=True)
        self.check_error(
            "Failed instantiating section 'myrepo':\n"
            "Failed instantiating section 'myrepo': exception caught from 'module.config.test_central.myrepo':\n"
            "I raised",
                self.get_config_obj, manager, 'myrepo', 'myrepo',
                klass=errors.ConfigurationError)
github pkgcore / pkgcore / tests / scripts / helpers.py View on Github external
def _mk_config(self, *args, **kwds):
        config = central.ConfigManager(*args, **kwds)
        if self.requires_compat_config_manager:
            config = central.CompatConfigManager(config)
        return config
github pkgcore / pkgcore / tests / module / config / test_central.py View on Github external
def test_list_prepend(self):
        @configurable({'seq': 'list'})
        def seq(seq):
            return seq
        manager = central.ConfigManager([{
                    'inh': basics.HardCodedConfigSection({
                            'inherit': ['sect'],
                            'seq.prepend': ['pre'],
                            }),
                    'sect': basics.HardCodedConfigSection({
                            'inherit': ['base'],
                            'seq': ['1', '2'],
                            })}, {
                    'base': basics.HardCodedConfigSection({
                            'class': seq,
                            'seq.prepend': ['-1'],
                            'seq.append': ['post'],
                            })}])
        self.assertEqual(['-1', 'post'], manager.objects.seq['base'])
        self.assertEqual(['1', '2'], manager.objects.seq['sect'])
        self.assertEqual(['pre', '1', '2'], manager.objects.seq['inh'])
github pkgcore / pkgcore / src / pkgcore / config / __init__.py View on Github external
configs = list(prepend_sources)
    if not skip_config_files:
        # load a pkgcore config file if one exists
        for config in (location, user_conf_file, system_conf_file):
            if config is not None and os.path.isfile(config):
                with open(config) as f:
                    configs.append(cparser.config_from_file(f))
                break
        # otherwise load the portage config
        else:
            # delay importing to avoid circular imports
            from pkgcore.ebuild.portage_conf import PortageConfig
            configs.append(PortageConfig(
                location=location, profile_override=profile_override, **kwargs))
    configs.extend(append_sources)
    return central.CompatConfigManager(central.ConfigManager(configs, debug=debug))