#!/usr/bin/python # Copyright (C) 2014 by Steve Litt # Expat license: http://directory.fsf.org/wiki/License:Expat # See COPYING.EXPAT file that comes with this software. from __future__ import print_function import sys import re there_are_dups = False hotkeys={} for line in sys.stdin: line = line.strip() if re.search('gtk_accel_path', line): line = re.sub('.*gtk_accel_path\s*', '', line) line = re.sub('\)\s*', '', line) #hotkey = re.sub('\s*"[^"]+"', '', line) hotkey = re.sub('^[^"]*"[^"]+"', '', line) action = re.sub('\s*' + hotkey, '', line) hotkey = re.sub('"', '', hotkey) hotkey = hotkey.strip() action = re.sub('"', '', action) if hotkey != '': if hotkey in hotkeys: hotkeys[hotkey]['quantity'] += 1 hotkeys[hotkey]['actions'].append(action) there_are_dups = True else: hotkeys[hotkey] = {'quantity': 1, 'actions': [action]} if there_are_dups: print('FOLLOWING HOTKEYS HAVE MULTIPLE ACTIONS: THIS IS AN ERROR:\n') for hotkey in sorted(hotkeys.iterkeys()): quantity = hotkeys[hotkey]['quantity'] actions = hotkeys[hotkey]['actions'] if quantity > 1: print('{} instances of hotkey {}:'.format(str(quantity), hotkey)) for action in actions: print(' {}'.format(action)) print('\n\n\nFOLLOWING HOTKEYS HAVE ONLY ONE ACTION:\n') for hotkey in sorted(hotkeys.iterkeys()): quantity = hotkeys[hotkey]['quantity'] actions = hotkeys[hotkey]['actions'] if quantity == 1: print('Hotkey={}: Action={}'.format(hotkey, action))