def symage(path): ext = magic.from_file(path).split(" ").pop(0).lower() if ext not in ["png", "jpeg"]: log("converting %s to png!" % (ext, )) cmd("convert -append -alpha off %s %s.png" % (path, path)) cmd("mv %s.png %s" % (path, path)) ext = "png" sname = "%s.%s" % (path.replace("blob", "build"), ext) if not os.path.exists(sname): sym("../%s" % (path, ), sname) return sname
def md2pdf(doc, mdname, bname, pname=None): initpandoc() fcfg = config.ctman.font pcmd = "pandoc %s -o %s --%s-engine=xelatex -H tex/imps.tex -V geometry:margin=0.8in" % ( mdname, bname, PDINFO['version'] == 1 and "latex" or "pdf") if fcfg.size: pcmd += " -V fontsize:%s" % (fcfg.size, ) if pname: pcmd += " -B %s" % (pname, ) if doc.polytype == "document" and doc.table_of_contents: pcmd += " --toc -N" cmd(pcmd)
def snap(): log("attempting snap", important=True) if not os.path.exists("archive"): log("creating archive directory") os.mkdir("archive") data = read("data.db", binary=True) match = indir(data, "archive") if match: log("matching archive: %s - aborting snap" % (match, )) return match aname = str(datetime.now()).rsplit(":", 1)[0].replace(" ", "_") cmd('cp data.db "%s"' % (os.path.join("archive", aname), )) return aname
def vcignore(self): log("configuring version control path exclusion", 1) itype = raw_input("would you like to generate exclusion rules for symlinks and dot files (if you select svn, we will add the project to your repository first)? [NO/git/svn] ") if itype == "git": log("configuring git", 2) cfg = config.init.vcignore["."] for path in ["css", "js"]: for fname in config.init.vcignore[path]: cfg.append(os.path.join(path, fname)) cp("\n".join(cfg), ".gitignore") elif itype == "svn": log("configuring svn", 2) cmd("svn add .") for root, files in config.init.vcignore.items(): cp("\n".join(files), "_tmp") cmd("svn propset svn:ignore -F _tmp %s"%(root,)) rm("_tmp")
def vcignore(self): log("configuring version control path exclusion", 1) itype = raw_input( "would you like to generate exclusion rules for symlinks and dot files (if you select svn, we will add the project to your repository first)? [NO/git/svn] " ) if itype == "git": log("configuring git", 2) cfg = config.init.vcignore["."] for path in ["css", "js"]: for fname in config.init.vcignore[path]: cfg.append(os.path.join(path, fname)) cp("\n".join(cfg), ".gitignore") elif itype == "svn": log("configuring svn", 2) cmd("svn add .") for root, files in config.init.vcignore.items(): cp("\n".join(files), "_tmp") cmd("svn propset svn:ignore -F _tmp %s" % (root, )) rm("_tmp")
def swap(archname): snap() cmd('cp "%s" data.db' % (os.path.join("archive", archname), ))