[f22-branch 1/1] Empty label means default label (#1141981)

bcl installerbot-noreply at redhat.com
Wed Mar 11 18:41:10 UTC 2015


From: "Brian C. Lane" <bcl at redhat.com>

If the label UI entry is blank use the default label for the filesystem.
This is normally a blank label, except for the Linux HFS+ ESP partition.

Thanks to mulhern for the code.
---
 pyanaconda/ui/gui/spokes/custom.py                     | 12 ++++--------
 pyanaconda/ui/gui/spokes/lib/custom_storage_helpers.py | 12 +++++-------
 2 files changed, 9 insertions(+), 15 deletions(-)

diff --git a/pyanaconda/ui/gui/spokes/custom.py b/pyanaconda/ui/gui/spokes/custom.py
index a278842..8462294 100644
--- a/pyanaconda/ui/gui/spokes/custom.py
+++ b/pyanaconda/ui/gui/spokes/custom.py
@@ -977,8 +977,8 @@ def _save_right_side(self, selector):
         new_device_info["encrypted"] = encrypted
 
         # FS LABEL
-        label = self._labelEntry.get_text()
-        old_label = getattr(device.format, "label", "")
+        label = self._labelEntry.get_text() or None
+        old_label = getattr(device.format, "label", None)
         changed_label = (label != old_label)
         old_device_info["label"] = old_label
         new_device_info["label"] = label
@@ -1475,12 +1475,8 @@ def _populate_right_side(self, selector):
         self._mountPointEntry.set_text(getattr(device.format, "mountpoint", "") or "")
         fancy_set_sensitive(self._mountPointEntry, device.format.mountable)
 
-        if hasattr(device.format, "label"):
-            if device.format.label is None:
-                device.format.label = ""
-            self._labelEntry.set_text(device.format.label)
-        else:
-            self._labelEntry.set_text("")
+        # The empty string signifies None, i.e., accept the default label
+        self._labelEntry.set_text(getattr(device.format, "label", "") or "")
         fancy_set_sensitive(self._labelEntry, True)
 
         self._sizeEntry.set_text(device.size.humanReadable(max_places=self.MAX_SIZE_PLACES))
diff --git a/pyanaconda/ui/gui/spokes/lib/custom_storage_helpers.py b/pyanaconda/ui/gui/spokes/lib/custom_storage_helpers.py
index 42d0e63..3a823d8 100644
--- a/pyanaconda/ui/gui/spokes/lib/custom_storage_helpers.py
+++ b/pyanaconda/ui/gui/spokes/lib/custom_storage_helpers.py
@@ -129,18 +129,16 @@ def validate_label(label, fmt):
        stands for accept the default, but in the case where the format can
        assign a label the empty string represents itself.
 
-       :param str label: The label
+       :param label: The label
+       :type label: str or NoneType
        :param DeviceFormat fmt: The device format to label
 
     """
     if fmt.exists:
         return _("Cannot relabel already existing file system.")
-    if not fmt.labeling():
-        if label == "":
-            return ""
-        else:
-            return _("Cannot set label on file system.")
-    if not fmt.labelFormatOK(label):
+    if not fmt.labeling() and label:
+        return _("Cannot set label on file system.")
+    elif not fmt.labelFormatOK(label):
         return _("Unacceptable label format for file system.")
     return ""
 


-- 
To view this commit on github, visit https://github.com/rhinstaller/anaconda/commit/957e719fb824f34ba9eb647d9ff64ec4f29ae902


More information about the anaconda-patches mailing list