summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVitezslav Crhonek <vcrhonek@redhat.com>2014-06-19 15:36:51 +0200
committerVitezslav Crhonek <vcrhonek@redhat.com>2014-06-19 15:36:51 +0200
commit4f05bb193b150b09ab9ee2e0bd57c604e9e0737f (patch)
tree4fe0b65a57509a9a0ffe49dbca51fb4dfdd0e6e8
parent4775bd70f47f1e7be64e9a9992035417613cac80 (diff)
downloadopenlmi-scripts-4f05bb193b150b09ab9ee2e0bd57c604e9e0737f.tar.gz
openlmi-scripts-4f05bb193b150b09ab9ee2e0bd57c604e9e0737f.tar.xz
openlmi-scripts-4f05bb193b150b09ab9ee2e0bd57c604e9e0737f.zip
locale: various minor fixes
-rw-r--r--commands/locale/doc/python.rst4
-rw-r--r--commands/locale/lmi/scripts/locale/__init__.py59
-rw-r--r--commands/locale/lmi/scripts/locale/cmd.py14
3 files changed, 29 insertions, 48 deletions
diff --git a/commands/locale/doc/python.rst b/commands/locale/doc/python.rst
index c2471f7..e9fb7e3 100644
--- a/commands/locale/doc/python.rst
+++ b/commands/locale/doc/python.rst
@@ -1,6 +1,6 @@
Python reference for OpenLMI client scripts
===========================================
-Local Module API
-----------------
+Locale Module API
+-----------------
.. automodule:: lmi.scripts.locale
:members:
diff --git a/commands/locale/lmi/scripts/locale/__init__.py b/commands/locale/lmi/scripts/locale/__init__.py
index 03b5764..2bd8e1b 100644
--- a/commands/locale/lmi/scripts/locale/__init__.py
+++ b/commands/locale/lmi/scripts/locale/__init__.py
@@ -56,17 +56,14 @@ def set_locale(ns, locales, values):
"""
Set given locale variables with new values.
- :type locales: list of strings
- :param locales: Locale variables to be set.
- :type values: list of strings
- :param values: New values for locale variables.
+ :param list locales: List of locale variable names to be set.
+ :param list values: List of new values for locale variables.
"""
inst = get_locale(ns)
- method = 'SetLocale'
args = {l: v for l, v in zip(locales, values)}
- (rval, _, errorstr) = getattr(inst, method)(**args)
+ (rval, _, errorstr) = inst.SetLocale(**args)
if rval != 0:
if errorstr:
raise LmiFailed("Cannot set locale: %s.", errorstr)
@@ -79,27 +76,22 @@ def set_vc_keyboard(ns, keymap, keymap_toggle, convert):
"""
Set the key mapping on the virtual console.
- :type keymap: string
- :param keymap: Requested keyboard mapping for the
+ :param string keymap: Requested keyboard mapping for the
virtual console.
- :type keymap_toggle: string
- :param keymap_toggle: Requested toggle keyboard
+ :param string keymap_toggle: Requested toggle keyboard
mapping for the virtual console.
- :type convert: bool
- :param convert: Whether also X11 keyboard should be set
+ :param bool convert: Whether also X11 keyboard should be set
to the nearest X11 keyboard setting for the chosen
console keyboard setting.
"""
inst = get_locale(ns)
- method = 'SetVConsoleKeyboard'
- args = {
- 'Keymap': keymap,
- 'KeymapToggle': keymap_toggle,
- 'Convert': convert,
- }
- (rval, _, errorstr) = getattr(inst, method)(**args)
+ (rval, _, errorstr) = inst.SetVConsoleKeyboard(
+ Keymap=keymap,
+ KeymapToggle=keymap_toggle,
+ Convert=convert
+ )
LOG().info("Virtual console keyboard set to '%s'.", keymap)
if keymap_toggle:
@@ -112,31 +104,26 @@ def set_x11_keymap(ns, layouts, model, variant, options, convert):
"""
Set the default key mapping of the X11 server.
- :type layouts: string
- :param layouts: Requested X11 keyboard mappings.
- :type model: string
- :param model: Requested X11 keyboard model.
- :type variant: string
- :param model: Requested X11 keyboard variant.
- :type options: string
- :param model: Requested X11 keyboard options.
- :type convert: bool
- :param convert: Whether also console keyboard should be set
+ :param string layouts: Requested X11 keyboard mappings.
+ :param string model: Requested X11 keyboard model.
+ :param string variant: Requested X11 keyboard variant.
+ :param string options: Requested X11 keyboard options.
+ :param bool convert: Whether also console keyboard should be set
to the nearest console keyboard setting for the chosen
X11 keyboard setting.
"""
inst = get_locale(ns)
- method = 'SetX11Keyboard'
args = {
- 'Layouts': layouts,
- 'Model': model,
- 'Variant': variant,
- 'Options': options,
- 'Convert': convert,
}
- (rval, _, errorstr) = getattr(inst, method)(**args)
+ (rval, _, errorstr) = inst.SetX11Keyboard(
+ Layouts=layouts,
+ Model=model,
+ Variant=variant,
+ Options=options,
+ Convert=convert,
+ )
LOG().info("Default X11 keyboard mapping set to '%s'.", layouts)
if model:
diff --git a/commands/locale/lmi/scripts/locale/cmd.py b/commands/locale/lmi/scripts/locale/cmd.py
index c0fcb13..5fb36a1 100644
--- a/commands/locale/lmi/scripts/locale/cmd.py
+++ b/commands/locale/lmi/scripts/locale/cmd.py
@@ -108,28 +108,22 @@ class SetLocale(command.LmiCheckResult):
class SetX11Keymap(command.LmiCheckResult):
EXPECT = None
- def execute(self, ns, layouts, model, variant, options, _convert):
- convert = False
- if _convert:
- convert = True
+ def execute(self, ns, layouts, model, variant, options, _convert=False):
if not model:
model = ''
if not variant:
variant = ''
if not options:
options = ''
- loc.set_x11_keymap(ns, layouts, model, variant, options, convert)
+ loc.set_x11_keymap(ns, layouts, model, variant, options, _convert)
class SetVCKeyboard(command.LmiCheckResult):
EXPECT = None
- def execute(self, ns, keymap, keymap_toggle, _convert):
- convert = False
- if _convert:
- convert = True
+ def execute(self, ns, keymap, keymap_toggle, _convert=False):
if not keymap_toggle:
keymap_toggle = ''
- loc.set_vc_keyboard(ns, keymap, keymap_toggle, convert)
+ loc.set_vc_keyboard(ns, keymap, keymap_toggle, _convert)
Locale = command.register_subcommands(
'Locale', __doc__,