From 570c0a93fb24a393a2bf013a5aad5b6759713ce7 Mon Sep 17 00:00:00 2001 From: Yves Fischer Date: Sun, 20 Dec 2015 18:47:45 +0100 Subject: start migrating from shell scripts --- .../resources/rewrite-locale/data_pack.py | 115 +++++++++++++++++++++ .../resources/rewrite-locale/input.pak | Bin 0 -> 196003 bytes .../resources/rewrite-locale/output.pak | Bin 0 -> 196603 bytes 3 files changed, 115 insertions(+) create mode 100755 packages/gwt-chromium/resources/rewrite-locale/data_pack.py create mode 100644 packages/gwt-chromium/resources/rewrite-locale/input.pak create mode 100644 packages/gwt-chromium/resources/rewrite-locale/output.pak (limited to 'packages/gwt-chromium/resources/rewrite-locale') diff --git a/packages/gwt-chromium/resources/rewrite-locale/data_pack.py b/packages/gwt-chromium/resources/rewrite-locale/data_pack.py new file mode 100755 index 0000000..ba9790b --- /dev/null +++ b/packages/gwt-chromium/resources/rewrite-locale/data_pack.py @@ -0,0 +1,115 @@ +#!/usr/bin/env python +# Copyright (c) 2012 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. + +"""Support for formatting a data pack file used for platform agnostic resource +files. +""" + +import collections +import exceptions +import os +import struct +import sys +if __name__ == '__main__': + sys.path.append(os.path.join(os.path.dirname(__file__), '../..')) + + +PACK_FILE_VERSION = 4 +HEADER_LENGTH = 2 * 4 + 1 # Two uint32s. (file version, number of entries) and + # one uint8 (encoding of text resources) +BINARY, UTF8, UTF16 = range(3) + + +class WrongFileVersion(Exception): + pass + + +DataPackContents = collections.namedtuple( + 'DataPackContents', 'resources encoding') + + +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, encoding = struct.unpack('data in the data pack format.""" + ids = sorted(resources.keys()) + ret = [] + + # Write file header. + ret.append(struct.pack('data into output_file as a data pack.""" + content = WriteDataPackToString(resources, encoding) + with open(output_file, 'wb') as file: + file.write(content) + + + + + +# Temporary hack for external programs that import data_pack. +# TODO(benrg): Remove this. +class DataPack(object): + pass +DataPack.ReadDataPack = staticmethod(ReadDataPack) +DataPack.WriteDataPackToString = staticmethod(WriteDataPackToString) +DataPack.WriteDataPack = staticmethod(WriteDataPack) + + +def main(): + data = ReadDataPack("input.pak").resources + for (key,val) in data.items(): + if "Chromium" in val: + data[key] = val.replace("Chromium", "GWT-Chromium") + WriteDataPack(data, "output.pak", UTF8) + + +if __name__ == '__main__': + main() diff --git a/packages/gwt-chromium/resources/rewrite-locale/input.pak b/packages/gwt-chromium/resources/rewrite-locale/input.pak new file mode 100644 index 0000000..689c22f Binary files /dev/null and b/packages/gwt-chromium/resources/rewrite-locale/input.pak differ diff --git a/packages/gwt-chromium/resources/rewrite-locale/output.pak b/packages/gwt-chromium/resources/rewrite-locale/output.pak new file mode 100644 index 0000000..fe141a2 Binary files /dev/null and b/packages/gwt-chromium/resources/rewrite-locale/output.pak differ -- cgit v1.2.1