Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 #!/usr/bin/python | |
|
nyquist
2015/03/24 00:25:35
I think the new hotness is to use
#!/usr/bin/env p
pval...(no longer on Chromium)
2015/03/26 21:17:57
Done.
| |
| 2 # Copyright 2015 The Chromium Authors. All rights reserved. | |
| 3 # Use of this source code is governed by a BSD-style license that can be | |
| 4 # found in the LICENSE file. | |
| 5 | |
| 6 import optparse | |
| 7 import os | |
| 8 import shutil | |
| 9 import sys | |
| 10 | |
| 11 def main(): | |
|
nyquist
2015/03/24 00:25:36
What does this script do? Could you add a python-s
pval...(no longer on Chromium)
2015/03/26 21:17:57
Done.
| |
| 12 parser = optparse.OptionParser( | |
| 13 usage='Usage: %prog [options...] original_proto_files') | |
| 14 parser.add_option('-o', '--output_dir', dest='output_dir', | |
| 15 help='Where to put the modified proto files') | |
| 16 | |
| 17 options, args = parser.parse_args() | |
| 18 if not options.output_dir: | |
| 19 print 'output_dir not specified.' | |
| 20 return 1 | |
| 21 | |
| 22 # Copy the original proto files to the new location. | |
| 23 for original_proto_file in args: | |
| 24 shutil.copy(original_proto_file, options.output_dir) | |
| 25 | |
| 26 for new_proto_file_name in os.listdir(options.output_dir): | |
| 27 new_proto_file_path = os.path.join(options.output_dir, new_proto_file_name) | |
| 28 # The retain_unknown_fields option is removed because it is not supported by | |
| 29 # the protobuf nano library (used in Chromium Java). | |
| 30 # Java-specific options are set to ensure that the protos are properly | |
| 31 # organized and compiled. | |
| 32 os.system("sed -i 's/option retain_unknown_fields = true;/" | |
|
pval...(no longer on Chromium)
2015/03/13 00:32:45
should I match whitespace here? for example, what
nyquist
2015/03/24 00:25:36
I'd use built in tools in python for regexp here i
pval...(no longer on Chromium)
2015/03/26 21:17:57
Done.
| |
| 33 "option java_multiple_files = true; " | |
| 34 "option java_package = \"org.chromium.sync.protocol\";" | |
| 35 "/g' %s" % new_proto_file_path) | |
| 36 | |
| 37 | |
| 38 if __name__ == '__main__': | |
| 39 sys.exit(main()) | |
| OLD | NEW |