Exemplo n.º 1
0
def minfile(filename):
    insize = os.path.getsize(filename)
    print "Processing %s: %d ->" % (filename, insize),
    cmd = CMD % {'type': 'js', 'file': filename}
    print get_command_output(cmd)
    outsize = os.path.getsize(filename)
    print "%d [%.2f%%]" % (outsize, ((insize-outsize)*100)/insize)
Exemplo n.º 2
0
import os
from os import listdir
from os.path import isdir
from common.utils.commands import get_command_output

PROJECT_PATH = os.path.normpath(os.path.abspath(os.path.dirname(__file__)))
MEDIA_PATH = os.path.join(PROJECT_PATH, 'site_media')
JS_PATH = os.path.join(MEDIA_PATH, 'js','src')
CSS_PATH = os.path.join(MEDIA_PATH, 'css')

CMD = 'java -jar yuicompressor.jar --type %(type)s --charset utf-8 %(file)s'
 
out = []
for file in listdir(JS_PATH):
    if not isdir(file):
        print "Processing %s" % file
        cmd = CMD % {'type': 'js', 'file': os.path.join(JS_PATH, file)}
        out.append("".join(get_command_output(cmd)))

res = "\n".join(out)
print res
dest = open('application.js','w')
dest.write(res)
dest.close()