Chromium Code Reviews| Index: tools/data_pack/repack.py |
| diff --git a/tools/data_pack/repack.py b/tools/data_pack/repack.py |
| index 21f568d11f0e842b4756fbad0801682047d173e3..8a0b5412aa435e9f9a9698b2d139d92e957d7422 100755 |
| --- a/tools/data_pack/repack.py |
| +++ b/tools/data_pack/repack.py |
| @@ -17,17 +17,30 @@ def RePack(output_file, input_files): |
| """Write a new data pack to |output_file| based on a list of filenames |
| (|input_files|)""" |
| resources = {} |
| + encoding = None |
| for filename in input_files: |
| - new_resources = data_pack.ReadDataPack(filename) |
| + new_content = data_pack.ReadDataPack(filename) |
| + #new_resources, new_encoding = data_pack.ReadDataPack(filename) |
|
tony
2011/08/30 21:19:58
Nit: You probably meant to remove this line.
marcvs
2011/08/30 22:17:22
Done.
|
| # Make sure we have no dups. |
| - duplicate_keys = set(new_resources.keys()) & set(resources.keys()) |
| + duplicate_keys = set(new_content.resources.keys()) & set(resources.keys()) |
| if len(duplicate_keys) != 0: |
| raise exceptions.KeyError("Duplicate keys: " + str(list(duplicate_keys))) |
| - resources.update(new_resources) |
| + # Make sure encoding is consistent. |
| + if encoding in (None, data_pack.BINARY): |
| + encoding = new_content.encoding |
| + elif new_content.encoding not in (data_pack.BINARY, encoding): |
| + raise exceptions.KeyError("Inconsistent encodings: " + |
| + str(encoding) + " vs " + |
| + str(new_content.encoding)) |
| - data_pack.WriteDataPack(resources, output_file) |
| + resources.update(new_content.resources) |
| + |
| + # Encoding is 0 for BINARY, 1 for UTF8 and 2 for UTF16 |
| + if encoding is None: |
| + encoding = data_pack.BINARY |
| + data_pack.WriteDataPack(resources, output_file, encoding) |
| def main(argv): |
| if len(argv) < 3: |