[PATCH 07/13] Make getting raid level less hacky

Vratislav Podzimek vpodzime at redhat.com
Mon Mar 10 13:22:13 UTC 2014


We can simply store our pre-defined strings in the stores instead of doing some
crazy magic on translated strings.

Signed-off-by: Vratislav Podzimek <vpodzime at redhat.com>
---
 pyanaconda/ui/gui/spokes/custom.glade              | 47 +++++++++++++---------
 pyanaconda/ui/gui/spokes/custom.py                 |  6 +--
 .../ui/gui/spokes/lib/custom_storage_helpers.glade | 47 +++++++++++++---------
 .../ui/gui/spokes/lib/custom_storage_helpers.py    | 19 ++-------
 4 files changed, 63 insertions(+), 56 deletions(-)

diff --git a/pyanaconda/ui/gui/spokes/custom.glade b/pyanaconda/ui/gui/spokes/custom.glade
index e563d47..82110d7 100644
--- a/pyanaconda/ui/gui/spokes/custom.glade
+++ b/pyanaconda/ui/gui/spokes/custom.glade
@@ -1224,6 +1224,8 @@ until you click on the main menu's 'Begin Installation' button.</property>
     <columns>
       <!-- column-name raidLevel -->
       <column type="gchararray"/>
+      <!-- column-name canonRaidLevel -->
+      <column type="gchararray"/>
       <!-- column-name validForLVM -->
       <column type="gboolean"/>
       <!-- column-name validForRAID -->
@@ -1236,52 +1238,59 @@ until you click on the main menu's 'Begin Installation' button.</property>
     <data>
       <row>
         <col id="0" translatable="yes">None</col>
-        <col id="1">True</col>
-        <col id="2">False</col>
-        <col id="3">True</col>
+        <col id="1">none</col>
+        <col id="2">True</col>
+        <col id="3">False</col>
         <col id="4">True</col>
+        <col id="5">True</col>
       </row>
       <row>
         <col id="0" translatable="yes">RAID0 &lt;span foreground="grey"&gt;(Performance)&lt;/span&gt;</col>
-        <col id="1">True</col>
+        <col id="1">raid0</col>
         <col id="2">True</col>
         <col id="3">True</col>
         <col id="4">True</col>
+        <col id="5">True</col>
       </row>
       <row>
         <col id="0" translatable="yes">RAID1 &lt;span foreground="grey"&gt;(Redundancy)&lt;/span&gt;</col>
-        <col id="1">True</col>
+        <col id="1">raid1</col>
         <col id="2">True</col>
         <col id="3">True</col>
         <col id="4">True</col>
+        <col id="5">True</col>
       </row>
       <row>
         <col id="0" translatable="yes">RAID4 &lt;span foreground="grey"&gt;(Error Checking)&lt;/span&gt;</col>
-        <col id="1">False</col>
-        <col id="2">True</col>
-        <col id="3">False</col>
-        <col id="4">True</col>
+        <col id="1">raid4</col>
+        <col id="2">False</col>
+        <col id="3">True</col>
+        <col id="4">False</col>
+        <col id="5">True</col>
       </row>
       <row>
         <col id="0" translatable="yes">RAID5 &lt;span foreground="grey"&gt;(Distributed Error Checking)&lt;/span&gt;</col>
-        <col id="1">False</col>
-        <col id="2">True</col>
-        <col id="3">False</col>
-        <col id="4">True</col>
+        <col id="1">raid5</col>
+        <col id="2">False</col>
+        <col id="3">True</col>
+        <col id="4">False</col>
+        <col id="5">True</col>
       </row>
       <row>
         <col id="0" translatable="yes">RAID6 &lt;span foreground="grey"&gt;(Redundant Error Checking)&lt;/span&gt;</col>
-        <col id="1">False</col>
-        <col id="2">True</col>
-        <col id="3">False</col>
-        <col id="4">True</col>
+        <col id="1">raid6</col>
+        <col id="2">False</col>
+        <col id="3">True</col>
+        <col id="4">False</col>
+        <col id="5">True</col>
       </row>
       <row>
         <col id="0" translatable="yes">RAID10 &lt;span foreground="grey"&gt;(Performance, Redundancy)&lt;/span&gt;</col>
-        <col id="1">False</col>
-        <col id="2">True</col>
+        <col id="1">raid10</col>
+        <col id="2">False</col>
         <col id="3">True</col>
         <col id="4">True</col>
+        <col id="5">True</col>
       </row>
     </data>
   </object>
diff --git a/pyanaconda/ui/gui/spokes/custom.py b/pyanaconda/ui/gui/spokes/custom.py
index 8765e01..fb13541 100644
--- a/pyanaconda/ui/gui/spokes/custom.py
+++ b/pyanaconda/ui/gui/spokes/custom.py
@@ -1120,11 +1120,11 @@ class CustomPartitioningSpoke(NormalSpoke, StorageChecker):
     def _raid_level_visible(self, model, itr, user_data):
         device_type = self._get_current_device_type()
         if device_type == DEVICE_TYPE_LVM:
-            return model[itr][1]
-        elif device_type == DEVICE_TYPE_MD:
             return model[itr][2]
-        elif device_type == DEVICE_TYPE_BTRFS:
+        elif device_type == DEVICE_TYPE_MD:
             return model[itr][3]
+        elif device_type == DEVICE_TYPE_BTRFS:
+            return model[itr][4]
 
     def _populate_raid(self, raid_level):
         """ Set up the raid-specific portion of the device details. """
diff --git a/pyanaconda/ui/gui/spokes/lib/custom_storage_helpers.glade b/pyanaconda/ui/gui/spokes/lib/custom_storage_helpers.glade
index 605bd98..72afdc1 100644
--- a/pyanaconda/ui/gui/spokes/lib/custom_storage_helpers.glade
+++ b/pyanaconda/ui/gui/spokes/lib/custom_storage_helpers.glade
@@ -17,6 +17,8 @@
     <columns>
       <!-- column-name raidLevel -->
       <column type="gchararray"/>
+      <!-- column-name canonRaidLevel -->
+      <column type="gchararray"/>
       <!-- column-name validForLVM -->
       <column type="gboolean"/>
       <!-- column-name validForRAID -->
@@ -29,52 +31,59 @@
     <data>
       <row>
         <col id="0" translatable="yes">None</col>
-        <col id="1">True</col>
-        <col id="2">False</col>
-        <col id="3">True</col>
+        <col id="1">none</col>
+        <col id="2">True</col>
+        <col id="3">False</col>
         <col id="4">True</col>
+        <col id="5">True</col>
       </row>
       <row>
         <col id="0" translatable="yes">RAID0 &lt;span foreground="grey"&gt;(Performance)&lt;/span&gt;</col>
-        <col id="1">True</col>
+        <col id="1">raid0</col>
         <col id="2">True</col>
         <col id="3">True</col>
         <col id="4">True</col>
+        <col id="5">True</col>
       </row>
       <row>
         <col id="0" translatable="yes">RAID1 &lt;span foreground="grey"&gt;(Redundancy)&lt;/span&gt;</col>
-        <col id="1">True</col>
+        <col id="1">raid1</col>
         <col id="2">True</col>
         <col id="3">True</col>
         <col id="4">True</col>
+        <col id="5">True</col>
       </row>
       <row>
         <col id="0" translatable="yes">RAID4 &lt;span foreground="grey"&gt;(Error Checking)&lt;/span&gt;</col>
-        <col id="1">False</col>
-        <col id="2">True</col>
-        <col id="3">False</col>
-        <col id="4">True</col>
+        <col id="1">raid4</col>
+        <col id="2">False</col>
+        <col id="3">True</col>
+        <col id="4">False</col>
+        <col id="5">True</col>
       </row>
       <row>
         <col id="0" translatable="yes">RAID5 &lt;span foreground="grey"&gt;(Distributed Error Checking)&lt;/span&gt;</col>
-        <col id="1">False</col>
-        <col id="2">True</col>
-        <col id="3">False</col>
-        <col id="4">True</col>
+        <col id="1">raid5</col>
+        <col id="2">False</col>
+        <col id="3">True</col>
+        <col id="4">False</col>
+        <col id="5">True</col>
       </row>
       <row>
         <col id="0" translatable="yes">RAID6 &lt;span foreground="grey"&gt;(Redundant Error Checking)&lt;/span&gt;</col>
-        <col id="1">False</col>
-        <col id="2">True</col>
-        <col id="3">False</col>
-        <col id="4">True</col>
+        <col id="1">raid6</col>
+        <col id="2">False</col>
+        <col id="3">True</col>
+        <col id="4">False</col>
+        <col id="5">True</col>
       </row>
       <row>
         <col id="0" translatable="yes">RAID10 &lt;span foreground="grey"&gt;(Performance, Redundancy)&lt;/span&gt;</col>
-        <col id="1">False</col>
-        <col id="2">True</col>
+        <col id="1">raid10</col>
+        <col id="2">False</col>
         <col id="3">True</col>
         <col id="4">True</col>
+        <col id="5">True</col>
       </row>
     </data>
   </object>
diff --git a/pyanaconda/ui/gui/spokes/lib/custom_storage_helpers.py b/pyanaconda/ui/gui/spokes/lib/custom_storage_helpers.py
index 5288b18..26280e0 100644
--- a/pyanaconda/ui/gui/spokes/lib/custom_storage_helpers.py
+++ b/pyanaconda/ui/gui/spokes/lib/custom_storage_helpers.py
@@ -177,22 +177,11 @@ def selectedRaidLevel(raidLevelCombo):
     if not itr:
         return
 
-    selected_level_string = store[itr][0]   # eg: "RAID1 (Redundancy)"
-    level = selected_level_string.split()[0]    # -> "RAID1"
-
-    # The RAID level strings are not translated, but the "None" string in
-    # the container dialog is. Transformations in relation to "None" need
-    # to happen within the locale settings, but transformations in
-    # relation to "RAID* ..." need to happen only within ASCII. For example,
-    # "RAID1".lower() in Turkish would become "raıd1", which is not what
-    # we want.
-    levelLocale = level.lower()
-    levelASCII = lowerASCII(level)
-
-    if levelASCII == "none" or levelLocale == _("None").lower():
+    selected_level = store[itr][1]
+    if selected_level == "none":
         return None
-
-    return levelASCII
+    else:
+        return selected_level
 
 def get_container_type_name(device_type):
     return CONTAINER_TYPE_NAMES.get(device_type, _("container"))
-- 
1.8.5.3



More information about the anaconda-patches mailing list