[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 19:42:28 UTC 2013


---
 yum/comps.py | 17 ++++++++++++++++-
 1 file changed, 16 insertions(+), 1 deletion(-)

diff --git a/yum/comps.py b/yum/comps.py
index fe5649d..04e002a 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,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
 
     def add(self, obj):
         """Add another category object to this object"""
@@ -373,6 +382,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 +418,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