Sha256: a5797c7acad53692df7daa21794d8e3d9aef17bad1e879f03443cd61457ba4bd

Contents?: true

Size: 861 Bytes

Versions: 12

Compression:

Stored size: 861 Bytes

Contents

#!/usr/bin/python

import httplib, urllib, sys
import time
# Define the parameters for the POST request and encode them in
# a URL-safe format.

def minimize(code):

    params = urllib.urlencode([
        ('js_code', code),
        ('compilation_level', 'SIMPLE_OPTIMIZATIONS'),
        ('output_format', 'text'),
        ('output_info', 'compiled_code'),
      ])
    
    t = time.time()
    # 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()
    data = response.read()
    conn.close()
    if data.startswith("Error"):
        raise Exception(data)
    print "%.3f seconds to compile" % (time.time() - t) 
    return data

Version data entries

12 entries across 12 versions & 2 rubygems

Version Path
postrunner-0.0.10 misc/openlayers/tools/closure_ws.py
postrunner-0.0.9 misc/openlayers/tools/closure_ws.py
postrunner-0.0.8 misc/openlayers/tools/closure_ws.py
postrunner-0.0.7 misc/openlayers/tools/closure_ws.py
postrunner-0.0.6 misc/openlayers/tools/closure_ws.py
postrunner-0.0.5 misc/openlayers/tools/closure_ws.py
postrunner-0.0.4 misc/openlayers/tools/closure_ws.py
gb_mapfish_appserver-0.0.5 vendor/assets/javascripts/openlayers/tools/closure_ws.py
gb_mapfish_appserver-0.0.4 vendor/assets/javascripts/openlayers/tools/closure_ws.py
gb_mapfish_appserver-0.0.3 vendor/assets/javascripts/openlayers/tools/closure_ws.py
gb_mapfish_appserver-0.0.2 vendor/assets/javascripts/openlayers/tools/closure_ws.py
gb_mapfish_appserver-0.0.1 vendor/assets/javascripts/openlayers/tools/closure_ws.py