Chromium Code Reviews| Index: grit/format/repack.py |
| diff --git a/grit/format/repack.py b/grit/format/repack.py |
| index e42acdbfc57e6b65915ba1180935994776a6064e..337b7af20b5af3c53c465bcf07dc82385b388d2d 100755 |
| --- a/grit/format/repack.py |
| +++ b/grit/format/repack.py |
| @@ -9,19 +9,29 @@ http://dev.chromium.org/developers/design-documents/linuxresourcesandlocalizedst |
| for details about the file format. |
| """ |
| +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
|
| import os |
| import sys |
| + |
| if __name__ == '__main__': |
| sys.path.append(os.path.join(os.path.dirname(__file__), '../..')) |
| import grit.format.data_pack |
| + |
| def main(argv): |
| - if len(argv) < 3: |
| - print ("Usage:\n %s <output_filename> <input_file1> [input_file2] ... " % |
| - argv[0]) |
| - sys.exit(-1) |
| - grit.format.data_pack.RePack(argv[1], argv[2:]) |
| + parser = optparse.OptionParser('usage: %prog [options] <output_filename>' |
| + '<input_file1> [input_file2] ...') |
| + parser.add_option('--whitelist', action='store', dest='whitelist', |
| + default=None, help='Full path to the whitelist used to' |
| + 'filter output pak file resource IDs') |
| + options, file_paths = parser.parse_args(argv) |
| + |
| + if len(file_paths) < 2: |
| + parser.error('Please specify output and at least one input filenames') |
| + |
| + grit.format.data_pack.RePack(file_paths[0], file_paths[1:], |
| + whitelist_file=options.whitelist) |
| if '__main__' == __name__: |
| - main(sys.argv) |
| + main(sys.argv[1:]) |