OLD | NEW |
(Empty) | |
| 1 # Copyright (c) 2009 The Chromium Authors. All rights reserved. |
| 2 # Use of this source code is governed by a BSD-style license that can be |
| 3 # found in the LICENSE file. |
| 4 |
| 5 """ Strip a .proto of options not supported by open-source protobuf tools. """ |
| 6 |
| 7 import re |
| 8 import sys |
| 9 |
| 10 if __name__ == '__main__': |
| 11 if len(sys.argv) != 3: |
| 12 print "Usage: %s input_file output_file " % sys.argv[0] |
| 13 sys.exit(1) |
| 14 |
| 15 input_file = sys.argv[1] |
| 16 output_file = sys.argv[2] |
| 17 |
| 18 protobuf = open(input_file).read() |
| 19 |
| 20 # Comment out lines like "option java_api_version = 1;" |
| 21 protobuf = re.sub("(option .*api_version.*\=.*)", r"// \1", protobuf) |
| 22 |
| 23 # Comment out lines like "option java_java5_enums = false;" |
| 24 protobuf = re.sub("(option .*java_java5_enums.*\=.*)", r"// \1", protobuf) |
| 25 |
| 26 # Comment out the java package. |
| 27 protobuf = re.sub("(option .*java_package.*\=.*)", r"// \1", protobuf) |
| 28 |
| 29 open(output_file, "w").write(protobuf) |
| 30 |
OLD | NEW |