Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Side by Side Diff: abp_rewrite.py

Issue 29350236: Issue 4373 - Made jshydra compatible with Python 3 (Closed)
Patch Set: Use urllib2, removed redundant future import, added option to test without caching Created Aug. 30, 2016, 11:33 a.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « .hgignore ('k') | autotest.py » ('j') | utils.py » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/usr/bin/env python
2 # coding: utf-8
3
4 # This Source Code is subject to the terms of the Mozilla Public License 1 # This Source Code is subject to the terms of the Mozilla Public License
5 # version 2.0 (the "License"). You can obtain a copy of the License at 2 # version 2.0 (the "License"). You can obtain a copy of the License at
6 # http://mozilla.org/MPL/2.0/. 3 # http://mozilla.org/MPL/2.0/.
7 4
8 import sys
9 import os 5 import os
10 import subprocess 6 import subprocess
7
11 import utils 8 import utils
12 9
13 10
14 def doRewrite(files, args): 11 def rewrite_js(args, script=None):
15 application = utils.ensureJSShell() 12 jsshell = utils.ensureJSShell()
13 env = {'LD_LIBRARY_PATH': os.path.relpath(os.path.dirname(jsshell))}
14 base_dir = os.path.dirname(__file__)
16 15
17 env = { 16 if not script:
18 'LD_LIBRARY_PATH': os.path.relpath(os.path.dirname(application)), 17 script = os.path.join(base_dir, 'scripts', 'abprewrite.js')
19 }
20 18
21 baseDir = os.path.dirname(utils.__file__) 19 command = [jsshell, os.path.join(base_dir, 'jshydra.js'), script] + args
22 command = [ 20 return subprocess.check_output(command, env=env, universal_newlines=True)
23 application, os.path.join(baseDir, 'jshydra.js'),
24 os.path.join(baseDir, 'scripts', 'abprewrite.js'),
25 '--arg', ' '.join(args)
26 ] + files
27 return subprocess.check_output(command, env=env).replace('\r', '')
28
29 if __name__ == '__main__':
30 try:
31 scriptArgsStart = sys.argv.index('--arg')
32 except ValueError:
33 scriptArgsStart = len(sys.argv)
34 print doRewrite(sys.argv[1:scriptArgsStart], sys.argv[scriptArgsStart + 1:])
OLDNEW
« no previous file with comments | « .hgignore ('k') | autotest.py » ('j') | utils.py » ('J')

Powered by Google App Engine
This is Rietveld