OLD | NEW |
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # Copyright 2013 The Chromium Authors. All rights reserved. | 2 # Copyright 2013 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 """Embeds Chrome user data files in C++ code.""" | 6 """Embeds Chrome user data files in C++ code.""" |
7 | 7 |
8 import optparse | 8 import optparse |
9 import os | 9 import os |
10 import sys | 10 import sys |
11 | 11 |
12 import cpp_source | 12 import cpp_source |
13 | 13 |
14 | 14 |
15 def main(): | 15 def main(): |
16 parser = optparse.OptionParser() | 16 parser = optparse.OptionParser() |
17 parser.add_option( | 17 parser.add_option( |
18 '', '--directory', type='string', default='.', | 18 '', '--directory', type='string', default='.', |
19 help='Path to directory where the cc/h file should be created') | 19 help='Path to directory where the cc/h file should be created') |
20 options, args = parser.parse_args() | 20 options, args = parser.parse_args() |
21 | 21 |
22 global_string_map = {} | 22 global_string_map = {} |
23 for data_file in args: | 23 for data_file in args: |
24 title = os.path.basename(os.path.splitext(data_file)[0]).title() | 24 title = os.path.basename(os.path.splitext(data_file)[0]).title() |
25 var_name = 'k' + title.replace('_', '') | 25 var_name = 'k' + title.replace('_', '') |
26 with open(data_file, 'r') as f: | 26 with open(data_file, 'r') as f: |
27 contents = f.read() | 27 contents = f.read() |
28 global_string_map[var_name] = contents | 28 global_string_map[var_name] = contents |
29 | 29 |
30 cpp_source.WriteSource('user_data_dir', 'chrome/test/chromedriver', | 30 cpp_source.WriteSource('user_data_dir', 'chrome/test/chromedriver/chrome', |
31 options.directory, global_string_map) | 31 options.directory, global_string_map) |
32 | 32 |
33 | 33 |
34 if __name__ == '__main__': | 34 if __name__ == '__main__': |
35 sys.exit(main()) | 35 sys.exit(main()) |
OLD | NEW |