[f18-branch] [PATCH] Check country_layouts is not None when using it (#893026)

Vratislav Podzimek vpodzime at redhat.com
Wed Jan 9 11:41:34 UTC 2013


In get_default_lang_country_layout we may have some layouts specified
for the given language and none for the given country. In such case
we should just return the first matching the given language. And vice
versa if there is no layout for the given language but there is some for
the given country.

Signed-off-by: Vratislav Podzimek <vpodzime at redhat.com>
---
 pyanaconda/keyboard.py | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/pyanaconda/keyboard.py b/pyanaconda/keyboard.py
index 98b4e19..7309709 100755
--- a/pyanaconda/keyboard.py
+++ b/pyanaconda/keyboard.py
@@ -469,15 +469,23 @@ class XklWrapper(object):
     def get_default_lang_country_layout(self, language, country):
         """
         Get default layout matching both language and country. If none such
-        layout is found, get default layout for language.
+        layout is found, get default layout for language. If no layout for
+        the given language is found but there is layout for the given country,
+        return the one for the country.
 
         """
 
         language_layouts = self.get_language_layouts(language)
         country_layouts = self._country_keyboard_variants.get(country, None)
-        if not language_layouts:
+        if not language_layouts and not country_layouts:
             return None
 
+        if not country_layouts:
+            return language_layouts[0].name
+
+        if not language_layouts:
+            return country_layouts[0].name
+
         matches_both = (layout for layout in language_layouts
                                 if layout in country_layouts)
 
-- 
1.7.11.7



More information about the anaconda-patches mailing list