Esempio n. 1
0
def setfile (ext):
    file = globals.probsettings['filename']
    type = exttotype[ext]
    testid = globals.gettestid()
    print 'Setting test case {} {} for problem {}'.format(testid, type, globals.getprob())
    input = ''
    if file is None:
        print 'Enter {} below (Ctrl-{} when finished)'.format(type, 'Z' if helper.iswindows() else 'D')
        print settings.smalldivider
        input = sys.stdin.read()
        print settings.smalldivider
    else:
        print 'Retrieving from ' + file.name
        input = file.read()
    helper.write(os.path.join(globals.probdir, testid + ext), input)
    print 'Set {} successfully'.format(exttotype[ext])
    return True
Esempio n. 2
0
def setfile(ext):
    file = globals.probsettings['filename']
    type = exttotype[ext]
    testid = globals.gettestid()
    print 'Setting test case {} {} for problem {}'.format(
        testid, type, globals.getprob())
    input = ''
    if file is None:
        print 'Enter {} below (Ctrl-{} when finished)'.format(
            type, 'Z' if helper.iswindows() else 'D')
        print settings.smalldivider
        input = sys.stdin.read()
        print settings.smalldivider
    else:
        print 'Retrieving from ' + file.name
        input = file.read()
    helper.write(os.path.join(globals.probdir, testid + ext), input)
    print 'Set {} successfully'.format(exttotype[ext])
    log.addmsg('Set test case {} {} for problem {}'.format(
        testid, type, globals.getprob()))
    return True
Esempio n. 3
0
def getfile (ext):
    file = parse.parseopts()['filename']
    type = exttotype[ext]
    testid = globals.gettestid()
    print 'Getting test case {} {} for problem {}'.format(testid, type, globals.getprob())
    output = helper.read(os.path.join(globals.probdir, testid + ext))
    if output is None:
        print 'Did not find {} file'.format(type)
        return False
    if file is None:
        print 'File found: {} below'.format(type)
        print settings.smalldivider
        print output + ('' if settings.eof is None else settings.eof)
    else:
        try:
            file.write(output)
            file.close()
            print 'Wrote {} to {}'.format(type, file.name)
        except IOError:
            print 'Unable to write to ' + file.name
            return False
    return True
Esempio n. 4
0
def getfile(ext):
    file = parse.parseopts()['filename']
    type = exttotype[ext]
    testid = globals.gettestid()
    print 'Getting test case {} {} for problem {}'.format(
        testid, type, globals.getprob())
    output = helper.read(os.path.join(globals.probdir, testid + ext))
    if output is None:
        print 'Did not find {} file'.format(type)
        return False
    if file is None:
        print 'File found: {} below'.format(type)
        print settings.smalldivider
        print output + ('' if settings.eof is None else settings.eof)
    else:
        try:
            file.write(output)
            file.close()
            print 'Wrote {} to {}'.format(type, file.name)
        except IOError:
            print 'Unable to write to ' + file.name
            return False
    return True