[Yum-devel] [PATCH] Allow environment options to have a 'default=true' option, for use in the anaconda UI.
Bill Nottingham
notting at redhat.com
Tue Apr 30 21:21:59 UTC 2013
James Antill (james at fedoraproject.org) said:
> On Tue, 2013-04-30 at 15:42 -0400, Bill Nottingham wrote:
> > ---
> > yum/comps.py | 17 ++++++++++++++++-
> > 1 file changed, 16 insertions(+), 1 deletion(-)
>
> It looks mostly fine, except:
>
> > diff --git a/yum/comps.py b/yum/comps.py
> > index fe5649d..04e002a 100755
> > --- a/yum/comps.py
> > +++ b/yum/comps.py
> > @@ -366,6 +372,9 @@ class Environment(CompsObj):
> > if child.tag == 'groupid':
> > optionid = child.text
> > self._options[optionid] = 1
> > + default = child.attrib.get('default')
> > + if default:
> > + self._defaultoptions[optionid] = 1
> [...]
Oof, right. Overassumption of boolean status here. How about the attached?
Bill
-------------- next part --------------
>From 0a950d32e6b1fb23fd49ed0e5d0f20341f960df4 Mon Sep 17 00:00:00 2001
From: Bill Nottingham <notting at redhat.com>
Date: Tue, 30 Apr 2013 17:20:44 -0400
Subject: [PATCH] Allow environment options to default to on.
---
yum/comps.py | 18 +++++++++++++++++-
1 file changed, 17 insertions(+), 1 deletion(-)
diff --git a/yum/comps.py b/yum/comps.py
index fe5649d..d2deb4a 100755
--- a/yum/comps.py
+++ b/yum/comps.py
@@ -295,6 +295,7 @@ class Environment(CompsObj):
self.installed = False
self._groups = {}
self._options = {}
+ self._defaultoptions = {}
if elem:
self.parse(elem)
@@ -316,6 +317,11 @@ class Environment(CompsObj):
options = property(_optioniter)
+ def _defaultoptioniter(self):
+ return self._defaultoptions.keys()
+
+ defaultoptions = property(_defaultoptioniter)
+
def parse(self, elem):
for child in elem:
if child.tag == 'id':
@@ -366,6 +372,10 @@ class Environment(CompsObj):
if child.tag == 'groupid':
optionid = child.text
self._options[optionid] = 1
+ defopt = child.attrib.get('default')
+ default = parse_boolean(defopt)
+ if default:
+ self._defaultoptions[optionid] = 1
def add(self, obj):
"""Add another category object to this object"""
@@ -373,6 +383,9 @@ class Environment(CompsObj):
for grp in obj.groups:
self._groups[grp] = 1
+ for grp in obj.defaultoptions:
+ self._defaultoptions[grp] = 1
+
for grp in obj.options:
self._options[grp] = 1
@@ -406,7 +419,10 @@ class Environment(CompsObj):
msg += """ </grouplist>\n"""
msg += """ <optionlist>\n"""
for grp in self.options:
- msg += """ <groupid>%s</groupid>\n""" % grp
+ if grp in self.defaultoptions:
+ msg += """ <groupid default="true">%s</groupid>\n""" % grp
+ else:
+ msg += """ <groupid>%s</groupid>\n""" % grp
msg += """ </optionlist>\n"""
msg += """ </environment>\n"""
--
1.8.2.1
More information about the Yum-devel
mailing list