File: run.py

package info (click to toggle)
txt2tags 3.9-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 2,160 kB
  • sloc: python: 3,002; sh: 45; makefile: 35
file content (39 lines) | stat: -rw-r--r-- 1,013 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#
# txt2tags %!include command tester (http://txt2tags.org)
# See also: ../run.py ../lib.py
#

import glob
import os
import re
import sys

sys.path.insert(0, "..")
import lib

del sys.path[0]


def run():
    # test all OK files found
    for outfile in glob.glob("ok/*"):
        stderr = 0
        basename = re.sub(r"\..*?$", "", outfile.replace("ok/", ""))
        target = re.sub(r".*\.", "", outfile)
        if target == "out":
            target = "txt"
            stderr = 1
        infile = basename + ".t2t"
        outfile = outfile.replace("ok/", "")
        if lib.initTest(basename, infile, outfile):
            cmdline = ["-H"]
            cmdline.extend(["-t", target])
            cmdline.extend(["-i", infile])
            if stderr:
                cmdline.extend(["-o", "-"])
                cmdline.append(">" + outfile)
                cmdline.append("2>&1")
            lib.test(cmdline, outfile)
    # clean up
    if os.path.isfile(lib.CONFIG_FILE):
        os.remove(lib.CONFIG_FILE)