Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2229)

Side by Side Diff: create_wrapped_standalone_js.py

Issue 863863007: Add support for wrapping the standalone JavaScript. (Closed) Base URL: git@github.com:chromium/dom-distiller.git@master
Patch Set: Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « build.xml ('k') | war/wrapped_domdistiller_template.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 # Copyright 2015 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file.
4
5 """Wraps the standalone JavaScript inside a templated outer JavaScript.
6
7 Chrome needs to wrap the standalone JavaScript so it does not access the real
8 window object, which is done in the wrapper JS. The output of this script is
9 the file which is included in the Chrome builds.
10 """
11
12 import optparse
13 import sys
14
15 def main(argv):
16 parser = optparse.OptionParser()
17 parser.add_option('-t', '--templatefile',
18 help='The path to the output JavaScript template.')
19 parser.add_option('-i', '--infile',
20 help='The path to the standalone JavaScript to inject into the template.')
21 parser.add_option('-o', '--outfile',
22 help='The path to the output JavaScript.')
23 options, _ = parser.parse_args(argv)
24
25 templatepath = options.templatefile
26 inpath = options.infile
27 outpath = options.outfile
28
29 if templatepath:
30 templatefile = open(templatepath, 'r')
31 else:
32 print 'Please provide path to the template file'
33 return 1
34
35 if inpath:
36 infile = open(inpath, 'r')
37 else:
38 print 'Reading input from stdin'
39 infile = sys.stdin
40
41 if outpath:
42 outfile = open(outpath, 'w')
43 else:
44 outfile = sys.stdout
45
46 standalone_js = infile.read()
47 template_js = templatefile.read()
48 output_js = template_js.replace('$$DISTILLER_JAVASCRIPT', standalone_js)
49 outfile.write(output_js)
50 return 0
51
52 if __name__ == '__main__':
53 sys.exit(main(sys.argv))
OLDNEW
« no previous file with comments | « build.xml ('k') | war/wrapped_domdistiller_template.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698