When _ENABLE_SET_CONFIG is False, disable reading/writing of the
authorZac Medico <zmedico@gentoo.org>
Mon, 30 Aug 2010 23:15:12 +0000 (16:15 -0700)
committerZac Medico <zmedico@gentoo.org>
Mon, 30 Aug 2010 23:15:12 +0000 (16:15 -0700)
world_sets file in WorldSelectedSet.

pym/portage/_sets/files.py

index 8116d07cdd98ef517d071350f16d4e62404bbca2..e880c1eff8a3c72c8318f44e9980ad20f23d2134 100644 (file)
@@ -11,6 +11,7 @@ from portage import _unicode_decode
 from portage import _unicode_encode
 from portage.util import grabfile, write_atomic, ensure_dirs, normalize_path
 from portage.const import USER_CONFIG_PATH, WORLD_FILE, WORLD_SETS_FILE
+from portage.const import _ENABLE_SET_CONFIG
 from portage.localization import _
 from portage.locks import lockfile, unlockfile
 from portage import portage_gid
@@ -229,8 +230,11 @@ class WorldSelectedSet(EditablePackageSet):
        def write(self):
                write_atomic(self._filename,
                        "".join(sorted("%s\n" % x for x in self._atoms)))
-               write_atomic(self._filename2, "\n".join(sorted(self._nonatoms))+"\n")
-       
+
+               if _ENABLE_SET_CONFIG:
+                       write_atomic(self._filename2,
+                               "".join(sorted("%s\n" % x for x in self._nonatoms)))
+
        def load(self):
                atoms = []
                nonatoms = []
@@ -258,6 +262,16 @@ class WorldSelectedSet(EditablePackageSet):
                        atoms_changed = True
                else:
                        atoms.extend(self._atoms)
+
+               if _ENABLE_SET_CONFIG:
+                       changed2, nonatoms = self._load2()
+                       atoms_changed |= changed2
+
+               if atoms_changed:
+                       self._setAtoms(atoms+nonatoms)
+
+       def _load2(self):
+               changed = False
                try:
                        mtime = os.stat(self._filename2).st_mtime
                except (OSError, IOError):
@@ -275,12 +289,12 @@ class WorldSelectedSet(EditablePackageSet):
                                data = {}
                        nonatoms = list(data)
                        self._mtime2 = mtime
-                       atoms_changed = True
+                       changed = True
                else:
-                       nonatoms.extend(self._nonatoms)
-               if atoms_changed:
-                       self._setAtoms(atoms+nonatoms)
-               
+                       nonatoms = self._nonatoms
+
+               return changed, nonatoms
+
        def _ensure_dirs(self):
                ensure_dirs(os.path.dirname(self._filename), gid=portage_gid, mode=0o2750, mask=0o2)