diff options
author | maruel@chromium.org <maruel@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-11-27 20:56:51 +0000 |
---|---|---|
committer | maruel@chromium.org <maruel@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-11-27 20:56:51 +0000 |
commit | 2fac37585d3dfa0d7cf7a976698aae7627186573 (patch) | |
tree | d2f233a6afa5d8093f15f2f3c56cc4c009b05904 /chrome/third_party | |
parent | 071302929ab813f647e51253af4e885b33eab463 (diff) | |
download | chromium_src-2fac37585d3dfa0d7cf7a976698aae7627186573.zip chromium_src-2fac37585d3dfa0d7cf7a976698aae7627186573.tar.gz chromium_src-2fac37585d3dfa0d7cf7a976698aae7627186573.tar.bz2 |
Fix python scripts in src/chrome/
Make sure that:
- shebang is only present for executable files
- shebang is #!/usr/bin/env python
- __main__ is only present for executable files
- file's executable bit is coherent
Also fix EOF LF to be only one.
Minor python style fixes.
TBR=nirnimesh@chromium.org
BUG=105108
TEST=
Review URL: http://codereview.chromium.org/8680018
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@111658 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/third_party')
-rwxr-xr-x | chrome/third_party/jstemplate/compile.py | 66 |
1 files changed, 36 insertions, 30 deletions
diff --git a/chrome/third_party/jstemplate/compile.py b/chrome/third_party/jstemplate/compile.py index 3d16d96..3e75807 100755 --- a/chrome/third_party/jstemplate/compile.py +++ b/chrome/third_party/jstemplate/compile.py @@ -1,38 +1,44 @@ #!/usr/bin/env python -# Copyright (c) 2009 The Chromium Authors. All rights reserved. +# Copyright (c) 2011 The Chromium Authors. All rights reserved. # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. -# A python script that combines the javascript files needed by jstemplate into -# a single file. +"""Combines the javascript files needed by jstemplate into a single file.""" import httplib import urllib -srcs ="util.js jsevalcontext.js jstemplate.js exports.js".split() -out = "jstemplate_compiled.js" - -# Wrap the output in an anonymous function to prevent poluting the global -# namespace. -output_wrapper = "(function(){%s})()" - -# Define the parameters for the POST request and encode them in a URL-safe -# format. See http://code.google.com/closure/compiler/docs/api-ref.html for API -# reference. -params = urllib.urlencode( - map(lambda src: ('js_code', file(src).read()), srcs) + - [ - ('compilation_level', 'ADVANCED_OPTIMIZATIONS'), - ('output_format', 'text'), - ('output_info', 'compiled_code'), - ]) - -# Always use the following value for the Content-type header. -headers = {'Content-type': 'application/x-www-form-urlencoded'} -conn = httplib.HTTPConnection('closure-compiler.appspot.com') -conn.request('POST', '/compile', params, headers) -response = conn.getresponse() -out_file = file(out, 'w') -out_file.write(output_wrapper % response.read()) -out_file.close() -conn.close() + +def main(): + srcs = ['util.js', 'jsevalcontext.js', 'jstemplate.js', 'exports.js'] + out = 'jstemplate_compiled.js' + + # Wrap the output in an anonymous function to prevent poluting the global + # namespace. + output_wrapper = '(function(){%s})()' + + # Define the parameters for the POST request and encode them in a URL-safe + # format. See http://code.google.com/closure/compiler/docs/api-ref.html for + # API reference. + params = urllib.urlencode( + map(lambda src: ('js_code', file(src).read()), srcs) + + [ + ('compilation_level', 'ADVANCED_OPTIMIZATIONS'), + ('output_format', 'text'), + ('output_info', 'compiled_code'), + ]) + + # Always use the following value for the Content-type header. + headers = {'Content-type': 'application/x-www-form-urlencoded'} + conn = httplib.HTTPConnection('closure-compiler.appspot.com') + conn.request('POST', '/compile', params, headers) + response = conn.getresponse() + out_file = file(out, 'w') + out_file.write(output_wrapper % response.read()) + out_file.close() + conn.close() + return 0 + + +if __name__ == '__main__': + sys.exit(main()) |