import os import glob import subprocess import shutil METADATA={"Name":"LliureX 11.09 hicolor","Comment":"Lliurex Pime 11.09 icon theme based on Faenza","Inherits":"Faenza","Example":"start-here","Directories":""} CONTEXT={"places":"Places","apps":"Applications"} SRC_DIR="hicolor" DST_DIR="build-hicolor" DIRS=["apps"] SIZES=[0,16,32,24,48] print "* building icon set" if not os.path.exists(DST_DIR): print "* creating dst path" os.mkdir(DST_DIR) for sz in SIZES: if sz==0: "* building scalable" sz_dir="scalable" else: sz_dir=str(sz) print "* building %dx%d" % (sz,sz) if not os.path.exists(DST_DIR+"/"+sz_dir): print "* creating path: %s" % (DST_DIR+"/"+sz_dir) os.mkdir(DST_DIR+"/"+sz_dir) for dr in DIRS: if not sz==0: METADATA["Directories"]=METADATA["Directories"]+","+sz_dir+"/"+dr else: METADATA["Directories"]=METADATA["Directories"]+",scalable/"+dr if not os.path.exists(DST_DIR+"/"+sz_dir+"/"+dr): print "* creating path %s" % (DST_DIR+"/"+sz_dir+"/"+dr) os.mkdir(DST_DIR+"/"+sz_dir+"/"+dr) print "* %s" % (DST_DIR+"/"+str(sz_dir)+"/"+dr) for f in glob.glob(SRC_DIR+"/"+dr+"/*.svg"): if not os.path.islink(f): #png if not sz==0: print "* processing %s" % (os.path.basename(f)) subprocess.Popen(["rsvg","--width="+str(sz),"--height="+str(sz),f,DST_DIR+"/"+sz_dir+"/"+dr+"/"+os.path.basename(f).replace(".svg",".png")]) #scalable case else: shutil.copy(f,DST_DIR+"/"+sz_dir+"/"+dr) else: if not sz==0: print "* symlink %s:%s" % (os.path.basename(f),os.path.realpath(f)) #shutil.copy(f,DST_DIR+"/"+sz_dir+"/"+dr) os.symlink(os.readlink(f).replace(".svg",".png"),DST_DIR+"/"+sz_dir+"/"+dr+"/"+os.path.basename(f).replace(".svg",".png")) else: os.symlink(os.readlink(f),DST_DIR+"/"+sz_dir+"/"+dr+"/"+os.path.basename(f)) METADATA["Directories"]=METADATA["Directories"].lstrip(",")