Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(365)

Side by Side Diff: chromeos/ime/gen_input_methods.py

Issue 22980018: Disable non Latin keyboard layout on Lock screen and Sign-in screen. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix test case. Created 7 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chromeos/ime/component_extension_ime_manager.cc ('k') | chromeos/ime/input_method_descriptor.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. 2 # Copyright (c) 2012 The Chromium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be 3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file. 4 # found in the LICENSE file.
5 5
6 """Generate a C++ header from ibus_input_methods.txt. 6 """Generate a C++ header from ibus_input_methods.txt.
7 7
8 This program generates a C++ header file containing the information on 8 This program generates a C++ header file containing the information on
9 available input methods. It parses input_methods.txt, and then generates a 9 available input methods. It parses input_methods.txt, and then generates a
10 static array definition from the information extracted. The input and output 10 static array definition from the information extracted. The input and output
11 file names are specified on the command line. 11 file names are specified on the command line.
12 12
13 Run it like: 13 Run it like:
14 gen_input_methods.py input_methods.txt input_methods.h 14 gen_input_methods.py input_methods.txt input_methods.h
15 15
16 It will produce output that looks like: 16 It will produce output that looks like:
17 17
18 // This file is automatically generated by gen_input_methods.py 18 // This file is automatically generated by gen_input_methods.py
19 #ifndef CHROME_BROWSER_CHROMEOS_INPUT_METHOD_INPUT_METHODS_H_ 19 #ifndef CHROME_BROWSER_CHROMEOS_INPUT_METHOD_INPUT_METHODS_H_
20 #define CHROME_BROWSER_CHROMEOS_INPUT_METHOD_INPUT_METHODS_H_ 20 #define CHROME_BROWSER_CHROMEOS_INPUT_METHOD_INPUT_METHODS_H_
21 21
22 namespace chromeos { 22 namespace chromeos {
23 namespace input_method { 23 namespace input_method {
24 24
25 struct InputMethodsInfo { 25 struct InputMethodsInfo {
26 const char* input_method_id; 26 const char* input_method_id;
27 const char* language_code; 27 const char* language_code;
28 const char* xkb_keyboard_id; 28 const char* xkb_keyboard_id;
29 bool is_login_keyboard;
29 }; 30 };
30 const InputMethodsInfo kInputMethods[] = { 31 const InputMethodsInfo kInputMethods[] = {
31 {"mozc-chewing", "zh-TW", "us"}, 32 {"xkb:us::eng", "en-US", "us", true},
32 {"xkb:us::eng", "en-US", "us"}, 33 {"xkb:us:dvorak:eng", "en-US", "us(dvorak)", true},
33 {"xkb:us:dvorak:eng", "en-US", "us(dvorak)"}, 34 {"xkb:be::fra", "fr", "be", true},
34 {"xkb:be::fra", "fr", "be"}, 35 {"xkb:br::por", "pt-BR", "br", true},
35 {"xkb:br::por", "pt-BR", "br"}, 36 {"xkb:ru::rus", "ru", "ru", false},
36 }; 37 };
37 38
38 } // namespace input_method 39 } // namespace input_method
39 } // namespace chromeos 40 } // namespace chromeos
40 41
41 #endif // CHROME_BROWSER_CHROMEOS_INPUT_METHOD_INPUT_METHODS_H_ 42 #endif // CHROME_BROWSER_CHROMEOS_INPUT_METHOD_INPUT_METHODS_H_
42 43
43 """ 44 """
44 45
45 import fileinput 46 import fileinput
46 import re 47 import re
47 import sys 48 import sys
48 49
49 OUTPUT_HEADER = """// Automatically generated by gen_input_methods.py 50 OUTPUT_HEADER = """// Automatically generated by gen_input_methods.py
50 #ifndef CHROME_BROWSER_CHROMEOS_INPUT_METHOD_INPUT_METHODS_H_ 51 #ifndef CHROME_BROWSER_CHROMEOS_INPUT_METHOD_INPUT_METHODS_H_
51 #define CHROME_BROWSER_CHROMEOS_INPUT_METHOD_INPUT_METHODS_H_ 52 #define CHROME_BROWSER_CHROMEOS_INPUT_METHOD_INPUT_METHODS_H_
52 53
53 namespace chromeos { 54 namespace chromeos {
54 namespace input_method { 55 namespace input_method {
55 56
56 struct InputMethodsInfo { 57 struct InputMethodsInfo {
57 const char* input_method_id; 58 const char* input_method_id;
58 const char* language_code; 59 const char* language_code;
59 const char* xkb_layout_id; 60 const char* xkb_layout_id;
61 bool is_login_keyboard;
60 }; 62 };
61 const InputMethodsInfo kInputMethods[] = { 63 const InputMethodsInfo kInputMethods[] = {
62 """ 64 """
63 65
64 CPP_FORMAT = '#if %s\n' 66 CPP_FORMAT = '#if %s\n'
65 ENGINE_FORMAT = (' {"%(input_method_id)s", "%(language_code)s", ' + 67 ENGINE_FORMAT = (' {"%(input_method_id)s", "%(language_code)s", ' +
66 '"%(xkb_layout_id)s"},\n') 68 '"%(xkb_layout_id)s", %(is_login_keyboard)s},\n')
67 69
68 OUTPUT_FOOTER = """ 70 OUTPUT_FOOTER = """
69 }; 71 };
70 72
71 } // namespace input_method 73 } // namespace input_method
72 } // namespace chromeos 74 } // namespace chromeos
73 75
74 #endif // CHROME_BROWSER_CHROMEOS_INPUT_METHOD_INPUT_METHODS_H_ 76 #endif // CHROME_BROWSER_CHROMEOS_INPUT_METHOD_INPUT_METHODS_H_
75 """ 77 """
76 78
(...skipping 26 matching lines...) Expand all
103 for line in fileinput.input(sys.argv[1]): 105 for line in fileinput.input(sys.argv[1]):
104 line = line.strip() 106 line = line.strip()
105 if not line or re.match(r'#', line): 107 if not line or re.match(r'#', line):
106 continue 108 continue
107 columns = line.split() 109 columns = line.split()
108 assert len(columns) == 3 or len(columns) == 4, "Invalid format: " + line 110 assert len(columns) == 3 or len(columns) == 4, "Invalid format: " + line
109 engine = {} 111 engine = {}
110 engine['input_method_id'] = columns[0] 112 engine['input_method_id'] = columns[0]
111 engine['xkb_layout_id'] = columns[1] 113 engine['xkb_layout_id'] = columns[1]
112 engine['language_code'] = columns[2] 114 engine['language_code'] = columns[2]
115 is_login_keyboard = "false"
113 if len(columns) == 4: 116 if len(columns) == 4:
114 engine['if'] = columns[3] 117 assert columns[3] == "login", "Invalid attribute: " + columns[3]
118 is_login_keyboard = "true"
119 engine['is_login_keyboard'] = is_login_keyboard
115 engines.append(engine) 120 engines.append(engine)
116 121
117 output = CreateEngineHeader(engines) 122 output = CreateEngineHeader(engines)
118 output_file = open(sys.argv[2], 'w') 123 output_file = open(sys.argv[2], 'w')
119 output_file.write(output) 124 output_file.write(output)
120 125
121 126
122 if __name__ == '__main__': 127 if __name__ == '__main__':
123 main(sys.argv) 128 main(sys.argv)
OLDNEW
« no previous file with comments | « chromeos/ime/component_extension_ime_manager.cc ('k') | chromeos/ime/input_method_descriptor.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698