From e629ea89ffe7e30c1f766bcf65492bf3b5be443b Mon Sep 17 00:00:00 2001 From: Lipu Fei Date: Thu, 13 Sep 2018 10:55:33 +0200 Subject: Improve shortcut check script CURA-5642 More information in the output. --- scripts/check_shortcut_keys.py | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) (limited to 'scripts') diff --git a/scripts/check_shortcut_keys.py b/scripts/check_shortcut_keys.py index 2796002c3f..a47a8143f7 100644 --- a/scripts/check_shortcut_keys.py +++ b/scripts/check_shortcut_keys.py @@ -85,10 +85,12 @@ class ShortcutKeysChecker: msg_section = data_dict[self.MSGCTXT] keys_dict = shortcut_dict[msg_section] if shortcut_key not in keys_dict: - keys_dict[shortcut_key] = dict() - existing_data_dict = keys_dict[shortcut_key] + keys_dict[shortcut_key] = {"shortcut_key": shortcut_key, + "section": msg_section, + "existing_lines": dict(), + } + existing_data_dict = keys_dict[shortcut_key]["existing_lines"] existing_data_dict[start_line] = {"message": msg, - "shortcut_key": shortcut_key, } def _get_shortcut_key(self, text: str) -> Optional[str]: @@ -105,16 +107,18 @@ class ShortcutKeysChecker: has_duplicates = False for keys_dict in shortcut_dict.values(): for shortcut_key, data_dict in keys_dict.items(): - if len(data_dict) == 1: + if len(data_dict["existing_lines"]) == 1: continue has_duplicates = True print("") print("The following messages have the same shortcut key '%s':" % shortcut_key) - for line, msg in data_dict.items(): + print(" shortcut: '%s'" % data_dict["shortcut_key"]) + print(" section : '%s'" % data_dict["section"]) + for line, msg in data_dict["existing_lines"].items(): relative_filename = (filename.rsplit("..", 1)[-1])[1:] - print(" - [%s] L%7d : [%s]" % (relative_filename, line, msg)) + print(" - [%s] L%7d : '%s'" % (relative_filename, line, msg["message"])) return has_duplicates -- cgit v1.2.3 From 7a3e61e8f113b4285d04db27d69631aa347596a3 Mon Sep 17 00:00:00 2001 From: Lipu Fei Date: Thu, 13 Sep 2018 10:56:27 +0200 Subject: chmod a+x check_shortcut_keys.py CURA-5642 --- scripts/check_shortcut_keys.py | 0 1 file changed, 0 insertions(+), 0 deletions(-) mode change 100644 => 100755 scripts/check_shortcut_keys.py (limited to 'scripts') diff --git a/scripts/check_shortcut_keys.py b/scripts/check_shortcut_keys.py old mode 100644 new mode 100755 -- cgit v1.2.3