def compileServerOnlyTemplates(src, mVars, mFuns, package=[]): tmpPath = src+"/"+tmpFolder; if not bash.exists(tmpPath): bash.mkdir(tmpPath); for fil in bash.ls(src): path = src+"/"+fil; if bash.isdir(path) and fil != tmpFolder: compileServerOnlyTemplates(path, mVars, mFuns, package+[fil]); elif fil.endswith(tmpltExt): fil = fil[:len(fil)-len(tmpltExt)]; assert(bash.exists(src+"/"+fil+".tspec")); tmpTmplt = tmpPath+"/"+fil+".tmplt"; tmpTspec = tmpPath+"/"+fil+".tspec"; bash.cp_r(src+"/"+fil+".tmplt", tmpTmplt); bash.cp_r(src+"/"+fil+".tspec", tmpTspec); macros.run(tmpTmplt, mVars, mFuns); macros.run(tmpTspec, mVars, mFuns); compileTemplateToJava(tmpPath+"/"+fil, package); bash.rm_r(tmpPath);
def compileServerOnlyTemplates(src, mVars, mFuns, package=[]): tmpPath = src + "/" + tmpFolder if not bash.exists(tmpPath): bash.mkdir(tmpPath) for fil in bash.ls(src): path = src + "/" + fil if bash.isdir(path) and fil != tmpFolder: compileServerOnlyTemplates(path, mVars, mFuns, package + [fil]) elif fil.endswith(tmpltExt): fil = fil[:len(fil) - len(tmpltExt)] assert (bash.exists(src + "/" + fil + ".tspec")) tmpTmplt = tmpPath + "/" + fil + ".tmplt" tmpTspec = tmpPath + "/" + fil + ".tspec" bash.cp_r(src + "/" + fil + ".tmplt", tmpTmplt) bash.cp_r(src + "/" + fil + ".tspec", tmpTspec) macros.run(tmpTmplt, mVars, mFuns) macros.run(tmpTspec, mVars, mFuns) compileTemplateToJava(tmpPath + "/" + fil, package) bash.rm_r(tmpPath)
def transferLeaf(src, dest, plat, debug, mVars, mFuns, parents, merge): if merge: assert(len(parents) > 0); isDir = bash.isdir(src) wantsMacros = not (isDir and (os.path.basename(src) in noTemplating)); ext = src[src.rfind("/_")+2:] if isDir else src[src.rfind(".")+1:]; outPath = dest+("/"+ext if isDir else ""); for parent in parents: if not bash.exists(outPath): bash.mkdir(outPath); outPath += "/" + parent; if not merge and not bash.exists(outPath): bash.mkdir(outPath); if isDir: # Get list of files to transfer baseFolders = ["", "/_"+plat] + (["/"+debugFolder, "/_"+plat+"/"+debugFolder] if debug else []); # Actually transfer if merge: ofpath = outPath+"."+ext; outfil = bash.writefile(ofpath); i = 0; while i < len(baseFolders): baseFolder = src+baseFolders[i]; if bash.exists(baseFolder): fils = bash.ls(baseFolder); oFil = baseFolder+"/"+orderFile; if bash.exists(oFil): oFilReader = bash.readfile(oFil); o = oFilReader.read().strip().split(); oFilReader.close(); fils = o+list(set(fils).difference(o)); for fil in fils: fname = baseFolder+"/"+fil; if bash.isdir(fname): if fil[0] != '_': baseFolders.insert(i+1, fname[len(src):]); elif fil.endswith("."+ext): infil = bash.readfile(fname); outfil.write(infil.read()+"\n"); infil.close() i += 1; outfil.close(); if wantsMacros: macros.run(ofpath, mVars, mFuns); if ext == "js" and not debug: print "\tCompressing \""+ofpath+"\"..." bash.compressJS(ofpath, (plat != webPlat)); else: for baseFolder in baseFolders: baseFolder = src+baseFolder; if bash.exists(baseFolder): for fil in bash.ls(baseFolder): fname = baseFolder+"/"+fil; if fil[0] != '_' or not bash.isdir(fname): oPath = outPath+"/"+fil; bash.cp_r(fname, oPath); if wantsMacros: macros.run(oPath, mVars, mFuns); else: oPath = outPath + ("."+ext if merge else ""); bash.cp_r(src, oPath); if wantsMacros: macros.run(oPath, mVars, mFuns);
def transferLeaf(src, dest, plat, debug, mVars, mFuns, parents, merge): if merge: assert (len(parents) > 0) isDir = bash.isdir(src) wantsMacros = not (isDir and (os.path.basename(src) in noTemplating)) ext = src[src.rfind("/_") + 2:] if isDir else src[src.rfind(".") + 1:] outPath = dest + ("/" + ext if isDir else "") for parent in parents: if not bash.exists(outPath): bash.mkdir(outPath) outPath += "/" + parent if not merge and not bash.exists(outPath): bash.mkdir(outPath) if isDir: # Get list of files to transfer baseFolders = ["", "/_" + plat] + ( ["/" + debugFolder, "/_" + plat + "/" + debugFolder] if debug else []) # Actually transfer if merge: ofpath = outPath + "." + ext outfil = bash.writefile(ofpath) i = 0 while i < len(baseFolders): baseFolder = src + baseFolders[i] if bash.exists(baseFolder): fils = bash.ls(baseFolder) oFil = baseFolder + "/" + orderFile if bash.exists(oFil): oFilReader = bash.readfile(oFil) o = oFilReader.read().strip().split() oFilReader.close() fils = o + list(set(fils).difference(o)) for fil in fils: fname = baseFolder + "/" + fil if bash.isdir(fname): if fil[0] != '_': baseFolders.insert(i + 1, fname[len(src):]) elif fil.endswith("." + ext): infil = bash.readfile(fname) outfil.write(infil.read() + "\n") infil.close() i += 1 outfil.close() if wantsMacros: macros.run(ofpath, mVars, mFuns) if ext == "js" and not debug: print "\tCompressing \"" + ofpath + "\"..." bash.compressJS(ofpath, (plat != webPlat)) else: for baseFolder in baseFolders: baseFolder = src + baseFolder if bash.exists(baseFolder): for fil in bash.ls(baseFolder): fname = baseFolder + "/" + fil if fil[0] != '_' or not bash.isdir(fname): oPath = outPath + "/" + fil bash.cp_r(fname, oPath) if wantsMacros: macros.run(oPath, mVars, mFuns) else: oPath = outPath + ("." + ext if merge else "") bash.cp_r(src, oPath) if wantsMacros: macros.run(oPath, mVars, mFuns)