diff options
author | tc@google.com <tc@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-01-15 01:15:48 +0000 |
---|---|---|
committer | tc@google.com <tc@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-01-15 01:15:48 +0000 |
commit | 7cb4af565c1017625df2e55d581c1f62ed4c4451 (patch) | |
tree | 2cec53ebe8736f7a3e8e52e3cb030b306ba75c39 /tools/data_pack/repack.py | |
parent | e9d6398c5de33b6b13405717b85f3c31961816fe (diff) | |
download | chromium_src-7cb4af565c1017625df2e55d581c1f62ed4c4451.zip chromium_src-7cb4af565c1017625df2e55d581c1f62ed4c4451.tar.gz chromium_src-7cb4af565c1017625df2e55d581c1f62ed4c4451.tar.bz2 |
add a repack utility for combining .pak files generated
by grit into a single .pak file.
Review URL: http://codereview.chromium.org/18254
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@8063 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'tools/data_pack/repack.py')
-rwxr-xr-x | tools/data_pack/repack.py | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/tools/data_pack/repack.py b/tools/data_pack/repack.py new file mode 100755 index 0000000..5d7a344 --- /dev/null +++ b/tools/data_pack/repack.py @@ -0,0 +1,40 @@ +#!/usr/bin/python +# Copyright (c) 2008 The Chromium Authors. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +"""A simple utility function to merge data pack files into a single data pack. +See base/pack_file* for details about the file format. +""" + +import exceptions +import struct +import sys + +import data_pack + +def RePack(output_file, input_files): + """Write a new data pack to |output_file| based on a list of filenames + (|input_files|)""" + resources = {} + for filename in input_files: + new_resources = 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))) + + resources.update(new_resources) + + data_pack.WriteDataPack(resources, output_file) + +def main(argv): + if len(argv) < 4: + print ("Usage:\n %s <output_filename> <input_file1> <input_file2> " + "[input_file3] ..." % argv[0]) + sys.exit(-1) + RePack(argv[1], argv[2:]) + +if '__main__' == __name__: + main(sys.argv) |