PageRenderTime 26ms CodeModel.GetById 22ms app.highlight 2ms RepoModel.GetById 1ms app.codeStats 0ms

/test/target/run.py

http://txt2tags.googlecode.com/
Python | 44 lines | 32 code | 6 blank | 6 comment | 3 complexity | cb295747aebab60fab8c88ce3e4dbda1 MD5 | raw file
 1#
 2# txt2tags target code tester (http://txt2tags.org)
 3# See also: ../run.py ../lib.py
 4#
 5
 6import os, sys, re, glob
 7
 8sys.path.insert(0, '..')
 9import lib
10del sys.path[0]
11
12# sux
13lib.OK = lib.FAILED = 0
14lib.ERROR_FILES = []
15
16all_targets = 'aap aapw aas aasw aat aatw adoc bbcode creole dbk doku gwiki html html5 htmls lout man md mgp moin pm6 pmw csv csvs ods red rst rtf sgml spip tex texs txt txt2t wiki xhtml xhtmls'.split()
17
18tableable = 'aat aatw aas aasw aap aapw creole doku gwiki html html5 htmls man md moin pmw csv csvs ods red rst rtf sgml spip tex texs wiki xhtml xhtmls'.split()
19
20def run():
21    # test all .t2t files found
22    for infile in glob.glob("*.t2t"):
23        basename = infile.replace('.t2t', '')
24        
25        # Choose targets
26        targets = all_targets
27        if basename == 'table':
28            targets = tableable
29        
30        for target in targets:
31            outfile = basename + '.' + target
32            testname = '%s in %s' % (basename, target)
33            if lib.initTest(testname, infile, outfile):
34                cmdline = []
35                cmdline.extend(['-i', infile])
36                cmdline.extend(['-t', target])
37                if target == 'aap':
38                    cmdline.extend(['--width', '80'])
39                lib.convert(cmdline)
40                lib.diff(outfile)
41    return lib.OK, lib.FAILED, lib.ERROR_FILES
42
43if __name__ == '__main__':
44    print lib.MSG_RUN_ALONE