def generate_output(args):
if not args.test:
args.test = glob_with_format(args.format) # by default
tests = construct_relationship_of_files(args.test, args.format)
for name, it in sorted(tests.items()):
log.emit('')
log.info('%s', name)
if 'out' in it:
log.info('output file already exists.')
log.info('skipped.')
continue
with open(it['in']) as inf:
begin = time.perf_counter()
answer, proc = utils.exec_command(args.command, shell=args.shell, stdin=inf)
end = time.perf_counter()
log.status('time: %f sec', end - begin)
if proc.returncode != 0:
log.failure(log.red('RE') + ': return code %d', proc.returncode)
log.info('skipped.')
continue
log.emit(log.bold(answer.decode().rstrip()))
path = path_from_format(args.format, match_with_format(args.format, it['in']).groupdict()['name'], 'out')
with open(path, 'w') as fh:
fh.buffer.write(answer)
log.success('saved to: %s', path)
评论列表
文章目录