Exemplo n.º 1
0
Arquivo: build.py Projeto: chkex/cx
def compileFolder(path, parents=[]):
    for fil in bash.ls(path):
        fpath = path+"/"+fil;
        if bash.isdir(fpath):
            if not fil in noTemplating:
                compileFolder(fpath, parents+[fil]);
    if bash.isdir(path+"/"+styleFolder):
        bash.cp_r(path+"/"+styleFolder, path+"/"+cssFolder);
        bash.sass(path+"/"+cssFolder, path+"/"+cssFolder);
    if bash.isdir(path+"/"+templateFolder):
        compileWebTemplates(path+"/"+templateFolder, parents);
Exemplo n.º 2
0
def compileFolder(path, parents=[]):
    for fil in bash.ls(path):
        fpath = path + "/" + fil
        if bash.isdir(fpath):
            if not fil in noTemplating:
                compileFolder(fpath, parents + [fil])
    if bash.isdir(path + "/" + styleFolder):
        bash.cp_r(path + "/" + styleFolder, path + "/" + cssFolder)
        bash.sass(path + "/" + cssFolder, path + "/" + cssFolder)
    if bash.isdir(path + "/" + templateFolder):
        compileWebTemplates(path + "/" + templateFolder, parents)
Exemplo n.º 3
0
def compileFolder(path, parents=[]):
    for fil in bash.ls(path):
        fpath = path+"/"+fil;
        if bash.isdir(fpath):
            if not fil in noTemplating:
                compileFolder(fpath, parents+[fil]);
    if bash.isdir(path+"/"+styleFolder):
        bash.cp_r(path+"/"+styleFolder, path+"/"+cssFolder);
        bash.sass(path+"/"+cssFolder, path+"/"+cssFolder);
    if bash.isdir(path+"/"+templateFolder):
        compileWebTemplates(path+"/"+templateFolder, parents);
    if bash.isdir(path+"/_tmplt"): #TODO make a variable for "tmplt" folder
        compileTemplates(path+"/_tmplt", parents);
Exemplo n.º 4
0
def compileFolder(path, parents=[]):
    for fil in bash.ls(path):
        fpath = path + "/" + fil
        if bash.isdir(fpath):
            if not fil in noTemplating:
                compileFolder(fpath, parents + [fil])
    if bash.isdir(path + "/" + styleFolder):
        bash.cp_r(path + "/" + styleFolder, path + "/" + cssFolder)
        bash.sass(path + "/" + cssFolder, path + "/" + cssFolder)
    if bash.isdir(path + "/" + templateFolder):
        compileWebTemplates(path + "/" + templateFolder, parents)
    if bash.isdir(path + "/_tmplt"):  #TODO make a variable for "tmplt" folder
        compileTemplates(path + "/_tmplt", parents)
Exemplo n.º 5
0
def transferFls(src,
                dest,
                plat,
                debug,
                mVars,
                mFuns,
                foldersToFollow,
                parents=[]):
    if len(parents) == 0:
        print "Transfering files for " + plat + "..."
    for fil in bash.ls(src):
        fpath = src + "/" + fil
        if bash.isdir(fpath):
            if fil[0] == "_":
                if fil == rawFolder:
                    dpath = dest
                    for parent in parents:
                        dpath += "/" + parent
                        if not bash.exists(dpath):
                            bash.mkdir(dpath)
                    for f in bash.ls(fpath):
                        bash.cp_r(fpath + "/" + f, dpath + "/" + f)
                elif not fil in ignoreFolders:
                    transferLeaf(fpath, dest, plat, debug, mVars, mFuns,
                                 parents, fil in mergeFolders)
            elif fil in foldersToFollow:
                transferFls(fpath, dest, plat, debug, mVars, mFuns, uSet,
                            parents + [fil])
    htmlPath = src + "/" + indexHTML
    if bash.exists(htmlPath):
        transferLeaf(htmlPath, dest, plat, debug, mVars, mFuns, parents, True)
Exemplo n.º 6
0
Arquivo: macros.py Projeto: nomuna/cx
def run(path, consts, funs):
    if bash.isdir(path):
        for fil in bash.ls(path):
            run(path + "/" + fil, consts, funs)
    else:
        content = runOnFile(path, consts, funs)
        outfil = bash.writefile(path)
        outfil.write(content)
        outfil.close()
Exemplo n.º 7
0
def run(path, consts, funs):
    if bash.isdir(path):
        for fil in bash.ls(path):
            run(path+"/"+fil, consts, funs);
    else:
        content = runOnFile(path, consts, funs);
        outfil = bash.writefile(path);
        outfil.write(content);
        outfil.close();
Exemplo n.º 8
0
def compileTemplates(path, parentsOfT, parentsInT=[]):
    jsPath = path + "/.."*len(parentsInT) + "/../" + jsFolder;
    if not bash.exists(jsPath):
        bash.mkdir(jsPath);
    for fil in bash.ls(path):
        if bash.isdir(path+"/"+fil):
            compileTemplates(path+"/"+fil, parentsOfT, parentsInT+[fil]);
        elif fil.endswith(tmpltExt):
            fil = fil[:len(fil)-len(tmpltExt)];
            compileTemplate(path+"/"+fil, jsPath + "/templates." +
                ".".join(parentsInT) + ("." if len(parentsInT) > 0 else "") +
                fil + ".js", parentsInT);
Exemplo n.º 9
0
def compileTemplates(path, parentsOfT, parentsInT=[]):
    jsPath = path + "/.." * len(parentsInT) + "/../" + jsFolder
    if not bash.exists(jsPath):
        bash.mkdir(jsPath)
    for fil in bash.ls(path):
        if bash.isdir(path + "/" + fil):
            compileTemplates(path + "/" + fil, parentsOfT, parentsInT + [fil])
        elif fil.endswith(tmpltExt):
            fil = fil[:len(fil) - len(tmpltExt)]
            compileTemplate(
                path + "/" + fil,
                jsPath + "/templates." + ".".join(parentsInT) +
                ("." if len(parentsInT) > 0 else "") + fil + ".js", parentsInT)
Exemplo n.º 10
0
Arquivo: build.py Projeto: chkex/cx
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);
Exemplo n.º 11
0
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)
Exemplo n.º 12
0
def transferFls(src,dest,plat,debug,mVars,mFuns,foldersToFollow,parents=[]):
    if len(parents) == 0:
        print "Transfering files for "+plat+"..."
    for fil in bash.ls(src):
        fpath = src + "/" + fil;
        if bash.isdir(fpath):
            if fil[0] == "_":
                if fil == rawFolder:
                    dpath = dest;
                    for parent in parents:
                        dpath += "/"+parent;
                        if not bash.exists(dpath):
                            bash.mkdir(dpath);
                    for f in bash.ls(fpath):
                        bash.cp_r(fpath+"/"+f, dpath+"/"+f);
                elif not fil in ignoreFolders:
                    transferLeaf(fpath, dest, plat, debug, mVars, mFuns,
                                            parents, fil in mergeFolders);
            elif fil in foldersToFollow:
                transferFls(fpath, dest, plat, debug, mVars, mFuns, uSet,
                                                            parents+[fil])
    htmlPath = src+"/"+indexHTML;
    if bash.exists(htmlPath):
        transferLeaf(htmlPath,dest,plat,debug,mVars,mFuns,parents,True);
Exemplo n.º 13
0
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);
Exemplo n.º 14
0
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)