PageRenderTime 28ms CodeModel.GetById 25ms app.highlight 1ms RepoModel.GetById 1ms app.codeStats 0ms

/static/scripts/pack_scripts.py

https://bitbucket.org/h_morita_dbcls/galaxy-central
Python | 30 lines | 18 code | 7 blank | 5 comment | 5 complexity | 70854b0906be84538de5320b46b34b7a MD5 | raw file
 1#!/usr/bin/env python
 2
 3import sys
 4
 5from glob import glob
 6from subprocess import call
 7from shutil import copyfile
 8from os import path
 9
10# Scripts that should not be packed -- just copied
11do_not_pack = set()
12
13cmd = "java -jar ../../scripts/yuicompressor.jar --type js %(fname)s -o packed/%(fname)s"
14# cmd = "java -jar ../../scripts/compiler.jar --compilation_level SIMPLE_OPTIMIZATIONS --js %(fname)s --js_output_file packed/%(fname)s"
15
16# If specific scripts specified on command line, just pack them, otherwise pack
17# all.
18
19if len( sys.argv ) > 1:
20    to_pack = sys.argv[1:]
21else:
22    to_pack = glob( "*.js" )
23
24for fname in to_pack:
25    d = dict( fname=fname )
26    print "%(fname)s --> packed/%(fname)s" % d
27    if fname in do_not_pack:
28        copyfile( fname, path.join( 'packed', fname ) )
29    else:
30        out = call( cmd % d, shell=True )