FAQ Search Today's Posts Mark Forums Read
» Video Reviews

» Linux Archive

Linux-archive is a website aiming to archive linux email lists and to make them easily accessible for linux users/developers.


» Sponsor

» Partners

» Sponsor

Go Back   Linux Archive > Debian > Debian User

 
 
LinkBack Thread Tools
 
Old 05-04-2012, 10:53 AM
Vratislav Podzimek
 
Default Modify keyboard command to handle multiple layouts

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
keyboard"
+ 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@redhat.com
https://www.redhat.com/mailman/listinfo/anaconda-devel-list
 

Thread Tools




All times are GMT. The time now is 05:31 AM.

VBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright 2007 - 2008, www.linux-archive.org