| OLD | NEW |
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
| 2 # Copyright 2015 The Chromium Authors. All rights reserved. | 2 # Copyright 2015 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 import os | 6 import os |
| 7 import sys | 7 import sys |
| 8 import hashlib | 8 import hashlib |
| 9 | 9 |
| 10 in_file = sys.argv[1] | 10 in_file = sys.argv[1] |
| (...skipping 12 matching lines...) Expand all Loading... |
| 23 | 23 |
| 24 values = ["0x%02x" % ord(c) for c in data] | 24 values = ["0x%02x" % ord(c) for c in data] |
| 25 lines = [] | 25 lines = [] |
| 26 chunk_size = 16 | 26 chunk_size = 16 |
| 27 for i in range(0, len(values), chunk_size): | 27 for i in range(0, len(values), chunk_size): |
| 28 lines.append(", ".join(values[i: i + chunk_size])) | 28 lines.append(", ".join(values[i: i + chunk_size])) |
| 29 | 29 |
| 30 with open(out_file, "w") as f: | 30 with open(out_file, "w") as f: |
| 31 f.write('#include "services/icu_data/data.h"\n') | 31 f.write('#include "services/icu_data/data.h"\n') |
| 32 f.write("namespace icu_data {\n") | 32 f.write("namespace icu_data {\n") |
| 33 f.write("const char kICUDataTable[] = {\n") | 33 f.write("const char kICUDataTable[%d] = {\n" % len(data)) |
| 34 f.write(",\n".join(lines)) | 34 f.write(",\n".join(lines)) |
| 35 f.write("\n};\n") | 35 f.write("\n};\n") |
| 36 f.write("const size_t kICUDataTableSize = sizeof(kICUDataTable);\n") | 36 f.write("const size_t kICUDataTableSize = sizeof(kICUDataTable);\n") |
| 37 f.write("const char kICUDataTableHash[] = \"%s\";\n" % sha1hash) | 37 f.write("const char kICUDataTableHash[] = \"%s\";\n" % sha1hash) |
| 38 f.write("}\n") | 38 f.write("}\n") |
| OLD | NEW |