[2] | 1 | #!/usr/bin/env python |
---|
| 2 | |
---|
| 3 | import sys |
---|
| 4 | |
---|
| 5 | from glob import glob |
---|
| 6 | from subprocess import call |
---|
| 7 | from shutil import copyfile |
---|
| 8 | from os import path |
---|
| 9 | |
---|
| 10 | # Scripts that should not be packed -- just copied |
---|
| 11 | do_not_pack = set() |
---|
| 12 | |
---|
| 13 | cmd = "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 | |
---|
| 19 | if len( sys.argv ) > 1: |
---|
| 20 | to_pack = sys.argv[1:] |
---|
| 21 | else: |
---|
| 22 | to_pack = glob( "*.js" ) |
---|
| 23 | |
---|
| 24 | for 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 ) |
---|