Remove name from PackageSet, it's pointless as the caller has to keep track of the...
authorMarius Mauch <genone@gentoo.org>
Tue, 11 Sep 2007 06:06:24 +0000 (06:06 -0000)
committerMarius Mauch <genone@gentoo.org>
Tue, 11 Sep 2007 06:06:24 +0000 (06:06 -0000)
svn path=/main/trunk/; revision=7767

pym/portage/sets/__init__.py
pym/portage/sets/dbapi.py
pym/portage/sets/files.py
pym/portage/sets/profiles.py
pym/portage/sets/security.py
pym/portage/sets/shell.py
pym/portage/tests/sets/files/testConfigFileSet.py
pym/portage/tests/sets/files/testStaticFileSet.py
pym/portage/tests/sets/shell/testShell.py

index 7c288c264382d0929a378a070ea6842fc22a1a78..e62a9d750899bbd5a542a68b6fcf8ac3a755b8d4 100644 (file)
@@ -19,11 +19,9 @@ class PackageSet(object):
        # package sets, the latter doesn't make sense for some sets like "system"
        # or "security" and therefore isn't supported by them.
        _operations = ["merge"]
-       _atommap = {}
        description = "generic package set"
        
-       def __init__(self, name):
-               self.name = name
+       def __init__(self):
                self._atoms = set()
                self._atommap = {}
                self._loaded = False
@@ -150,7 +148,7 @@ class EditablePackageSet(PackageSet):
 
 class InternalPackageSet(EditablePackageSet):
        def __init__(self, initial_atoms=None):
-               super(InternalPackageSet, self).__init__("")
+               super(InternalPackageSet, self).__init__()
                if initial_atoms != None:
                        self.update(initial_atoms)
 
@@ -174,23 +172,23 @@ def make_default_sets(configroot, root, profile_paths, settings=None,
        from portage.sets.dbapi import EverythingSet
        from portage.const import PRIVATE_PATH, USER_CONFIG_PATH
        
-       rValue = set()
-       worldset = StaticFileSet("world", os.path.join(root, PRIVATE_PATH, "world"))
+       rValue = {}
+       worldset = StaticFileSet(os.path.join(root, PRIVATE_PATH, "world"))
        worldset.description = "Set of packages that were directly installed"
-       rValue.add(worldset)
+       rValue["world"] = worldset
        for suffix in ["mask", "unmask", "keywords", "use"]:
                myname = "package_"+suffix
-               myset = ConfigFileSet(myname, os.path.join(configroot, USER_CONFIG_PATH.lstrip(os.sep), "package."+suffix))
-               rValue.add(myset)
-       rValue.add(PackagesSystemSet("system", profile_paths))
+               myset = ConfigFileSet(os.path.join(configroot, USER_CONFIG_PATH.lstrip(os.sep), "package."+suffix))
+               rValue[myname] = myset
+       rValue["system"] = PackagesSystemSet(profile_paths)
        if settings != None and portdbapi != None:
-               rValue.add(NewAffectedSet("security", settings, vdbapi, portdbapi))
+               rValue["security"] = NewAffectedSet(settings, vdbapi, portdbapi)
        else:
-               rValue.add(InternalPackageSet("security"))
+               rValue["security"] = InternalPackageSet()
        if vdbapi != None:
-               rValue.add(EverythingSet("everything", vdbapi))
+               rValue["everything"] = EverythingSet(vdbapi)
        else:
-               rValue.add(InternalPackageSet("everything"))
+               rValue["everything"] = InternalPackageSet()
 
        return rValue
 
@@ -198,7 +196,7 @@ def make_extra_static_sets(configroot):
        from portage.sets.files import StaticFileSet
        from portage.const import PRIVATE_PATH, USER_CONFIG_PATH
        
-       rValue = set()
+       rValue = {}
        mydir = os.path.join(configroot, USER_CONFIG_PATH.lstrip(os.sep), "sets")
        try:
                mysets = os.listdir(mydir)
@@ -207,14 +205,14 @@ def make_extra_static_sets(configroot):
        for myname in mysets:
                if myname in DEFAULT_SETS:
                        continue
-               rValue.add(StaticFileSet(myname, os.path.join(mydir, myname)))
+               rValue[myname] = StaticFileSet(os.path.join(mydir, myname))
        return rValue
 
 def make_category_sets(portdbapi, settings, only_visible=True):
        from portage.sets.dbapi import CategorySet
-       rValue = set()
+       rValue = {}
        for c in settings.categories:
-               rValue.add(CategorySet("category_%s" % c, c, portdbapi, only_visible=only_visible))
+               rValue["category_%s" % c] = CategorySet(c, portdbapi, only_visible=only_visible)
        return rValue
 
 # adhoc test code
@@ -228,16 +226,18 @@ if __name__ == "__main__":
                for s in sys.argv[1:]:
                        if s.startswith("category_"):
                                c = s[9:]
-                               l.add(CategorySet("category_%s" % c, c, portage.db['/']['porttree'].dbapi, only_visible=False))
+                               l["category_%s" % c] = CategorySet(c, portage.db['/']['porttree'].dbapi, only_visible=False)
                        elif os.path.exists(s):
-                               l.add(StaticFileSet(os.path.basename(s), s))
+                               l[os.path.basename(s)] = StaticFileSet(s)
                        elif s != "*":
                                print "ERROR: could not create set '%s'" % s
                if not "*" in sys.argv:
-                       l = [s for s in l if s.name in sys.argv[1:]]
+                       for n in l:
+                               if n not in sys.argv[1:]:
+                                       del l[n]
        for x in l:
-               print x.name+":"
-               print "DESCRIPTION = %s" % x.getMetadata("Description")
-               for n in sorted(x.getAtoms()):
+               print x+":"
+               print "DESCRIPTION = %s" % l[x].getMetadata("Description")
+               for n in sorted(l[x].getAtoms()):
                        print "- "+n
                print
index 709bbbdece28c49dc6609e6590884b5cc79dd758..5c16b170198046bf861484ab485523a1db71a1de 100644 (file)
@@ -9,8 +9,8 @@ class EverythingSet(PackageSet):
        _operations = ["merge", "unmerge"]
        description = "Package set containing all installed packages"
        
-       def __init__(self, name, vdbapi):
-               super(EverythingSet, self).__init__(name)
+       def __init__(self, vdbapi):
+               super(EverythingSet, self).__init__()
                self._db = vdbapi
        
        def load(self):
@@ -27,9 +27,9 @@ class EverythingSet(PackageSet):
 class CategorySet(PackageSet):
        _operations = ["merge", "unmerge"]
        
-       def __init__(self, name, category, portdbapi, only_visible=True):
-               super(CategorySet, self).__init__(name)
-               self._db = portdbapi
+       def __init__(self, category, dbapi, only_visible=True):
+               super(CategorySet, self).__init__()
+               self._db = dbapi
                self._category = category
                self._check = only_visible
                if only_visible:
index b3f85d5536ee5556f3dcfbbccfca434f0627006c..6379e26416b0bb40daaf8efecffc49481f4ebb9e 100644 (file)
@@ -16,8 +16,8 @@ from portage.env.validators import ValidAtomValidator
 class StaticFileSet(EditablePackageSet):
        _operations = ["merge", "unmerge"]
        
-       def __init__(self, name, filename):
-               super(StaticFileSet, self).__init__(name)
+       def __init__(self, filename):
+               super(StaticFileSet, self).__init__()
                self._filename = filename
                self._mtime = None
                self.description = "Package set loaded from file %s" % self._filename
@@ -57,12 +57,13 @@ class StaticFileSet(EditablePackageSet):
                                if e.errno != errno.ENOENT:
                                        raise
                                del e
+                               data = {}
                        self._setAtoms(data.keys())
                        self._mtime = mtime
        
 class ConfigFileSet(PackageSet):
-       def __init__(self, name, filename):
-               super(ConfigFileSet, self).__init__(name)
+       def __init__(self, filename):
+               super(ConfigFileSet, self).__init__()
                self._filename = filename
                self.description = "Package set generated from %s" % self._filename
                self.loader = KeyListFileLoader(self._filename, ValidAtomValidator)
@@ -74,8 +75,8 @@ class ConfigFileSet(PackageSet):
 class WorldSet(StaticFileSet):
        description = "Set of packages that were directly installed by the user"
        
-       def __init__(self, name, root):
-               super(WorldSet, self).__init__(name, os.path.join(os.sep, root, PRIVATE_PATH, "world"))
+       def __init__(self, root):
+               super(WorldSet, self).__init__(os.path.join(os.sep, root, PRIVATE_PATH, "world"))
                self._lock = None
 
        def _ensure_dirs(self):
index a1be8e47f27d91b9dc33faba36391f48ccab1b66..7dbc35e367df60ac1dfe50d1c60b9684752fae41 100644 (file)
@@ -9,8 +9,8 @@ from portage.sets import PackageSet
 class PackagesSystemSet(PackageSet):
        _operations = ["merge"]
 
-       def __init__(self, name, profile_paths):
-               super(PackagesSystemSet, self).__init__(name)
+       def __init__(self, profile_paths):
+               super(PackagesSystemSet, self).__init__()
                self._profile_paths = profile_paths
                self.description = "System packages for profile %s" % self._profile_paths[-1]
        
index c2c6048e1bc3d8ca794534ee2f4254ee6397da67..6c463df9aba702ac20a38b80098b1d8e253600c6 100644 (file)
@@ -14,8 +14,8 @@ class SecuritySet(PackageSet):
        
        description = "package set that includes all packages possibly affected by a GLSA"
                
-       def __init__(self, name, settings, vardbapi, portdbapi):
-               super(SecuritySet, self).__init__(name)
+       def __init__(self, settings, vardbapi, portdbapi):
+               super(SecuritySet, self).__init__()
                self._settings = settings
                self._vardbapi = vardbapi
                self._portdbapi = portdbapi
index 6a84918a7fbc250c3711758ae28d4c877943e5cd..7bfaeaecbd7e82fabc00357463ce0972f7aad269 100644 (file)
@@ -23,8 +23,8 @@ class CommandOutputSet(PackageSet):
        """
        _operations = ["merge", "unmerge"]
 
-       def __init__(self, name, command):
-               super(CommandOutputSet, self).__init__(name)
+       def __init__(self, command):
+               super(CommandOutputSet, self).__init__()
                self._command = command
                self.description = "Package set generated from output of '%s'" % self._command
        
index 69acf3d10e56cbb82f0679e2de641f7934500073..7d588fbc33f0aa85338e42c54e3a22c865762129 100644 (file)
@@ -22,11 +22,10 @@ class ConfigFileSetTestCase(TestCase):
                os.close(fd)
 
        def tearDown(self):
-#              os.unlink(self.testfile)
-               pass
+               os.unlink(self.testfile)
 
        def testConfigStaticFileSet(self):
-               s = ConfigFileSet('test', self.testfile)
+               s = ConfigFileSet(self.testfile)
                s.load()
                self.assertEqual(set(test_cps), s.getAtoms())
 
index 8f0b5d050325b48b06569d8360933dfacdc1cb35..71c47dc1b70cb551c743854a443c56f0f55e057c 100644 (file)
@@ -22,7 +22,7 @@ class StaticFileSetTestCase(TestCase):
                os.unlink(self.testfile)
 
        def testSampleStaticFileSet(self):
-               s = StaticFileSet('test', self.testfile)
+               s = StaticFileSet(self.testfile)
                s.load()
                self.assertEqual(set(test_cps), s.getAtoms())
 
index 938c265e1194df189aaefff042d9f6b9073901c5..b1f4aa46c6c9aa8370e006d9326bca286063e5c5 100644 (file)
@@ -23,6 +23,6 @@ class CommandOutputSetTestCase(TestCase):
                command += " -e "
                for a in input:
                  command += "\"%s\n\"" % a
-               s = CommandOutputSet('testset', command)
+               s = CommandOutputSet(command)
                atoms = s.getAtoms()
                self.assertEqual(atoms, input)