예제 #1
0
파일: manage.py 프로젝트: 08haozi/uliweb
    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
예제 #2
0
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
예제 #3
0
파일: manage.py 프로젝트: chifeng/uliweb
 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
예제 #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
예제 #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"