Created
July 29, 2011 10:08
-
-
Save PaulGuo/1113559 to your computer and use it in GitHub Desktop.
Auto-Sprite *.css
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
# Author: Guokai | |
# CreateDate: 2011-07-29 | |
# Description: This script executed to auto-sprites *.css files. | |
# Rely: smartsprites-x.y.z | |
import os,sys,fnmatch,re | |
options="-Xms64m -Xmx256m" | |
lib='E:\\Tools\\smartsprites-0.2.8\\lib' | |
arg=sys.argv[1:] | |
def walk(path,pattern): | |
arr=[] | |
for i in pattern: | |
for root,dirs,files in os.walk(path): | |
for filename in fnmatch.filter(files,i): | |
if(not re.match(r'(.*(-sprite|\.sprite)\..*)',filename)): | |
arr.append(os.path.join(root,filename)) | |
return arr; | |
def smartsprites(files): | |
for file in files: | |
os.system('java %s -Djava.ext.dirs=%s org.carrot2.labs.smartsprites.SmartSprites --css-files %s' % (options,lib,file)) | |
if(len(arg)<2): | |
sys.exit(0) | |
else: | |
path=arg.pop(0) | |
pattern=arg | |
files=fnmatch.filter(walk(path,pattern),'*.css') | |
smartsprites(files) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment