error("Unexpected data in %s\n%s" % (log_file, line))
if snippet:
- ascent = string.atof(match.group(2)) + tp_ascent
- descent = string.atof(match.group(3)) - tp_descent
+ ascent = string.atoi(match.group(2))
+ descent = string.atoi(match.group(3))
frac = 0.5
- if abs(ascent + descent) > 0.1:
- frac = ascent / (ascent + descent)
+ if ascent > 0 and descent > 0:
+ ascent = float(ascent) + tp_ascent
+ descent = float(descent) - tp_descent
- metrics.write("Snippet %s %f\n" % (match.group(1), frac))
+ if abs(ascent + descent) > 0.1:
+ frac = ascent / (ascent + descent)
+
+ # Sanity check
+ if frac < 0 or frac > 1:
+ frac = 0.5
+
+ metrics.write("Snippet %s %f\n" % (match.group(1), frac))
else:
tp_descent = string.atof(match.group(2))
def crop_files(pnmcrop, basename):
t = pipes.Template()
- t.append('"%s" -left' % pnmcrop, '--')
- t.append('"%s" -right' % pnmcrop, '--')
+ t.append('%s -left' % pnmcrop, '--')
+ t.append('%s -right' % pnmcrop, '--')
for file in glob.glob("%s*.ppm" % basename):
tmp = mkstemp()
path = string.split(os.environ["PATH"], os.pathsep)
latex = find_exe_or_terminate(["pplatex", "latex2e", "latex"], path)
dvips = find_exe_or_terminate(["dvips"], path)
- gs = find_exe_or_terminate(["gswin32", "gs"], path)
+ gs = find_exe_or_terminate(["gswin32c", "gs"], path)
pnmcrop = find_exe(["pnmcrop"], path)
# Move color information into the latex file.
error("Unable to move color info into the latex file")
# Compile the latex file.
- latex_call = '"%s" "%s"' % (latex, latex_file)
+ latex_call = '%s "%s"' % (latex, latex_file)
latex_status, latex_stdout = run_command(latex_call)
if latex_status != None:
dvi_file = latex_file_re.sub(".dvi", latex_file)
ps_file = latex_file_re.sub(".ps", latex_file)
- dvips_call = '"%s" -o "%s" "%s"' % (dvips, ps_file, dvi_file)
+ dvips_call = '%s -o "%s" "%s"' % (dvips, ps_file, dvi_file)
dvips_status, dvips_stdout = run_command(dvips_call)
if dvips_status != None:
alpha = 2
# Generate the bitmap images
- gs_call = '"%s" -dNOPAUSE -dBATCH -dSAFER -sDEVICE=pnmraw ' \
+ gs_call = '%s -dNOPAUSE -dBATCH -dSAFER -sDEVICE=pnmraw ' \
'-sOutputFile="%s%%d.ppm" ' \
'-dGraphicsAlphaBit=%d -dTextAlphaBits=%d ' \
'-r%f "%s"' \