/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. import sys
  3. from glob import glob
  4. from subprocess import call
  5. from shutil import copyfile
  6. from os import path
  7. # Scripts that should not be packed -- just copied
  8. do_not_pack = set()
  9. cmd = "java -jar ../../scripts/yuicompressor.jar --type js %(fname)s -o packed/%(fname)s"
  10. # cmd = "java -jar ../../scripts/compiler.jar --compilation_level SIMPLE_OPTIMIZATIONS --js %(fname)s --js_output_file packed/%(fname)s"
  11. # If specific scripts specified on command line, just pack them, otherwise pack
  12. # all.
  13. if len( sys.argv ) > 1:
  14. to_pack = sys.argv[1:]
  15. else:
  16. to_pack = glob( "*.js" )
  17. for fname in to_pack:
  18. d = dict( fname=fname )
  19. print "%(fname)s --> packed/%(fname)s" % d
  20. if fname in do_not_pack:
  21. copyfile( fname, path.join( 'packed', fname ) )
  22. else:
  23. out = call( cmd % d, shell=True )