diff options
author | Zac Medico <zmedico@gentoo.org> | 2010-06-01 11:48:54 -0700 |
---|---|---|
committer | Zac Medico <zmedico@gentoo.org> | 2010-06-01 11:48:54 -0700 |
commit | ff845dd28b3a9b7bc29b28d168fb4f2e3fa392b6 (patch) | |
tree | 90d948b506d063214d4135e4badd68095f9c6a37 | |
parent | Add a Package.copy() method. (diff) | |
download | portage-idfetch-ff845dd28b3a9b7bc29b28d168fb4f2e3fa392b6.tar.gz portage-idfetch-ff845dd28b3a9b7bc29b28d168fb4f2e3fa392b6.tar.bz2 portage-idfetch-ff845dd28b3a9b7bc29b28d168fb4f2e3fa392b6.zip |
Add special handling for updates of Package.metadata['USE'], so that
internal state is consistent.
-rw-r--r-- | pym/_emerge/Package.py | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/pym/_emerge/Package.py b/pym/_emerge/Package.py index 9df7b644..bba55ca8 100644 --- a/pym/_emerge/Package.py +++ b/pym/_emerge/Package.py @@ -292,7 +292,7 @@ class _PackageMetadataWrapper(_PackageMetadataWrapperBase): __slots__ = ("_pkg",) _wrapped_keys = frozenset( - ["COUNTER", "INHERITED", "IUSE", "SLOT", "_mtime_"]) + ["COUNTER", "INHERITED", "IUSE", "SLOT", "USE", "_mtime_"]) _use_conditional_keys = frozenset( ['LICENSE', 'PROPERTIES', 'PROVIDE', 'RESTRICT',]) @@ -301,7 +301,7 @@ class _PackageMetadataWrapper(_PackageMetadataWrapperBase): self._pkg = pkg if not pkg.built: # USE is lazy, but we want it to show up in self.keys(). - self['USE'] = '' + _PackageMetadataWrapperBase.__setitem__(self, 'USE', '') self.update(metadata) @@ -326,7 +326,7 @@ class _PackageMetadataWrapper(_PackageMetadataWrapperBase): 'porttree'].dbapi.doebuild_settings pkgsettings.setcpv(self._pkg) v = pkgsettings["PORTAGE_USE"] - self['USE'] = v + _PackageMetadataWrapperBase.__setitem__(self, 'USE', v) return v @@ -366,6 +366,18 @@ class _PackageMetadataWrapper(_PackageMetadataWrapperBase): v = 0 self._pkg.counter = v + def _set_use(self, k, v): + # Force regeneration of _use attribute + self._pkg._use = None + # Use raw metadata to restore USE conditional values + # to unevaluated state + raw_metadata = self._pkg._raw_metadata + for x in self._use_conditional_keys: + try: + self[x] = raw_metadata[x] + except KeyError: + pass + def _set__mtime_(self, k, v): if isinstance(v, basestring): try: |