summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--pym/portage/sets/__init__.py48
-rw-r--r--pym/portage/sets/dbapi.py10
-rw-r--r--pym/portage/sets/files.py13
-rw-r--r--pym/portage/sets/profiles.py4
-rw-r--r--pym/portage/sets/security.py4
-rw-r--r--pym/portage/sets/shell.py4
-rw-r--r--pym/portage/tests/sets/files/testConfigFileSet.py5
-rw-r--r--pym/portage/tests/sets/files/testStaticFileSet.py2
-rw-r--r--pym/portage/tests/sets/shell/testShell.py2
9 files changed, 46 insertions, 46 deletions
diff --git a/pym/portage/sets/__init__.py b/pym/portage/sets/__init__.py
index 7c288c264..e62a9d750 100644
--- a/pym/portage/sets/__init__.py
+++ b/pym/portage/sets/__init__.py
@@ -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
diff --git a/pym/portage/sets/dbapi.py b/pym/portage/sets/dbapi.py
index 709bbbdec..5c16b1701 100644
--- a/pym/portage/sets/dbapi.py
+++ b/pym/portage/sets/dbapi.py
@@ -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:
diff --git a/pym/portage/sets/files.py b/pym/portage/sets/files.py
index b3f85d553..6379e2641 100644
--- a/pym/portage/sets/files.py
+++ b/pym/portage/sets/files.py
@@ -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):
diff --git a/pym/portage/sets/profiles.py b/pym/portage/sets/profiles.py
index a1be8e47f..7dbc35e36 100644
--- a/pym/portage/sets/profiles.py
+++ b/pym/portage/sets/profiles.py
@@ -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]
diff --git a/pym/portage/sets/security.py b/pym/portage/sets/security.py
index c2c6048e1..6c463df9a 100644
--- a/pym/portage/sets/security.py
+++ b/pym/portage/sets/security.py
@@ -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
diff --git a/pym/portage/sets/shell.py b/pym/portage/sets/shell.py
index 6a84918a7..7bfaeaecb 100644
--- a/pym/portage/sets/shell.py
+++ b/pym/portage/sets/shell.py
@@ -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
diff --git a/pym/portage/tests/sets/files/testConfigFileSet.py b/pym/portage/tests/sets/files/testConfigFileSet.py
index 69acf3d10..7d588fbc3 100644
--- a/pym/portage/tests/sets/files/testConfigFileSet.py
+++ b/pym/portage/tests/sets/files/testConfigFileSet.py
@@ -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())
diff --git a/pym/portage/tests/sets/files/testStaticFileSet.py b/pym/portage/tests/sets/files/testStaticFileSet.py
index 8f0b5d050..71c47dc1b 100644
--- a/pym/portage/tests/sets/files/testStaticFileSet.py
+++ b/pym/portage/tests/sets/files/testStaticFileSet.py
@@ -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())
diff --git a/pym/portage/tests/sets/shell/testShell.py b/pym/portage/tests/sets/shell/testShell.py
index 938c265e1..b1f4aa46c 100644
--- a/pym/portage/tests/sets/shell/testShell.py
+++ b/pym/portage/tests/sets/shell/testShell.py
@@ -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)