diff options
Diffstat (limited to 'pym/portage/package/ebuild/config.py')
-rw-r--r-- | pym/portage/package/ebuild/config.py | 66 |
1 files changed, 3 insertions, 63 deletions
diff --git a/pym/portage/package/ebuild/config.py b/pym/portage/package/ebuild/config.py index 315166659..ffff8c029 100644 --- a/pym/portage/package/ebuild/config.py +++ b/pym/portage/package/ebuild/config.py @@ -47,6 +47,7 @@ from portage.util import ensure_dirs, getconfig, grabdict, \ writemsg, writemsg_level from portage.versions import catpkgsplit, catsplit, cpv_getkey +from portage.package.ebuild._config.features_set import features_set from portage.package.ebuild._config.LicenseManager import LicenseManager from portage.package.ebuild._config.helper import ordered_by_atom_specificity @@ -98,67 +99,6 @@ def best_from_dict(key, top_dict, key_order, EmptyOnError=1, FullCopy=1, AllowEm else: raise KeyError("Key not found in list; '%s'" % key) -class _features_set(object): - """ - Provides relevant set operations needed for access and modification of - config.features. The FEATURES variable is automatically synchronized - upon modification. - - Modifications result in a permanent override that will cause the change - to propagate to the incremental stacking mechanism in config.regenerate(). - This eliminates the need to call config.backup_changes() when FEATURES - is modified, since any overrides are guaranteed to persist despite calls - to config.reset(). - """ - - def __init__(self, settings): - self._settings = settings - self._features = set() - - def __contains__(self, k): - return k in self._features - - def __iter__(self): - return iter(self._features) - - def _sync_env_var(self): - self._settings['FEATURES'] = ' '.join(sorted(self._features)) - - def add(self, k): - self._settings.modifying() - self._settings._features_overrides.append(k) - if k not in self._features: - self._features.add(k) - self._sync_env_var() - - def update(self, values): - self._settings.modifying() - values = list(values) - self._settings._features_overrides.extend(values) - need_sync = False - for k in values: - if k in self._features: - continue - self._features.add(k) - need_sync = True - if need_sync: - self._sync_env_var() - - def remove(self, k): - """ - This never raises KeyError, since it records a permanent override - that will prevent the given flag from ever being added again by - incremental stacking in config.regenerate(). - """ - self.discard(k) - - def discard(self, k): - self._settings.modifying() - self._settings._features_overrides.append('-' + k) - if k in self._features: - self._features.remove(k) - self._sync_env_var() - def _lazy_iuse_regex(iuse_implicit): """ The PORTAGE_IUSE value is lazily evaluated since re.escape() is slow @@ -514,7 +454,7 @@ class config(object): self.punmaskdict = copy.deepcopy(clone.punmaskdict) self.prevmaskdict = copy.deepcopy(clone.prevmaskdict) self.pprovideddict = copy.deepcopy(clone.pprovideddict) - self.features = _features_set(self) + self.features = features_set(self) self.features._features = copy.deepcopy(clone.features._features) self._features_overrides = copy.deepcopy(clone._features_overrides) @@ -2457,7 +2397,7 @@ class config(object): if hasattr(self, "features"): self.features._features.clear() else: - self.features = _features_set(self) + self.features = features_set(self) self.features._features.update(self.get('FEATURES', '').split()) self.features._sync_env_var() |