| Index: convert_js.py | 
| =================================================================== | 
| --- a/convert_js.py | 
| +++ b/convert_js.py | 
| @@ -1,7 +1,7 @@ | 
| #!/usr/bin/env python | 
| # coding: utf-8 | 
| -import sys, os, codecs, re | 
| +import sys, os, codecs, re, argparse | 
| baseDir = os.path.abspath(os.path.dirname(__file__)) | 
| sys.path.append(os.path.join(baseDir, 'adblockplus', 'buildtools', 'jshydra')) | 
| from abp_rewrite import doRewrite | 
| @@ -27,7 +27,9 @@ | 
| printFilesVerbatim(outHandle, verbatimBefore) | 
| - convertFiles = map(lambda f: f if os.path.isabs(f) else os.path.join(baseDir, f), convertFiles) | 
| + # We should trust that gyp is giving us the correct path names. In case we can't, however, the | 
| + # following is commented out rather than removed. We can add an optional argument for it if needed. | 
| + #convertFiles = map(lambda f: f if os.path.isabs(f) else os.path.join(baseDir, f), convertFiles) | 
| converted = doRewrite(convertFiles, ['module=true', 'source_repo=https://hg.adblockplus.org/adblockplus/']) | 
| print >>outHandle, toCString('adblockplus.js') + ',' | 
| print >>outHandle, toCString(converted) + ',' | 
| @@ -38,18 +40,14 @@ | 
| print >>outHandle, '};' | 
| if __name__ == '__main__': | 
| - args = sys.argv[1:] | 
| - outFile = args.pop() | 
| - | 
| - verbatimBefore = [] | 
| - verbatimAfter = [] | 
| - convertFiles = [] | 
| - for fileName in args: | 
| - if fileName.startswith('before='): | 
| - verbatimBefore.append(fileName.replace('before=', '')) | 
| - elif fileName.startswith('after='): | 
| - verbatimAfter.append(fileName.replace('after=', '')) | 
| - else: | 
| - convertFiles.append(fileName) | 
| - | 
| - convert(verbatimBefore, convertFiles, verbatimAfter, outFile) | 
| + parser = argparse.ArgumentParser(description='Convert JavaScript files') | 
| + parser.add_argument('--before', metavar='verbatim_file', nargs='+', | 
| + help='JavaScript file to include verbatim at the beginning') | 
| + parser.add_argument('--convert', metavar='file_to_convert', nargs='+', | 
| + help='JavaScript files to convert') | 
| + parser.add_argument('--after', metavar='verbatim_file', nargs='+', | 
| + help='JavaScript file to include verbatim at the end') | 
| + parser.add_argument('output_file', | 
| + help='output from the conversion') | 
| + args = parser.parse_args() | 
| + convert(args.before, args.convert, args.after, args.output_file) |