diff options
author | adriansc@chromium.org <adriansc@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-09-15 22:56:52 +0000 |
---|---|---|
committer | adriansc@chromium.org <adriansc@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-09-15 22:56:52 +0000 |
commit | d77739cf671173e84370dd3696ea6d2aded11451 (patch) | |
tree | 30fbec722ea861da5252d9c716c1ef91b1e83f37 /tools/data_pack | |
parent | 6aa40a9209158704eb5277cae331bf604d8b863a (diff) | |
download | chromium_src-d77739cf671173e84370dd3696ea6d2aded11451.zip chromium_src-d77739cf671173e84370dd3696ea6d2aded11451.tar.gz chromium_src-d77739cf671173e84370dd3696ea6d2aded11451.tar.bz2 |
Removed dead data_pack code.
Followup for WebKit rev95132.
BUG=none
TEST=builds
Review URL: http://codereview.chromium.org/7901023
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@101406 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'tools/data_pack')
-rwxr-xr-x | tools/data_pack/data_pack.py | 79 | ||||
-rwxr-xr-x | tools/data_pack/repack.py | 43 |
2 files changed, 0 insertions, 122 deletions
diff --git a/tools/data_pack/data_pack.py b/tools/data_pack/data_pack.py deleted file mode 100755 index 93a6cfd..0000000 --- a/tools/data_pack/data_pack.py +++ /dev/null @@ -1,79 +0,0 @@ -#!/usr/bin/python -# Copyright (c) 2011 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 produce data pack files. -See base/pack_file* for details. - -TOOD(adriansc): Remove this file once the dependency has been updated in WebKit -to point to grit scripts. -""" - -import struct - -FILE_FORMAT_VERSION = 3 -HEADER_LENGTH = 2 * 4 # Two uint32s. (file version and number of entries) - -class WrongFileVersion(Exception): - pass - -def ReadDataPack(input_file): - """Reads a data pack file and returns a dictionary.""" - data = open(input_file, "rb").read() - original_data = data - - # Read the header. - version, num_entries = struct.unpack("<II", data[:HEADER_LENGTH]) - if version != FILE_FORMAT_VERSION: - raise WrongFileVersion - - resources = {} - if num_entries == 0: - return resources - - # Read the index and data. - data = data[HEADER_LENGTH:] - kIndexEntrySize = 2 + 4 # Each entry is a uint16 and a uint32. - for _ in range(num_entries): - id, offset = struct.unpack("<HI", data[:kIndexEntrySize]) - data = data[kIndexEntrySize:] - next_id, next_offset = struct.unpack("<HI", data[:kIndexEntrySize]) - resources[id] = original_data[offset:next_offset] - - return resources - -def WriteDataPack(resources, output_file): - """Write a map of id=>data into output_file as a data pack.""" - ids = sorted(resources.keys()) - file = open(output_file, "wb") - - # Write file header. - file.write(struct.pack("<II", FILE_FORMAT_VERSION, len(ids))) - - # Each entry is a uint16 and a uint32. We have one extra entry for the last - # item. - index_length = (len(ids) + 1) * (2 + 4) - - # Write index. - data_offset = HEADER_LENGTH + index_length - for id in ids: - file.write(struct.pack("<HI", id, data_offset)) - data_offset += len(resources[id]) - - file.write(struct.pack("<HI", 0, data_offset)) - - # Write data. - for id in ids: - file.write(resources[id]) - -def main(): - # Just write a simple file. - data = { 1: "", 4: "this is id 4", 6: "this is id 6", 10: "" } - WriteDataPack(data, "datapack1.pak") - data2 = { 1000: "test", 5: "five" } - WriteDataPack(data2, "datapack2.pak") - print "wrote datapack1 and datapack2 to current directory." - -if __name__ == '__main__': - main() diff --git a/tools/data_pack/repack.py b/tools/data_pack/repack.py deleted file mode 100755 index 2729b10..0000000 --- a/tools/data_pack/repack.py +++ /dev/null @@ -1,43 +0,0 @@ -#!/usr/bin/python -# Copyright (c) 2011 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. - -TODO(adriansc): Remove this file once the dependency has been updated in WebKit -to point to grit scripts. -""" - -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) < 3: - print ("Usage:\n %s <output_filename> <input_file1> [input_file2] ... " % - argv[0]) - sys.exit(-1) - RePack(argv[1], argv[2:]) - -if '__main__' == __name__: - main(sys.argv) |