Esempio n. 1
0
def process_infile(indir, infile):
    """Process infile (.in) - substitutes and create reflection file
    (with the same name but without '.in' extension)"""
    f = change_ext(infile, '')
    shutil.copyfile(infile, f)
    buf = core.fread23(f)
    buf = substitute_infile(indir, buf)
    core.fwrite23(f, buf)
Esempio n. 2
0
    def runTest(self, *args):
        shfile = change_ext(self.filename, '.sh')
        args = [sys.executable, script_path("nlp.py")]
        if os.path.exists(shfile):
            # XXX no spaces in path!!!!
            args = args + core.fread23(shfile).split()
        else:
            args = args + ["-i", self.filename]
        proc = subprocess.Popen(args, stderr=subprocess.PIPE)
        exitcode = proc.wait()
        stderrbuf = core.bytestostr23(proc.stderr.read()).strip('\n')

        if exitcode != 0 or len(stderrbuf) != 0:
            err = os.path.splitext(self.filename)[0] + '.stderr'
            if os.path.exists(err):
                errbuf = readfile(err)
                self.assertRegexpMatches(stderrbuf, errbuf, msgfmt('unexpected exception'))
            else:
                self.fail('Exit with 1, stderr="%s"'%stderrbuf)
Esempio n. 3
0
def readfile(filename):
    """Return buffer from *.master file"""
    return core.fix_crlf(core.fread23(filename)).rstrip('\r\n')
Esempio n. 4
0
File: cat.py Progetto: kalkin/nanolp
# Itself testing facilities. Analogue of shell 'cat' command
#
# Author: Balkansoft.BlogSpot.com
# GNU GPL licensed

import sys
from nanolp import core
if len(sys.argv) > 1:
    sys.stdout.write(core.fread23(sys.argv[1]))