def setup(self): try: self.jar = self.get_config('CLOSURE_COMPRESSOR_PATH', what='Google Closure Compiler') except EnvironmentError: try: import closure self.jar = closure.get_jar_filename() except ImportError: raise EnvironmentError( "\nClosure Compiler jar can't be found." "\nPlease either install the closure package:" "\n\n pip install closure\n" "\nor provide a CLOSURE_COMPRESSOR_PATH setting " "or an environment variable with the full path to " "the Closure compiler jar." ) self.opt = self.get_config('CLOSURE_COMPRESSOR_OPTIMIZATION', require=False, what='Google Closure optimization level') if not self.opt: self.opt = 'WHITESPACE_ONLY' self.extra_args = self.get_config('CLOSURE_EXTRA_ARGS', require=False) self.java_setup()
def setup(self): super(ClosureJS, self).setup() try: self.jar = self.get_config('CLOSURE_COMPRESSOR_PATH', what='Google Closure Compiler') except EnvironmentError: try: import closure self.jar = closure.get_jar_filename() except ImportError: raise EnvironmentError( "\nClosure Compiler jar can't be found." "\nPlease either install the closure package:" "\n\n pip install closure\n" "\nor provide a CLOSURE_COMPRESSOR_PATH setting " "or an environment variable with the full path to " "the Closure compiler jar.")
def jsmin(code): # need java & pip/closure """ JS-minimize (transpile to ES5 JS compliant) with closure-compiler (pip package 'closure', need java !) """ if hasClosure: import closure # py2 or py3 else: raise VBuildException("jsmin error: closure is not installed (sudo pip closure)") cmd = ["java", "-jar", closure.get_jar_filename()] try: p = subprocess.Popen(cmd, stdout=subprocess.PIPE, stdin=subprocess.PIPE, stderr=subprocess.PIPE) except Exception as e: raise VBuildException("jsmin error: %s" % e) out, err = p.communicate(code.encode("utf8")) if p.returncode == 0: return out.decode("utf8") else: raise VBuildException("jsmin error:" + err.decode("utf8"))
def setup(self): super(ClosureJS, self).setup() try: self.jar = self.get_config('CLOSURE_COMPRESSOR_PATH', what='Google Closure Compiler') except EnvironmentError: try: import closure self.jar = closure.get_jar_filename() except ImportError: raise EnvironmentError( "\nClosure Compiler jar can't be found." "\nPlease either install the closure package:" "\n\n pip install closure\n" "\nor provide a CLOSURE_COMPRESSOR_PATH setting " "or an environment variable with the full path to " "the Closure compiler jar." )
def setup(self): try: self.jar = self.get_config('CLOSURE_COMPRESSOR_PATH', what='Google Closure Compiler') except EnvironmentError: try: import closure self.jar = closure.get_jar_filename() except ImportError: raise EnvironmentError( "\nClosure Compiler jar can't be found." "\nPlease either install the closure package:" "\n\n pip install closure\n" "\nor provide a CLOSURE_COMPRESSOR_PATH setting " "or an environment variable with the full path to " "the Closure compiler jar.") self.opt = self.get_config('CLOSURE_COMPRESSOR_OPTIMIZATION', require=False, what='Google Closure optimization level') if not self.opt: self.opt = 'WHITESPACE_ONLY' self.extra_args = self.get_config('CLOSURE_EXTRA_ARGS', require=False) self.java_setup()
#!/usr/bin/env python import argparse import subprocess import sys from pathlib import Path try: import closure except ImportError: closure_compiler = None else: closure_compiler = closure.get_jar_filename() js_path = Path(__file__).parent.parent / 'static' / 'admin' / 'js' def main(): description = """With no file paths given this script will automatically compress all jQuery-based files of the admin app. Requires the Google Closure Compiler library and Java version 6 or later.""" parser = argparse.ArgumentParser(description=description) parser.add_argument('file', nargs='*') parser.add_argument( "-c", dest="compiler", default="~/bin/compiler.jar", help="path to Closure Compiler jar file", ) parser.add_argument("-v", "--verbose", action="store_true", dest="verbose") parser.add_argument("-q", "--quiet", action="store_false", dest="verbose") options = parser.parse_args()
#!/usr/bin/env python import argparse import subprocess import sys from pathlib import Path try: import closure except ImportError: closure_compiler = None else: closure_compiler = closure.get_jar_filename() js_path = Path(__file__).parent.parent / 'static' / 'admin' / 'js' def main(): description = """With no file paths given this script will automatically compress all jQuery-based files of the admin app. Requires the Google Closure Compiler library and Java version 6 or later.""" parser = argparse.ArgumentParser(description=description) parser.add_argument('file', nargs='*') parser.add_argument( "-c", dest="compiler", default="~/bin/compiler.jar", help="path to Closure Compiler jar file", ) parser.add_argument("-v", "--verbose", action="store_true", dest="verbose") parser.add_argument("-q", "--quiet", action="store_false", dest="verbose") options = parser.parse_args() compiler = Path(closure_compiler or options.compiler).expanduser()