def process_file(self, infile, outfile=None):
'''Processes input file and writes result to output file.
Args:
infile (str): Name of the file to read and process. If its value is
'-', input is read from stdin.
outfile (str, optional): Name of the file to write the result to.
If its value is '-', result is written to stdout. If not
present, result will be returned as string.
env (dict, optional): Additional definitions for the evaluator.
Returns:
str: Result of processed input, if no outfile was specified.
'''
infile = STDIN if infile == '-' else infile
output = self._preprocessor.process_file(infile)
if outfile is None:
return output
else:
if outfile == '-':
outfile = sys.stdout
else:
outfile = _open_output_file(outfile, self._create_parent_folder)
outfile.write(output)
if outfile != sys.stdout:
outfile.close()
评论列表
文章目录