Example #1
0
    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
Example #2
0
def minimizeJs( file_path ):
    print "Opening " + file_path
    js_suffix = file_path[len( file_path ) - 2 : ]
    if not js_suffix == 'js':
        print file_path + " is not a js file"
        return None
    js_file = open(file_path).read()
    js_name = file_path[ : len( file_path ) - 3 ]
    js_minimized = rjsmin.jsmin(js_file)
    js_save_name = js_name + ".min.js"
    js_min_file = open( js_save_name, "w" )
    js_min_file.write( js_minimized )
    print "Finished saving Js file " + js_save_name 
Example #3
0
 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
Example #4
0
 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
Example #5
0
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"