def process_file(self, sfile, dpath, dfile): from rjsmin.rjsmin import jsmin from rcssmin.rcssmin import cssmin js_compressor = None css_compressor = None if ( sfile.endswith(".js") and (".min." not in sfile and ".pack." not in sfile) and (self.options.js or self.options.auto) ): open(dfile, "w").write(jsmin(open(sfile).read())) if self.global_options.verbose: print "Compress %s to %s" % (sfile, dfile) return True if ( sfile.endswith(".css") and (".min." not in sfile and ".pack." not in sfile) and (self.options.css or self.options.auto) ): open(dfile, "w").write(cssmin(open(sfile).read())) if self.global_options.verbose: print "Compress %s to %s" % (sfile, dfile) return True
def minimizeCSS( file_path ): print "Opening " + file_path css_suffix = file_path[len( file_path ) - 3 : ] if not css_suffix == 'css': print file_path + " is not a css file" return None css_file = open( file_path ).read() css_name = file_path[ : len( file_path ) - 4] css_minimized = rcssmin.cssmin( css_file ) css_save_name = css_name + ".min.css" css_min_file = open( css_save_name , "w") css_min_file.write( css_minimized ) print "Finished saving Css file " + css_save_name
def process_file(self, sfile, dpath, dfile): from rjsmin.rjsmin import jsmin from rcssmin.rcssmin import cssmin js_compressor = None css_compressor = None if sfile.endswith('.js') and ('.min.' not in sfile and '.pack.' not in sfile) and (self.options.js or self.options.auto): open(dfile, 'w').write(jsmin(open(sfile).read())) if self.global_options.verbose: print 'Compress %s to %s' % (sfile, dfile) return True if sfile.endswith('.css') and ('.min.' not in sfile and '.pack.' not in sfile) and (self.options.css or self.options.auto): open(dfile, 'w').write(cssmin(open(sfile).read())) if self.global_options.verbose: print 'Compress %s to %s' % (sfile, dfile) return True
import sys, getopt, os from rcssmin import rcssmin from rjsmin import rjsmin opts, agrs = getopt.getopt(sys.argv[1:], "hj:c:o:") js_file = "" css_file = "" for op, value in opts: if op == "-j": js_file = open(value) js_name = value[ : len( value ) - 3 ] js_min = rjsmin.jsmin( js_file.read() ) js_min_file = open( js_name + ".min.js", 'w' ) js_min_file.write( js_min ) print "Finished saving Js file" elif op == "-c": css_file = open(value) css_name = value[ : len( value ) - 4 ] css_min = rcssmin.cssmin( css_file.read() ) css_min_file = open( cs_name + ".min.css", 'w' ) css_min_file.write( css_min ) print "Finished saving Css file"