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

Unified Diff: tools/data_pack/repack.py

Issue 7744017: Updated *.pak file format to support both UTF8 and UTF16 (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Cleaned up comments/ Created 9 years, 4 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 side-by-side diff with in-line comments
Download patch
Index: tools/data_pack/repack.py
diff --git a/tools/data_pack/repack.py b/tools/data_pack/repack.py
index 21f568d11f0e842b4756fbad0801682047d173e3..be368f7db1f22bcfffcca98f47e5b57dc503424e 100755
--- a/tools/data_pack/repack.py
+++ b/tools/data_pack/repack.py
@@ -17,17 +17,29 @@ 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_resources, new_encoding = data_pack.ReadDataPack(filename)
# Make sure we have no dups.
duplicate_keys = set(new_resources.keys()) & set(resources.keys())
if len(duplicate_keys) != 0:
raise exceptions.KeyError("Duplicate keys: " + str(list(duplicate_keys)))
+ # Make sure encoding is consistent.
+ if (encoding is None or encoding is data_pack.BINARY):
tony 2011/08/29 21:24:39 Nit: no () around the condition and I would write
marcvs 2011/08/30 07:58:55 Done.
+ encoding = new_encoding
+ else:
+ if (new_encoding != data_pack.BINARY and encoding != new_encoding):
tony 2011/08/29 21:24:39 Nit: no () around the condition and use elif.
marcvs 2011/08/30 07:58:55 Done.
+ raise exceptions.KeyError("Inconsistent encodings: " +
+ str(encoding) + " vs " + str(new_encoding))
+
resources.update(new_resources)
- data_pack.WriteDataPack(resources, output_file)
+ # Encoding is 0 for BINARY, 1 for UTF8 and 2 for UTF16
+ if (encoding is None):
tony 2011/08/29 21:24:39 Nit: no () around the condition
marcvs 2011/08/30 07:58:55 Done.
+ encoding = data_pack.BINARY
+ data_pack.WriteDataPack(resources, output_file, encoding)
def main(argv):
if len(argv) < 3:

Powered by Google App Engine
This is Rietveld 408576698