Files
openlayers/tools/closure.py
crschmidt b22963a2ef Wrap path in abspath
git-svn-id: http://svn.openlayers.org/trunk/openlayers@11450 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
2011-02-24 23:59:51 +00:00

22 lines
550 B
Python

import sys
import os
import tempfile
path = os.path.abspath(os.path.join(os.path.dirname(__file__), "closure-compiler.jar"))
if not os.path.exists(path):
raise Exception("No closure-compiler.jar at %s; read README.txt!" % path)
def minimize(code):
ntf = tempfile.NamedTemporaryFile()
ntf.write(code)
ntf.flush()
ntf2 = tempfile.NamedTemporaryFile()
os.system("java -jar %s --js %s --js_output_file %s" % (path, ntf.name, ntf2.name))
ntf2.seek(0)
data = ntf2.read()
ntf.close()
ntf2.close()
return data