Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
| 2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
| 4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
| 5 | 5 |
| 6 """ | 6 """ |
| 7 A simple utility function to merge data pack files into a single data pack. See | 7 A simple utility function to merge data pack files into a single data pack. See |
| 8 http://dev.chromium.org/developers/design-documents/linuxresourcesandlocalizedst rings | 8 http://dev.chromium.org/developers/design-documents/linuxresourcesandlocalizedst rings |
| 9 for details about the file format. | 9 for details about the file format. |
| 10 """ | 10 """ |
| 11 | 11 |
| 12 import optparse | |
|
Nico
2014/04/02 00:24:46
(i hear argparse is where it's at these days)
aurimas (slooooooooow)
2014/04/02 00:55:55
argparse was only introduced in Python 2.7 and gri
Nico
2014/04/02 00:57:09
All of chromium's infra is on python 2.7 by now. D
| |
| 12 import os | 13 import os |
| 13 import sys | 14 import sys |
| 15 | |
| 14 if __name__ == '__main__': | 16 if __name__ == '__main__': |
| 15 sys.path.append(os.path.join(os.path.dirname(__file__), '../..')) | 17 sys.path.append(os.path.join(os.path.dirname(__file__), '../..')) |
| 16 | 18 |
| 17 import grit.format.data_pack | 19 import grit.format.data_pack |
| 18 | 20 |
| 21 | |
| 19 def main(argv): | 22 def main(argv): |
| 20 if len(argv) < 3: | 23 parser = optparse.OptionParser('usage: %prog [options] <output_filename>' |
| 21 print ("Usage:\n %s <output_filename> <input_file1> [input_file2] ... " % | 24 '<input_file1> [input_file2] ...') |
| 22 argv[0]) | 25 parser.add_option('--whitelist', action='store', dest='whitelist', |
| 23 sys.exit(-1) | 26 default=None, help='Full path to the whitelist used to' |
| 24 grit.format.data_pack.RePack(argv[1], argv[2:]) | 27 'filter output pak file resource IDs') |
| 28 options, file_paths = parser.parse_args(argv) | |
| 29 | |
| 30 if len(file_paths) < 2: | |
| 31 parser.error('Please specify output and at least one input filenames') | |
| 32 | |
| 33 grit.format.data_pack.RePack(file_paths[0], file_paths[1:], | |
| 34 whitelist_file=options.whitelist) | |
| 25 | 35 |
| 26 if '__main__' == __name__: | 36 if '__main__' == __name__: |
| 27 main(sys.argv) | 37 main(sys.argv[1:]) |
| OLD | NEW |