Beispiel #1
0
Datei: stydd.py Projekt: olpa/tex
def main(digger=None):
  mode     = 'char'
  out_file = None
  argv     = sys.argv[1:]
  if '-o' in argv:
    i = argv.index('-o')
    out_file = argv[i+1]
    del argv[i:i+2]
  if '--lines' in argv:
    mode = 'line'
    argv.remove('--lines')
  stop_after_master = '--stop-after-master' in argv
  if stop_after_master:
    argv.remove('--stop-after-master')
  (tex_file, sty_file) = argv
  runlatex.guess_latex_tool(tex_file)
  dd = StyDD(tex_file, sty_file, mode, digger=digger)
  dd.decider.print_master_errors()
  if stop_after_master:
    sys.exit()
  deltas = dd.get_deltas()
  c = dd.ddmin(deltas)
  print 'The 1-minimal failure-inducing sty input is:'
  print '--------------------------------------------'
  if out_file is None:
    h = sys.stdout
  else:
    h = open(out_file, 'w')
    print "In the file", out_file
  dd.show_applied_delta(h, c)
  if out_file is not None:
    h.close()
Beispiel #2
0
Datei: stydd.py Projekt: olpa/tex
def main(digger=None):
    mode = 'char'
    out_file = None
    argv = sys.argv[1:]
    if '-o' in argv:
        i = argv.index('-o')
        out_file = argv[i + 1]
        del argv[i:i + 2]
    if '--lines' in argv:
        mode = 'line'
        argv.remove('--lines')
    stop_after_master = '--stop-after-master' in argv
    if stop_after_master:
        argv.remove('--stop-after-master')
    (tex_file, sty_file) = argv
    runlatex.guess_latex_tool(tex_file)
    dd = StyDD(tex_file, sty_file, mode, digger=digger)
    dd.decider.print_master_errors()
    if stop_after_master:
        sys.exit()
    deltas = dd.get_deltas()
    c = dd.ddmin(deltas)
    print 'The 1-minimal failure-inducing sty input is:'
    print '--------------------------------------------'
    if out_file is None:
        h = sys.stdout
    else:
        h = open(out_file, 'w')
        print "In the file", out_file
    dd.show_applied_delta(h, c)
    if out_file is not None:
        h.close()
Beispiel #3
0
def run_recording(tex_file, ti):
    env = runlatex.RunEnv()
    runlatex.guess_latex_tool(env, tex_file)
    env.set_extra_latex_opt("-recorder")
    env.set_texinputs(ti)
    rl = runlatex.RunLatex(env)
    env.set_rundir("run_recording_pass")
    rundir = rl.create_run_dir()
    rl.run_latex_collect_errors(tex_file)
    tbname = os.path.basename(tex_file)
    fls_file = os.path.join(rundir, os.path.splitext(tbname)[0] + ".fls")
    seen = [tbname]
    for l in open(fls_file):
        if "INPUT " != l[:6]:
            continue
        fname = l[6:].strip()
        if not os.path.isabs(fname):
            continue
        bname = os.path.basename(fname)
        if bname in seen:
            continue
        seen.append(bname)
        tgt_fname = os.path.join(rundir, bname)
        shutil.copy(fname, tgt_fname)
Beispiel #4
0
Datei: depdd.py Projekt: olpa/tex
def run_recording(tex_file, ti):
  env = runlatex.RunEnv()
  runlatex.guess_latex_tool(env, tex_file)
  env.set_extra_latex_opt('-recorder')
  env.set_texinputs(ti)
  rl = runlatex.RunLatex(env)
  env.set_rundir('run_recording_pass')
  rundir = rl.create_run_dir()
  rl.run_latex_collect_errors(tex_file)
  tbname = os.path.basename(tex_file)
  fls_file = os.path.join(rundir, os.path.splitext(tbname)[0]+'.fls')
  seen = [tbname]
  for l in open(fls_file):
    if 'INPUT ' != l[:6]:
      continue
    fname = l[6:].strip()
    if not os.path.isabs(fname):
      continue
    bname = os.path.basename(fname)
    if bname in seen:
      continue
    seen.append(bname)
    tgt_fname = os.path.join(rundir, bname)
    shutil.copy(fname, tgt_fname)
Beispiel #5
0
      arg_chunker = a
    elif '--chunker-ini' == o:
      arg_chunker_ini.append(a)
    else:
      assert 0, "unhandled option " + o
  assert main_file, "Main .tex-file is required"
  if not stop_after_master:
    assert out_file, "Output .tex-file is required"
  if not chunker:
    if 'line' == arg_chunker:
      chunker = LatexFileDeltaLineChar('line')
    elif 'char' == arg_chunker:
      chunker = LatexFileDeltaLineChar('char')
    elif 'section' == arg_chunker:
      chunker = LatexFileDeltaBlock(arg_chunker_ini)
    else:
      assert 0, "Unknown chunker name (expected line/char/section): ''" % arg_chunker
  env = runlatex.RunEnv()
  runlatex.guess_latex_tool(env, main_file)
  dd = LatexDD(env, main_file, digger, chunker)
  dd.decider.print_master_errors()
  if stop_after_master:
    sys.exit(0)
  deltas = dd.get_deltas()
  c = dd.ddmin(deltas)
  chunker.write_file_for_deltas(out_file, c)

if '__main__' == __name__:
  logging.basicConfig(filename='latex_dd_log', level=logging.DEBUG)
  main()
Beispiel #6
0
        if '' == self.master_errors:
            print "Compiling against 'fail' sty should produce errors"
            sys.exit(-1)

    def run_latex(self, deltas):
        rundir = runlatex.create_run_dir()
        self.diff.write_file(os.path.join(rundir, self.sty_name), deltas)
        return runlatex.run_latex_collect_errors(rundir, self.tex_file)

    def _test(self, deltas):
        errors = self.run_latex(deltas)
        if '' == errors:
            return self.PASS
        if self.master_errors == errors:
            return self.FAIL
        return self.UNRESOLVED

    def get_deltas(self):
        return self.diff.get_deltas()


if '__main__' == __name__:
    (tex_file, fname_pass, fname_fail) = sys.argv[1:]
    runlatex.guess_latex_tool(tex_file)
    dd = DiffDeltaDD(tex_file, fname_pass, fname_fail)
    deltas = dd.get_deltas()
    c = dd.ddmin(deltas)
    print 'The 1-minimal failure-inducing delta is:'
    print '----------------------------------------'
    dd.diff.write_diff(sys.stdout, c)
Beispiel #7
0
      arg_chunker_ini.append(a)
    else:
      assert 0, "unhandled option " + o
  assert main_file, "Main .tex-file is required"
  if not stop_after_master:
    assert out_file, "Output .tex-file is required"
  if not chunker:
    if 'line' == arg_chunker:
      chunker = LatexFileDeltaLineChar('line')
    elif 'char' == arg_chunker:
      chunker = LatexFileDeltaLineChar('char')
    elif 'section' == arg_chunker:
      chunker = LatexFileDeltaBlock(arg_chunker_ini)
    elif 'cmd' == arg_chunker:
      chunker = LatexFileDeltaCmd()
    else:
      assert 0, "Unknown chunker name (expected line/char/section): '%s'" % arg_chunker
  env = runlatex.RunEnv()
  runlatex.guess_latex_tool(env, main_file)
  dd = LatexDD(env, main_file, digger, chunker)
  dd.decider.print_master_errors()
  if stop_after_master:
    sys.exit(0)
  deltas = dd.get_deltas()
  c = dd.ddmin(deltas)
  chunker.write_file_for_deltas(out_file, c)

if '__main__' == __name__:
  logging.basicConfig(filename='latex_dd_log', level=logging.DEBUG)
  main()
Beispiel #8
0
    print self.master_errors
    if '' == self.master_errors:
      print "Compiling against 'fail' sty should produce errors"
      sys.exit(-1)

  def run_latex(self, deltas):
    rundir = runlatex.create_run_dir()
    self.diff.write_file(os.path.join(rundir, self.sty_name), deltas)
    return runlatex.run_latex_collect_errors(rundir, self.tex_file)

  def _test(self, deltas):
    errors = self.run_latex(deltas)
    if '' == errors:
      return self.PASS
    if self.master_errors == errors:
      return self.FAIL
    return self.UNRESOLVED

  def get_deltas(self):
    return self.diff.get_deltas()

if '__main__' == __name__:
  (tex_file, fname_pass, fname_fail) = sys.argv[1:]
  runlatex.guess_latex_tool(tex_file)
  dd = DiffDeltaDD(tex_file, fname_pass, fname_fail)
  deltas = dd.get_deltas()
  c = dd.ddmin(deltas)
  print 'The 1-minimal failure-inducing delta is:'
  print '----------------------------------------'
  dd.diff.write_diff(sys.stdout, c)