Tree @debian/2.20.2673.102+dfsg-2 (Download .tar.gz)
- ..
- protobuf
- android_jni_mock.cc
- android_jni_mock.h
- android_jni_proxy.cc
- android_jni_proxy.h
- android_jni_proxy_test.cc
- android_util.cc
- android_util.h
- android_util_test.cc
- base.gyp
- base_test.gyp
- bitarray.h
- bitarray_test.cc
- clock.cc
- clock.h
- clock_mock.cc
- clock_mock.h
- clock_mock_test.cc
- clock_test.cc
- codegen_bytearray_stream.h
- codegen_bytearray_stream_test.cc
- compiler_specific.h
- config_file_stream.cc
- config_file_stream.h
- config_file_stream_test.cc
- const.h
- coordinates.h
- cpu_stats.cc
- cpu_stats.h
- cpu_stats_main.cc
- cpu_stats_test.cc
- crash_report_handler.cc
- crash_report_handler.h
- crash_report_handler_mac.mm
- debug.cc
- debug.h
- double_array.h
- embedded_file.h
- embedded_file_test.cc
- encryptor.cc
- encryptor.h
- encryptor_main.cc
- encryptor_test.cc
- file_stream.cc
- file_stream.h
- file_util.cc
- file_util.h
- file_util_test.cc
- flags.cc
- flags.h
- flags_test.cc
- freelist.h
- gen_character_set.py
- gen_config_file_stream_data.py
- hash.cc
- hash.h
- hash_test.cc
- init_mozc.cc
- init_mozc.h
- iterator_adapter.h
- iterator_adapter_test.cc
- japanese_util_rule.cc
- japanese_util_rule.h
- logging.cc
- logging.h
- logging_test.cc
- mac_process.h
- mac_process.mm
- mac_util.h
- mac_util.mm
- mac_util_main.cc
- mac_util_test.mm
- mmap.cc
- mmap.h
- mmap_sync_interface.h
- mmap_test.cc
- multifile.cc
- multifile.h
- multifile_test.cc
- mutex.cc
- mutex.h
- mutex_test.cc
- namespace.h
- number_util.cc
- number_util.h
- number_util_test.cc
- password_manager.cc
- password_manager.h
- password_manager_main.cc
- password_manager_test.cc
- pepper_file_system_mock.cc
- pepper_file_system_mock.h
- pepper_file_system_mock_test.cc
- pepper_file_util.cc
- pepper_file_util.h
- pepper_scoped_obj.h
- port.h
- process.cc
- process.h
- process_main.cc
- process_mutex.cc
- process_mutex.h
- process_mutex_main.cc
- process_mutex_test.cc
- run_level.cc
- run_level.h
- run_level_main.cc
- scheduler.cc
- scheduler.h
- scheduler_stub.cc
- scheduler_stub.h
- scheduler_stub_test.cc
- scheduler_test.cc
- scoped_cftyperef.h
- scoped_handle.cc
- scoped_handle.h
- scoped_nsobject.h
- serialized_string_array.cc
- serialized_string_array.h
- serialized_string_array_test.cc
- singleton.cc
- singleton.h
- singleton_test.cc
- stl_util.h
- stl_util_test.cc
- stopwatch.cc
- stopwatch.h
- stopwatch_main.cc
- stopwatch_test.cc
- string_piece.cc
- string_piece.h
- string_piece_test.cc
- system_util.cc
- system_util.h
- system_util_test.cc
- text_normalizer.cc
- text_normalizer.h
- text_normalizer_test.cc
- thread.cc
- thread.h
- thread_annotations.h
- thread_test.cc
- trie.h
- trie_test.cc
- unnamed_event.cc
- unnamed_event.h
- unnamed_event_test.cc
- unverified_aes256.cc
- unverified_aes256.h
- unverified_aes256_test.cc
- unverified_sha1.cc
- unverified_sha1.h
- unverified_sha1_test.cc
- update_util.cc
- update_util.h
- update_util_test.cc
- url.cc
- url.h
- url_test.cc
- util.cc
- util.h
- util_test.cc
- version.cc
- version.h
- version_def_template.h
- version_test.cc
- win_api_test_helper.cc
- win_api_test_helper.h
- win_api_test_helper_test.cc
- win_font_test_helper.cc
- win_font_test_helper.h
- win_sandbox.cc
- win_sandbox.h
- win_sandbox_test.cc
- win_util.cc
- win_util.h
- win_util_test.cc
- win_util_test_dll.cc
- win_util_test_dll.def
- winmain.h
gen_config_file_stream_data.py @debian/2.20.2673.102+dfsg-2 — raw · history · blame
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 | # -*- coding: utf-8 -*- # Copyright 2010-2016, Google Inc. # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are # met: # # * Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # * Redistributions in binary form must reproduce the above # copyright notice, this list of conditions and the following disclaimer # in the documentation and/or other materials provided with the # distribution. # * Neither the name of Google Inc. nor the names of its # contributors may be used to endorse or promote products derived from # this software without specific prior written permission. # # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. """Script to generate config_file_stream_data.h.""" __author__ = "hidehiko" import optparse import os.path import sys def ParseOptions(): """Parses options from given argument.""" parser = optparse.OptionParser() parser.add_option('--output', dest='output', help='Output file path') return parser.parse_args() def GenerateFileData(path): """Generate FileData entry from given file path. The generated FileData entry looks as follows: { "something_original_file_path", "\xAA\xBB\xCC", 3 } Args: path: a filepath to be converted into FileData. Returns: Generated code of a FileData entry. """ result = [] result.append(' { "%s", "' % os.path.basename(path)) with open(path, 'rb') as stream: result.extend(r'\x%02X' % ord(byte) for byte in stream.read()) result.append('", %d }' % os.path.getsize(path)) return ''.join(result) def OutputConfigFileStreamData(path_list, output): """Outputs the generated FileData entries for path_list. Prints the config_file_stream_data.h file, which contains FileData entries of files in given path_list, to the output stream. The generated code looks like: static const FileData kFileData[] = { { "filename1", "\x00\x01\x02\x03", 4 }, { "filename2", "\x10\x11\x12\x13\x14\x15\x16\x17", 8 }, : : }; Args: path_list: a list of file path which should be included in the config_file_stream_data as FileData entries. output: a stream of the output data. """ output.write('static const FileData kFileData[] = {\n') for path in path_list: output.write(GenerateFileData(path)) output.write(',\n') output.write('};\n') def main(): (options, args) = ParseOptions() if not options.output: print >>sys.stderr, ( 'usage: gen_config_file_stream_data.py --output=filepath input ...') sys.exit(2) with open(options.output, 'w') as output: OutputConfigFileStreamData(args, output) if __name__ == '__main__': main() |