summaryrefslogtreecommitdiffstats
path: root/tools/gen_keyboard_overlay_data
diff options
context:
space:
mode:
authormazda@chromium.org <mazda@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-06-17 07:59:25 +0000
committermazda@chromium.org <mazda@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-06-17 07:59:25 +0000
commit2c046f04af7805b04463d8b742e55f21029b896a (patch)
tree07a16983ddf2aab8cfac489029445178c904805d /tools/gen_keyboard_overlay_data
parent04457cbe1a67e3846ebf39f6856b7c3c93490c95 (diff)
downloadchromium_src-2c046f04af7805b04463d8b742e55f21029b896a.zip
chromium_src-2c046f04af7805b04463d8b742e55f21029b896a.tar.gz
chromium_src-2c046f04af7805b04463d8b742e55f21029b896a.tar.bz2
Revert "Revert "Remove duplicate entries from the keyboard overlay code.""
Fixed gen_keyboard_overlay_data.py in order not to generate duplicated entries in cc and grd files and using it to create this patch. This reverts commit 8f5c2e9ed0cd58b1106f60de012a1eaba03d33bd. BUG=none TEST=Built chrome with the generated data. Review URL: http://codereview.chromium.org/7189010 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@89450 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'tools/gen_keyboard_overlay_data')
-rwxr-xr-xtools/gen_keyboard_overlay_data/gen_keyboard_overlay_data.py16
1 files changed, 14 insertions, 2 deletions
diff --git a/tools/gen_keyboard_overlay_data/gen_keyboard_overlay_data.py b/tools/gen_keyboard_overlay_data/gen_keyboard_overlay_data.py
index 18f3735..dd40249 100755
--- a/tools/gen_keyboard_overlay_data/gen_keyboard_overlay_data.py
+++ b/tools/gen_keyboard_overlay_data/gen_keyboard_overlay_data.py
@@ -340,6 +340,18 @@ def GenerateCopyrightHeader():
return COPYRIGHT_HEADER_TEMPLATE % datetime.date.today().year
+def UniqueBehaviors(hotkey_data):
+ """Retrieves a list of unique behaviors from |hotkey_data|."""
+ behaviors = []
+ added = set()
+ for (behavior, _) in hotkey_data:
+ if behavior in added:
+ continue
+ behaviors.append(behavior)
+ added.add(behavior)
+ return behaviors
+
+
def OutputJson(keyboard_glyph_data, hotkey_data, layouts, var_name, outfile):
"""Outputs the keyboard overlay data as a JSON file."""
print 'Generating: %s' % outfile
@@ -363,7 +375,7 @@ def OutputGrd(hotkey_data, outfile):
print 'Generating: %s' % outfile
desc = 'The text in the keyboard overlay to explain the shortcut.'
out = file(outfile, 'w')
- for (behavior, _) in hotkey_data:
+ for behavior in UniqueBehaviors(hotkey_data):
out.write(GRD_SNIPPET_TEMPLATE % (ToMessageName(behavior), desc, behavior))
@@ -371,7 +383,7 @@ def OutputCC(hotkey_data, outfile):
"""Outputs a snippet used for C++ file."""
print 'Generating: %s' % outfile
out = file(outfile, 'w')
- for (behavior, _) in hotkey_data:
+ for behavior in UniqueBehaviors(hotkey_data):
message_name = ToMessageName(behavior)
# Indent the line if message_name is longer than 45 characters, which means
# the second line in the generated code is longer than 80 characters.