From 6c0cb0dada52a0d189517d125f57e86cffaf0d9e Mon Sep 17 00:00:00 2001 From: Marco Herrn Date: Thu, 27 Apr 2023 23:13:31 +0200 Subject: [PATCH] Fix stripping of enclosing parentheses The current code strips _all_ surrounding parentheses, while only the outermost should be stripped. This commit changes this. Closes https://github.com/yskoht/keymapviz/issues/91 --- keymapviz/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/keymapviz/__init__.py b/keymapviz/__init__.py index 0b5b126..769d1b8 100644 --- a/keymapviz/__init__.py +++ b/keymapviz/__init__.py @@ -80,7 +80,7 @@ def __parse_keymap_c(self): r'\s*(\w+(?\((?:[^()]|(?&rec))*\))*)\s*,?' ) keymaps = keymap_regexp.findall(src) - keymaps = [_.lstrip('(').rstrip(')') for _ in keymaps] + keymaps = [re.sub(r"^\(?(.*)\)?$", r"\1", _) for _ in keymaps] keymaps = [[__[0] for __ in keycode_regexp.findall(_)] for _ in keymaps] return keymaps