From 46464991f12df8b9823ef913d18e0072c740ebbb Mon Sep 17 00:00:00 2001 From: "Chris St. Pierre" Date: Thu, 20 Sep 2012 11:51:04 -0400 Subject: Packages: fixed unknown_filter --- src/lib/Bcfg2/Server/Plugins/Packages/Source.py | 23 +++++++++++++-------- src/lib/Bcfg2/Server/Plugins/Packages/Yum.py | 27 ++++++++++++++++--------- 2 files changed, 32 insertions(+), 18 deletions(-) (limited to 'src/lib/Bcfg2/Server/Plugins') diff --git a/src/lib/Bcfg2/Server/Plugins/Packages/Source.py b/src/lib/Bcfg2/Server/Plugins/Packages/Source.py index 7188394b3..0e27f99f1 100644 --- a/src/lib/Bcfg2/Server/Plugins/Packages/Source.py +++ b/src/lib/Bcfg2/Server/Plugins/Packages/Source.py @@ -111,14 +111,6 @@ class Source(Bcfg2.Server.Plugin.Debuggable): #: make sources of this type available to clients. basegroups = [] - #: A predicate that is used by :func:`filter_unknown` to filter - #: packages from the results of - #: :func:`Bcfg2.Server.Plugins.Packages.Collection.Collection.complete` - #: that should not be shown to the end user (i.e., that are not - #: truly unknown, but are rather packaging system artifacts). By - #: default, excludes any package whose name starts with "choice" - unknown_filter = lambda p: p.startswith("choice") - #: The Package type handled by this Source class. The ``type`` #: attribute of Package entries will be set to the value ``ptype`` #: when they are handled by :mod:`Bcfg2.Server.Plugins.Packages`. @@ -573,6 +565,21 @@ class Source(Bcfg2.Server.Plugin.Debuggable): self.provides[barch][prov] = prov[barch].get(prov, ()) self.save_state() + def unknown_filter(self, package): + """ A predicate that is used by :func:`filter_unknown` to + filter packages from the results of + :func:`Bcfg2.Server.Plugins.Packages.Collection.Collection.complete` + that should not be shown to the end user (i.e., that are not + truly unknown, but are rather packaging system artifacts). By + default, excludes any package whose name starts with "choice" + + :param package: The name of a package that was unknown to the + backend + :type package: string + :returns: bool + """ + return package.startswith("choice") + def filter_unknown(self, unknown): """ After :func:`Bcfg2.Server.Plugins.Packages.Collection.Collection.complete`, diff --git a/src/lib/Bcfg2/Server/Plugins/Packages/Yum.py b/src/lib/Bcfg2/Server/Plugins/Packages/Yum.py index 474bddc49..9b915048d 100644 --- a/src/lib/Bcfg2/Server/Plugins/Packages/Yum.py +++ b/src/lib/Bcfg2/Server/Plugins/Packages/Yum.py @@ -778,16 +778,6 @@ class YumSource(Source): #: YumSource sets the ``type`` on Package entries to "yum" ptype = 'yum' - #: By default, - #: :class:`Bcfg2.Server.Plugins.Packages.Source.Source` filters - #: out unknown packages that start with "choice", but that doesn't - #: mean anything to Yum or RPM. Instead, we filter out unknown - #: packages that start with "rpmlib", although this is likely - #: legacy behavior; that would seem to indicate that a package - #: required some RPM feature that isn't provided, which is a bad - #: thing. This should probably go away at some point. - unknown_filter = lambda u: u.startswith("rpmlib") - def __init__(self, basepath, xsource, setup): Source.__init__(self, basepath, xsource, setup) self.pulp_id = None @@ -1022,6 +1012,23 @@ class YumSource(Source): return rv get_vpkgs.__doc__ = Source.get_vpkgs.__doc__ + def unknown_filter(self, package): + """ By default, + :class:`Bcfg2.Server.Plugins.Packages.Source.Source` filters + out unknown packages that start with "choice", but that + doesn't mean anything to Yum or RPM. Instead, we filter out + unknown packages that start with "rpmlib", although this is + likely legacy behavior; that would seem to indicate that a + package required some RPM feature that isn't provided, which + is a bad thing. This should probably go away at some point. + + :param package: The name of a package that was unknown to the + backend + :type package: string + :returns: bool + """ + return package.startswith("rpmlib") + def filter_unknown(self, unknown): if self.use_yum: filtered = set() -- cgit v1.2.3-1-g7c22