[master][PATCH] Keyboard variant names may contain dashes (#1008730)
Vratislav Podzimek
vpodzime at redhat.com
Fri Sep 20 13:32:15 UTC 2013
On Fri, 2013-09-20 at 09:21 -0400, David Shea wrote:
> On 09/20/2013 09:12 AM, Vratislav Podzimek wrote:
> > Signed-off-by: Vratislav Podzimek <vpodzime at redhat.com>
> > ---
> > pyanaconda/keyboard.py | 2 +-
> > tests/pyanaconda_tests/keyboard_test.py | 6 +++++-
> > 2 files changed, 6 insertions(+), 2 deletions(-)
> >
> > diff --git a/pyanaconda/keyboard.py b/pyanaconda/keyboard.py
> > index 03d988a..e86771a 100644
> > --- a/pyanaconda/keyboard.py
> > +++ b/pyanaconda/keyboard.py
> > @@ -61,7 +61,7 @@ LOCALED_IFACE = "org.freedesktop.locale1"
> > # should match and parse strings like 'cz' or 'cz (qwerty)' regardless of white
> > # space
> > LAYOUT_VARIANT_RE = re.compile(r'^\s*(\w+)\s*' # layout plus
> > - r'(?:(?:\(\s*(\w+)\s*\))' # variant in parentheses
> > + r'(?:(?:\(\s*([-\w]+)\s*\))' # variant in parentheses
> > r'|(?:$))\s*') # or nothing
> >
> > # namedtuple for information about a keyboard layout (its language and description)
> > diff --git a/tests/pyanaconda_tests/keyboard_test.py b/tests/pyanaconda_tests/keyboard_test.py
> > index ca8aa38..1b8974d 100644
> > --- a/tests/pyanaconda_tests/keyboard_test.py
> > +++ b/tests/pyanaconda_tests/keyboard_test.py
> > @@ -25,11 +25,15 @@ class ParsingAndJoiningTests(unittest.TestCase):
> > def layout_variant_parsing_test(self):
> > """Should correctly parse keyboard layout and variant string specs."""
> >
> > - # a valid layout variant spec
> > + # valid layout variant specs
> > layout, variant = keyboard._parse_layout_variant("cz (qwerty)")
> > self.assertEqual(layout, "cz")
> > self.assertEqual(variant, "qwerty")
> >
> > + layout, variant = keyboard._parse_layout_variant("cz (dvorak-ucw)")
> > + self.assertEqual(layout, "cz")
> > + self.assertEqual(variant, "dvorak-ucw")
> > +
> > # a valid layout variant spec with no variant specified
> > layout, variant = keyboard._parse_layout_variant("cz")
> > self.assertEqual(layout, "cz")
> Ack, with a question on the test. Is it possible to test parsing every
> layout? Would that require an X display?
I was thinking about that, but yes, it would require an X display. Well,
unless we want to parse a lot of XML files on our own because that way
we could avoid initializing libxklavier's structures requiring the X
server running. But still it may result in an incomplete list.
--
Vratislav Podzimek
Anaconda Rider | Red Hat, Inc. | Brno - Czech Republic
More information about the anaconda-patches
mailing list