[PATCH 3/3] Modify keyboard command to handle multiple layouts

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



We want to let the user to set up multiple keyboard layouts but
in the same time we want to preserve backwards compatibility.
---
 pykickstart/commands/keyboard.py |   37 +++++++++++++++++++++++++++++++++++++
 pykickstart/handlers/control.py  |    2 +-
 tests/commands/keyboard.py       |   13 +++++++++++++
 3 files changed, 51 insertions(+), 1 deletions(-)

diff --git a/pykickstart/commands/keyboard.py b/pykickstart/commands/keyboard.py
index babc2ac..ed4d7f6 100644
--- a/pykickstart/commands/keyboard.py
+++ b/pykickstart/commands/keyboard.py
@@ -53,3 +53,40 @@ class FC3_Keyboard(KickstartCommand):
 
         self.keyboard = extra[0]
         return self
+
+class F18_Keyboard(FC3_Keyboard):
+    def __init__(self, writePriority=0, *args, **kwargs):
+        FC3_Keyboard.__init__(self, writePriority, *args, **kwargs)
+        self.op = self._getParser()
+        self.layouts_list = kwargs.get("layouts_list", [])
+
+    def __str__(self):
+        if not self.layouts_list:
+            return ""
+
+        retval = "# Keyboard layouts\nkeyboard"
+        for layout in self.layouts_list:
+            retval += " %s" % layout
+
+        return retval
+
+    def parse(self, args):
+        (opts, extra) = self.op.parse_args(args=args, lineno=self.lineno)
+
+        if len(extra) < 1:
+            raise KickstartValueError, formatErrorMsg(self.lineno, msg=_("Kickstart command %s requires at least"\
+                                                                         "one argument") % "keyboard")
+        self.layouts_list = extra
+        return self
+
+    @property
+    def keyboard(self):
+        if self.layouts_list:
+            return self.layouts_list[0]
+
+        else:
+            return ""
+
+    @keyboard.setter
+    def keyboard(self, value):
+        self.layouts_list = [value]
diff --git a/pykickstart/handlers/control.py b/pykickstart/handlers/control.py
index ab610b9..6fe7c10 100644
--- a/pykickstart/handlers/control.py
+++ b/pykickstart/handlers/control.py
@@ -910,7 +910,7 @@ commandMap = {
         "install": upgrade.F11_Upgrade,
         "iscsi": iscsi.F17_Iscsi,
         "iscsiname": iscsiname.FC6_IscsiName,
-        "keyboard": keyboard.FC3_Keyboard,
+        "keyboard": keyboard.F18_Keyboard,
         "lang": lang.FC3_Lang,
         "logging": logging.FC6_Logging,
         "logvol": logvol.F17_LogVol,
diff --git a/tests/commands/keyboard.py b/tests/commands/keyboard.py
index eec7b18..a21b4d3 100644
--- a/tests/commands/keyboard.py
+++ b/tests/commands/keyboard.py
@@ -36,5 +36,18 @@ class FC3_TestCase(CommandTest):
         self.assert_parse_error("keyboard us uk", KickstartValueError)
         self.assert_parse_error("keyboard --foo us", KickstartParseError)
 
+class F18_TestCase(FC3_TestCase):
+    command = "keyboard"
+
+    def runTest(self):
+        self.assert_parse("keyboard us")
+
+        # we now support defining multiple layouts
+        self.assert_parse("keyboard us cz")
+
+        # fail
+        self.assert_parse_error("keyboard", KickstartValueError)
+        self.assert_parse_error("keyboard --foo us", KickstartParseError)
+
 if __name__ == "__main__":
     unittest.main()
-- 
1.7.4.4

_______________________________________________
Anaconda-devel-list mailing list
Anaconda-devel-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/anaconda-devel-list


[Index of Archives]     [Kickstart]     [Fedora Users]     [Fedora Legacy List]     [Fedora Maintainers]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [Yosemite Photos]     [KDE Users]     [Fedora Tools]
  Powered by Linux