def timingfun(string, id, buildDir, baseDir): m = md5.new() m.update(string) fname = "%s/%s/%s.%s.timing.pdf" % (baseDir, buildDir, id, m.hexdigest()) if not os.path.isfile(fname): print "generating timing ", fname timing.parseTiming(string, "%s/%s/%s.timing.svg" % (baseDir, buildDir, id)) # here's where we perform the actual bounded pdf conversion svg2boundedPDF("%s/%s/%s.timing.svg" % (baseDir, buildDir, id), "%s/%s/%s.%s.timing.pdf" % (baseDir, buildDir, id, m.hexdigest())) x = r"""\begin{center} \includegraphics[scale=0.8]{%s.%s.timing.pdf} \end{center}""" % (id, m.hexdigest()) return x
def genGraphicsDeps(textstr, buildDir, baseDir): """ find everything that's in an \includegraphics[blah][foo.ext} identify the extension perform the conversion place the result in builddir modify the string replace the appropriate text file. if there's not a match, we change the build dir """ # replace the PDFs with the relevant files: igre = re.compile(r"(\\includegraphics\[.*\]){(.+)\.(\w+)}", ) resultstr = "" for s in textstr.split('\n'): m = igre.search(s) if m: include = m.group(1) filebase = m.group(2) fileext = m.group(3) if fileext == "svg" : #perform svg conversion if hasChanged("%s/%s.%s" % (baseDir, filebase, fileext), "%s/%s/%s.%s.pdf" % (baseDir, buildDir, filebase, fileext)): svg2boundedPDF("%s/%s.%s" % (baseDir, filebase, fileext), "%s/%s/%s.%s.pdf" % (baseDir, buildDir, filebase,fileext)) resultstr += igre.sub("%s{%s.%s.pdf}" % (include, filebase, fileext), s) + '\n' else: # native type? resultstr += "%s{%s/%s.%s}\n" % (include, buildDir, filebase, fileext) else: resultstr += "%s\n" % s return resultstr