From: Marius Mauch Date: Tue, 23 Oct 2007 20:24:54 +0000 (-0000) Subject: just pass the SetConfig instance instead of only the settings and trees attributes X-Git-Tag: v2.2_pre1~540 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=b33b64927fa016db2835c04e34d079148b91ffc7;p=portage.git just pass the SetConfig instance instead of only the settings and trees attributes svn path=/main/trunk/; revision=8256 --- diff --git a/pym/portage/sets/__init__.py b/pym/portage/sets/__init__.py index ac3f4b0cb..1698c20a7 100644 --- a/pym/portage/sets/__init__.py +++ b/pym/portage/sets/__init__.py @@ -207,7 +207,7 @@ class SetConfig(SafeConfigParser): if self.has_option(sname, "multiset") and self.getboolean(sname, "multiset"): if hasattr(setclass, "multiBuilder"): try: - self.psets.update(setclass.multiBuilder(optdict, self.settings, self.trees)) + self.psets.update(setclass.multiBuilder(optdict, self)) except SetConfigError, e: self.errors.append("Configuration error in section '%s': %s" % (sname, str(e))) continue @@ -221,7 +221,7 @@ class SetConfig(SafeConfigParser): setname = "sets/"+sname if hasattr(setclass, "singleBuilder"): try: - self.psets[setname] = setclass.singleBuilder(optdict, self.settings, self.trees) + self.psets[setname] = setclass.singleBuilder(optdict, self) except SetConfigError, e: self.errors.append("Configuration error in section '%s': %s" % (sname, str(e))) continue diff --git a/pym/portage/sets/dbapi.py b/pym/portage/sets/dbapi.py index bc842ae2c..491a6d4c4 100644 --- a/pym/portage/sets/dbapi.py +++ b/pym/portage/sets/dbapi.py @@ -30,8 +30,8 @@ class EverythingSet(PackageSet): myatoms.append(cp) self._setAtoms(myatoms) - def singleBuilder(self, options, settings, trees): - return EverythingSet(trees["vartree"].dbapi) + def singleBuilder(self, options, setconfig): + return EverythingSet(setconfig.trees["vartree"].dbapi) singleBuilder = classmethod(singleBuilder) class CategorySet(PackageSet): @@ -70,7 +70,7 @@ class CategorySet(PackageSet): return bool(visible in ["1", "yes", "true", "on"]) _builderGetVisible = classmethod(_builderGetVisible) - def singleBuilder(cls, options, settings, trees): + def singleBuilder(cls, options, setconfig): if not "category" in options: raise SetConfigError("no category given") @@ -78,24 +78,24 @@ class CategorySet(PackageSet): if not category in categories: raise SetConfigError("invalid category name '%s'" % category) - repository = cls._builderGetRepository(options, trees.keys()) + repository = cls._builderGetRepository(options, setconfig.trees.keys()) visible = cls._builderGetVisible(options) - return CategorySet(category, dbapi=trees[repository].dbapi, only_visible=visible) + return CategorySet(category, dbapi=setconfig.trees[repository].dbapi, only_visible=visible) singleBuilder = classmethod(singleBuilder) - def multiBuilder(cls, options, settings, trees): + def multiBuilder(cls, options, setconfig): rValue = {} if "categories" in options: categories = options["categories"].split() - invalid = set(categories).difference(settings.categories) + invalid = set(categories).difference(setconfig.settings.categories) if invalid: raise SetConfigError("invalid categories: %s" % ", ".join(list(invalid))) else: - categories = settings.categories + categories = setconfig.settings.categories - repository = cls._builderGetRepository(options, trees.keys()) + repository = cls._builderGetRepository(options, setconfig.trees.keys()) visible = cls._builderGetVisible(options) name_pattern = options.get("name_pattern", "$category/*") @@ -103,7 +103,7 @@ class CategorySet(PackageSet): raise SetConfigError("name_pattern doesn't include $category placeholder") for cat in categories: - myset = CategorySet(cat, trees[repository].dbapi, only_visible=visible) + myset = CategorySet(cat, setconfig.trees[repository].dbapi, only_visible=visible) myname = name_pattern.replace("$category", cat) myname = myname.replace("${category}", cat) rValue[myname] = myset @@ -146,8 +146,8 @@ class PreservedLibraryConsumerSet(LibraryConsumerSet): return self._setAtoms(self.mapPathsToAtoms(consumers)) - def singleBuilder(cls, options, settings, trees): - return PreservedLibraryConsumerSet(trees["vartree"].dbapi) + def singleBuilder(cls, options, setconfig): + return PreservedLibraryConsumerSet(setconfig.trees["vartree"].dbapi) singleBuilder = classmethod(singleBuilder) class MissingLibraryConsumerSet(LibraryConsumerSet): @@ -172,10 +172,10 @@ class MissingLibraryConsumerSet(LibraryConsumerSet): return self._setAtoms(self.mapPathsToAtoms(consumers)) - def singleBuilder(cls, options, settings, trees): + def singleBuilder(cls, options, setconfig): if options.get("debug", "true").lower() in ["true", "on", "1", "yes"]: debug = True else: debug = False - return MissingLibraryConsumerSet(trees["vartree"].dbapi, debug=debug) + return MissingLibraryConsumerSet(setconfig.trees["vartree"].dbapi, debug=debug) singleBuilder = classmethod(singleBuilder) diff --git a/pym/portage/sets/files.py b/pym/portage/sets/files.py index 5716822c0..788dead85 100644 --- a/pym/portage/sets/files.py +++ b/pym/portage/sets/files.py @@ -67,15 +67,16 @@ class StaticFileSet(EditablePackageSet): self._setAtoms(data.keys()) self._mtime = mtime - def singleBuilder(self, options, settings, trees): + def singleBuilder(self, options, setconfig): if not "filename" in options: raise SetConfigError("no filename specified") return ConfigFileSet(options[filename]) singleBuilder = classmethod(singleBuilder) - def multiBuilder(self, options, settings, trees): + def multiBuilder(self, options, setconfig): rValue = {} - directory = options.get("directory", os.path.join(settings["PORTAGE_CONFIGROOT"], USER_CONFIG_PATH.lstrip(os.sep), "sets")) + directory = options.get("directory", \ + os.path.join(setconfig.settings["PORTAGE_CONFIGROOT"], USER_CONFIG_PATH.lstrip(os.sep), "sets")) name_pattern = options.get("name_pattern", "sets/$name") if not "$name" in name_pattern and not "${name}" in name_pattern: raise SetConfigError("name_pattern doesn't include $name placeholder") @@ -100,15 +101,16 @@ class ConfigFileSet(PackageSet): data, errors = self.loader.load() self._setAtoms(data.keys()) - def singleBuilder(self, options, settings, trees): + def singleBuilder(self, options, setconfig): if not "filename" in options: raise SetConfigError("no filename specified") return ConfigFileSet(options[filename]) singleBuilder = classmethod(singleBuilder) - def multiBuilder(self, options, settings, trees): + def multiBuilder(self, options, setconfig): rValue = {} - directory = options.get("directory", os.path.join(settings["PORTAGE_CONFIGROOT"], USER_CONFIG_PATH.lstrip(os.sep))) + directory = options.get("directory", \ + os.path.join(setconfig.settings["PORTAGE_CONFIGROOT"], USER_CONFIG_PATH.lstrip(os.sep))) name_pattern = options.get("name_pattern", "sets/package_$suffix") if not "$suffix" in name_pattern and not "${suffix}" in name_pattern: raise SetConfigError("name_pattern doesn't include $suffix placeholder") @@ -161,6 +163,6 @@ class WorldSet(StaticFileSet): self.replace(newworldlist) self.unlock() - def singleBuilder(self, options, settings, trees): - return WorldSet(settings["ROOT"]) + def singleBuilder(self, options, setconfig): + return WorldSet(setconfig.settings["ROOT"]) singleBuilder = classmethod(singleBuilder) diff --git a/pym/portage/sets/profiles.py b/pym/portage/sets/profiles.py index fcefaff88..379fb06ec 100644 --- a/pym/portage/sets/profiles.py +++ b/pym/portage/sets/profiles.py @@ -21,6 +21,6 @@ class PackagesSystemSet(PackageSet): mylist = stack_lists(mylist, incremental=1) self._setAtoms([x[1:] for x in mylist if x[0] == "*"]) - def singleBuilder(self, options, settings, trees): - return PackagesSystemSet(settings.profiles) + def singleBuilder(self, options, setconfig): + return PackagesSystemSet(setconfig.settings.profiles) singleBuilder = classmethod(singleBuilder) diff --git a/pym/portage/sets/security.py b/pym/portage/sets/security.py index f58e725f9..e2d595698 100644 --- a/pym/portage/sets/security.py +++ b/pym/portage/sets/security.py @@ -55,13 +55,14 @@ class SecuritySet(PackageSet): applied_list.append(glsaid) write_atomic(self._checkfile, "\n".join(applied_list)) - def singleBuilder(cls, options, settings, trees): + def singleBuilder(cls, options, setconfig): if "use_emerge_resoler" in options \ and options.get("use_emerge_resolver").lower() in ["1", "yes", "true", "on"]: least_change = False else: least_change = True - return cls(settings, trees["vartree"].dbapi, trees["porttree"].dbapi, least_change=least_change) + return cls(setconfig.settings, setconfig.trees["vartree"].dbapi, \ + setconfig.trees["porttree"].dbapi, least_change=least_change) singleBuilder = classmethod(singleBuilder) class NewGlsaSet(SecuritySet): diff --git a/pym/portage/sets/shell.py b/pym/portage/sets/shell.py index 56b8ef5ef..fe4babbab 100644 --- a/pym/portage/sets/shell.py +++ b/pym/portage/sets/shell.py @@ -36,7 +36,7 @@ class CommandOutputSet(PackageSet): text = pipe.stdout.read() self._setAtoms(text.split("\n")) - def singleBuilder(self, options, settings, trees): + def singleBuilder(self, options, setconfig): if not command in options: raise SetConfigError("no command specified") return CommandOutputSet(options["command"])