def minify(self, in_files, outfile, concat=False): """ Compress in_files into outfile, give some stats """ from build import verbose import os # concat everything into temp outtype = outfile.split('.')[-1] temp = self.concat(in_files, is_js=True) out = open(outfile, 'w') org_size = len(temp.getvalue()) temp.seek(0) # minify jsm = JavascriptMinify() jsm.minify(temp, out) out.close() self.vc.repo.add(outfile) new_size = os.path.getsize(outfile) if verbose: print '=> %s' % outfile print 'Original: %.2f kB' % (org_size / 1024.0) print 'Compressed: %.2f kB' % (new_size / 1024.0) print 'Reduction: %.1f%%' % (float(org_size - new_size) / org_size * 100)