| OLD | NEW | 
|---|
| 1 # Copyright (c) 2011, the Dart project authors.  Please see the AUTHORS file | 1 # Copyright (c) 2011, the Dart project authors.  Please see the AUTHORS file | 
| 2 # for details. All rights reserved. Use of this source code is governed by a | 2 # for details. All rights reserved. Use of this source code is governed by a | 
| 3 # BSD-style license that can be found in the LICENSE file. | 3 # BSD-style license that can be found in the LICENSE file. | 
| 4 | 4 | 
| 5 #!/usr/bin/env python | 5 #!/usr/bin/env python | 
| 6 # | 6 # | 
| 7 | 7 | 
| 8 """Rewrites HTML files, converting Dart script sections into JavaScript. | 8 """Rewrites HTML files, converting Dart script sections into JavaScript. | 
| 9 | 9 | 
| 10 Process HTML files, and internally changes script sections that use Dart code | 10 Process HTML files, and internally changes script sections that use Dart code | 
| (...skipping 452 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 463   result.add_option("-o", "--out", | 463   result.add_option("-o", "--out", | 
| 464       help="Output directory", | 464       help="Output directory", | 
| 465       type="string", | 465       type="string", | 
| 466       default=None, | 466       default=None, | 
| 467       action="store") | 467       action="store") | 
| 468   result.add_option("-t", "--target", | 468   result.add_option("-t", "--target", | 
| 469       help="The target html to generate", | 469       help="The target html to generate", | 
| 470       metavar="[js,chromium,dartium]", | 470       metavar="[js,chromium,dartium]", | 
| 471       default='chromium') | 471       default='chromium') | 
| 472   result.add_option("--extra-flags", | 472   result.add_option("--extra-flags", | 
| 473       help="Extra flags for dartc", | 473       help="Extra flags for frogc", | 
| 474       type="string", | 474       type="string", | 
| 475       default="") | 475       default="") | 
| 476   result.set_usage("htmlconverter.py input.html -o OUTDIR") | 476   result.set_usage("htmlconverter.py input.html -o OUTDIR") | 
| 477   return result | 477   return result | 
| 478 | 478 | 
| 479 def writeOut(contents, filepath): | 479 def writeOut(contents, filepath): | 
| 480   """ Writes contents to a file, ensuring that the output directory exists. """ | 480   """ Writes contents to a file, ensuring that the output directory exists. """ | 
| 481   safeMakeDirs(dirname(filepath)) | 481   safeMakeDirs(dirname(filepath)) | 
| 482   with open(filepath, 'w') as f: | 482   with open(filepath, 'w') as f: | 
| 483     f.write(contents) | 483     f.write(contents) | 
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 549     if 'dartium' in options.target: | 549     if 'dartium' in options.target: | 
| 550       convertForDartium(filename, options.out, | 550       convertForDartium(filename, options.out, | 
| 551           outfile.replace(extension, '-dart' + extension), options.verbose) | 551           outfile.replace(extension, '-dart' + extension), options.verbose) | 
| 552   except Exception as e: | 552   except Exception as e: | 
| 553     print "%sERROR%s: %s" % (RED_COLOR, NO_COLOR, str(e)) | 553     print "%sERROR%s: %s" % (RED_COLOR, NO_COLOR, str(e)) | 
| 554     return 1 | 554     return 1 | 
| 555   return 0 | 555   return 0 | 
| 556 | 556 | 
| 557 if __name__ == '__main__': | 557 if __name__ == '__main__': | 
| 558   sys.exit(main()) | 558   sys.exit(main()) | 
| OLD | NEW | 
|---|