| OLD | NEW |
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
| 2 | 2 |
| 3 # Copyright 2014 The Chromium Authors. All rights reserved. | 3 # Copyright 2014 The Chromium Authors. All rights reserved. |
| 4 # Use of this source code is governed by a BSD-style license that can be | 4 # Use of this source code is governed by a BSD-style license that can be |
| 5 # found in the LICENSE file. | 5 # found in the LICENSE file. |
| 6 | 6 |
| 7 # This script updates the address_input_strings.grdp file based on the strings | 7 # This script updates the address_input_strings.grdp file based on the strings |
| 8 # in libaddressinput. | 8 # in libaddressinput. |
| 9 | 9 |
| 10 import os | 10 import os |
| 11 import sys | 11 import sys |
| 12 | 12 |
| 13 HEADER = """<!-- | 13 HEADER = """<!-- |
| 14 | 14 |
| 15 DO NOT MODIFY. | 15 DO NOT MODIFY. |
| 16 | 16 |
| 17 This file is generated by "gclient runhooks" from | 17 This file is generated by "gclient runhooks" from |
| 18 src/third_party/libaddressinput/src/cpp/res/messages.grdp. Submit modifications | 18 src/third_party/libaddressinput/src/cpp/res/messages.grdp. Submit modifications |
| 19 to the upstream library at https://libaddressinput.googlecode.com/. | 19 to the upstream library at https://libaddressinput.googlecode.com/. |
| 20 | 20 |
| 21 --> | 21 --> |
| 22 """ | 22 """ |
| 23 | 23 |
| 24 script_dir = os.path.dirname(os.path.realpath(__file__)) | 24 script_dir = os.path.dirname(os.path.realpath(__file__)) |
| 25 from_file = os.path.abspath(os.path.join( | 25 from_file = os.path.abspath(os.path.join( |
| 26 script_dir, os.pardir, os.pardir, 'src', 'cpp', 'res', 'messages.grdp')) | 26 script_dir, os.pardir, os.pardir, 'src', 'cpp', 'res', 'messages.grdp')) |
| 27 | |
| 28 if not os.path.isfile(from_file): | |
| 29 # Android and iOS do not use src/third_party/libaddressinput/src/. Gclient | |
| 30 # cannot filter out hooks based on OS or (when using git) based on file name | |
| 31 # patterns. | |
| 32 print('No libaddressinput for this target OS.') | |
| 33 sys.exit() | |
| 34 | |
| 35 to_file = os.path.abspath(os.path.join( | 27 to_file = os.path.abspath(os.path.join( |
| 36 script_dir, os.pardir, os.pardir, os.pardir, os.pardir, 'chrome', 'app', | 28 script_dir, os.pardir, os.pardir, os.pardir, os.pardir, 'chrome', 'app', |
| 37 'address_input_strings.grdp')) | 29 'address_input_strings.grdp')) |
| 38 | 30 |
| 39 with open(from_file, 'r') as source: | 31 with open(from_file, 'r') as source: |
| 40 with open(to_file, 'w') as destination: | 32 with open(to_file, 'w') as destination: |
| 41 destination.write(source.readline()) # XML declaration. | 33 destination.write(source.readline()) # XML declaration. |
| 42 destination.write(HEADER) | 34 destination.write(HEADER) |
| 43 destination.write(source.read()) | 35 destination.write(source.read()) |
| OLD | NEW |