diff options
author | 2023-01-16 20:43:04 -0800 | |
---|---|---|
committer | 2023-02-05 20:08:20 +0200 | |
commit | cbda36d50efd616a2c149deea42785c745253566 (patch) | |
tree | fa419b48d936b8400feb5f48bc806954f2355cae /src | |
parent | ebuild.repository: fix traversal from root of overlays (diff) | |
download | pkgcore-cbda36d50efd616a2c149deea42785c745253566.tar.gz pkgcore-cbda36d50efd616a2c149deea42785c745253566.tar.bz2 pkgcore-cbda36d50efd616a2c149deea42785c745253566.zip |
refactor(config): drop duplicated add_config_source methods.
Previously we had .update() and .add_config_source; rename (and internalize)
accordingly so we have just one.
Signed-off-by: Brian Harring <ferringb@gmail.com>
Signed-off-by: Arthur Zamarin <arthurzam@gentoo.org>
Diffstat (limited to 'src')
-rw-r--r-- | src/pkgcore/config/central.py | 19 | ||||
-rw-r--r-- | src/pkgcore/ebuild/domain.py | 2 |
2 files changed, 10 insertions, 11 deletions
diff --git a/src/pkgcore/config/central.py b/src/pkgcore/config/central.py index 9ac4d9f5..350e25f5 100644 --- a/src/pkgcore/config/central.py +++ b/src/pkgcore/config/central.py @@ -8,6 +8,7 @@ __all__ = ( "ConfigManager", ) +import functools import typing import weakref from collections import defaultdict, deque, namedtuple @@ -338,9 +339,9 @@ class ConfigManager: return basics.GeneratedConfigSource(config, "unknown") def reload(self) -> None: - """Reinitialize from the config sources originally passed in. + """Reinitialize from the configured config sources. - This throws away all cached instances and re-executes autoloads. + This throws away all cached instances. """ # "Attribute defined outside __init__" # pylint: disable-msg=W0201 @@ -352,23 +353,21 @@ class ConfigManager: # force regeneration. self._types = klass._uncached_singleton for config in self.original_config_sources: - self.add_config_source(config) + self._integrate_config_source(config) - def update(self, config) -> None: - """Reinitialize using an additional supplied config.""" + def add_config_source(self, config) -> None: + """Add the given config source and reload the internal rendering""" self.original_config_sources += (config,) self.reload() - def add_config_source(self, config) -> None: - self._add_config_source(self._compat_mangle_config(config)) - - def _add_config_source(self, config) -> None: + def _integrate_config_source(self, config) -> None: """Pull extra type and config sections from configs and use them. Things loaded this way are added after already loaded things (meaning the config containing the autoload section overrides the config(s) added by that section). """ + config = self._compat_mangle_config(config) config_data = config.sections() collision = set(self.rendered_sections) @@ -414,7 +413,7 @@ class ConfigManager: except Exception as e: raise errors.AutoloadInstantiationError(name) from e if collapsed.type.name == "configsection": - self.add_config_source(instance) + self._integrate_config_source(instance) def sections(self) -> typing.Iterator[str]: """Return an iterator of all section names.""" diff --git a/src/pkgcore/ebuild/domain.py b/src/pkgcore/ebuild/domain.py index 3339019d..8d3f1966 100644 --- a/src/pkgcore/ebuild/domain.py +++ b/src/pkgcore/ebuild/domain.py @@ -774,7 +774,7 @@ class domain(config_domain): } data[f"conf:{path}"] = basics.AutoConfigSection(repo_conf_data) data[path] = basics.AutoConfigSection(repo_data) - config.update(data) + config.add_config_source(data) # reset repo-related jit attrs for attr in (x for x in dir(self) if x.startswith("_jit_repo_")): |