[PATCH 13/14] Normalize keyboard layout and variant strings from langtable
Vratislav Podzimek
vpodzime at redhat.com
Wed Sep 25 17:27:56 UTC 2013
Langtable uses e.g. 'cz(qwerty)' as a layout ('cz') and variant ('qwerty')
specification. However, we use strings like 'cz (qwerty)' (with a space
separating the fields) as IDs in dictionaries etc., so we need to normalize all
strings to the same format.
Related: rhbz#1006458
(cherry-picked 8cfac2bf646d91b75af174f89424d882cfd1500b from master)
Signed-off-by: Vratislav Podzimek <vpodzime at redhat.com>
---
pyanaconda/keyboard.py | 15 +++++++++++++++
pyanaconda/ui/gui/spokes/welcome.py | 5 +++--
2 files changed, 18 insertions(+), 2 deletions(-)
diff --git a/pyanaconda/keyboard.py b/pyanaconda/keyboard.py
index 138b4d0..70b67ce 100755
--- a/pyanaconda/keyboard.py
+++ b/pyanaconda/keyboard.py
@@ -112,6 +112,21 @@ def _join_layout_variant(layout, variant=""):
else:
return layout
+def normalize_layout_variant(layout_str):
+ """
+ Normalize keyboard layout and variant specification given as a single
+ string. E.g. for a 'layout(variant) string missing the space between the
+ left parenthesis return 'layout (variant)' which is a proper layout and
+ variant specification we use.
+
+ :param layout_str: a string specifying keyboard layout and its variant
+ :type layout_str: string
+
+ """
+
+ layout, variant = _parse_layout_variant(layout_str)
+ return _join_layout_variant(layout, variant)
+
def populate_missing_items(keyboard):
"""
Function that populates keyboard.vc_keymap and keyboard.x_layouts if
diff --git a/pyanaconda/ui/gui/spokes/welcome.py b/pyanaconda/ui/gui/spokes/welcome.py
index 90d3e10..45abe88 100644
--- a/pyanaconda/ui/gui/spokes/welcome.py
+++ b/pyanaconda/ui/gui/spokes/welcome.py
@@ -111,8 +111,9 @@ class WelcomeLanguageSpoke(LangLocaleHandler, StandaloneSpoke):
layouts = localization.get_locale_keyboards(locale)
if layouts:
- # take the first locale (with highest rank) from the list
- new_layouts = [layouts[0]]
+ # take the first locale (with highest rank) from the list and
+ # store it normalized
+ new_layouts = [keyboard.normalize_layout_variant(layouts[0])]
if not langtable.supports_ascii(layouts[0]):
# does not support typing ASCII chars, append the 'us' layout
new_layouts.append("us")
--
1.7.11.7
More information about the anaconda-patches
mailing list